com.tffenterprises.music.tag.id3v2.frame
Class FrameHeader_3_0

java.lang.Object
  extended by com.tffenterprises.music.tag.id3v2.frame.FrameHeader
      extended by com.tffenterprises.music.tag.id3v2.frame.FrameHeader_3_0
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
FrameHeader_3_0_NoCompression

public class FrameHeader_3_0
extends FrameHeader
implements java.io.Serializable, java.lang.Cloneable

FrameHeader_3_0 is a class that provides ID3v2 with an interpretation of the frame header structure, as defined in the ID3v2.3 specification.

Version:
1.0d1 $Date: 2003/03/19 22:48:21 $
Author:
Guillaume Lessard
See Also:
Serialized Form

Field Summary
static byte COMPRESSED_FRAME
          Format flags mask that, if set, signifies that the frame's data is compressed using the standard "deflate" algorithm, as implemented by the zlib library.
static byte ENCRYPTED_FRAME
          Format flags mask that, if set, signifies that the frame's data has been encrypted.
static byte FILE_ALTER_DISPOSE
          Status flags mask that, if set, signifies that the frame is to be discarded or recomputed if the tagged file is altered.
private  byte formatFlags
          The frame format flags.
static byte GROUPED_FRAME
          Format flags mask that, if set, signifies that the frame is part of a group of frames.
static byte READ_ONLY
          Status flags mask that, if set, signifies that the frame is read-only, and shouldn't be changed.
private  byte statusFlags
          The frame status flags.
static byte TAG_ALTER_DISPOSE
          Status flags mask that, if set, signifies that the frame is to be discarded or recomputed if the tag is altered.
 
Fields inherited from class com.tffenterprises.music.tag.id3v2.frame.FrameHeader
NULL_ID
 
Constructor Summary
FrameHeader_3_0()
          Default constructor.
FrameHeader_3_0(java.io.InputStream in)
          Constructs a FrameHeader_2_0 from an InputStream.
 
Method Summary
 java.lang.Object clone()
          Returns a clone of this Flags object.
 boolean equals(java.lang.Object other)
          Compares this FrameHeader object with another one.
 byte getFormatFlags()
          Returns this frame's format flags byte.
 byte getStatusFlags()
          Returns this frame's status flags byte.
private  java.io.OutputStream processCompression(java.io.OutputStream out)
          This sets up the decompression process for ID3v2.3 frames by layering/substituting a compressing OutputStream over the one received as a parameter.
private  java.io.InputStream processDecompression(java.io.InputStream in)
          This sets up the decompression process for ID3v2.3 frames by layering a decompressing InputStream over the one received as a parameter.
protected  java.io.InputStream processInput(java.io.InputStream in)
          Layer input stream filters over in in accordance with the frame flags, and return the resulting input stream.
protected  java.io.OutputStream processOutput(java.io.OutputStream out)
          Process the OutputStream in which the frame is to be embedded.
 void setFormatFlags(byte flags)
          Sets this frame's format flags byte.
 void setStatusFlags(byte flags)
          Sets this frame's status flags byte.
 java.lang.String toString()
          Returns a String representation of this FrameHeader object.
 void updateChecksum(DataOutputChecksum checksum)
          Updates a Checskum with all this object's data.
 boolean usesCompression()
          Returns whether this frame uses compression
 void writeTo(java.io.OutputStream os)
          Writes this FrameHeader to an OutputStream.
 
Methods inherited from class com.tffenterprises.music.tag.id3v2.frame.FrameHeader
checkFormatMask, checkStatusMask, getChecksum, getDataLength, getFrameBytesFromStream, getFrameID, getFrameLength, getNewInstance, getNewInstance, getNewInstance, getNewInstance, hashCode, isChanged, isValidFrameID, setChanged, setDataLength, setFormatMask, setFrameID, setFrameLength, setStatusMask, unsetFormatMask, unsetStatusMask, usesDataLengthIndicator, usesEncryption, usesGroupID, usesUnsynchronization
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TAG_ALTER_DISPOSE

public static final byte TAG_ALTER_DISPOSE
Status flags mask that, if set, signifies that the frame is to be discarded or recomputed if the tag is altered.

See Also:
Constant Field Values

FILE_ALTER_DISPOSE

public static final byte FILE_ALTER_DISPOSE
Status flags mask that, if set, signifies that the frame is to be discarded or recomputed if the tagged file is altered.

See Also:
Constant Field Values

READ_ONLY

public static final byte READ_ONLY
Status flags mask that, if set, signifies that the frame is read-only, and shouldn't be changed.

See Also:
Constant Field Values

COMPRESSED_FRAME

public static final byte COMPRESSED_FRAME
Format flags mask that, if set, signifies that the frame's data is compressed using the standard "deflate" algorithm, as implemented by the zlib library. The uncompressed length of the data in 32 bits prepends the compressed frame data.

See Also:
Constant Field Values

ENCRYPTED_FRAME

public static final byte ENCRYPTED_FRAME
Format flags mask that, if set, signifies that the frame's data has been encrypted. An unencrypted byte prepends the encrypted data, containing an identifier for an encryption algorithm. The encryption algorithm be described in another frame in the same tag.

See Also:
Constant Field Values

GROUPED_FRAME

public static final byte GROUPED_FRAME
Format flags mask that, if set, signifies that the frame is part of a group of frames. An group identifier byte prepends the data.

See Also:
Constant Field Values

statusFlags

private byte statusFlags
The frame status flags.


formatFlags

private byte formatFlags
The frame format flags.

Constructor Detail

FrameHeader_3_0

public FrameHeader_3_0()
Default constructor. Constructs a FrameHeader object with zeroed flags and and undefined frame ID.

This constructor should not be called by normal users of FrameHeader objects. Use the factory method getNewInstance(short version) instead.


FrameHeader_3_0

public FrameHeader_3_0(java.io.InputStream in)
                throws java.io.IOException,
                       PaddingException,
                       TagDataFormatException
Constructs a FrameHeader_2_0 from an InputStream. This should not be called by normal users of FrameHeader objects. Use the factory class method getNewInstance(short version, InputStream in) instead.

Parameters:
in - An InputStream from which to read the FrameHeader information.
Throws:
PaddingException - if all the read bytes are nulls
java.io.IOException - if the InputStream throws one
TagDataFormatException
Method Detail

updateChecksum

public void updateChecksum(DataOutputChecksum checksum)
Updates a Checskum with all this object's data. This is used by the getChecksum() method, and can be used by other objects which may have this object as a data member.

Overrides:
updateChecksum in class FrameHeader
Parameters:
checksum - a Checksum to be updated.

clone

public java.lang.Object clone()
Returns a clone of this Flags object. The object returned by this implementation already has the proper type. In order for this method to work, subclasses of BaseFrame must have a default constructor accessible to this class.

Overrides:
clone in class FrameHeader
Returns:
a clone of this Flags object.

equals

public boolean equals(java.lang.Object other)
Compares this FrameHeader object with another one.

Overrides:
equals in class FrameHeader
Parameters:
other - The other object.
Returns:
true if the two objects are equivalent, false otherwise.

toString

public java.lang.String toString()
Returns a String representation of this FrameHeader object.

Overrides:
toString in class FrameHeader
Returns:
a String representation of this FrameHeader object.

getStatusFlags

public byte getStatusFlags()
Returns this frame's status flags byte.

Overrides:
getStatusFlags in class FrameHeader
Returns:
this frame's status flags byte.

setStatusFlags

public void setStatusFlags(byte flags)
Sets this frame's status flags byte.

Overrides:
setStatusFlags in class FrameHeader
Parameters:
flags - The new status flags byte.

getFormatFlags

public byte getFormatFlags()
Returns this frame's format flags byte.

Overrides:
getFormatFlags in class FrameHeader
Returns:
this frame's format flags byte.

setFormatFlags

public void setFormatFlags(byte flags)
Sets this frame's format flags byte.

Overrides:
setFormatFlags in class FrameHeader
Parameters:
flags - The new format flags byte.

usesCompression

public boolean usesCompression()
Returns whether this frame uses compression

Overrides:
usesCompression in class FrameHeader
Returns:
whether this frame uses compression

writeTo

public void writeTo(java.io.OutputStream os)
             throws java.io.IOException
Writes this FrameHeader to an OutputStream. This method is used by Frame subclasses during the execution of their writeTo(OutputStream) and getBytes() methods.

The state of the object should be assumed to have preliminarily been updated with data and values obtained from the writeTo in class FrameHeader

Parameters:
os - the stream to which this object will be written.
Throws:
java.io.IOException - if an I/O error occurs while writing.

processInput

protected java.io.InputStream processInput(java.io.InputStream in)
                                    throws FrameDataFormatException
Layer input stream filters over in in accordance with the frame flags, and return the resulting input stream. This is called from within getFrameBytesFromStream().

Overrides:
processInput in class FrameHeader
Parameters:
in - the initial input stream.
Returns:
an input stream capable of completely decoding the frame data.
Throws:
FrameDataFormatException - if the frame cannot be decoded for any reason (most likely due to incorrect data formatting).

processDecompression

private java.io.InputStream processDecompression(java.io.InputStream in)
                                          throws java.io.IOException
This sets up the decompression process for ID3v2.3 frames by layering a decompressing InputStream over the one received as a parameter.

Parameters:
in - an input stream from which the frame is being read.
Returns:
an input stream from which the frame will be read.
Throws:
java.io.IOException - if an I/O error occurs while reading.

processOutput

protected java.io.OutputStream processOutput(java.io.OutputStream out)
                                      throws java.io.IOException
Process the OutputStream in which the frame is to be embedded. This method is called by Frame subclasses when the frame is being written to a file or stream

A FrameHeader subclass should override this method and apply whatever calculations and FilterOutputStream subclasses are necessary to output a correct stream of the frame. See the method postProcessUnsynchronization() of Flags for an example of a FilterOutputStream that can be applied through this method.

Overrides:
processOutput in class FrameHeader
Parameters:
out - the OutputStream to which the frame will be written
Returns:
the OutputStream to which the frame will be written
Throws:
java.io.IOException - if an error occurs

processCompression

private java.io.OutputStream processCompression(java.io.OutputStream out)
This sets up the decompression process for ID3v2.3 frames by layering/substituting a compressing OutputStream over the one received as a parameter.

Parameters:
out - an input stream to which the frame will be written.
Returns:
an input stream to which the frame will be written.