org.jaudiotagger.tag.datatype
Class AbstractDataType

java.lang.Object
  extended by org.jaudiotagger.tag.datatype.AbstractDataType
Direct Known Subclasses:
AbstractString, BooleanByte, BooleanString, ByteArraySizeTerminated, ID3v2LyricLine, Lyrics3Image, Lyrics3Line, Lyrics3TimeStamp, MultipleTextEncodedStringNullTerminated, NumberFixedLength, NumberVariableLength

public abstract class AbstractDataType
extends java.lang.Object

Represents a field/data type that can be held within a frames body, these map loosely onto Section 4. ID3v2 frame overview at http://www.id3.org/id3v2.4.0-structure.txt


Field Summary
protected  AbstractTagFrameBody frameBody
          Holds the calling body, allows an datatype to query other objects in the body such as the Text Encoding of the frame
protected  java.lang.String identifier
          Holds the key such as "Text" or "PictureType", the naming of keys are fairly arbitary but are intended to make it easier to for the developer, the keys themseleves are not written to the tag.
static java.util.logging.Logger logger
           
protected  int size
          Holds the size of the data in file when read/written
protected static java.lang.String TYPE_ELEMENT
           
protected  java.lang.Object value
          Holds the data
 
Constructor Summary
  AbstractDataType(AbstractDataType copyObject)
          This is used by subclasses, to clone the data within the copyObject

TODO:It seems to be missing some of the more complex value types.

protected AbstractDataType(java.lang.String identifier, AbstractTagFrameBody frameBody)
          Construct an abstract datatype identified by identifier and linked to a framebody without setting an initial value.
protected AbstractDataType(java.lang.String identifier, AbstractTagFrameBody frameBody, java.lang.Object value)
          Construct an abstract datatype identified by identifier and linked to a framebody initilised with a value
 
Method Summary
 void createStructure()
          Return String Representation of Datatype *
 boolean equals(java.lang.Object obj)
           
 AbstractTagFrameBody getBody()
          Get the framebody associated with this datatype
 java.lang.String getIdentifier()
          Return the key as declared by the frame bodies datatype list
abstract  int getSize()
          This defines the size in bytes of the datatype being held when read/written to file.
 java.lang.Object getValue()
          Get value held by this Object
 void readByteArray(byte[] arr)
          Simplified wrapper for reading bytes from file into Object.
abstract  void readByteArray(byte[] arr, int offset)
          This is the starting point for reading bytes from the file into the ID3 datatype starting at offset.
 void setBody(AbstractTagFrameBody frameBody)
          Set the framebody that this datatype is associated with
 void setValue(java.lang.Object value)
          Set the value held by this datatype, this is used typically used when the user wants to modify the value in an existing frame.
abstract  byte[] writeByteArray()
          Starting point write ID3 Datatype back to array of bytes.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_ELEMENT

protected static final java.lang.String TYPE_ELEMENT
See Also:
Constant Field Values

logger

public static java.util.logging.Logger logger

value

protected java.lang.Object value
Holds the data


identifier

protected java.lang.String identifier
Holds the key such as "Text" or "PictureType", the naming of keys are fairly arbitary but are intended to make it easier to for the developer, the keys themseleves are not written to the tag.


frameBody

protected AbstractTagFrameBody frameBody
Holds the calling body, allows an datatype to query other objects in the body such as the Text Encoding of the frame


size

protected int size
Holds the size of the data in file when read/written

Constructor Detail

AbstractDataType

protected AbstractDataType(java.lang.String identifier,
                           AbstractTagFrameBody frameBody)
Construct an abstract datatype identified by identifier and linked to a framebody without setting an initial value.

Parameters:
identifier - to allow retrieval of this datatype by name from framebody
frameBody - that the dataype is associated with

AbstractDataType

protected AbstractDataType(java.lang.String identifier,
                           AbstractTagFrameBody frameBody,
                           java.lang.Object value)
Construct an abstract datatype identified by identifier and linked to a framebody initilised with a value

Parameters:
identifier - to allow retrieval of this datatype by name from framebody
frameBody - that the dataype is associated with
value - of this DataType

AbstractDataType

public AbstractDataType(AbstractDataType copyObject)
This is used by subclasses, to clone the data within the copyObject

TODO:It seems to be missing some of the more complex value types.

Parameters:
copyObject -
Method Detail

setBody

public void setBody(AbstractTagFrameBody frameBody)
Set the framebody that this datatype is associated with

Parameters:
frameBody -

getBody

public AbstractTagFrameBody getBody()
Get the framebody associated with this datatype

Returns:
the framebody that this datatype is associated with

getIdentifier

public java.lang.String getIdentifier()
Return the key as declared by the frame bodies datatype list

Returns:
the key used to reference this datatype from a framebody

setValue

public void setValue(java.lang.Object value)
Set the value held by this datatype, this is used typically used when the user wants to modify the value in an existing frame.

Parameters:
value -

getValue

public java.lang.Object getValue()
Get value held by this Object

Returns:
value held by this Object

readByteArray

public final void readByteArray(byte[] arr)
                         throws InvalidDataTypeException
Simplified wrapper for reading bytes from file into Object. Used for reading Strings, this class should be overridden for non String Objects

Parameters:
arr -
Throws:
InvalidDataTypeException

getSize

public abstract int getSize()
This defines the size in bytes of the datatype being held when read/written to file.

Returns:
the size in bytes of the datatype

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
Parameters:
obj -
Returns:
whether this and obj are deemed equivalent

readByteArray

public abstract void readByteArray(byte[] arr,
                                   int offset)
                            throws InvalidDataTypeException
This is the starting point for reading bytes from the file into the ID3 datatype starting at offset. This class must be overridden

Parameters:
arr -
offset -
Throws:
InvalidDataTypeException

writeByteArray

public abstract byte[] writeByteArray()
Starting point write ID3 Datatype back to array of bytes. This class must be overridden.

Returns:
the array of bytes representing this datatype that should be written to file

createStructure

public void createStructure()
Return String Representation of Datatype *