helliker.id3
Class ID3v2Frame

java.lang.Object
  |
  +--helliker.id3.ID3v2Frame

public class ID3v2Frame
extends java.lang.Object


Constructor Summary
ID3v2Frame(java.lang.String id, byte[] data)
          Create and ID3v2 frame with the specified id and data.
ID3v2Frame(java.lang.String id, byte[] data, boolean tagAlterDiscard, boolean fileAlterDiscard, boolean readOnly, boolean grouped, boolean compressed, boolean encrypted, boolean unsynchronised, boolean lengthIndicator)
          Create an ID3v2Frame with the specified id, data, and flags set.
ID3v2Frame(java.lang.String id, byte[] flags, byte[] data)
          Create an ID3v2Frame with a specified id, a byte array containing the frame header flags, and a byte array containing the data for this frame.
 
Method Summary
 boolean getCompressed()
          Returns true if this frame is compressed
 int getDataLength()
          If a length indicator has been added, the length of the data is returned.
 java.lang.String getDataString()
          If possible, this method attempts to convert textual part of the data into a string.
 boolean getEncrypted()
          Returns true if this frame is encrypted
 byte getEncryptionType()
          If encrypted, this returns the encryption method byte.
 boolean getFileAlterDiscard()
          Returns true if the file alter preservation bit has been set.
 byte[] getFrameBytes()
          Returns a byte array representation of this frame that can be written to a file.
 byte[] getFrameData()
          Returns the data for this frame
 int getFrameLength()
          Return the length of this frame in bytes, including the header.
 byte getGroup()
          Returns the group identifier if added.
 boolean getGrouped()
          Returns true if this frame is a part of a group
 boolean getLengthIndicator()
          Returns true if this frame has a length indicator added
 boolean getReadOnly()
          Returns true if this frame is read only
 boolean getTagAlterDiscard()
          Returns true if the tag alter preservation bit has been set.
 boolean getUnsynchronised()
          Returns true if this frame is unsynchronised
 boolean isEmpty()
          Returns true if there is no data in the frame.
 void setFrameData(byte[] newData)
          Set the data for this frame.
 java.lang.String toString()
          Return a string representation of this object that contains all the information contained within it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ID3v2Frame

public ID3v2Frame(java.lang.String id,
                  byte[] flags,
                  byte[] data)
           throws ID3v2FormatException
Create an ID3v2Frame with a specified id, a byte array containing the frame header flags, and a byte array containing the data for this frame.

Parameters:
id - the id of this frame
flags - the flags found in the header of the frame (2 bytes)
data - the data found in this frame
Throws:
ID3v2FormatException - if an error occurs

ID3v2Frame

public ID3v2Frame(java.lang.String id,
                  byte[] data)
Create and ID3v2 frame with the specified id and data. All the flag bits are set to false.

Parameters:
id - the id of this frame
data - the data for this frame

ID3v2Frame

public ID3v2Frame(java.lang.String id,
                  byte[] data,
                  boolean tagAlterDiscard,
                  boolean fileAlterDiscard,
                  boolean readOnly,
                  boolean grouped,
                  boolean compressed,
                  boolean encrypted,
                  boolean unsynchronised,
                  boolean lengthIndicator)
Create an ID3v2Frame with the specified id, data, and flags set. It is expected that the corresponing data for the flags that require extra data is found in the data array in the standard place.

Parameters:
id - the id for this frame
data - the data for this frame
tagAlterDiscard - the tag alter preservation flag
fileAlterDiscard - the file alter preservation flag
readOnly - the read only flag
grouped - the grouping identity flag
compressed - the compression flag
encrypted - the encryption flag
unsynchronised - the unsynchronisation flag
lengthIndicator - the data length indicator flag
Method Detail

getFrameData

public byte[] getFrameData()
Returns the data for this frame

Returns:
the data for this frame

setFrameData

public void setFrameData(byte[] newData)
Set the data for this frame. This does nothing if this frame is read only.

Parameters:
newData - a byte array containing the new data

getFrameLength

public int getFrameLength()
Return the length of this frame in bytes, including the header.

Returns:
the length of this frame

getFrameBytes

public byte[] getFrameBytes()
Returns a byte array representation of this frame that can be written to a file. Includes the header and data.

Returns:
a binary representation of this frame to be written to a file

getTagAlterDiscard

public boolean getTagAlterDiscard()
Returns true if the tag alter preservation bit has been set. If set then the frame should be discarded if it is altered and the id is unknown.

Returns:
true if the tag alter preservation bit has been set

getFileAlterDiscard

public boolean getFileAlterDiscard()
Returns true if the file alter preservation bit has been set. If set then the frame should be discarded if the file is altered and the id is unknown.

Returns:
true if the file alter preservation bit has been set

getReadOnly

public boolean getReadOnly()
Returns true if this frame is read only

Returns:
true if this frame is read only

getGrouped

public boolean getGrouped()
Returns true if this frame is a part of a group

Returns:
true if this frame is a part of a group

getCompressed

public boolean getCompressed()
Returns true if this frame is compressed

Returns:
true if this frame is compressed

getEncrypted

public boolean getEncrypted()
Returns true if this frame is encrypted

Returns:
true if this frame is encrypted

getUnsynchronised

public boolean getUnsynchronised()
Returns true if this frame is unsynchronised

Returns:
true if this frame is unsynchronised

getLengthIndicator

public boolean getLengthIndicator()
Returns true if this frame has a length indicator added

Returns:
true if this frame has a length indicator added

getGroup

public byte getGroup()
Returns the group identifier if added. Otherwise the null byte is returned.

Returns:
the groupd identifier if added, null byte otherwise

getEncryptionType

public byte getEncryptionType()
If encrypted, this returns the encryption method byte. If it is not encrypted, the null byte is returned.

Returns:
the encryption method if set and the null byte if not

getDataLength

public int getDataLength()
If a length indicator has been added, the length of the data is returned. Otherwise -1 is returned.

Returns:
the length of the data if a length indicator is present or -1

getDataString

public java.lang.String getDataString()
                               throws ID3v2FormatException
If possible, this method attempts to convert textual part of the data into a string. If this frame does not contain textual information, an empty string is returned.

Returns:
the textual portion of the data in this frame
Throws:
ID3v2FormatException - if an error occurs

isEmpty

public boolean isEmpty()
Returns true if there is no data in the frame.

Returns:
true if there is no data in the frame

toString

public java.lang.String toString()
Return a string representation of this object that contains all the information contained within it.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this object