FileDocCategorySizeDatePackage
AbstractTagFrameBody.javaAPI DocJaudiotagger 2.0.410547Wed Mar 30 16:12:06 BST 2011org.jaudiotagger.tag.id3

AbstractTagFrameBody

public abstract class AbstractTagFrameBody extends AbstractTagItem
A frame body contains the data content for a frame

Fields Summary
private AbstractTagFrame
header
Reference to the header associated with this frame body, a framebody can be created without a header but one it is associated with a header this should be set. It is principally useful for the framebody to know its header, because this will specify its tag version and some framebodies behave slighly different between tag versions.
protected ArrayList
objectList
List of data types that make up this particular frame body.
Constructors Summary
protected AbstractTagFrameBody()
Creates a new framebody, at this point the bodys ObjectList is setup which defines what datatypes are expected in body

        setupObjectList();
    
protected AbstractTagFrameBody(AbstractTagFrameBody copyObject)
Copy Constructor for fragment body. Copies all objects in the Object Iterator with data.

param
copyObject

        AbstractDataType newObject;
        for (int i = 0; i < copyObject.objectList.size(); i++)
        {
            newObject = (AbstractDataType) ID3Tags.copyObject(copyObject.objectList.get(i));
            newObject.setBody(this);
            this.objectList.add(newObject);
        }
    
Methods Summary
public voidcreateStructure()

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

param
obj datatype to determine equality of
return
true if this datatype and its entire MP3Object array list equals the argument.

        if (!(obj instanceof AbstractTagFrameBody))
        {
            return false;
        }
        AbstractTagFrameBody object = (AbstractTagFrameBody) obj;
        boolean check =this.objectList.equals(object.objectList) && super.equals(obj);
        return check;
    
public java.lang.StringgetBriefDescription()
This method calls toString for all it's objects and appends them without any newline characters.

return
brief description string

        String str = "";
        for (AbstractDataType object : objectList)
        {
            if ((object.toString() != null) && (object.toString().length() > 0))
            {
                str += (object.getIdentifier() + "=\"" + object.toString() + "\"; ");
            }
        }
        return str;
    
public AbstractTagFramegetHeader()
Get Reference to header

return

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

return
formatted description string

        String str = "";
        for (AbstractDataType object : objectList)
        {
            if ((object.toString() != null) && (object.toString().length() > 0))
            {
                str += (object.getIdentifier() + " = " + object.toString() + "\n");
            }
        }
        return str;
    
public final org.jaudiotagger.tag.datatype.AbstractDataTypegetObject(java.lang.String identifier)
Returns the datatype with the specified identifier

param
identifier
return
the datatype with the specified identifier

        AbstractDataType object;
        Iterator<AbstractDataType> iterator = objectList.listIterator();
        while (iterator.hasNext())
        {
            object = iterator.next();
            if (object.getIdentifier().equals(identifier))
            {
                return object;
            }
        }
        return null;
    
public final java.lang.ObjectgetObjectValue(java.lang.String identifier)
Returns the value of the datatype with the specified identifier

param
identifier
return
the value of the dattype with the specified identifier

        return getObject(identifier).getValue();
    
public intgetSize()
Returns the size in bytes of this fragmentbody

return
estimated size in bytes of this datatype

        int size = 0;
        AbstractDataType object;
        Iterator<AbstractDataType> iterator = objectList.listIterator();
        while (iterator.hasNext())
        {
            object = iterator.next();
            size += object.getSize();
        }
        return size;
    
public final bytegetTextEncoding()
Return the Text Encoding

return
the text encoding used by this framebody


                     
       
    
        AbstractDataType o = getObject(DataTypes.OBJ_TEXT_ENCODING);

        if (o != null)
        {
            Long encoding = (Long) (o.getValue());
            return encoding.byteValue();
        }
        else
        {
            return TextEncoding.ISO_8859_1;
        }
    
public java.lang.StringgetUserFriendlyValue()

return
the text value that the user would expect to see for this framebody type, this should be overrridden for all framebodies

        return toString();
    
public booleanisSubsetOf(java.lang.Object obj)
Returns true if this instance and its entire DataType array list is a subset of the argument. This class is a subset if it is the same class as the argument.

param
obj datatype to determine subset of
return
true if this instance and its entire datatype array list is a subset of the argument.

        if (!(obj instanceof AbstractTagFrameBody))
        {
            return false;
        }
        ArrayList<AbstractDataType> superset = ((AbstractTagFrameBody) obj).objectList;
        for (AbstractDataType anObjectList : objectList)
        {
            if (anObjectList.getValue() != null)
            {
                if (!superset.contains(anObjectList))
                {
                    return false;
                }
            }
        }
        return true;
    
public java.util.Iteratoriterator()
Returns an iterator of the DataType list.

return
iterator of the DataType list.

        return objectList.iterator();
    
public voidsetHeader(AbstractTagFrame header)
Set header

param
header

        this.header = header;
    
public final voidsetObjectValue(java.lang.String identifier, java.lang.Object value)
Sets all objects of identifier type to value defined by obj argument.

param
identifier MP3Object identifier
param
value new datatype value

        AbstractDataType object;
        Iterator<AbstractDataType> iterator = objectList.listIterator();
        while (iterator.hasNext())
        {
            object = iterator.next();
            if (object.getIdentifier().equals(identifier))
            {
                object.setValue(value);
            }
        }
    
public final voidsetTextEncoding(byte textEncoding)
Set the Text Encoding to use for this frame body

param
textEncoding to use for this frame body

        //Number HashMap actually converts this byte to a long
        setObjectValue(DataTypes.OBJ_TEXT_ENCODING, textEncoding);
    
protected abstract voidsetupObjectList()
Create the list of Datatypes that this body expects in the correct order This method needs to be implemented by concrete subclasses

public java.lang.StringtoString()
Return brief description of FrameBody

return
brief description of FrameBody

        return getBriefDescription();