helliker.id3
Class ID3v2Header

java.lang.Object
  extended byhelliker.id3.ID3v2Header

public class ID3v2Header
extends java.lang.Object


Field Summary
private  java.lang.String ENC_TYPE
           
private  boolean experimental
           
private  boolean extended
           
private  boolean footer
           
private  int HEAD_LOCATION
           
private  int HEAD_SIZE
           
private  boolean headerExists
           
private  int majorVersion
           
private  int minorVersion
           
private  java.io.File mp3
           
private  int NEW_MAJOR_VERSION
           
private  int NEW_MINOR_VERSION
           
private  java.lang.String TAG_START
           
private  int tagSize
           
private  boolean unsynchronisation
           
 
Constructor Summary
ID3v2Header(java.io.File mp3)
          Create an id3v2header linked to the file passed as a parameter.
 
Method Summary
private  boolean checkHeader(java.io.RandomAccessFile raf)
          Checks to see if there is an id3v2 header in the file provided to the constructor.
 byte[] getBytes()
          Return an array of bytes representing the header.
 boolean getExperimental()
          Returns true if the experimental bit of this header is set.
 boolean getExtendedHeader()
          Returns true if this tag has an extended header.
private  byte getFlagByte()
          A helper function for the getBytes function that returns a byte with the proper flags set.
 boolean getFooter()
          Returns true if this tag has a footer.
 int getHeaderSize()
          Returns the size (in bytes) of this header.
 int getMajorVersion()
          Returns the major version of this id3v2 tag.
 int getMinorVersion()
          Return the minor version/revision of this id3v2 tag.
 int getTagSize()
          Returns the size (in bytes) of the frames and/or extended header portion of the id3v2 tag according to the size field in the header.
 boolean getUnsynchronisation()
          Returns true if the unsynchronisation bit is set in this header.
 boolean headerExists()
          Returns true if a header exists
private  void readHeader(java.io.RandomAccessFile raf)
          Extracts the information from the header.
 void setExperimental(boolean experiment)
          Set the value of the experimental bit of this header.
 void setExtendedHeader(boolean extend)
          Set the value of the extended header bit of this header.
 void setFooter(boolean foot)
          Sets the value of the footer bit for this header.
 void setTagSize(int size)
          Sets the size of the frames and/or extended header.
 void setUnsynchronisation(boolean unsynch)
          Set the unsynchronisation flag for this header.
 java.lang.String toString()
          Return a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TAG_START

private final java.lang.String TAG_START
See Also:
Constant Field Values

ENC_TYPE

private final java.lang.String ENC_TYPE
See Also:
Constant Field Values

HEAD_SIZE

private final int HEAD_SIZE
See Also:
Constant Field Values

HEAD_LOCATION

private final int HEAD_LOCATION
See Also:
Constant Field Values

NEW_MAJOR_VERSION

private final int NEW_MAJOR_VERSION
See Also:
Constant Field Values

NEW_MINOR_VERSION

private final int NEW_MINOR_VERSION
See Also:
Constant Field Values

mp3

private java.io.File mp3

headerExists

private boolean headerExists

majorVersion

private int majorVersion

minorVersion

private int minorVersion

unsynchronisation

private boolean unsynchronisation

extended

private boolean extended

experimental

private boolean experimental

footer

private boolean footer

tagSize

private int tagSize
Constructor Detail

ID3v2Header

public ID3v2Header(java.io.File mp3)
            throws java.io.FileNotFoundException,
                   java.io.IOException
Create an id3v2header linked to the file passed as a parameter. An attempt will be made to read the header from the file. If a header exists, then information in the header will be extracted. If a header doesn't exist, default data will be used.

Parameters:
mp3 - the file to attempt to read data from
Throws:
java.io.FileNotFoundException - if an error occurs
java.io.IOException - if an error occurs
Method Detail

checkHeader

private boolean checkHeader(java.io.RandomAccessFile raf)
                     throws java.io.FileNotFoundException,
                            java.io.IOException
Checks to see if there is an id3v2 header in the file provided to the constructor.

Parameters:
raf - the open file to read from
Returns:
true if an id3v2 header exists in the file
Throws:
java.io.FileNotFoundException - if an error occurs
java.io.IOException - if an error occurs

readHeader

private void readHeader(java.io.RandomAccessFile raf)
                 throws java.io.FileNotFoundException,
                        java.io.IOException
Extracts the information from the header.

Parameters:
raf - the open file to read from
Throws:
java.io.FileNotFoundException - if an error occurs
java.io.IOException - if an error occurs

getBytes

public byte[] getBytes()
Return an array of bytes representing the header. This can be used to easily write the header to a file. When this method is called it automatically updates the header to the newest format.

Returns:
a binary representation of this header

getFlagByte

private byte getFlagByte()
A helper function for the getBytes function that returns a byte with the proper flags set.

Returns:
the flags byte of this header

headerExists

public boolean headerExists()
Returns true if a header exists

Returns:
true if a header exists

getHeaderSize

public int getHeaderSize()
Returns the size (in bytes) of this header. This is always 10.

Returns:
the size of this header

getTagSize

public int getTagSize()
Returns the size (in bytes) of the frames and/or extended header portion of the id3v2 tag according to the size field in the header.

Returns:
the size field of the header

setTagSize

public void setTagSize(int size)
Sets the size of the frames and/or extended header. If this function is called, the headerExists function will return true. This is called every time a frame is updated, added, or removed.

Parameters:
size - a value of type 'int'

getMajorVersion

public int getMajorVersion()
Returns the major version of this id3v2 tag.

Returns:
the major version of this id3v2 tag.

getMinorVersion

public int getMinorVersion()
Return the minor version/revision of this id3v2 tag.

Returns:
the minor version/revision of this id3v2 tag.

getUnsynchronisation

public boolean getUnsynchronisation()
Returns true if the unsynchronisation bit is set in this header.

Returns:
true if the unsynchronisation bit is set in this header.

setUnsynchronisation

public void setUnsynchronisation(boolean unsynch)
Set the unsynchronisation flag for this header.

Parameters:
unsynch - the new value of the unsynchronisation flag

getExtendedHeader

public boolean getExtendedHeader()
Returns true if this tag has an extended header.

Returns:
true if this tag has an extended header

setExtendedHeader

public void setExtendedHeader(boolean extend)
Set the value of the extended header bit of this header.

Parameters:
extend - the new value of the extended header bit

getExperimental

public boolean getExperimental()
Returns true if the experimental bit of this header is set.

Returns:
true if the experimental bit of this header is set

setExperimental

public void setExperimental(boolean experiment)
Set the value of the experimental bit of this header.

Parameters:
experiment - the new value of the experimental bit

getFooter

public boolean getFooter()
Returns true if this tag has a footer.

Returns:
true if this tag has a footer

setFooter

public void setFooter(boolean foot)
Sets the value of the footer bit for this header.

Parameters:
foot - the new value of the footer bit for this header

toString

public java.lang.String toString()
Return a string representation of this object. Contains all information contained within.

Returns:
a string representation of this object


Copyright © 2004 NeurosDBM Dev Team All Rights Reserved.