de.vdheide.mp3
Class ID3v2Frame

java.lang.Object
  extended byde.vdheide.mp3.ID3v2Frame

public class ID3v2Frame
extends java.lang.Object

This class contains one ID3v2 frame. Note: ID3v2 frame does not now anything about unsynchronization. That is up to higher level objects (i.e. ID3v2)


Field Summary
static byte DO_COMPRESS
          Compression requested
static java.lang.String ID_INVALID
          Invalid ID
static byte IS_COMPRESSED
          Compression present
static byte NO_COMPRESSION
          No compression present or requested
 
Constructor Summary
ID3v2Frame(java.io.InputStream in)
          Creates a new ID3v2 frame from a stream.
ID3v2Frame(java.lang.String id, byte[] content, boolean tag_alter_preservation, boolean file_alter_preservation, boolean read_only, byte compression_type, byte encryption_id, byte group)
          Creates a new ID3v2 frame
 
Method Summary
 boolean equals(java.lang.Object other)
          Check whether this frame is equal to another frame.
 byte[] getBytes()
          Returns an array of bytes representing this frame
 boolean getCompression()
          Determine whether the frame is compressed
 byte[] getContent()
          Returns content (decompressed)
 byte getEncryptionID()
           
 boolean getFileAlterPreservation()
          Determine whether the frame should be preserved if the file but not the frame is altered and the frame ID is unknown to the altering application.
 byte getGroup()
          Get the group ID this frame belongs to
 java.lang.String getID()
          Get the ID of this frame.
 int getLength()
          Calculates the number of bytes necessary to store a byte representation of this frame.
 boolean getReadOnly()
          Determine whether the frame is read-only
 boolean getTagAlterPreservation()
          Determine whether the frame should be preserved if the tag is altered and the frame ID is unknown to the altering application.
 void setCompression(boolean compression)
          Determine whether the frame should be compressed
 void setEncryption(byte encryption_id)
          Set the encryption ID to use.
 void setFileAlterPreservation(boolean file_alter_preservation)
          Determine whether the frame should be preserved if the file but not the frame is altered and the frame ID is unknown to the altering application.
 void setGroup(byte group)
          Set the group ID this frame belongs to
 void setID(java.lang.String id)
          Set the ID of this frame
 void setReadOnly(boolean read_only)
          Determine whether the frame is read-only
 void setTagAlterPreservation(boolean tag_alter_preservation)
          Determine whether the frame should be preserved if the tag is altered and the frame ID is unknown to the altering application.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_COMPRESSION

public static final byte NO_COMPRESSION
No compression present or requested

See Also:
Constant Field Values

IS_COMPRESSED

public static final byte IS_COMPRESSED
Compression present

See Also:
Constant Field Values

DO_COMPRESS

public static final byte DO_COMPRESS
Compression requested

See Also:
Constant Field Values

ID_INVALID

public static final java.lang.String ID_INVALID
Invalid ID

Constructor Detail

ID3v2Frame

public ID3v2Frame(java.lang.String id,
                  byte[] content,
                  boolean tag_alter_preservation,
                  boolean file_alter_preservation,
                  boolean read_only,
                  byte compression_type,
                  byte encryption_id,
                  byte group)
           throws ID3v2DecompressionException
Creates a new ID3v2 frame

Parameters:
id - Frame id
content - Frame content. Must not be unsynchronized!
tag_alter_preservation - True if frame should be discarded if frame id is unknown to software and tag is altered
file_alter_preservation - Same as tag_alter_preservation, but applies if file (excluding tag) is altered
read_only - True if frame should not be changed
compression_type - Use contant from this class: ID3v2Frame.NO_COMPRESSION: content is not compressed and should not be compressed. ID3v2Frame.IS_COMPRESSED: content is already compressed ID3v2Frame.DO_COMPRESS:content is not compressed, but should be Compression can also be switched on/off with setCompression
encryption_id - Encryption method or 0 if not encrypted (not completely supported, encryption must be done externally)
group - Group of frames this frame belongs to or 0 if frame does not belong to any group
Throws:
ID3v2DecompressionException - If content is compressed and decompresson fails

ID3v2Frame

public ID3v2Frame(java.io.InputStream in)
           throws java.io.IOException,
                  ID3v2DecompressionException
Creates a new ID3v2 frame from a stream. Stream position must be set to first byte of frame. Note: Encryption/Deencryption is not supported, so content of encrypted frames will be returned encrypted. It is up to the higher level routines to decompress it. Note^2: Compression/decompression supports only GZIP.

Parameters:
in - Stream to read from
Throws:
ID3v2DecompressionException - If input is compressed and decompression fails
java.io.IOException - If I/O error occurs
Method Detail

getID

public java.lang.String getID()
Get the ID of this frame.

Returns:
ID of frame

setID

public void setID(java.lang.String id)
Set the ID of this frame

Parameters:
id - ID to set

getTagAlterPreservation

public boolean getTagAlterPreservation()
Determine whether the frame should be preserved if the tag is altered and the frame ID is unknown to the altering application.

Returns:
true if the frame should be preserved

setTagAlterPreservation

public void setTagAlterPreservation(boolean tag_alter_preservation)
Determine whether the frame should be preserved if the tag is altered and the frame ID is unknown to the altering application.

Parameters:
tag_alter_preservation - true if the frame should be preserved

getFileAlterPreservation

public boolean getFileAlterPreservation()
Determine whether the frame should be preserved if the file but not the frame is altered and the frame ID is unknown to the altering application.

Returns:
true if the frame should be preserved

setFileAlterPreservation

public void setFileAlterPreservation(boolean file_alter_preservation)
Determine whether the frame should be preserved if the file but not the frame is altered and the frame ID is unknown to the altering application.

Parameters:
file_alter_preservation - true if the frame should be preserved

getReadOnly

public boolean getReadOnly()
Determine whether the frame is read-only

Returns:
true if the frame is read-only

setReadOnly

public void setReadOnly(boolean read_only)
Determine whether the frame is read-only

Parameters:
read_only - true if the frame is read-only

getCompression

public boolean getCompression()
Determine whether the frame is compressed

Returns:
true if the frame is compressed

setCompression

public void setCompression(boolean compression)
Determine whether the frame should be compressed

Parameters:
compression - true if the frame should be compressed

getEncryptionID

public byte getEncryptionID()
Returns:
Encrytion ID or 0 if not encrypted

setEncryption

public void setEncryption(byte encryption_id)
Set the encryption ID to use.

Parameters:
encryption_id - encryption ID to use or 0 for no encryption

getGroup

public byte getGroup()
Get the group ID this frame belongs to

Returns:
group ID or 0 if no group

setGroup

public void setGroup(byte group)
Set the group ID this frame belongs to

Parameters:
group - group ID or 0 if no group

getLength

public int getLength()
Calculates the number of bytes necessary to store a byte representation of this frame.

Returns:
Number of bytes necessary for this frame

getContent

public byte[] getContent()
Returns content (decompressed)

Returns:
Decompressed content

getBytes

public byte[] getBytes()
Returns an array of bytes representing this frame

Returns:
Content taking into account any flags

equals

public boolean equals(java.lang.Object other)
Check whether this frame is equal to another frame. Two frames are considered equal if the ids, the content and all flags are equal.

Parameters:
other - the other frame
Returns:
true if both frames are equal