AbstractLyrics3v2FieldFrameBodypublic abstract class AbstractLyrics3v2FieldFrameBody extends org.jaudiotagger.tag.id3.AbstractTagFrameBody
Constructors Summary |
---|
public AbstractLyrics3v2FieldFrameBody()
| public AbstractLyrics3v2FieldFrameBody(AbstractLyrics3v2FieldFrameBody copyObject)
super(copyObject);
|
Methods Summary |
---|
public void | read(java.nio.ByteBuffer byteBuffer)This reads a frame body from its file into the appropriate FrameBody class
Read the data from the given file into this datatype. The file needs to
have its file pointer in the correct location. The size as indicated in the
header is passed to the frame constructor when reading from file.
int size = getSize();
//Allocate a buffer to the size of the Frame Body and read from file
byte[] buffer = new byte[size];
byteBuffer.get(buffer);
//Offset into buffer, incremented by length of previous MP3Object
int offset = 0;
//Go through the ObjectList of the Frame reading the data into the
//correct datatype.
AbstractDataType object;
Iterator<AbstractDataType> iterator = objectList.listIterator();
while (iterator.hasNext())
{
//The read has extended further than the defined frame size
if (offset > (size - 1))
{
throw new InvalidTagException("Invalid size for Frame Body");
}
//Get next Object and load it with data from the Buffer
object = iterator.next();
object.readByteArray(buffer, offset);
//Increment Offset to start of next datatype.
offset += object.getSize();
}
| protected int | readHeader(java.io.RandomAccessFile file)This is called by superclass when attempt to read data from file.
int size;
byte[] buffer = new byte[5];
// read the 5 character size
file.read(buffer, 0, 5);
size = Integer.parseInt(new String(buffer, 0, 5));
if ((size == 0) && (!TagOptionSingleton.getInstance().isLyrics3KeepEmptyFieldIfRead()))
{
throw new InvalidTagException("Lyircs3v2 Field has size of zero.");
}
return size;
| public void | write(java.io.RandomAccessFile file)Write the contents of this datatype to the file at the position it is
currently at.
//Write the various fields to file in order
byte[] buffer;
AbstractDataType object;
Iterator<AbstractDataType> iterator = objectList.listIterator();
while (iterator.hasNext())
{
object = iterator.next();
buffer = object.writeByteArray();
file.write(buffer);
}
| protected void | writeHeader(java.io.RandomAccessFile file, int size)This is called by superclass when attempt to write data from file.
String str;
int offset = 0;
byte[] buffer = new byte[5];
/**
* @todo change this to use pad String
*/
str = Integer.toString(getSize());
for (int i = 0; i < (5 - str.length()); i++)
{
buffer[i] = (byte) '0";
}
offset += (5 - str.length());
for (int i = 0; i < str.length(); i++)
{
buffer[i + offset] = (byte) str.charAt(i);
}
file.write(buffer);
|
|