public class ID3v23TagExtendedHeader
extends java.lang.Object
This class provides methods for reading and writing the optional ID3v2.3 tag extended header. It contains fields that are not vital to the processing of the ID3v2.3 tag and hence are optional. The ID3v2.3 tag extended header, if present, is at least 10 bytes long and directly follows the standard tag header.
The structure of an .mp3 file containing an ID3v2.3 tag is shown below.
An ID3v2.3 extended header contains the following fields:
Field | Description | |
---|---|---|
1. | size | specifies the size, in bytes, of the extended header. |
2. | CRCDataPresent | flag indicating whether a CRC (Cyclical Redundancy Check) for the .mp3 file has been calculated and the result stored in in the CRCData field. |
3. | paddingSize | specifies the number of bytes of padding stored after the ID3v2.3 tag and before the audio data in the .mp3 file. |
4. | CRCData | an optional field which is valid only if the CRCDataPresent flag is set, this field contains the actual CRC (Cyclical Redundancy Check) data. |
Constructor and Description |
---|
ID3v23TagExtendedHeader()
The default constructor is called when creating a new ID3v2.3 tag extended header.
|
ID3v23TagExtendedHeader(java.io.InputStream inputStream)
This constructor is called when reading in an existing ID3v2.3 tag extended header from an .mp3 file.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
getCRCData()
gets the CRC data.
|
int |
getPaddingSize()
gets the size of the padding, which is an area filled with 0's and is found after the end of the ID3v2.3 tag and before the actual audio portion of the .mp3 file.
|
int |
getSize()
gets the total number of bytes in the ID3v2.3 tag extended header.
|
boolean |
isCRCDataPresent()
gets whether the ID3v2.3 tag extended header contains a Cyclic Redundancy Check (CRC).
|
boolean |
isDirty()
indicates whether or not the tag's extended header's fields have been modified.
|
void |
save(java.io.OutputStream outputStream)
save the ID3v2.3 tag extended header to the .mp3 file.
|
void |
save(java.io.RandomAccessFile file)
save the ID3v2.3 tag extended header to the .mp3 file.
|
void |
setBuffer()
if the tag's extended header's values have been modified, then resize the raw binary buffer and store the new values there.
|
void |
setCRCData(byte[] CRCData)
sets the CRC data and the CRCDataPresent flag.
|
void |
setPaddingSize(int paddingSize)
sets the size of the padding, which is an area filled with 0's and found after the end of the ID3v2.3 tag and before the actual audio portion of the .mp3 file.
|
java.lang.String |
toString()
gets a string representation of the ID3v2.3 tag extended header showing the values of its fields.
|
public ID3v23TagExtendedHeader()
public ID3v23TagExtendedHeader(java.io.InputStream inputStream) throws java.io.IOException
inputStream
- input stream pointing to the end of the beginning of the ID3v2.3 tag extended header in the .mp3 file.java.io.IOException
- if the ID3v2.3 tag extended header can not be loaded from the .mp3 file.public boolean isDirty()
setBuffer()
public void setBuffer()
public int getSize()
public int getPaddingSize()
setPaddingSize(int)
public void setPaddingSize(int paddingSize)
paddingSize
- the size of the padding.getPaddingSize()
public boolean isCRCDataPresent()
setPaddingSize(int)
public byte[] getCRCData() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if the CRCDataPresent flag is not set.isCRCDataPresent()
,
setCRCData(byte[])
public void setCRCData(byte[] CRCData)
CRCData
- the data for the Cyclic Redundancy Check. The CRC data will be cleared if the CRCdata is null or an empty byte array of length 0, ie new byte[0].
Otherwise, it must be a valid CRC and be 4 bytes in length.getCRCData()
public void save(java.io.OutputStream outputStream) throws java.io.IOException
outputStream
- output stream pointing to the starting location of the ID3v2.3 tag extended header within the .mp3 file.java.io.IOException
- if there was an error writing the ID3v2.3 tag extended 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.3 tag extended header within the .mp3 file.java.io.IOException
- if there was an error writing the ID3v2.3 tag extended header to the .mp3 file.public java.lang.String toString()
toString
in class java.lang.Object