|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.tffenterprises.music.tag.id3v2.Flags
public abstract class Flags
Flags is a class that provides ID3v2 with an interpretation of the ID3v2 header flags. It is also the base class for all other versions of the ID3v2 flags. Flags features a factory class method that will return an object of the appropriate subclass for the version of ID3v2 being read.
A Flags subclass must override the processFlags() and postProcessFlags() methods, and provide a default constructor that is accessible to the factory static method Flags.getNewInstance(short version, byte flags).
Nested Class Summary | |
---|---|
class |
Flags.InputProcessingStream
|
Field Summary | |
---|---|
private boolean |
changed
Whether this Flags object has been changed. |
static java.lang.String |
DEFAULT
A mnemotechnic/easy parameter to pass the ResourceBundle and obtain the Flags subclass implementing the newest spec. |
static byte |
EXPERIMENTAL_FLAG
Flag bit for experimental status. |
private byte |
flags
A byte containing the ID3v2 flags field; 8 bits stored in a byte. |
private static java.util.ResourceBundle |
FLAGS_CLASS_INFO
A resource bundle listing the subclass by version |
private static java.util.Hashtable |
FLAGS_CLASSES
The Hashtable which contains all the initialized class objects of our subclasses, keyed by version. |
static byte |
UNSYNCHRONIZATION_FLAG
Flag bit for unsynchronization. |
private short |
version
A short containing the represented ID3v2 specification version |
Constructor Summary | |
---|---|
protected |
Flags()
Default constructor. |
protected |
Flags(byte flags)
Constructs a Flags object with zeroed flags. |
Method Summary | |
---|---|
boolean |
check(byte flagMask)
Check whether a combination of bits is set in the flags byte. |
abstract void |
checkVersion()
Asserts that this Flags object's version is compatible with the code. |
java.lang.Object |
clone()
Returns a clone of this Flags object. |
boolean |
equals(java.lang.Object other)
Compares this Flags object with another one. |
java.util.zip.Checksum |
getChecksum()
Returns a Checksum of all this object's data. |
byte |
getFlags()
Return the current state of the flags. |
private static java.lang.Class |
GetFlagsClass(short version)
Obtain the Class object for the subclass of Flags corresponding to the given specification version. |
private static java.lang.Class |
GetFlagsClass(java.lang.String versionString)
Obtain the Class object for the subclass of Flags corresponding to the given specification version. |
static Flags |
getNewInstance()
Create a new Flags object; use the subclass implementing the latest version of the specification supported by this library. |
static Flags |
getNewInstance(short version)
Create a new Flags object of a subclass appropriate for the version parameter. |
static Flags |
getNewInstance(short version,
byte flagByte)
Create a new Flags object of a subclass appropriate for the version parameter. |
short |
getVersion()
Returns the ID3v2 specification version given to this Flags object |
int |
hashCode()
Returns a hash code for this Flags object. |
boolean |
isChanged()
Returns true if this Flags object has been changed. |
boolean |
isMarkedExperimental()
Return true if the flags indicate experimental status. |
java.io.InputStream |
processInput(java.io.InputStream is)
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 java.io.OutputStream |
processUnsynchronization(java.io.OutputStream out)
This sets up the unsynchronization process for ID3v2 tags (versions prior to 4.0). |
void |
set(byte flagMask)
Set the bits corresponding to a mask of bits. |
void |
setChanged(boolean changed)
Sets or clears the "changed" bit. |
void |
setFlags(byte newFlags)
Set the flags as indicated by the newFlags parameter. |
java.lang.String |
toString()
Returns a String representation of this ID3v2 Flags object. |
void |
unset(byte flagMask)
Unset the bits corresponding to a mask of bits. |
void |
updateChecksum(java.util.zip.Checksum checksum)
Updates a Checskum with all this object's data. |
boolean |
usesUnsynchronization()
Return true if this tag used unsynchronization at the time it was read from a stream. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final byte UNSYNCHRONIZATION_FLAG
public static final byte EXPERIMENTAL_FLAG
public static final java.lang.String DEFAULT
private static java.util.ResourceBundle FLAGS_CLASS_INFO
private static final java.util.Hashtable FLAGS_CLASSES
private short version
private byte flags
private transient boolean changed
Constructor Detail |
---|
protected Flags()
protected Flags(byte flags)
flags
- a byte set to the desired flag values.Method Detail |
---|
public static Flags getNewInstance()
public static Flags getNewInstance(short version) throws TagDataFormatException
version
- the version of ID3v2 for which to get a Flags object
TagDataFormatException
- if the specified version is unsupported.public static Flags getNewInstance(short version, byte flagByte) throws TagDataFormatException
version
- the version of ID3v2 for which to get a Flags objectflagByte
- the value of the header flags
TagDataFormatException
- if the specified version is unsupported.private static java.lang.Class GetFlagsClass(short version) throws TagDataFormatException
version
- the desired specification version.
TagDataFormatException
- if the specified version is unsupported.private static java.lang.Class GetFlagsClass(java.lang.String versionString)
versionString
- the desired specification version.public void updateChecksum(java.util.zip.Checksum checksum)
checksum
- a Checksum to be updated.public final java.util.zip.Checksum getChecksum()
public final int hashCode()
hashCode
in class java.lang.Object
public java.lang.Object clone()
clone
in class java.lang.Object
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
other
- The other object.
public java.lang.String toString()
toString
in class java.lang.Object
public short getVersion()
public abstract void checkVersion() throws TagDataFormatException
TagDataFormatException
- if the version is not compatible.public boolean isChanged()
public void setChanged(boolean changed)
changed
- true to set the changed bit, false to clear it.public byte getFlags()
public void setFlags(byte newFlags)
newFlags
- the combination of bit values to assign to the flags.public boolean check(byte flagMask)
flagMask
- the combination of bits to check
public void set(byte flagMask)
flagMask
- the combination of bits to setpublic void unset(byte flagMask)
flagMask
- the combination of bits to unsetpublic boolean isMarkedExperimental()
public boolean usesUnsynchronization()
public java.io.InputStream processInput(java.io.InputStream is) throws java.io.IOException, TagDataFormatException
ID3v2
when parsing the stream.
A Flags
subclass should override this method act in
accordance with the tag flags to correctly parse the stream.
Applying a FilterInputStream
subclass to the
InputStream
passed as is
or calculating
a value are typical actions.
is
- the InputStream in which the ID3v2 information is embedded.
java.io.IOException
- if an I/O error occurs.
TagDataFormatException
- if the stream contains a malformed
tag, or some erroneous parameters.public java.io.OutputStream processOutput(java.io.OutputStream out)
ID3v2
when writing the tag to a
file or stream.
A Flags
subclass should override this method and apply
whatever calculations and FilterOutputStream
subclasses
are necessary to output a correct stream of the tag. See the
postProcessUnsynchronization
for an example of a FilterOutputStream
that can be
applied through this method.
out
- the OutputStream to which the ID3v2 tag will be written
protected java.io.OutputStream processUnsynchronization(java.io.OutputStream out)
OutputStream
will handle the unsynchronization
process and set the Unsynchronization flag if any unsynchronization
has been necessary.
out
- an output stream to which the tag is being written.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |