com.tffenterprises.music.tag.id3v2
Class Flags_3_0

java.lang.Object
  extended by com.tffenterprises.music.tag.id3v2.Flags
      extended by com.tffenterprises.music.tag.id3v2.Flags_3_0
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
Flags_3_0_NoSync

 class Flags_3_0
extends Flags
implements java.io.Serializable, java.lang.Cloneable

Flags_3_0 implements the flags for version 3.0 of ID3v2 (aka ID3v2.3.0).

Version:
1.0d1 $Date: 2003/03/16 18:52:29 $
Author:
Guillaume Lessard

Nested Class Summary
 
Nested classes/interfaces inherited from class com.tffenterprises.music.tag.id3v2.Flags
Flags.InputProcessingStream
 
Field Summary
static short CRC_EXTFLAG
          Extended flag bit for CRC32 presence.
static byte EXTENDED_HEADER_FLAG
          Flag bit for extended header presence.
private  short extendedFlags
          The extended flags field; 16 bits stored in a short.
private  int paddingLength
          The padding length, a useless value.
private  long tagCRC32
          A CRC32 value, if necessary
 
Fields inherited from class com.tffenterprises.music.tag.id3v2.Flags
DEFAULT, EXPERIMENTAL_FLAG, UNSYNCHRONIZATION_FLAG
 
Constructor Summary
protected Flags_3_0()
          Default constructor.
protected Flags_3_0(byte flags)
          Constructs a Flags_3_0 object with the given flags and zeroed extended flags.
protected Flags_3_0(byte flags, short extFlags)
          Constructs a Flags_3_0 object with the given flags extended flags.
 
Method Summary
 boolean checkExtFlagMask(short flagMask)
          Check whether a combination of bits is set in the extended flags short.
 void checkVersion()
          Asserts that the object's assigned version number is compatible.
 boolean equals(java.lang.Object other)
          Compares this Flags object with another one.
 short getExtFlags()
          Returns the current state of the extended flags.
protected  java.io.InputStream processCRC32ExtFlag(java.io.InputStream is)
           
protected  java.io.InputStream processExtendedFlags(java.io.InputStream in)
          Process the extended header's flags, reading information from the InputStream in, and returning an InputStream suitable for decoding the tag information.
 java.io.InputStream processInput(java.io.InputStream in)
          Process the InputStream in which the ID3v2 information is embedded.
 java.io.OutputStream processOutput(java.io.OutputStream out)
          Process the OutputStream in which the ID3v2 tag is to be embedded.
protected  int readExtendedHeader(java.io.InputStream in)
          Reads the extended header.
 void setExtFlagMask(short flagMask)
          Set the bits corresponding to a mask of bits.
 void setExtFlags(short newFlags)
          Set the flags as indicated by the newFlags parameter.
 java.lang.String toString()
          Returns a String representation of these flags.
 void unsetExtFlagMask(short flagMask)
          Unset the bits corresponding to a mask of bits.
 void updateChecksum(DataOutputChecksum checksum)
          Updates a Checksum with all of this object's data.
 boolean usesCRC32()
          Returns whether these flags indicate the use of a CRC32
 boolean usesExtendedHeader()
          v * Returns whether these flags indicate the use of an extended header
 
Methods inherited from class com.tffenterprises.music.tag.id3v2.Flags
check, clone, getChecksum, getFlags, getNewInstance, getNewInstance, getNewInstance, getVersion, hashCode, isChanged, isMarkedExperimental, processUnsynchronization, set, setChanged, setFlags, unset, updateChecksum, usesUnsynchronization
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CRC_EXTFLAG

public static final short CRC_EXTFLAG
Extended flag bit for CRC32 presence.

See Also:
Constant Field Values

EXTENDED_HEADER_FLAG

public static final byte EXTENDED_HEADER_FLAG
Flag bit for extended header presence.

See Also:
Constant Field Values

extendedFlags

private short extendedFlags
The extended flags field; 16 bits stored in a short.


paddingLength

private transient int paddingLength
The padding length, a useless value.


tagCRC32

private transient long tagCRC32
A CRC32 value, if necessary

Constructor Detail

Flags_3_0

protected Flags_3_0()
Default constructor. Constructs a Flags_3_0 object with zeroed flags. This should not be called by normal users of Flags objects. Use the factory method newInstance() instead.


Flags_3_0

protected Flags_3_0(byte flags)
Constructs a Flags_3_0 object with the given flags and zeroed extended flags. This should not be called by normal users of Flags objects. Use the factory method newInstance() instead.

Parameters:
flags - the flags used to initialize the object.

Flags_3_0

protected Flags_3_0(byte flags,
                    short extFlags)
Constructs a Flags_3_0 object with the given flags extended flags. This should not be called by normal users of Flags objects. Use the factory method newInstance() instead.

Parameters:
flags - the flags used to initialize the object.
extFlags - the extended flags used to initialize the object.
Method Detail

updateChecksum

public void updateChecksum(DataOutputChecksum checksum)
Updates a Checksum with all of this object's data. This is used by the hashCode() and getChecksum() methods of Flags.

Parameters:
checksum - the Checksum to be updated.

equals

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

Overrides:
equals in class Flags
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 these flags.

Overrides:
toString in class Flags
Returns:
a String representation of these flags.

getExtFlags

public short getExtFlags()
Returns the current state of the extended flags.

Returns:
the current state of the extended flags.

setExtFlags

public void setExtFlags(short newFlags)
Set the flags as indicated by the newFlags parameter.

Parameters:
newFlags - the combination of values to assign to the extended flags.

checkExtFlagMask

public boolean checkExtFlagMask(short flagMask)
Check whether a combination of bits is set in the extended flags short.

Parameters:
flagMask - the combination of bits to check
Returns:
whether the bits from the mask are set in the extended flags.

setExtFlagMask

public void setExtFlagMask(short flagMask)
Set the bits corresponding to a mask of bits.

Parameters:
flagMask - the combination of bits to set

unsetExtFlagMask

public void unsetExtFlagMask(short flagMask)
Unset the bits corresponding to a mask of bits.

Parameters:
flagMask - the combination of bits to unset

checkVersion

public void checkVersion()
                  throws TagDataFormatException
Asserts that the object's assigned version number is compatible.

Specified by:
checkVersion in class Flags
Throws:
TagDataFormatException - if the version is not compatible.

usesExtendedHeader

public boolean usesExtendedHeader()
v * Returns whether these flags indicate the use of an extended header

Returns:
whether these flags indicate the use of an extended header

usesCRC32

public boolean usesCRC32()
Returns whether these flags indicate the use of a CRC32

Returns:
whether these flags indicate the use of a CRC32

processInput

public java.io.InputStream processInput(java.io.InputStream in)
                                 throws java.io.IOException,
                                        TagDataFormatException
Process the InputStream in which the ID3v2 information is embedded.

Overrides:
processInput in class Flags
Parameters:
in - the InputStream in which the ID3v2 information is embedded.
Returns:
an InputStream which will correctly process the tag..
Throws:
TagDataFormatException - if the stream contains a malformed tag, or some erroneous parameters.
java.io.IOException - if an I/O error occurs.

readExtendedHeader

protected int readExtendedHeader(java.io.InputStream in)
                          throws java.io.IOException,
                                 TagDataFormatException
Reads the extended header. Obviously, the stream needs to be positioned correctly for this to work.

Parameters:
in - the inputstream from which the extended header is to be read.
Returns:
the number of bytes that remain to be read in the extended header.
Throws:
java.io.IOException - if an I/O error occurs during reading.
TagDataFormatException - if the data format is incorrect.

processExtendedFlags

protected java.io.InputStream processExtendedFlags(java.io.InputStream in)
                                            throws java.io.IOException
Process the extended header's flags, reading information from the InputStream in, and returning an InputStream suitable for decoding the tag information.

In the case of this class, there is in fact nothing to do, since the behaviour of ID3v2.3's extended header is defined in a way that is unusable. We provide an example of how a functional CRC32 might be checked for, but no error is generated.

Parameters:
in - the inputstream from which to read the data, and that is to be encapsulated if appropriate.
Returns:
an InputStream suitable for decoding the tag data.
Throws:
java.io.IOException - if an I/O error occurs.

processCRC32ExtFlag

protected java.io.InputStream processCRC32ExtFlag(java.io.InputStream is)

processOutput

public java.io.OutputStream processOutput(java.io.OutputStream out)
Process the OutputStream in which the ID3v2 tag is to be embedded. This method is called by ID3v2 when writing the tag to a file or stream.

This method applies a FilterOutputStream which processes any necessary unsynchronization for the tag, and makes sure the compression flag is not set.

Overrides:
processOutput in class Flags
Parameters:
out - the OutputStream to which the ID3v2 tag will be written
Returns:
the OutputStream to which the ID3v2 tag will be written