org.metasyntactic.id3.v2
Class Tag
java.lang.Object
|
+--org.metasyntactic.id3.v2.Tag
- All Implemented Interfaces:
- Id3v2Constants
- public class Tag
- extends java.lang.Object
- implements Id3v2Constants
ID3v2 is a general tagging format for audio, which makes it possible to
store meta data about the audio inside the audio file itself. The ID3 tag
described in this document is mainly targeted at files encoded with MPEG-1/2
layer I, MPEG-1/2 layer II, MPEG-1/2 layer III and MPEG-2.5, but may work
with other types of encoded audio or as a stand alone format for audio meta
data.
ID3v2 is designed to be as flexible and expandable as possible to meet new
meta information needs that might arise. To achieve that ID3v2 is
constructed as a container for several information blocks, called frames,
whose format need not be known to the software that encounters them. At the
start of every frame is an unique and predefined identifier, a size
descriptor that allows software to skip unknown frames and a flags field.
The flags describes encoding details and if the frame should remain in the
tag, should it be unknown to the software, if the file is altered.
The bitorder in ID3v2 is most significant bit first (MSB). The byteorder in
multibyte numbers is most significant byte first (e.g. $12345678 would be
encoded $12 34 56 78), also known as big endian and network byte order.
Overall tag structure:
+-----------------------------+
| Header (10 bytes) |
+-----------------------------+
| Extended Header |
| (variable length, OPTIONAL) |
+-----------------------------+
| Frames (variable length) |
+-----------------------------+
| Padding |
| (variable length, OPTIONAL) |
+-----------------------------+
| Footer (10 bytes, OPTIONAL) |
+-----------------------------+
Fields inherited from interface org.metasyntactic.id3.v2.Id3v2Constants |
ISO_8859_1, JAVA_ISO_8859_1, JAVA_US_ASCII, JAVA_UTF_16, JAVA_UTF_16_BIG_ENDIAN, JAVA_UTF_8, MAJOR_VERSION, MAX_ENCODING, MIN_ENCODING, REVISION_NUMBER, UTF_16, UTF_16_BIG_ENDIAN, UTF_8 |
Constructor Summary |
Tag(Tag tag)
|
Method Summary |
void |
addPadding()
|
void |
addPadding(int size)
|
int |
getSize()
The ID3v2 tag size is the sum of the byte length of the extended
header, the padding and the frames after unsynchronisation. |
int |
getTotalSize()
|
boolean |
hasPadding()
|
static void |
main(java.lang.String[] args)
|
static Tag |
read(java.io.InputStream _in)
Reads an Id3v2 tag from this input stream. |
void |
removePadding()
|
java.lang.String |
toString()
|
void |
write(java.io.OutputStream out)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Tag
public Tag(Tag tag)
throws java.io.IOException
getSize
public int getSize()
throws java.io.IOException
- The ID3v2 tag size is the sum of the byte length of the extended
header, the padding and the frames after unsynchronisation. If a
footer is present this equals to ('total size' - 20) bytes, otherwise
('total size' - 10) bytes.
java.io.IOException
getTotalSize
public int getTotalSize()
throws java.io.IOException
java.io.IOException
hasPadding
public boolean hasPadding()
addPadding
public void addPadding()
throws java.io.IOException
java.io.IOException
addPadding
public void addPadding(int size)
throws java.io.IOException
java.io.IOException
removePadding
public void removePadding()
throws java.io.IOException
java.io.IOException
write
public void write(java.io.OutputStream out)
throws java.io.IOException
java.io.IOException
read
public static Tag read(java.io.InputStream _in)
throws java.io.IOException,
Id3v2Exception
- Reads an Id3v2 tag from this input stream. The tag must appear at the
beginning of this stream. If no tag exists null is returned
java.io.IOException
Id3v2Exception
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
main
public static void main(java.lang.String[] args)