FileDocCategorySizeDatePackage
AbstractString.javaAPI DocJaudiotagger 2.0.43672Wed Mar 30 16:12:12 BST 2011org.jaudiotagger.tag.datatype

AbstractString

public abstract class AbstractString extends AbstractDataType
A partial implementation for String based ID3 fields

Fields Summary
Constructors Summary
protected AbstractString(String identifier, org.jaudiotagger.tag.id3.AbstractTagFrameBody frameBody)
Creates a new datatype

param
identifier
param
frameBody

        super(identifier, frameBody);
    
public AbstractString(String identifier, org.jaudiotagger.tag.id3.AbstractTagFrameBody frameBody, String value)
Creates a new datatype, with value

param
identifier
param
frameBody
param
value

        super(identifier, frameBody, value);
    
protected AbstractString(AbstractString object)
Copy constructor

param
object

        super(object);
    
Methods Summary
public booleancanBeEncoded()
Check the value can be encoded with the specified encoding

return

        //Try and write to buffer using the CharSet defined by the textEncoding field (note if using UTF16 we dont
        //need to worry about LE,BE at this point it makes no difference)
        byte textEncoding = this.getBody().getTextEncoding();
        String charSetName = TextEncoding.getInstanceOf().getValueForId(textEncoding);
        CharsetEncoder encoder = Charset.forName(charSetName).newEncoder();

        if (encoder.canEncode((String) value))
        {
            return true;
        }
        else
        {
            logger.finest("Failed Trying to decode" + value + "with" + encoder.toString());
            return false;
        }
    
public intgetSize()
Return the size in bytes of this datatype as it was/is held in file this will be effected by the encoding type.

return
the size

        return size;
    
protected voidsetSize(int size)
Sets the size in bytes of this data type. This is set after writing the data to allow us to recalculate the size for frame header.

param
size

        this.size = size;
    
public java.lang.StringtoString()
Return String representation of data type

return
a string representation of the value

        return (String) value;