org.jaudiotagger.tag.datatype
Class StringFixedLength

java.lang.Object
  extended by org.jaudiotagger.tag.datatype.AbstractDataType
      extended by org.jaudiotagger.tag.datatype.AbstractString
          extended by org.jaudiotagger.tag.datatype.StringFixedLength
Direct Known Subclasses:
StringDate, StringHashMap

public class StringFixedLength
extends AbstractString

Represents a fixed length String, whereby the length of the String is known. The String will be encoded based upon the text encoding of the frame that it belongs to.


Field Summary
 
Fields inherited from class org.jaudiotagger.tag.datatype.AbstractDataType
frameBody, identifier, logger, size, TYPE_ELEMENT, value
 
Constructor Summary
StringFixedLength(java.lang.String identifier, AbstractTagFrameBody frameBody, int size)
          Creates a new ObjectStringFixedsize datatype.
StringFixedLength(StringFixedLength copyObject)
           
 
Method Summary
 boolean equals(java.lang.Object obj)
           
protected  java.lang.String getTextEncodingCharSet()
           
 void readByteArray(byte[] arr, int offset)
          Read a string from buffer of fixed size(size has already been set in constructor)
 byte[] writeByteArray()
          Write String into byte array

The string will be adjusted to ensure the correct number of bytes are written, If the current value is null or to short the written value will have the 'space' character appended to ensure this.

 
Methods inherited from class org.jaudiotagger.tag.datatype.AbstractString
canBeEncoded, getSize, setSize, toString
 
Methods inherited from class org.jaudiotagger.tag.datatype.AbstractDataType
createStructure, getBody, getIdentifier, getValue, readByteArray, setBody, setValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringFixedLength

public StringFixedLength(java.lang.String identifier,
                         AbstractTagFrameBody frameBody,
                         int size)
Creates a new ObjectStringFixedsize datatype.

Parameters:
identifier -
frameBody -
size -
Throws:
java.lang.IllegalArgumentException

StringFixedLength

public StringFixedLength(StringFixedLength copyObject)
Method Detail

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class AbstractDataType
Parameters:
obj -
Returns:
if obj is equivalent to this

readByteArray

public void readByteArray(byte[] arr,
                          int offset)
                   throws InvalidDataTypeException
Read a string from buffer of fixed size(size has already been set in constructor)

Specified by:
readByteArray in class AbstractDataType
Parameters:
arr - this is the buffer for the frame
offset - this is where to start reading in the buffer for this field
Throws:
InvalidDataTypeException

writeByteArray

public byte[] writeByteArray()
Write String into byte array

The string will be adjusted to ensure the correct number of bytes are written, If the current value is null or to short the written value will have the 'space' character appended to ensure this. We write this instead of the null character because the null character is likely to confuse the parser into misreading the next field.

Specified by:
writeByteArray in class AbstractDataType
Returns:
the byte array to be written to the file

getTextEncodingCharSet

protected java.lang.String getTextEncodingCharSet()
Returns:
the encoding of the frame body this datatype belongs to