public class ID3v24FrameHeader
extends java.lang.Object
This class provides methods for reading and writing frame headers in ID3V2.4 frames. An ID3v2.4 frame header is 10 bytes long and precedes the
frame body
in an ID3v2.4 frame
, as shown below.
An ID3v2.4 frame header has the following fields:
Field | Description | |
---|---|---|
1. | frameType | which of the 83 ID3v2.4 defined types of frame is this the header for. |
2. | frameBodySize | number of bytes in the associated frame body. |
3. | tagAlterPreservation | an indicator to mp3 software whether the frame should be preserved or discarded if the frame is unknown and the tag is altered in any way. |
4. | fileAlterPreservation | an indicator to mp3 software whether the frame should be preserved or discarded if the frame is unknown and the audio is altered in any way. note: this does not apply when the audio is completely replaced with other audio data. |
5. | readOnly | whether the contents of this frame are intended to be read only. |
6. | belongsToGroup | whether the frame belongs in a group with other frames. If it does, then the groupId field will contain the group's id. Every frame belonging to the same group will have the same group id. |
7. | compressed | whether the frame has been compressed using zlib. If it has, then the uncompressedSize field will contain the uncompressed size of the frame. |
8. | encrypted | whether the frame has been encrypted. If it has, then the encryptionMethod field will contain the method used to encrypt the frame. |
9. | unsynchronized | whether the frame has been whether or not unsynchronisation was applied to this frame. If this flag is set all data from the end of this header to the end of this frame has been unsynchronised. |
10. | dataLengthIndicatorPresent | whether the frame has a data length indicator added to it. If set, then the data length indicator fiels will have the value one would write as the 'frame length' if all of the frame format flags were zeroed. |
11. | groupId | optional field set only if the belongsToGroup field is true, it contains the id of the group to which the frame belongs. |
12. | uncompressedSize | optional field set only if the compressed field is true, it contains the uncompressed size of the frame. |
13. | encryptionMethod | optional field set only if the encrypted field is true, it contains the id of the method used to encrypt the frame. |
14. | dataLengthIndicator | optional field set only if the dataLengthIndicatorPresent field is true, it contains the value one would write as the 'frame length' if all of the frame format flags were zeroed. |
15. | dirty | whether the frame header has been modified. |
Constructor and Description |
---|
ID3v24FrameHeader(FrameType frameType)
This constructor is called when creating a new frame header.
|
ID3v24FrameHeader(ID3v24FrameHeader header)
copy constructor.
|
ID3v24FrameHeader(java.io.InputStream inputStream)
This constructor is called when an existing frame header is being read in from an .mp3 file.
|
Modifier and Type | Method and Description |
---|---|
int |
getDataLengthIndicator()
if the frame has a data length indicator as indicated by the dataLengthIndicatorPresent field, then this method returns the data length indicator of the frame.
|
byte |
getEncryptionMethod()
if the frame has been encrypted, as indicated by the encrypted field, then this method gets the method used to encrypt the frame.
|
int |
getFrameBodySize()
gets the size of the associated frame body.
|
FrameType |
getFrameType()
gets the ID3v2.4 frame type.
|
byte |
getGroupId()
if the frame belongs to a group, as indicated by the belongsToGroup field, then this method gets the id used to uniquely indentify the group.
|
java.lang.String |
getInvalidFrameId()
if the frame id read in is not a valid ID3v2.4 frame id, then this field is set so that the error can be reported later
after the entire frame has been read in (and discarded) so that we may continue processing the remaining frames.
|
int |
getSize()
gets the size (in bytes) of the frame header.
|
int |
getUncompressedSize()
if the frame has been compressed using zlib as indicated by the compressed field, then this method returns the uncompressed size of the frame.
|
boolean |
isBelongsToGroup()
gets whether the frame belongs in a group with other frames.
|
boolean |
isCompressed()
gets whether the frame is compressed using zlib.
|
boolean |
isDataLengthIndicatorPresent()
gets whether the frame has a data length indicator.
|
boolean |
isDirty()
gets whether the frame header has been modified since the last time it was saved.
|
boolean |
isEncrypted()
gets whether the frame is encrypted.
|
boolean |
isFileAlterPreservation()
gets whether the frame should be preserved or discarded if the frame is unknown and the file, excluding the tag, is altered.
|
boolean |
isPadding()
although an ID3v2.4 tag header specifies the size of the tag, it does not specifiy how many frames there are, the total size of the frames, nor the size of the padding.
|
boolean |
isReadOnly()
gets whether the contents of this frame are intended to be read only.
|
boolean |
isTagAlterPreservation()
gets whether the frame should be preserved or discarded if the frame is unknown and the tag is altered in any way.
|
boolean |
isUnsynchronized()
gets whether the frame is unsynchronized.
|
void |
save(java.io.OutputStream outputStream)
save the frame header to the .mp3 file.
|
void |
save(java.io.RandomAccessFile file)
save the frame header to the .mp3 file.
|
void |
setBelongsToGroup(boolean belongsToGroup)
sets whether the frame belongs in a group with other frames.
|
void |
setBuffer()
if the frame header's values have been modified, then resize the raw binary buffer and store the new values there.
|
void |
setCompressed(boolean compressed)
sets whether the frame is compressed using zlib.
|
void |
setDataLengthIndicator(int dataLengthIndicator)
sets the frame's data length indicator as well as the dataLengthIndicatorPresent flag.
|
void |
setDataLengthIndicatorPresent(boolean dataLengthIndicatorPresent)
sets whether the frame has a data length indicator.
|
void |
setEncrypted(boolean encrypted)
sets whether the frame is encrypted.
|
void |
setEncryptionMethod(byte encryptionMethod)
sets the frame's encryption method as well as the encrypted flag.
|
void |
setFileAlterPreservation(boolean fileAlterPreservation)
sets whether the frame should be preserved or discarded if the frame is unknown and the file, excluding the tag, is altered.
|
void |
setFrameBodySize(int frameBodySize)
sets the size of the frame body.
|
void |
setFrameType(FrameType frameType)
sets the frame type.
|
void |
setGroupId(byte groupId)
sets the frame's group id as well as the belongsToGroup flag.
|
void |
setReadOnly(boolean readOnly)
sets whether the contents of this frame are intended to be read only.
|
void |
setTagAlterPreservation(boolean tagAlterPreservation)
sets whether the frame should be preserved or discarded if the frame is unknown and the tag is altered in any way.
|
void |
setUncompressedSize(int uncompressedSize)
sets the frame's uncompressed size as well as the compressed flag.
|
void |
setUnsynchronized(boolean unsynchronized)
sets whether the frame is unsynchronized.
|
java.lang.String |
toString()
gets a string representation of an ID3v2.4 frame's header.
|
public ID3v24FrameHeader(FrameType frameType)
frameType
- ID3v2.4 frame type.public ID3v24FrameHeader(java.io.InputStream inputStream) throws java.io.IOException
inputStream
- input stream pointing to an ID3v2.4 frame header in the .mp3 file.java.io.IOException
- if there is an error while reading the frame header in from the .mp3 file.public ID3v24FrameHeader(ID3v24FrameHeader header)
header
- an ID3v2.4 header that was previously read in.public FrameType getFrameType()
setFrameType(FrameType)
public void setFrameType(FrameType frameType)
frameType
- the type of ID3v2.4 frame.getFrameType()
public int getFrameBodySize()
setFrameBodySize(int)
public void setFrameBodySize(int frameBodySize)
frameBodySize
- the size of the frame body (in bytes).getFrameBodySize()
public boolean isTagAlterPreservation()
setTagAlterPreservation(boolean)
public void setTagAlterPreservation(boolean tagAlterPreservation)
tagAlterPreservation
- the tag alteration preservation flag.isTagAlterPreservation()
public boolean isFileAlterPreservation()
setFileAlterPreservation(boolean)
public void setFileAlterPreservation(boolean fileAlterPreservation)
fileAlterPreservation
- the file alteration preservation flag.isFileAlterPreservation()
public boolean isReadOnly()
setReadOnly(boolean)
public void setReadOnly(boolean readOnly)
readOnly
- booleain indicating whether the contents of this frame are intended to be read only.isReadOnly()
public boolean isBelongsToGroup()
setBelongsToGroup(boolean)
public void setBelongsToGroup(boolean belongsToGroup)
belongsToGroup
- boolean indicating whether the frame belongs in a group with other frames.isBelongsToGroup()
public boolean isCompressed()
setCompressed(boolean)
,
getUncompressedSize()
public void setCompressed(boolean compressed)
compressed
- boolean indicating whether the frame is compressed using zlib.isCompressed()
public boolean isEncrypted()
setEncrypted(boolean)
public void setEncrypted(boolean encrypted)
encrypted
- whether the frame is encrypted.isEncrypted()
,
setEncryptionMethod(byte)
public boolean isUnsynchronized()
setUnsynchronized(boolean)
public void setUnsynchronized(boolean unsynchronized)
unsynchronized
- whether the frame is unsynchronized.isUnsynchronized()
public boolean isDataLengthIndicatorPresent()
setDataLengthIndicatorPresent(boolean)
,
getDataLengthIndicator()
,
setDataLengthIndicator(int)
public void setDataLengthIndicatorPresent(boolean dataLengthIndicatorPresent)
dataLengthIndicatorPresent
- whether the frame has a data length indicator.isDataLengthIndicatorPresent()
,
getDataLengthIndicator()
,
setDataLengthIndicator(int)
public int getUncompressedSize()
setUncompressedSize(int)
,
setCompressed(boolean)
public void setUncompressedSize(int uncompressedSize)
uncompressedSize
- the frame's uncompressed size or 0 to indicate that the frame is not compressed.getUncompressedSize()
,
setCompressed(boolean)
public byte getEncryptionMethod()
setEncryptionMethod(byte)
,
setEncrypted(boolean)
public void setEncryptionMethod(byte encryptionMethod)
encryptionMethod
- the encryption algorithm used to encrypt the frame or 0 to indicate that the frame is not encrypted.getEncryptionMethod()
,
setEncrypted(boolean)
public int getDataLengthIndicator()
setDataLengthIndicator(int)
,
setDataLengthIndicatorPresent(boolean)
public void setDataLengthIndicator(int dataLengthIndicator)
dataLengthIndicator
- the frame's data length indicator or 0 to indicate that the frame does not have a data length indicator.getDataLengthIndicator()
,
setDataLengthIndicatorPresent(boolean)
public byte getGroupId()
setGroupId(byte)
,
setBelongsToGroup(boolean)
public void setGroupId(byte groupId)
groupId
- the id that will uniquely indentify a frame group or 0 to indicate that the frame does not belong to a group of frames.getGroupId()
,
setBelongsToGroup(boolean)
public int getSize()
getFrameBodySize()
public boolean isDirty()
setBuffer()
public boolean isPadding()
ID3v24Frame
public java.lang.String getInvalidFrameId()
public void save(java.io.OutputStream outputStream) throws java.io.IOException
outputStream
- output stream pointing to the starting location of the ID3v2.4 frame header within the .mp3 file.java.io.IOException
- if there was an error writing the ID3v2.4 frame header to the .mp3 file.public void save(java.io.RandomAccessFile file) throws java.io.IOException
file
- random access file pointing to the starting location of the ID3v2.4 frame header within the .mp3 file.java.io.IOException
- if there was an error writing the ID3v2.4 frame header to the .mp3 file.public void setBuffer()
public java.lang.String toString()
toString
in class java.lang.Object