com.dusbabek.lib.id3
Class BasicTagHeader

java.lang.Object
  extended by com.dusbabek.lib.id3.BasicTagHeader
All Implemented Interfaces:
TagHeader
Direct Known Subclasses:
TagHeader_v2_2

public abstract class BasicTagHeader
extends java.lang.Object
implements TagHeader

This class represents the 10 bytes that are the basic header on any ID3v2 tag. For the uninitiated, that format is 'I' 'D' '3' 0x00-0x02 version 0x03 revision 0x04 flags 0x05 tag size 0x06-0x09 the tag size can be calculated by ignorning the first bit of each bit (hi) and converting the 28 bits that are left over into an integer.


Field Summary
static int BASIC_TAG_HEADER_LEN
          size of a basic tag header.
 
Constructor Summary
BasicTagHeader(byte[] tenBytes)
          Constructor.
 
Method Summary
 long getDataSize()
          returns the size of the data (not including ANY headers).
 byte getFlags()
           
 long getTagSize()
          returned as long to avoid sign extension problems in java.
 byte getVersion()
           
 void setDataSize(long l)
          set the size of the data.
protected  void setTagSize(long l)
          set the size of the tag.
 int sizeOf()
          kind of moot.
abstract  boolean usesUnsynchronization()
           
 void write(java.io.OutputStream out)
          write this header to a stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BASIC_TAG_HEADER_LEN

public static final int BASIC_TAG_HEADER_LEN
size of a basic tag header.

See Also:
Constant Field Values
Constructor Detail

BasicTagHeader

public BasicTagHeader(byte[] tenBytes)
               throws java.io.IOException
Constructor. Fills value based on byte array passed in.

Parameters:
tenBytes - byte[]
Throws:
java.io.IOException
Method Detail

getVersion

public byte getVersion()
Specified by:
getVersion in interface TagHeader
Returns:
the version field

getFlags

public byte getFlags()
Specified by:
getFlags in interface TagHeader
Returns:
the flag field

getTagSize

public long getTagSize()
returned as long to avoid sign extension problems in java. A java long is unsigned, but think of this value as a 28 bit unsigned integer.

Specified by:
getTagSize in interface TagHeader
Returns:
the size of the entire tag minus the 10 byte header.

sizeOf

public int sizeOf()
kind of moot. returns the actual size of the header, which will include an extended header in some versions.

Specified by:
sizeOf in interface TagHeader
Returns:
int

getDataSize

public long getDataSize()
returns the size of the data (not including ANY headers).

Specified by:
getDataSize in interface TagHeader
Returns:
long

setDataSize

public void setDataSize(long l)
set the size of the data.

Specified by:
setDataSize in interface TagHeader
Parameters:
l - long

setTagSize

protected void setTagSize(long l)
set the size of the tag.

Parameters:
l - long

write

public void write(java.io.OutputStream out)
           throws java.io.IOException
write this header to a stream. Note that the tag size needs to be correct BEFORE the write. All Tag implementations need to be aware of this.

Specified by:
write in interface TagHeader
Parameters:
out - OutputStream
Throws:
java.io.IOException

usesUnsynchronization

public abstract boolean usesUnsynchronization()
Specified by:
usesUnsynchronization in interface TagHeader
Returns:
true if unsynchronization is used.


Copyright © 2004, 2005 Gary Dusbabek. All Rights Reserved.