org.farng.mp3
Class AbstractMP3FragmentBody

java.lang.Object
  extended byorg.farng.mp3.AbstractMP3FileItem
      extended byorg.farng.mp3.AbstractMP3FragmentBody
Direct Known Subclasses:
AbstractID3v2FrameBody, AbstractLyrics3v2FieldBody

public abstract class AbstractMP3FragmentBody
extends AbstractMP3FileItem

This class is contained in the AbstractMP3Fragment and represents the actual data of tags. It contains default get/set methods for all data objects. The data is represented as an ArrayList of MP3Object. ID3v2 tags have frames. Lyrics3 tags have fields. ID3v1 tags do not have fragments.

Version:
$Revision: 1.6 $
Author:
Eric Farng

Constructor Summary
protected AbstractMP3FragmentBody()
          Creates a new MP3FragmentBody object.
protected AbstractMP3FragmentBody(AbstractMP3FragmentBody copyObject)
          Creates a new AbstractMP3FragmentBody object.
 
Method Summary
protected  void appendToObjectList(AbstractMP3Object object)
           
 boolean equals(java.lang.Object obj)
          Returns true if this object and its entire MP3Object array list equals the argument.
 java.lang.String getBriefDescription()
          This method calls toString for all it's objects and appends them without any newline characters.
 java.lang.String getDescription()
          This method calls toString for all it's objects and appends them.
 java.lang.Object getObject(java.lang.String identifier)
          Returns the object of the MP3Object with the specified identifier
 java.util.Iterator getObjectListIterator()
           
 int getSize()
          Returns the estimated size in bytes of this object if it was to be written to file.
protected static boolean has6ByteHeader()
           
 boolean isSubsetOf(java.lang.Object object)
          Returns true if this instance and its entire MP3Object array list is a subset of the argument.
 java.util.Iterator iterator()
          Returns an iterator of the MP3Object object list.
 void read(java.io.RandomAccessFile file)
          Read the data from the given file into this object.
protected abstract  int readHeader(java.io.RandomAccessFile file)
          Reads the header for the fragment body.
 void setObject(java.lang.String identifier, java.lang.Object object)
          Sets the all objects of identifier type to object argument.
protected abstract  void setupObjectList()
          Create the order of MP3Object objects that this body expects.
 java.lang.String toString()
          Calls toString for all MP3Object objects and creates a string with a new line character.
 void write(java.io.RandomAccessFile file)
          Write the contents of this object to the file at the position it is currently at.
protected abstract  void writeHeader(java.io.RandomAccessFile file, int size)
          Write the body header to the file at the current file position.
 
Methods inherited from class org.farng.mp3.AbstractMP3FileItem
getIdentifier
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractMP3FragmentBody

protected AbstractMP3FragmentBody()
Creates a new MP3FragmentBody object.


AbstractMP3FragmentBody

protected AbstractMP3FragmentBody(AbstractMP3FragmentBody copyObject)
Creates a new AbstractMP3FragmentBody object.

Method Detail

getBriefDescription

public java.lang.String getBriefDescription()
This method calls toString for all it's objects and appends them without any newline characters.

Returns:
brief description string

getDescription

public java.lang.String getDescription()
This method calls toString for all it's objects and appends them. It contains new line characters and is more suited for display purposes

Returns:
formatted description string

getObjectListIterator

public java.util.Iterator getObjectListIterator()

setObject

public void setObject(java.lang.String identifier,
                      java.lang.Object object)
Sets the all objects of identifier type to object argument.

Parameters:
identifier - MP3Object identifier
object - new object value

getObject

public java.lang.Object getObject(java.lang.String identifier)
Returns the object of the MP3Object with the specified identifier

Parameters:
identifier - MP3Object identifier
Returns:
the object of the MP3Object with the specified identifier

getSize

public int getSize()
Returns the estimated size in bytes of this object if it was to be written to file. This is not guaranteed to be accurate 100% of the time.

Specified by:
getSize in class AbstractMP3FileItem
Returns:
estimated size in bytes of this object

isSubsetOf

public boolean isSubsetOf(java.lang.Object object)
Returns true if this instance and its entire MP3Object array list is a subset of the argument. This class is a subset if it is the same class as the argument.

Overrides:
isSubsetOf in class AbstractMP3FileItem
Parameters:
object - object to determine subset of
Returns:
true if this instance and its entire object array list is a subset of the argument.

equals

public boolean equals(java.lang.Object obj)
Returns true if this object and its entire MP3Object array list equals the argument. This object is equal to the argument only if they are the same class.

Overrides:
equals in class AbstractMP3FileItem
Parameters:
obj - object to determine equality of
Returns:
true if this object and its entire MP3Object array list equals the argument.

iterator

public java.util.Iterator iterator()
Returns an iterator of the MP3Object object list.

Returns:
iterator of the MP3Object object list.

appendToObjectList

protected void appendToObjectList(AbstractMP3Object object)

read

public void read(java.io.RandomAccessFile file)
          throws java.io.IOException,
                 InvalidTagException
Read the data from the given file into this object. The file needs to have its file pointer in the correct location.

Specified by:
read in class AbstractMP3FileItem
Parameters:
file - file to read from
Throws:
java.io.IOException - on any I/O error
InvalidTagException - if there is any error in the data format.

toString

public java.lang.String toString()
Calls toString for all MP3Object objects and creates a string with a new line character.

Returns:
description string

write

public void write(java.io.RandomAccessFile file)
           throws java.io.IOException
Write the contents of this object to the file at the position it is currently at.

Specified by:
write in class AbstractMP3FileItem
Parameters:
file - destination file
Throws:
java.io.IOException - on any I/O error

readHeader

protected abstract int readHeader(java.io.RandomAccessFile file)
                           throws java.io.IOException,
                                  InvalidTagException
Reads the header for the fragment body. The header contains things such as the length.

Parameters:
file - file to read the header from.
Returns:
size of body in bytes as stated in the header.
Throws:
java.io.IOException - on any I/O error
InvalidTagException - if there is any error in the data format.

setupObjectList

protected abstract void setupObjectList()
Create the order of MP3Object objects that this body expects. This method needs to be overwritten.


writeHeader

protected abstract void writeHeader(java.io.RandomAccessFile file,
                                    int size)
                             throws java.io.IOException
Write the body header to the file at the current file position.

Parameters:
file - file to write to
size - number of bytes the body contains.
Throws:
java.io.IOException - on any I/O error

has6ByteHeader

protected static boolean has6ByteHeader()


Copyright (c) 2004 Eric Farng