org.jaudiotagger.tag.id3
Class AbstractID3v2Frame

java.lang.Object
  extended by org.jaudiotagger.tag.id3.AbstractTagItem
      extended by org.jaudiotagger.tag.id3.AbstractTagFrame
          extended by org.jaudiotagger.tag.id3.AbstractID3v2Frame
All Implemented Interfaces:
TagField
Direct Known Subclasses:
ID3v22Frame, ID3v23Frame, ID3v24Frame

public abstract class AbstractID3v2Frame
extends AbstractTagFrame
implements TagField

This abstract class is each frame header inside a ID3v2 tag.

Version:
$Id: AbstractID3v2Frame.java,v 1.30 2009/11/12 15:42:57 paultaylor Exp $
Author:
: Paul Taylor, : Eric Farng

Nested Class Summary
(package private)  class AbstractID3v2Frame.EncodingFlags
           
(package private)  class AbstractID3v2Frame.StatusFlags
           
 
Field Summary
(package private)  AbstractID3v2Frame.EncodingFlags encodingFlags
          This holds the Encoding flags (not supported in v2.20)
protected  int frameSize
           
protected  java.lang.String identifier
           
private  java.lang.String loggingFilename
           
(package private)  AbstractID3v2Frame.StatusFlags statusFlags
          This holds the Status flags (not supported in v2.20
protected static java.lang.String TYPE_FRAME
           
protected static java.lang.String TYPE_FRAME_SIZE
           
protected static java.lang.String UNSUPPORTED_ID
           
 
Fields inherited from class org.jaudiotagger.tag.id3.AbstractTagFrame
frameBody
 
Fields inherited from class org.jaudiotagger.tag.id3.AbstractTagItem
logger
 
Constructor Summary
protected AbstractID3v2Frame()
          Create an empty frame
  AbstractID3v2Frame(AbstractID3v2Frame frame)
          Create a frame based on another frame
  AbstractID3v2Frame(AbstractID3v2FrameBody body)
          Create a frame based on a body
  AbstractID3v2Frame(java.lang.String identifier)
          Create a new frame with empty body based on identifier
 
Method Summary
 void copyContent(TagField field)
          This method copies the data of the given field to the current data.
 void createStructure()
          Return String Representation of frame
protected  AbstractID3v2Frame.EncodingFlags getEncodingFlags()
           
 java.lang.String getId()
          Return the frame identifier, this only identifies the frame it does not provide a unique key, when using frames such as TXXX which are used by many fields *
 java.lang.String getIdentifier()
          Return the frame identifier
protected  java.lang.String getLoggingFilename()
          Retrieve the logging filename to be used in debugging
 byte[] getRawContent()
          This method delivers the binary representation of the fields data in order to be directly written to the file.
protected  AbstractID3v2Frame.StatusFlags getStatusFlags()
           
 void isBinary(boolean b)
          This method will set the field to represent binary data.

Some implementations may support conversions.
As of now (Octobre 2005) there is no implementation really using this method to perform useful operations.

 boolean isEmpty()
          Determines whether the content of the field is empty.
protected  AbstractID3v2FrameBody readBody(java.lang.String identifier, AbstractID3v2FrameBody body)
          This creates a new body based of type identifier but populated by the data in the body.
protected  AbstractID3v2FrameBody readBody(java.lang.String identifier, java.nio.ByteBuffer byteBuffer, int frameSize)
          Read the frame body from the specified file via the buffer
protected  void setLoggingFilename(java.lang.String loggingFilename)
          Set logging filename when construct tag for read from file
abstract  void write(java.io.ByteArrayOutputStream tagBuffer)
           
 
Methods inherited from class org.jaudiotagger.tag.id3.AbstractTagFrame
equals, getBody, isSubsetOf, setBody
 
Methods inherited from class org.jaudiotagger.tag.id3.AbstractTagItem
getSize, read
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jaudiotagger.tag.TagField
isBinary, isCommon, toString
 

Field Detail

TYPE_FRAME

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

TYPE_FRAME_SIZE

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

UNSUPPORTED_ID

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

identifier

protected java.lang.String identifier

frameSize

protected int frameSize

loggingFilename

private java.lang.String loggingFilename

statusFlags

AbstractID3v2Frame.StatusFlags statusFlags
This holds the Status flags (not supported in v2.20


encodingFlags

AbstractID3v2Frame.EncodingFlags encodingFlags
This holds the Encoding flags (not supported in v2.20)

Constructor Detail

AbstractID3v2Frame

protected AbstractID3v2Frame()
Create an empty frame


AbstractID3v2Frame

public AbstractID3v2Frame(AbstractID3v2Frame frame)
Create a frame based on another frame

Parameters:
frame -

AbstractID3v2Frame

public AbstractID3v2Frame(AbstractID3v2FrameBody body)
Create a frame based on a body

Parameters:
body -

AbstractID3v2Frame

public AbstractID3v2Frame(java.lang.String identifier)
Create a new frame with empty body based on identifier

Parameters:
identifier -
Method Detail

getLoggingFilename

protected java.lang.String getLoggingFilename()
Retrieve the logging filename to be used in debugging

Returns:
logging filename to be used in debugging

setLoggingFilename

protected void setLoggingFilename(java.lang.String loggingFilename)
Set logging filename when construct tag for read from file

Parameters:
loggingFilename -

getId

public java.lang.String getId()
Return the frame identifier, this only identifies the frame it does not provide a unique key, when using frames such as TXXX which are used by many fields *

Specified by:
getId in interface TagField
Returns:
the frame identifier (Tag Field Interface)

getIdentifier

public java.lang.String getIdentifier()
Return the frame identifier

Specified by:
getIdentifier in class AbstractTagItem
Returns:
the frame identifier

copyContent

public void copyContent(TagField field)
Description copied from interface: TagField
This method copies the data of the given field to the current data.

Specified by:
copyContent in interface TagField
Parameters:
field - The field containing the data to be taken.

readBody

protected AbstractID3v2FrameBody readBody(java.lang.String identifier,
                                          java.nio.ByteBuffer byteBuffer,
                                          int frameSize)
                                   throws InvalidFrameException
Read the frame body from the specified file via the buffer

Parameters:
identifier - the frame identifier
byteBuffer - to read the frabe body from
frameSize -
Returns:
a newly created FrameBody
Throws:
InvalidFrameException - unable to construct a framebody from the data

readBody

protected AbstractID3v2FrameBody readBody(java.lang.String identifier,
                                          AbstractID3v2FrameBody body)
                                   throws InvalidFrameException
This creates a new body based of type identifier but populated by the data in the body. This is a different type to the body being created which is why TagUtility.copyObject() can't be used. This is used when converting between different versions of a tag for frames that have a non-trivial mapping such as TYER in v3 to TDRC in v4. This will only work where appropriate constructors exist in the frame body to be created, for example a FrameBodyTYER requires a constructor consisting of a FrameBodyTDRC.

If this method is called and a suitable constructor does not exist then an InvalidFrameException will be thrown

Parameters:
identifier - to determine type of the frame
body -
Returns:
newly created framebody for this type
Throws:
InvalidFrameException - if unable to construct a framebody for the identifier and body provided.

getRawContent

public byte[] getRawContent()
Description copied from interface: TagField
This method delivers the binary representation of the fields data in order to be directly written to the file.

Specified by:
getRawContent in interface TagField
Returns:
Binary data representing the current tag field.

write

public abstract void write(java.io.ByteArrayOutputStream tagBuffer)

isBinary

public void isBinary(boolean b)
Description copied from interface: TagField
This method will set the field to represent binary data.

Some implementations may support conversions.
As of now (Octobre 2005) there is no implementation really using this method to perform useful operations.

Specified by:
isBinary in interface TagField
Parameters:
b -

isEmpty

public boolean isEmpty()
Description copied from interface: TagField
Determines whether the content of the field is empty.

Specified by:
isEmpty in interface TagField
Returns:
true if no data is stored (or empty String).

getStatusFlags

protected AbstractID3v2Frame.StatusFlags getStatusFlags()

getEncodingFlags

protected AbstractID3v2Frame.EncodingFlags getEncodingFlags()

createStructure

public void createStructure()
Return String Representation of frame