org.jaudiotagger.tag.datatype
Class NumberVariableLength

java.lang.Object
  extended by org.jaudiotagger.tag.datatype.AbstractDataType
      extended by org.jaudiotagger.tag.datatype.NumberVariableLength

public class NumberVariableLength
extends AbstractDataType

Represents a number which may span a number of bytes when written to file depending what size is to be represented.

The bitorder in ID3v2 is most significant bit first (MSB). The byteorder in multibyte numbers is most significant byte first (e.g. $12345678 would be encoded $12 34 56 78), also known as big endian and network byte order.

In ID3Specification would be denoted as $xx xx xx xx (xx ...) , this denotes at least four bytes but may be more. Sometimes may be completely optional (zero bytes)


Field Summary
private static int MAXIMUM_NO_OF_DIGITS
           
private static int MINIMUM_NO_OF_DIGITS
           
(package private)  int minLength
           
 
Fields inherited from class org.jaudiotagger.tag.datatype.AbstractDataType
frameBody, identifier, logger, size, TYPE_ELEMENT, value
 
Constructor Summary
NumberVariableLength(NumberVariableLength copy)
           
NumberVariableLength(java.lang.String identifier, AbstractTagFrameBody frameBody, int minimumSize)
          Creates a new ObjectNumberVariableLength datatype, set minimum length to zero if this datatype is optional.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 int getMaximumLenth()
          Return the maximum number of digits that can be used to express the number
 int getMinimumLength()
          Return the minimum number of digits that can be used to express the number
 int getSize()
          This defines the size in bytes of the datatype being held when read/written to file.
 void readByteArray(byte[] arr, int offset)
          Read from Byte Array
 void setMinimumSize(int minimumSize)
           
 java.lang.String toString()
           
 byte[] writeByteArray()
          Write to Byte Array
 
Methods inherited from class org.jaudiotagger.tag.datatype.AbstractDataType
createStructure, getBody, getIdentifier, getValue, readByteArray, setBody, setValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MINIMUM_NO_OF_DIGITS

private static final int MINIMUM_NO_OF_DIGITS
See Also:
Constant Field Values

MAXIMUM_NO_OF_DIGITS

private static final int MAXIMUM_NO_OF_DIGITS
See Also:
Constant Field Values

minLength

int minLength
Constructor Detail

NumberVariableLength

public NumberVariableLength(java.lang.String identifier,
                            AbstractTagFrameBody frameBody,
                            int minimumSize)
Creates a new ObjectNumberVariableLength datatype, set minimum length to zero if this datatype is optional.

Parameters:
identifier -
frameBody -
minimumSize -

NumberVariableLength

public NumberVariableLength(NumberVariableLength copy)
Method Detail

getMaximumLenth

public int getMaximumLenth()
Return the maximum number of digits that can be used to express the number

Returns:
the maximum number of digits that can be used to express the number

getMinimumLength

public int getMinimumLength()
Return the minimum number of digits that can be used to express the number

Returns:
the minimum number of digits that can be used to express the number

setMinimumSize

public void setMinimumSize(int minimumSize)
Parameters:
minimumSize -

getSize

public int getSize()
Description copied from class: AbstractDataType
This defines the size in bytes of the datatype being held when read/written to file.

Specified by:
getSize in class AbstractDataType
Returns:
the number of bytes required to write this to a file

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class AbstractDataType
Parameters:
obj -
Returns:

readByteArray

public void readByteArray(byte[] arr,
                          int offset)
                   throws InvalidDataTypeException
Read from Byte Array

Specified by:
readByteArray in class AbstractDataType
Parameters:
arr -
offset -
Throws:
java.lang.NullPointerException
java.lang.IndexOutOfBoundsException
InvalidDataTypeException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
String representation of the number

writeByteArray

public byte[] writeByteArray()
Write to Byte Array

Specified by:
writeByteArray in class AbstractDataType
Returns:
the datatype converted to a byte array