|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.tffenterprises.music.tag.id3v2.Frame
com.tffenterprises.music.tag.id3v2.frame.BaseFrame
public abstract class BaseFrame
This is an abstract superclass implementing common code for subclasses of Frame. BaseFrame implements shared instance code, while Frame has static code only.
The only methods required of a a subclass of BaseFrame are appropriate constructor, including a default public constructor and a constructor accepting a FrameHeader object as a parameter (see BaseFrame(FrameHeader header). BaseFrame subclasess must also provide implementations of getRawData() and setRawData(byte[] data).
Ideally, subclasses should also override and extend the methods clone(), getChecksum() and toString().
Note that among the constructors, a the default constructor is required for correct behaviour of the clone() method.
Field Summary | |
---|---|
private boolean |
changed
The changed bit for this frame. |
private FrameHeader |
header
This frame's FrameHeader |
Constructor Summary | |
---|---|
protected |
BaseFrame()
Protected default constructor. |
protected |
BaseFrame(FrameHeader header)
Frame subclasses MUST provide a constructor with this parameter list. |
Method Summary | |
---|---|
java.lang.Object |
clone()
Returns a clone of this ID3v2 frame. |
boolean |
equals(java.lang.Object other)
Compares this ID3v2 frame with another object. |
protected byte[] |
getBytes()
Returns this frame object's byte representation, in a fast way that is potentially less secure than getRawData() . |
java.util.zip.Checksum |
getChecksum()
Returns a CheckSum object updated with this object. |
byte |
getFormatFlags()
Returns the format flags of this frame. |
java.lang.String |
getFrameID()
Returns the frame ID of this frame. |
protected FrameHeader |
getHeader()
Returns this frame object's FrameHeader instance. |
abstract byte[] |
getRawData()
Returns the raw data corresponding to this frame. |
byte |
getStatusFlags()
Returns the status flags of this frame. |
int |
hashCode()
Returns a hash code for this ID3v2 frame. |
boolean |
isChanged()
Returns the changed state of this frame. |
boolean |
isOfRepeatableType()
Returns whether it is correct for multiple frames of the same type as this one to coexist in the same ID3v2 tag. |
void |
setChanged(boolean changed)
Sets the changed state of this frame |
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. |
void |
setStatusFlags(byte flags)
Sets the status flags of this frame. |
byte[] |
toByteArray()
Returns a byte array containing the representation of this frame as it should be written to an ID3v2 tag. |
java.lang.String |
toString()
Returns a String representation of this frame. |
void |
updateChecksum(DataOutputChecksum checksum)
Updates a DataOutputChecksum object with this
frame's data. |
private void |
writeFrameBytesToStream(java.io.OutputStream os,
byte[] frameBytes)
Utility method to write the given frame data to the given output stream. |
void |
writeTo(java.io.OutputStream outputStream)
Writes this tag to an output stream. |
Methods inherited from class com.tffenterprises.music.tag.id3v2.Frame |
---|
FromByteArray, FromByteArray, FromInputStream, GetFrameClassForID, getNewInstance, getNewInstance, getNewInstance, MinimumLength, RegisterFrameClass, UnregisterFrameClass |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private FrameHeader header
private transient boolean changed
Constructor Detail |
---|
protected BaseFrame()
protected BaseFrame(FrameHeader header) throws java.lang.IllegalArgumentException
header
- The FrameHeader to be used for this Frame instance.
See FrameHeader
for details.
java.lang.IllegalArgumentException
- This is exception is thrown when
the parameter is unacceptable for
use with an object of this
Frame class/subclass.Method Detail |
---|
public java.lang.Object clone()
clone
in class Frame
public void updateChecksum(DataOutputChecksum checksum)
DataOutputChecksum
object with this
frame's data. Subclasses don't need to override this method, as
the output of the getRawData()
method is processed.
If somehow some other transient data is relevant, then they
can override this method.
updateChecksum
in class Frame
checksum
- the Checksum to be updated.public final java.util.zip.Checksum getChecksum()
Note that as long as all the frame's significant data makes it in the output of getRawData(), there isn't really a need to override this method.
getChecksum
in class Frame
public final int hashCode()
hashCode
in class Frame
public boolean equals(java.lang.Object other)
equals
in class Frame
other
- The other object.
public java.lang.String toString()
String
representation of this frame.
toString
in class Frame
String
representation of this frame.public java.lang.String getFrameID()
getFrameID
in class Frame
public byte getStatusFlags()
getStatusFlags
in class Frame
public void setStatusFlags(byte flags)
setStatusFlags
in class Frame
flags
- The new status flags.public byte getFormatFlags()
getFormatFlags
in class Frame
public void setFormatFlags(byte flags)
setFormatFlags
in class Frame
flags
- The new format flags.public boolean isChanged()
isChanged
in class Frame
public void setChanged(boolean changed)
setChanged
in class Frame
changed
- whether the frame is to be considered changed.public abstract byte[] getRawData()
getRawData
in class Frame
public abstract void setRawData(byte[] rawData) throws FrameDataFormatException, java.lang.IllegalArgumentException
NOTE: subclasses must override this.
setRawData
in class Frame
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 byte[] toByteArray()
toByteArray
in class Frame
public void writeTo(java.io.OutputStream outputStream) throws java.io.IOException, java.lang.IllegalArgumentException
writeTo
in class Frame
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.private void writeFrameBytesToStream(java.io.OutputStream os, byte[] frameBytes) throws java.io.IOException
os
- The output stream.frameBytes
- the bytes to be written out to the output stream.
java.io.IOException
- if there is a problem writing to the stream.public boolean isOfRepeatableType()
isOfRepeatableType
in class Frame
protected final FrameHeader getHeader()
FrameHeader
instance.
getHeader
in class Frame
FrameHeader
instance.protected byte[] getBytes()
getRawData()
.
This method is to be used by subclasses of BaseFrame only, and
overridden in cases where the functionality of
getRawData()
can be sped up at the expense of security.
The default implementation (this one) simply calls
getRawData()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |