org.jaudiotagger.tag.id3
Class ID3v22Frame

java.lang.Object
  extended by org.jaudiotagger.tag.id3.AbstractTagItem
      extended by org.jaudiotagger.tag.id3.AbstractTagFrame
          extended by org.jaudiotagger.tag.id3.AbstractID3v2Frame
              extended by org.jaudiotagger.tag.id3.ID3v22Frame
All Implemented Interfaces:
TagField

public class ID3v22Frame
extends AbstractID3v2Frame

Represents an ID3v2.2 frame.

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

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jaudiotagger.tag.id3.AbstractID3v2Frame
AbstractID3v2Frame.EncodingFlags, AbstractID3v2Frame.StatusFlags
 
Field Summary
protected static int FRAME_HEADER_SIZE
           
protected static int FRAME_ID_SIZE
           
protected static int FRAME_SIZE_SIZE
           
private static java.util.regex.Pattern validFrameIdentifier
           
 
Fields inherited from class org.jaudiotagger.tag.id3.AbstractID3v2Frame
encodingFlags, frameSize, identifier, statusFlags, TYPE_FRAME, TYPE_FRAME_SIZE, UNSUPPORTED_ID
 
Fields inherited from class org.jaudiotagger.tag.id3.AbstractTagFrame
frameBody
 
Fields inherited from class org.jaudiotagger.tag.id3.AbstractTagItem
logger
 
Constructor Summary
ID3v22Frame()
           
ID3v22Frame(AbstractID3v2Frame frame)
          Creates a new ID3v22 Frame from another frame of a different tag version
ID3v22Frame(AbstractID3v2FrameBody body)
          Creates a new ID3v22 Frame with given body
ID3v22Frame(java.nio.ByteBuffer byteBuffer)
          Deprecated. use ID3v22Frame(ByteBuffer,String) instead
ID3v22Frame(java.nio.ByteBuffer byteBuffer, java.lang.String loggingFilename)
          Creates a new ID3v22Frame datatype by reading from byteBuffer.
ID3v22Frame(ID3v22Frame frame)
          Copy Constructor

Creates a new v22 frame based on another v22 frame

ID3v22Frame(java.lang.String identifier)
          Creates a new ID3v22 Frame of type identifier.
 
Method Summary
 void createStructure()
          Return String Representation of body
private  void createV22FrameFromV23Frame(ID3v23Frame frame)
           
private  int decodeSize(byte[] buffer)
          Read Frame Size, which has to be decoded
private  void encodeSize(java.nio.ByteBuffer headerBuffer, int size)
          Write Frame Size (can now be accurately calculated, have to convert 4 byte int to 3 byte format.
 int getSize()
          Return size of frame
 boolean isBinary()
          Determines whether the represented field contains (is made up of) binary data, instead of text data.
Software can identify fields to be displayed because they are human readable if this method returns false.
 boolean isCommon()
          Identifies a field to be of common use.

Some software may differ between common and not common fields.

 boolean isValidID3v2FrameIdentifier(java.lang.String identifier)
          Does the frame identifier meet the syntax for a idv3v2 frame identifier.
 void read(java.nio.ByteBuffer byteBuffer)
          Read frame from file.
 void write(java.io.ByteArrayOutputStream tagBuffer)
          Write Frame raw data
 
Methods inherited from class org.jaudiotagger.tag.id3.AbstractID3v2Frame
copyContent, getEncodingFlags, getId, getIdentifier, getLoggingFilename, getRawContent, getStatusFlags, isBinary, isEmpty, readBody, readBody, setLoggingFilename
 
Methods inherited from class org.jaudiotagger.tag.id3.AbstractTagFrame
equals, getBody, isSubsetOf, setBody
 
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
toString
 

Field Detail

validFrameIdentifier

private static java.util.regex.Pattern validFrameIdentifier

FRAME_ID_SIZE

protected static final int FRAME_ID_SIZE
See Also:
Constant Field Values

FRAME_SIZE_SIZE

protected static final int FRAME_SIZE_SIZE
See Also:
Constant Field Values

FRAME_HEADER_SIZE

protected static final int FRAME_HEADER_SIZE
See Also:
Constant Field Values
Constructor Detail

ID3v22Frame

public ID3v22Frame()

ID3v22Frame

public ID3v22Frame(AbstractID3v2FrameBody body)
Creates a new ID3v22 Frame with given body

Parameters:
body - New body and frame is based on this

ID3v22Frame

public ID3v22Frame(java.lang.String identifier)
Creates a new ID3v22 Frame of type identifier.

An empty body of the correct type will be automatically created. This constructor should be used when wish to create a new frame from scratch using user values

Parameters:
identifier -

ID3v22Frame

public ID3v22Frame(ID3v22Frame frame)
Copy Constructor

Creates a new v22 frame based on another v22 frame

Parameters:
frame -

ID3v22Frame

public ID3v22Frame(AbstractID3v2Frame frame)
            throws InvalidFrameException
Creates a new ID3v22 Frame from another frame of a different tag version

Parameters:
frame - to construct the new frame from
Throws:
InvalidFrameException

ID3v22Frame

public ID3v22Frame(java.nio.ByteBuffer byteBuffer,
                   java.lang.String loggingFilename)
            throws InvalidFrameException
Creates a new ID3v22Frame datatype by reading from byteBuffer.

Parameters:
byteBuffer - to read from
loggingFilename -
Throws:
InvalidFrameException

ID3v22Frame

public ID3v22Frame(java.nio.ByteBuffer byteBuffer)
            throws InvalidFrameException
Deprecated. use ID3v22Frame(ByteBuffer,String) instead

Creates a new ID3v23Frame datatype by reading from byteBuffer.

Parameters:
byteBuffer - to read from
Throws:
InvalidFrameException
Method Detail

createV22FrameFromV23Frame

private void createV22FrameFromV23Frame(ID3v23Frame frame)
                                 throws InvalidFrameException
Throws:
InvalidFrameException

getSize

public int getSize()
Return size of frame

Specified by:
getSize in class AbstractTagItem
Returns:
int size of frame

read

public void read(java.nio.ByteBuffer byteBuffer)
          throws InvalidFrameException
Read frame from file. Read the frame header then delegate reading of data to frame body.

Specified by:
read in class AbstractTagItem
Parameters:
byteBuffer -
Throws:
InvalidFrameException

decodeSize

private int decodeSize(byte[] buffer)
Read Frame Size, which has to be decoded

Parameters:
buffer -
Returns:

write

public void write(java.io.ByteArrayOutputStream tagBuffer)
Write Frame raw data

Specified by:
write in class AbstractID3v2Frame
Throws:
java.io.IOException

encodeSize

private void encodeSize(java.nio.ByteBuffer headerBuffer,
                        int size)
Write Frame Size (can now be accurately calculated, have to convert 4 byte int to 3 byte format.

Parameters:
headerBuffer -
size -

isValidID3v2FrameIdentifier

public boolean isValidID3v2FrameIdentifier(java.lang.String identifier)
Does the frame identifier meet the syntax for a idv3v2 frame identifier. must start with a capital letter and only contain capital letters and numbers

Parameters:
identifier -
Returns:

createStructure

public void createStructure()
Return String Representation of body

Overrides:
createStructure in class AbstractID3v2Frame

isCommon

public boolean isCommon()
Description copied from interface: TagField
Identifies a field to be of common use.

Some software may differ between common and not common fields. A common one is for sure the title field. A web link may not be of common use for tagging. However some file formats, or future development of users expectations will make more fields common than now can be known.

Returns:
true if considered a common frame

isBinary

public boolean isBinary()
Description copied from interface: TagField
Determines whether the represented field contains (is made up of) binary data, instead of text data.
Software can identify fields to be displayed because they are human readable if this method returns false.

Returns:
true if considered a common frame