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

StringHashMap

public class StringHashMap extends StringFixedLength implements HashMapInterface
Represents a String thats acts as a key into an enumeration of values. The String will be encoded using the default encoding regardless of what encoding may be specified in the framebody

Fields Summary
Map
keyToValue
Map
valueToKey
boolean
hasEmptyValue
Constructors Summary
public StringHashMap(String identifier, org.jaudiotagger.tag.id3.AbstractTagFrameBody frameBody, int size)
Creates a new ObjectStringHashMap datatype.

param
identifier
param
frameBody
param
size
throws
IllegalArgumentException


                      
          
    
        super(identifier, frameBody, size);

        if (identifier.equals(DataTypes.OBJ_LANGUAGE))
        {
            valueToKey = Languages.getInstanceOf().getValueToIdMap();
            keyToValue = Languages.getInstanceOf().getIdToValueMap();
        }
        else
        {
            throw new IllegalArgumentException("Hashmap identifier not defined in this class: " + identifier);
        }
    
public StringHashMap(StringHashMap copyObject)

        super(copyObject);

        this.hasEmptyValue = copyObject.hasEmptyValue;
        this.keyToValue = copyObject.keyToValue;
        this.valueToKey = copyObject.valueToKey;
    
Methods Summary
public booleanequals(java.lang.Object obj)

param
obj
return

        if (!(obj instanceof StringHashMap))
        {
            return false;
        }

        StringHashMap object = (StringHashMap) obj;

        if (this.hasEmptyValue != object.hasEmptyValue)
        {
            return false;
        }

        if (this.keyToValue == null)
        {
            if (object.keyToValue != null)
            {
                return false;
            }
        }
        else
        {
            if (!this.keyToValue.equals(object.keyToValue))
            {
                return false;
            }
        }

        if (this.keyToValue == null)
        {
            if (object.keyToValue != null)
            {
                return false;
            }
        }
        else
        {
            if (!this.valueToKey.equals(object.valueToKey))
            {
                return false;
            }
        }

        return super.equals(obj);
    
public java.util.MapgetKeyToValue()

return

        return keyToValue;
    
protected java.lang.StringgetTextEncodingCharSet()

return
the ISO_8859 encoding for Datatypes of this type

        return TextEncoding.CHARSET_ISO_8859_1;
    
public java.util.MapgetValueToKey()

return

        return valueToKey;
    
public java.util.Iteratoriterator()

return

        if (keyToValue == null)
        {
            return null;
        }
        else
        {
            // put them in a treeset first to sort them
            TreeSet<String> treeSet = new TreeSet<String>(keyToValue.values());

            if (hasEmptyValue)
            {
                treeSet.add("");
            }

            return treeSet.iterator();
        }
    
public voidsetValue(java.lang.Object value)

param
value

        if (value instanceof String)
        {
            //Issue #273 temporary hack for MM
            if(value.equals("XXX"))
            {
                this.value=value.toString();
            }
            else
            {
                this.value = ((String) value).toLowerCase();
            }
        }
        else
        {
            this.value = value;
        }
    
public java.lang.StringtoString()

return

        if (value == null)
        {
            return "";
        }
        else if (keyToValue.get(value) == null)
        {
            return "";
        }
        else
        {
            return keyToValue.get(value);
        }