|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.tffenterprises.music.tag.id3v2.Frame
public abstract class Frame
This class is the superclass of all ID3v2 frame types. It contains factory methods to generate ID3v2 frames from streams and byte arrays, as well as accessor methods, output methods, and other methods common to all ID3v2 frames. As it is an abstract class, it cannot be instantiated on its own.
Note that all subclasses of Frame
are REQUIRED, in
addition to any special constructors they might have, to contain a
public constructor which takes a FrameHeader
object as
an argument. They are also required to override the setRawData(byte[] data)
method and update the internal representation of their data using
its byte array argument. See setRawData(byte[] data)
and BaseFrame(FrameHeader
header)
for further details.
Subclasses provided by TFF Enterprises
(e.g. TextFrame
, URLLinkFrame
) are
automatically used by this library. Subclasses provided by third
parties must be explicitly made known to the the Frame
class object, using the method RegisterFrameClass(String,
Class)
.
Field Summary | |
---|---|
private static java.lang.Class[] |
CONSTRUCTOR_TYPES
An array containing the Class objects which select the constructor of the Frame subclass to be used. |
private static java.lang.Class |
FRAME_CLASS
The Class object for this class. |
private static java.util.Hashtable |
FRAME_CLASSES
The Hashtable which contains all the frame IDs (types) and the frame classes with which they are associated. |
private static java.util.ResourceBundle |
FRAME_TYPE_CLASS_MAPPINGS
A ResourceBundle containing some mappings between frame IDs and classes. |
private static java.lang.Class |
GENERIC_FRAME_CLASS
The Class object for the generic frame class. |
private static java.lang.Class |
TEXT_FRAME_CLASS
The Class object for the generic text frame class. |
Constructor Summary | |
---|---|
Frame()
|
Method Summary | |
---|---|
abstract java.lang.Object |
clone()
Returns a clone of this ID3v2 frame. |
abstract boolean |
equals(java.lang.Object other)
Compares this ID3v2 frame with another object. |
static Frame |
FromByteArray(short version,
byte[] byteArray)
Creates an ID3v2 frame from a byte array. |
static Frame |
FromByteArray(short version,
byte[] byteArray,
int offset)
Creates an ID3v2 frame from a byte array, starting at the specified offset. |
static Frame |
FromInputStream(short version,
java.io.InputStream inputStream,
long availableBytes)
Creates an ID3v2 frame from an InputStream. |
abstract java.util.zip.Checksum |
getChecksum()
Returns a checksum updated with this frame's data. |
abstract byte |
getFormatFlags()
Returns the format flags of this frame. |
static java.lang.Class |
GetFrameClassForID(java.lang.String frameID)
Obtain a Frame subclass to handle a particular type of ID3v2 frame. |
abstract java.lang.String |
getFrameID()
Returns the frame ID of this frame. |
protected abstract FrameHeader |
getHeader()
Returns the FrameHeader object that corresponds to this
Frame instance. |
static Frame |
getNewInstance(FrameHeader header)
Create a new Frame object of an appropriate subtype,
given a FrameHeader . |
static Frame |
getNewInstance(FrameHeader header,
java.lang.String theID)
Create a new Frame object of an appropriate subtype,
given a FrameHeader and a specific frame ID. |
static Frame |
getNewInstance(java.lang.String theID)
Create a new Frame object of an appropriate subtype,
given a frame ID. |
abstract byte[] |
getRawData()
Returns the raw data corresponding to this frame. |
abstract byte |
getStatusFlags()
Returns the status flags of this frame. |
abstract int |
hashCode()
Returns a hash code for this ID3v2 frame. |
abstract boolean |
isChanged()
Returns true is this frame has been changed. |
abstract boolean |
isOfRepeatableType()
Certain frame types can coexist with others of their type within a certain tag, while others must be unique. |
static int |
MinimumLength(short version)
A little utility to return the minimum length of a frame according to the ID3v2 version. |
static java.lang.Class |
RegisterFrameClass(java.lang.String frameID,
java.lang.Class frameClass)
Registers a subclass for processing a particular type of ID3v2 frame. |
abstract void |
setChanged(boolean changed)
Sets the changed state of this frame |
abstract void |
setFormatFlags(byte flags)
Sets the format flags of this frame. |
abstract void |
setRawData(byte[] rawData)
Sets the raw data corresponding to this frame, and changes the frame's internal data represntation to reflect this new raw data, i.e. |
abstract void |
setStatusFlags(byte flags)
Sets the status flags of this frame. |
abstract byte[] |
toByteArray()
Returns a byte array containing the representation of this frame as it should be written to an ID3v2 tag. |
abstract java.lang.String |
toString()
Returns a String representation of this frame. |
static java.lang.Class |
UnregisterFrameClass(java.lang.String frameID)
Unregisters a subclass for processing a particular type of ID3v2 frame. |
abstract void |
updateChecksum(DataOutputChecksum checksum)
Updates a checksum with this frame's data |
abstract void |
writeTo(java.io.OutputStream outputStream)
Writes this tag to an output stream. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final java.lang.Class[] CONSTRUCTOR_TYPES
private static final java.util.Hashtable FRAME_CLASSES
private static final java.lang.Class FRAME_CLASS
private static final java.lang.Class GENERIC_FRAME_CLASS
private static final java.lang.Class TEXT_FRAME_CLASS
private static java.util.ResourceBundle FRAME_TYPE_CLASS_MAPPINGS
Constructor Detail |
---|
public Frame()
Method Detail |
---|
public static Frame FromInputStream(short version, java.io.InputStream inputStream, long availableBytes) throws PaddingException, TagDataFormatException, java.io.IOException
This method will in any case read all the bytes for a given frame
off the stream, but does not guarantee that a valid
Frame
object will be returned from the bytes that
were read. That is, if the method returns without throwing an
exception, the stream can be expected to be at the beginning of
the next frame even if no Frame
was returned.
version
- The version of the ID3v2 spec to be used for this frame.inputStream
- The InputStream to read from.availableBytes
- The number of bytes that should be considered
available in the stream.
PaddingException
- if padding is encountered instead of a frame.
java.io.IOException
- if there is a problem reading from the specified
InputStream.
TagDataFormatException
public static Frame FromByteArray(short version, byte[] byteArray) throws TagDataFormatException, PaddingException
version
- The version of the ID3v2 spec to be used for this frame.byteArray
- The byte array.
java.lang.IllegalArgumentException
- if the byte array is null.
PaddingException
- if padding is encountered instead of a frame.
TagDataFormatException
public static Frame FromByteArray(short version, byte[] byteArray, int offset) throws TagDataFormatException, PaddingException
version
- The version of the ID3v2 spec to be used for this frame.byteArray
- The byte array.offset
- The offset.
java.lang.IllegalArgumentException
- if the byte array is null.
PaddingException
- if padding is encountered instead of a frame.
TagDataFormatException
public static Frame getNewInstance(FrameHeader header, java.lang.String theID)
Frame
object of an appropriate subtype,
given a FrameHeader
and a specific frame ID.
header
- the new Frame
's FrameHeader
.theID
- the new frame ID.
Frame
object.public static Frame getNewInstance(java.lang.String theID)
Frame
object of an appropriate subtype,
given a frame ID. The object will implement the latest supported
ID3v2 specification.
theID
- the new frame ID.
Frame
object.public static Frame getNewInstance(FrameHeader header)
Frame
object of an appropriate subtype,
given a FrameHeader
.
header
- the new Frame
's FrameHeader
.
Frame
object.public static java.lang.Class RegisterFrameClass(java.lang.String frameID, java.lang.Class frameClass) throws java.lang.IllegalArgumentException
frameID
- The frame ID (4-letter String identifying the frame type).frameClass
- The Class
to be used to process frames
of the type corresponding to this ID.
java.lang.IllegalArgumentException
- if the specified frame ID does not
conform to the ID3v2 specification, or if the specified class is not
a subclass of Frame, or if either parameter is null.public static java.lang.Class UnregisterFrameClass(java.lang.String frameID)
frameID
- The frame ID (4-letter String identifying the frame type).
public static java.lang.Class GetFrameClassForID(java.lang.String frameID)
frameID
- The frame ID (String identifying the frame type).
public static int MinimumLength(short version)
version
- the ID3v2 version for which we want to find the
minimum length of a frame.
public abstract java.lang.Object clone()
clone
in class java.lang.Object
public abstract void updateChecksum(DataOutputChecksum checksum)
checksum
- the checksum to updatepublic abstract java.util.zip.Checksum getChecksum()
public abstract int hashCode()
hashCode
in class java.lang.Object
public abstract boolean equals(java.lang.Object other)
equals
in class java.lang.Object
other
- The other object.
public abstract java.lang.String getFrameID()
public abstract byte getFormatFlags()
public abstract void setFormatFlags(byte flags)
flags
- The flags.public abstract byte getStatusFlags()
public abstract void setStatusFlags(byte flags)
flags
- The flags.public abstract boolean isChanged()
public abstract void setChanged(boolean changed)
changed
- true if the frame is to be considered changed.public abstract byte[] getRawData()
public abstract void setRawData(byte[] rawData) throws FrameDataFormatException, java.lang.IllegalArgumentException
rawData
- The raw data.
FrameDataFormatException
- if the raw data is not in an
appropriate format for this
frame type.
java.lang.IllegalArgumentException
- if the specified raw data is null.public abstract java.lang.String toString()
toString
in class java.lang.Object
public abstract byte[] toByteArray()
public abstract void writeTo(java.io.OutputStream outputStream) throws java.io.IOException, java.lang.IllegalArgumentException
outputStream
- The output stream.
java.io.IOException
- if there is a problem writing to the
stream.
java.lang.IllegalArgumentException
- if the specified output stream
is null.public abstract boolean isOfRepeatableType()
Frame
can be queried whether it represents a frame
type that can exist in multiple instances if its
isOfRepeatableType()
method returns true.
protected abstract FrameHeader getHeader()
FrameHeader
object that corresponds to this
Frame
instance.
If there is a good reason to make this a public method, chime in.
FrameHeader
object.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |