FileDocCategorySizeDatePackage
IIOMetadataFormatImpl.javaAPI DocJava SE 5 API48165Fri Aug 26 14:57:30 BST 2005javax.imageio.metadata

IIOMetadataFormatImpl

public abstract class IIOMetadataFormatImpl extends Object implements IIOMetadataFormat
A concrete class providing a reusable implementation of the IIOMetadataFormat interface. In addition, a static instance representing the standard, plug-in neutral javax_imageio_1.0 format is provided by the getStandardFormatInstance method.

In order to supply localized descriptions of elements and attributes, a ResourceBundle with a base name of this.getClass().getName() + "Resources" should be supplied via the usual mechanism used by ResourceBundle.getBundle. Briefly, the subclasser supplies one or more additional classes according to a naming convention (by default, the fully-qualified name of the subclass extending IIMetadataFormatImpl, plus the string "Resources", plus the country, language, and variant codes separated by underscores). At run time, calls to getElementDescription or getAttributeDescription will attempt to load such classes dynamically according to the supplied locale, and will use either the element name, or the element name followed by a '/' character followed by the attribute name as a key. This key will be supplied to the ResourceBundle's getString method, and the resulting localized description of the node or attribute is returned.

The subclass may supply a different base name for the resource bundles using the setResourceBaseName method.

A subclass may choose its own localization mechanism, if so desired, by overriding the supplied implementations of getElementDescription and getAttributeDescription.

see
ResourceBundle#getBundle(String,Locale)
version
0.5

Fields Summary
public static final String
standardMetadataFormatName
A String constant containing the standard format name, "javax_imageio_1.0".
private static IIOMetadataFormat
standardFormat
private String
resourceBaseName
private String
rootName
private HashMap
elementMap
Constructors Summary
public IIOMetadataFormatImpl(String rootName, int childPolicy)
Constructs a blank IIOMetadataFormatImpl instance, with a given root element name and child policy (other than CHILD_POLICY_REPEAT). Additional elements, and their attributes and Object reference information may be added using the various add methods.

param
rootName the name of the root element.
param
childPolicy one of the CHILD_POLICY_* constants, other than CHILD_POLICY_REPEAT.
exception
IllegalArgumentException if rootName is null.
exception
IllegalArgumentException if childPolicy is not one of the predefined constants.

    

                                                                               
      
                                   
        if (rootName == null) {
            throw new IllegalArgumentException("rootName == null!");
        }
        if (childPolicy < CHILD_POLICY_EMPTY ||
            childPolicy > CHILD_POLICY_MAX ||
            childPolicy == CHILD_POLICY_REPEAT) {
            throw new IllegalArgumentException("Invalid value for childPolicy!");
        }

        this.rootName = rootName;

        Element root = new Element();
        root.elementName = rootName;
        root.childPolicy = childPolicy;

        elementMap.put(rootName, root);
    
public IIOMetadataFormatImpl(String rootName, int minChildren, int maxChildren)
Constructs a blank IIOMetadataFormatImpl instance, with a given root element name and a child policy of CHILD_POLICY_REPEAT. Additional elements, and their attributes and Object reference information may be added using the various add methods.

param
rootName the name of the root element.
param
minChildren the minimum number of children of the node.
param
maxChildren the maximum number of children of the node.
exception
IllegalArgumentException if rootName is null.
exception
IllegalArgumentException if minChildren is negative or larger than maxChildren.

        if (rootName == null) {
            throw new IllegalArgumentException("rootName == null!");
        }
        if (minChildren < 0) {
            throw new IllegalArgumentException("minChildren < 0!");
        }
        if (minChildren > maxChildren) {
            throw new IllegalArgumentException("minChildren > maxChildren!");
        }

        Element root = new Element();
        root.elementName = rootName;
        root.childPolicy = CHILD_POLICY_REPEAT;
        root.minChildren = minChildren;
        root.maxChildren = maxChildren;

        this.rootName = rootName;
        elementMap.put(rootName, root);
    
Methods Summary
protected voidaddAttribute(java.lang.String elementName, java.lang.String attrName, int dataType, boolean required, java.lang.String defaultValue)
Adds a new attribute to a previously defined element that may be set to an arbitrary value.

param
elementName the name of the element.
param
attrName the name of the attribute being added.
param
dataType the data type (string format) of the attribute, one of the DATATYPE_* constants.
param
required true if the attribute must be present.
param
defaultValue the default value for the attribute, or null.
exception
IllegalArgumentException if elementName is null, or is not a legal element name for this format.
exception
IllegalArgumentException if attrName is null.
exception
IllegalArgumentException if dataType is not one of the predefined constants.

        Element element = getElement(elementName);
        if (attrName == null) {
            throw new IllegalArgumentException("attrName == null!");
        }
        if (dataType < DATATYPE_STRING || dataType > DATATYPE_DOUBLE) {
            throw new IllegalArgumentException("Invalid value for dataType!");
        }

        Attribute attr = new Attribute();
        attr.attrName = attrName;
        attr.valueType = VALUE_ARBITRARY;
        attr.dataType = dataType;
        attr.required = required;
        attr.defaultValue = defaultValue;

        element.attrList.add(attrName);
        element.attrMap.put(attrName, attr);
    
protected voidaddAttribute(java.lang.String elementName, java.lang.String attrName, int dataType, boolean required, java.lang.String defaultValue, java.util.List enumeratedValues)
Adds a new attribute to a previously defined element that will be defined by a set of enumerated values.

param
elementName the name of the element.
param
attrName the name of the attribute being added.
param
dataType the data type (string format) of the attribute, one of the DATATYPE_* constants.
param
required true if the attribute must be present.
param
defaultValue the default value for the attribute, or null.
param
enumeratedValues a List of Strings containing the legal values for the attribute.
exception
IllegalArgumentException if elementName is null, or is not a legal element name for this format.
exception
IllegalArgumentException if attrName is null.
exception
IllegalArgumentException if dataType is not one of the predefined constants.
exception
IllegalArgumentException if enumeratedValues is null.
exception
IllegalArgumentException if enumeratedValues does not contain at least one entry.
exception
IllegalArgumentException if enumeratedValues contains an element that is not a String or is null.

        Element element = getElement(elementName);
        if (attrName == null) {
            throw new IllegalArgumentException("attrName == null!");
        }
        if (dataType < DATATYPE_STRING || dataType > DATATYPE_DOUBLE) {
            throw new IllegalArgumentException("Invalid value for dataType!");
        }
        if (enumeratedValues == null) {
            throw new IllegalArgumentException("enumeratedValues == null!");
        }
        if (enumeratedValues.size() == 0) {
            throw new IllegalArgumentException("enumeratedValues is empty!");
        }
        Iterator iter = enumeratedValues.iterator();
        while (iter.hasNext()) {
            Object o = iter.next();
            if (o == null) {
                throw new IllegalArgumentException
                    ("enumeratedValues contains a null!");
            }
            if (!(o instanceof String)) {
                throw new IllegalArgumentException
                    ("enumeratedValues contains a non-String value!");
            }
        }

        Attribute attr = new Attribute();
        attr.attrName = attrName;
        attr.valueType = VALUE_ENUMERATION;
        attr.dataType = dataType;
        attr.required = required;
        attr.defaultValue = defaultValue;
        attr.enumeratedValues = enumeratedValues;

        element.attrList.add(attrName);
        element.attrMap.put(attrName, attr);
    
protected voidaddAttribute(java.lang.String elementName, java.lang.String attrName, int dataType, boolean required, java.lang.String defaultValue, java.lang.String minValue, java.lang.String maxValue, boolean minInclusive, boolean maxInclusive)
Adds a new attribute to a previously defined element that will be defined by a range of values.

param
elementName the name of the element.
param
attrName the name of the attribute being added.
param
dataType the data type (string format) of the attribute, one of the DATATYPE_* constants.
param
required true if the attribute must be present.
param
defaultValue the default value for the attribute, or null.
param
minValue the smallest (inclusive or exclusive depending on the value of minInclusive) legal value for the attribute, as a String.
param
maxValue the largest (inclusive or exclusive depending on the value of minInclusive) legal value for the attribute, as a String.
param
minInclusive true if minValue is inclusive.
param
maxInclusive true if maxValue is inclusive.
exception
IllegalArgumentException if elementName is null, or is not a legal element name for this format.
exception
IllegalArgumentException if attrName is null.
exception
IllegalArgumentException if dataType is not one of the predefined constants.

        Element element = getElement(elementName);
        if (attrName == null) {
            throw new IllegalArgumentException("attrName == null!");
        }
        if (dataType < DATATYPE_STRING || dataType > DATATYPE_DOUBLE) {
            throw new IllegalArgumentException("Invalid value for dataType!");
        }

        Attribute attr = new Attribute();
        attr.attrName = attrName;
        attr.valueType = VALUE_RANGE;
        if (minInclusive) {
            attr.valueType |= VALUE_RANGE_MIN_INCLUSIVE_MASK;
        }
        if (maxInclusive) {
            attr.valueType |= VALUE_RANGE_MAX_INCLUSIVE_MASK;
        }
        attr.dataType = dataType;
        attr.required = required;
        attr.defaultValue = defaultValue;
        attr.minValue = minValue;
        attr.maxValue = maxValue;

        element.attrList.add(attrName);
        element.attrMap.put(attrName, attr);
    
protected voidaddAttribute(java.lang.String elementName, java.lang.String attrName, int dataType, boolean required, int listMinLength, int listMaxLength)
Adds a new attribute to a previously defined element that will be defined by a list of values.

param
elementName the name of the element.
param
attrName the name of the attribute being added.
param
dataType the data type (string format) of the attribute, one of the DATATYPE_* constants.
param
required true if the attribute must be present.
param
listMinLength the smallest legal number of list items.
param
listMaxLength the largest legal number of list items.
exception
IllegalArgumentException if elementName is null, or is not a legal element name for this format.
exception
IllegalArgumentException if attrName is null.
exception
IllegalArgumentException if dataType is not one of the predefined constants.
exception
IllegalArgumentException if listMinLength is negative or larger than listMaxLength.

        Element element = getElement(elementName);
        if (attrName == null) {
            throw new IllegalArgumentException("attrName == null!");
        }
        if (dataType < DATATYPE_STRING || dataType > DATATYPE_DOUBLE) {
            throw new IllegalArgumentException("Invalid value for dataType!");
        }
        if (listMinLength < 0 || listMinLength > listMaxLength) {
            throw new IllegalArgumentException("Invalid list bounds!");
        }

        Attribute attr = new Attribute();
        attr.attrName = attrName;
        attr.valueType = VALUE_LIST;
        attr.dataType = dataType;
        attr.required = required;
        attr.listMinLength = listMinLength;
        attr.listMaxLength = listMaxLength;

        element.attrList.add(attrName);
        element.attrMap.put(attrName, attr);
    
protected voidaddBooleanAttribute(java.lang.String elementName, java.lang.String attrName, boolean hasDefaultValue, boolean defaultValue)
Adds a new attribute to a previously defined element that will be defined by the enumerated values TRUE and FALSE, with a datatype of DATATYPE_BOOLEAN.

param
elementName the name of the element.
param
attrName the name of the attribute being added.
param
hasDefaultValue true if a default value should be present.
param
defaultValue the default value for the attribute as a boolean, ignored if hasDefaultValue is false.
exception
IllegalArgumentException if elementName is null, or is not a legal element name for this format.
exception
IllegalArgumentException if attrName is null.

        List values = new ArrayList();
        values.add("TRUE");
        values.add("FALSE");
        
        String dval = null;
        if (hasDefaultValue) {
            dval = defaultValue ? "TRUE" : "FALSE";
        }
        addAttribute(elementName,
                     attrName,
                     DATATYPE_BOOLEAN,
                     true,
                     dval,
                     values);
    
protected voidaddChildElement(java.lang.String elementName, java.lang.String parentName)
Adds an existing element to the list of legal children for a given parent node type.

param
parentName the name of the element that will be the new parent of the element.
param
elementName the name of the element to be addded as a child.
exception
IllegalArgumentException if elementName is null, or is not a legal element name for this format.
exception
IllegalArgumentException if parentName is null, or is not a legal element name for this format.

        Element parent = getElement(parentName);
        Element element = getElement(elementName);
        parent.childList.add(elementName);
        element.parentList.add(parentName);
    
protected voidaddElement(java.lang.String elementName, java.lang.String parentName, int childPolicy)
Adds a new element type to this metadata document format with a child policy other than CHILD_POLICY_REPEAT.

param
elementName the name of the new element.
param
parentName the name of the element that will be the parent of the new element.
param
childPolicy one of the CHILD_POLICY_* constants, other than CHILD_POLICY_REPEAT, indicating the child policy of the new element.
exception
IllegalArgumentException if parentName is null, or is not a legal element name for this format.
exception
IllegalArgumentException if childPolicy is not one of the predefined constants.

        Element parent = getElement(parentName);
        if (childPolicy < CHILD_POLICY_EMPTY ||
            childPolicy > CHILD_POLICY_MAX ||
            childPolicy == CHILD_POLICY_REPEAT) {
            throw new IllegalArgumentException
                ("Invalid value for childPolicy!");
        }

        Element element = new Element();
        element.elementName = elementName;
        element.childPolicy = childPolicy;

        parent.childList.add(elementName);
        element.parentList.add(parentName);

        elementMap.put(elementName, element);
    
protected voidaddElement(java.lang.String elementName, java.lang.String parentName, int minChildren, int maxChildren)
Adds a new element type to this metadata document format with a child policy of CHILD_POLICY_REPEAT.

param
elementName the name of the new element.
param
parentName the name of the element that will be the parent of the new element.
param
minChildren the minimum number of children of the node.
param
maxChildren the maximum number of children of the node.
exception
IllegalArgumentException if parentName is null, or is not a legal element name for this format.
exception
IllegalArgumentException if minChildren is negative or larger than maxChildren.

        Element parent = getElement(parentName);
        if (minChildren < 0) {
            throw new IllegalArgumentException("minChildren < 0!");
        }
        if (minChildren > maxChildren) {
            throw new IllegalArgumentException("minChildren > maxChildren!");
        }

        Element element = new Element();
        element.elementName = elementName;
        element.childPolicy = CHILD_POLICY_REPEAT;
        element.minChildren = minChildren;
        element.maxChildren = maxChildren;

        parent.childList.add(elementName);
        element.parentList.add(parentName);

        elementMap.put(elementName, element);
    
protected voidaddObjectValue(java.lang.String elementName, java.lang.Class classType, boolean required, T defaultValue)
Allows an Object reference of a given class type to be stored in nodes implementing the named element. The value of the Object is unconstrained other than by its class type.

If an Object reference was previously allowed, the previous settings are overwritten.

param
elementName the name of the element.
param
classType a Class variable indicating the legal class type for the object value.
param
required true if an object value must be present.
param
defaultValue the default value for the Object reference, or null.
exception
IllegalArgumentException if elementName is null, or is not a legal element name for this format.

        Element element = getElement(elementName);
        ObjectValue obj = new ObjectValue();
        obj.valueType = VALUE_ARBITRARY;
        obj.classType = classType;
        obj.defaultValue = defaultValue;

        element.objectValue = obj;
    
protected voidaddObjectValue(java.lang.String elementName, java.lang.Class classType, boolean required, T defaultValue, java.util.List enumeratedValues)
Allows an Object reference of a given class type to be stored in nodes implementing the named element. The value of the Object must be one of the values given by enumeratedValues.

If an Object reference was previously allowed, the previous settings are overwritten.

param
elementName the name of the element.
param
classType a Class variable indicating the legal class type for the object value.
param
required true if an object value must be present.
param
defaultValue the default value for the Object reference, or null.
param
enumeratedValues a List of Objects containing the legal values for the object reference.
exception
IllegalArgumentException if elementName is null, or is not a legal element name for this format.
exception
IllegalArgumentException if enumeratedValues is null.
exception
IllegalArgumentException if enumeratedValues does not contain at least one entry.
exception
IllegalArgumentException if enumeratedValues contains an element that is not an instance of the class type denoted by classType or is null.

        Element element = getElement(elementName);
        if (enumeratedValues == null) {
            throw new IllegalArgumentException("enumeratedValues == null!");
        }
        if (enumeratedValues.size() == 0) {
            throw new IllegalArgumentException("enumeratedValues is empty!");
        }
        Iterator iter = enumeratedValues.iterator();
        while (iter.hasNext()) {
            Object o = iter.next();
            if (o == null) {
                throw new IllegalArgumentException("enumeratedValues contains a null!");
            }
            if (!classType.isInstance(o)) {
                throw new IllegalArgumentException("enumeratedValues contains a value not of class classType!");
            }
        }

        ObjectValue obj = new ObjectValue();
        obj.valueType = VALUE_ENUMERATION;
        obj.classType = classType;
        obj.defaultValue = defaultValue;
        obj.enumeratedValues = enumeratedValues;

        element.objectValue = obj;
    
protected voidaddObjectValue(java.lang.String elementName, java.lang.Class classType, T defaultValue, java.lang.Comparable minValue, java.lang.Comparable maxValue, boolean minInclusive, boolean maxInclusive)
Allows an Object reference of a given class type to be stored in nodes implementing the named element. The value of the Object must be within the range given by minValue and maxValue. Furthermore, the class type must implement the Comparable interface.

If an Object reference was previously allowed, the previous settings are overwritten.

param
elementName the name of the element.
param
classType a Class variable indicating the legal class type for the object value.
param
defaultValue the default value for the
param
minValue the smallest (inclusive or exclusive depending on the value of minInclusive) legal value for the object value, as a String.
param
maxValue the largest (inclusive or exclusive depending on the value of minInclusive) legal value for the object value, as a String.
param
minInclusive true if minValue is inclusive.
param
maxInclusive true if maxValue is inclusive.
exception
IllegalArgumentException if elementName is null, or is not a legal element name for this format.

        Element element = getElement(elementName);
        ObjectValue obj = new ObjectValue();
        obj.valueType = VALUE_RANGE;
        if (minInclusive) {
            obj.valueType |= VALUE_RANGE_MIN_INCLUSIVE_MASK;
        }
        if (maxInclusive) {
            obj.valueType |= VALUE_RANGE_MAX_INCLUSIVE_MASK;
        }
        obj.classType = classType;
        obj.defaultValue = defaultValue;
        obj.minValue = minValue;
        obj.maxValue = maxValue;

        element.objectValue = obj;
    
protected voidaddObjectValue(java.lang.String elementName, java.lang.Class classType, int arrayMinLength, int arrayMaxLength)
Allows an Object reference of a given class type to be stored in nodes implementing the named element. The value of the Object must an array of objects of class type given by classType, with at least arrayMinLength and at most arrayMaxLength elements.

If an Object reference was previously allowed, the previous settings are overwritten.

param
elementName the name of the element.
param
classType a Class variable indicating the legal class type for the object value.
param
arrayMinLength the smallest legal length for the array.
param
arrayMaxLength the largest legal length for the array.
exception
IllegalArgumentException if elementName is not a legal element name for this format.

        Element element = getElement(elementName);
        ObjectValue obj = new ObjectValue();
        obj.valueType = VALUE_LIST;
        obj.classType = classType;
        obj.arrayMinLength = arrayMinLength;
        obj.arrayMaxLength = arrayMaxLength;

        element.objectValue = obj;
    
public abstract booleancanNodeAppear(java.lang.String elementName, javax.imageio.ImageTypeSpecifier imageType)

private static synchronized voidcreateStandardFormat()

        if (standardFormat == null) {
            standardFormat = new StandardMetadataFormat();
        }
    
private javax.imageio.metadata.IIOMetadataFormatImpl$AttributegetAttribute(java.lang.String elementName, java.lang.String attrName)

        Element element = getElement(elementName);
        Attribute attr = (Attribute)element.attrMap.get(attrName);
        if (attr == null) {
            throw new IllegalArgumentException("No such attribute \"" +
                                               attrName + "\"!");
        }
        return attr;
    
public intgetAttributeDataType(java.lang.String elementName, java.lang.String attrName)

 
        Attribute attr = getAttribute(elementName, attrName);
        return attr.dataType;
    
public java.lang.StringgetAttributeDefaultValue(java.lang.String elementName, java.lang.String attrName)

        Attribute attr = getAttribute(elementName, attrName);
        return attr.defaultValue;
    
public java.lang.StringgetAttributeDescription(java.lang.String elementName, java.lang.String attrName, java.util.Locale locale)
Returns a String containing a description of the named attribute, or null. The desciption will be localized for the supplied Locale if possible.

The default implementation will first locate a ResourceBundle using the current resource base name set by setResourceBaseName and the supplied Locale, using the fallback mechanism described in the comments for ResourceBundle.getBundle. If a ResourceBundle is found, the element name followed by a "/" character followed by the attribute name (elementName + "/" + attrName) will be used as a key to its getString method, and the result returned. If no ResourceBundle is found, or no such key is present, null will be returned.

If locale is null, the current default Locale returned by Locale.getLocale will be used.

param
elementName the name of the element.
param
attrName the name of the attribute.
param
locale the Locale for which localization will be attempted, or null.
return
the attribute description.
exception
IllegalArgumentException if elementName is null, or is not a legal element name for this format.
exception
IllegalArgumentException if attrName is null or is not a legal attribute name for this element.
see
#setResourceBaseName

        Element element = getElement(elementName);
        if (attrName == null) {
            throw new IllegalArgumentException("attrName == null!");
        }
        Attribute attr = (Attribute)element.attrMap.get(attrName);
        if (attr == null) {
            throw new IllegalArgumentException("No such attribute!");
        }

        String key = elementName + "/" + attrName;
        return getResource(key, locale);
    
public java.lang.String[]getAttributeEnumerations(java.lang.String elementName, java.lang.String attrName)

        Attribute attr = getAttribute(elementName, attrName);
        if (attr.valueType != VALUE_ENUMERATION) {
            throw new IllegalArgumentException
                ("Attribute not an enumeration!");
        }
        
        List values = attr.enumeratedValues;
        Iterator iter = values.iterator();
        String[] result = new String[values.size()];
        return (String[])values.toArray(result);
    
public intgetAttributeListMaxLength(java.lang.String elementName, java.lang.String attrName)

        Attribute attr = getAttribute(elementName, attrName);
        if (attr.valueType != VALUE_LIST) {
            throw new IllegalArgumentException("Attribute not a list!");
        }

        return attr.listMaxLength;
    
public intgetAttributeListMinLength(java.lang.String elementName, java.lang.String attrName)

        Attribute attr = getAttribute(elementName, attrName);
        if (attr.valueType != VALUE_LIST) {
            throw new IllegalArgumentException("Attribute not a list!");
        }

        return attr.listMinLength;
    
public java.lang.StringgetAttributeMaxValue(java.lang.String elementName, java.lang.String attrName)

        Attribute attr = getAttribute(elementName, attrName);
        if (attr.valueType != VALUE_RANGE &&
            attr.valueType != VALUE_RANGE_MIN_INCLUSIVE &&
            attr.valueType != VALUE_RANGE_MAX_INCLUSIVE &&
            attr.valueType != VALUE_RANGE_MIN_MAX_INCLUSIVE) {
            throw new IllegalArgumentException("Attribute not a range!");
        }

        return attr.maxValue;
    
public java.lang.StringgetAttributeMinValue(java.lang.String elementName, java.lang.String attrName)

        Attribute attr = getAttribute(elementName, attrName);
        if (attr.valueType != VALUE_RANGE &&
            attr.valueType != VALUE_RANGE_MIN_INCLUSIVE &&
            attr.valueType != VALUE_RANGE_MAX_INCLUSIVE &&
            attr.valueType != VALUE_RANGE_MIN_MAX_INCLUSIVE) {
            throw new IllegalArgumentException("Attribute not a range!");
        }

        return attr.minValue;
    
public java.lang.String[]getAttributeNames(java.lang.String elementName)

        Element element = getElement(elementName);
        List names = element.attrList;

        String[] result = new String[names.size()];
        return (String[])names.toArray(result);
    
public intgetAttributeValueType(java.lang.String elementName, java.lang.String attrName)

        Attribute attr = getAttribute(elementName, attrName);
        return attr.valueType;
    
public java.lang.String[]getChildNames(java.lang.String elementName)

        Element element = getElement(elementName);
        if (element.childPolicy == CHILD_POLICY_EMPTY) {
            return null;
        }
        return (String[])element.childList.toArray(new String[0]);
    
public intgetChildPolicy(java.lang.String elementName)

        Element element = getElement(elementName);
        return element.childPolicy;
    
private javax.imageio.metadata.IIOMetadataFormatImpl$ElementgetElement(java.lang.String elementName, boolean mustAppear)
Utility method for locating an element.

param
mustAppear if true, throw an IllegalArgumentException if no such node exists; if false, just return null.

        if (mustAppear && (elementName == null)) {
            throw new IllegalArgumentException("element name is null!");
        }
        Element element = (Element)elementMap.get(elementName);
        if (mustAppear && (element == null)) {
            throw new IllegalArgumentException("No such element: " +
                                               elementName);
        }
        return element;
    
private javax.imageio.metadata.IIOMetadataFormatImpl$ElementgetElement(java.lang.String elementName)

        return getElement(elementName, true);
    
public java.lang.StringgetElementDescription(java.lang.String elementName, java.util.Locale locale)
Returns a String containing a description of the named element, or null. The desciption will be localized for the supplied Locale if possible.

The default implementation will first locate a ResourceBundle using the current resource base name set by setResourceBaseName and the supplied Locale, using the fallback mechanism described in the comments for ResourceBundle.getBundle. If a ResourceBundle is found, the element name will be used as a key to its getString method, and the result returned. If no ResourceBundle is found, or no such key is present, null will be returned.

If locale is null, the current default Locale returned by Locale.getLocale will be used.

param
elementName the name of the element.
param
locale the Locale for which localization will be attempted.
return
the element description.
exception
IllegalArgumentException if elementName is null, or is not a legal element name for this format.
see
#setResourceBaseName

        Element element = getElement(elementName);
        return getResource(elementName, locale);
    
public intgetElementMaxChildren(java.lang.String elementName)

        Element element = getElement(elementName);
        if (element.childPolicy != CHILD_POLICY_REPEAT) {
            throw new IllegalArgumentException("Child policy not CHILD_POLICY_REPEAT!");
        }
        return element.maxChildren;
    
public intgetElementMinChildren(java.lang.String elementName)

        Element element = getElement(elementName);
        if (element.childPolicy != CHILD_POLICY_REPEAT) {
            throw new IllegalArgumentException("Child policy not CHILD_POLICY_REPEAT!");
        }
        return element.minChildren;
    
public intgetObjectArrayMaxLength(java.lang.String elementName)

        ObjectValue objv = getObjectValue(elementName);
        if (objv.valueType != VALUE_LIST) {
            throw new IllegalArgumentException("Not a list!");
        }
        return objv.arrayMaxLength;
    
public intgetObjectArrayMinLength(java.lang.String elementName)

        ObjectValue objv = getObjectValue(elementName);
        if (objv.valueType != VALUE_LIST) {
            throw new IllegalArgumentException("Not a list!");
        }
        return objv.arrayMinLength;
    
public java.lang.ClassgetObjectClass(java.lang.String elementName)

        ObjectValue objv = getObjectValue(elementName);
        return objv.classType;
    
public java.lang.ObjectgetObjectDefaultValue(java.lang.String elementName)

        ObjectValue objv = getObjectValue(elementName);
        return objv.defaultValue;
    
public java.lang.Object[]getObjectEnumerations(java.lang.String elementName)

        ObjectValue objv = getObjectValue(elementName);
        if (objv.valueType != VALUE_ENUMERATION) {
            throw new IllegalArgumentException("Not an enumeration!");
        }
        List vlist = objv.enumeratedValues;
        Object[] values = new Object[vlist.size()];
        return vlist.toArray(values);
    
public java.lang.ComparablegetObjectMaxValue(java.lang.String elementName)

        ObjectValue objv = getObjectValue(elementName);
        if ((objv.valueType & VALUE_RANGE) != VALUE_RANGE) {
            throw new IllegalArgumentException("Not a range!");
        }
        return objv.maxValue;
    
public java.lang.ComparablegetObjectMinValue(java.lang.String elementName)

        ObjectValue objv = getObjectValue(elementName);
        if ((objv.valueType & VALUE_RANGE) != VALUE_RANGE) {
            throw new IllegalArgumentException("Not a range!");
        }
        return objv.minValue;
    
private javax.imageio.metadata.IIOMetadataFormatImpl$ObjectValuegetObjectValue(java.lang.String elementName)

        Element element = getElement(elementName);
        ObjectValue objv = (ObjectValue)element.objectValue;
        if (objv == null) {
            throw new IllegalArgumentException("No object within element " +
                                               elementName + "!");
        }
        return objv;
    
public intgetObjectValueType(java.lang.String elementName)

        Element element = getElement(elementName);
        ObjectValue objv = (ObjectValue)element.objectValue;
        if (objv == null) {
            return VALUE_NONE;
        }
        return objv.valueType;
    
private java.lang.StringgetResource(java.lang.String key, java.util.Locale locale)

        if (locale == null) {
            locale = Locale.getDefault();
        }

        /**
         * If an applet supplies an implementation of IIOMetadataFormat and
         * resource bundles, then the resource bundle will need to be
         * accessed via the applet class loader. So first try the context
         * class loader to locate the resource bundle.
         * If that throws MissingResourceException, then try the
         * system class loader.
         */
        ClassLoader loader = (ClassLoader)
            java.security.AccessController.doPrivileged(
                new java.security.PrivilegedAction() {
                   public Object run() {
                       return Thread.currentThread().getContextClassLoader();
                   }
            });

        ResourceBundle bundle = null;
        try {
            bundle = ResourceBundle.getBundle(resourceBaseName,
                                              locale, loader);
        } catch (MissingResourceException mre) {
            try {
                bundle = ResourceBundle.getBundle(resourceBaseName, locale);
            } catch (MissingResourceException mre1) {
                return null;
            }
        }

        try {
            return bundle.getString(key);
        } catch (MissingResourceException e) {
            return null;
        }
    
protected java.lang.StringgetResourceBaseName()
Returns the currently set base name for locating ResourceBundles.

return
a String containing the base name.
see
#setResourceBaseName

        return resourceBaseName;
    
public java.lang.StringgetRootName()

        return rootName;
    
public static javax.imageio.metadata.IIOMetadataFormatgetStandardFormatInstance()
Returns an IIOMetadataFormat object describing the standard, plug-in neutral javax.imageio_1.0 metadata document format described in the comment of the javax.imageio.metadata package.

return
a predefined IIOMetadataFormat instance.

        createStandardFormat();
        return standardFormat;
    
public booleanisAttributeRequired(java.lang.String elementName, java.lang.String attrName)

        Attribute attr = getAttribute(elementName, attrName);
        return attr.required;
    
protected voidremoveAttribute(java.lang.String elementName, java.lang.String attrName)
Removes an attribute from a previously defined element. If no attribute with the given name was present in the given element, nothing happens and no exception is thrown.

param
elementName the name of the element.
param
attrName the name of the attribute being removed.
exception
IllegalArgumentException if elementName is null, or is not a legal element name for this format.

        Element element = getElement(elementName);
        element.attrList.remove(attrName);
        element.attrMap.remove(attrName);
    
protected voidremoveElement(java.lang.String elementName)
Removes an element from the format. If no element with the given name was present, nothing happens and no exception is thrown.

param
elementName the name of the element to be removed.

        Element element = getElement(elementName, false);
        if (element != null) {            
            Iterator iter = element.parentList.iterator();
            while (iter.hasNext()) {
                String parentName = (String)iter.next();
                Element parent = getElement(parentName, false);
                if (parent != null) {
                    parent.childList.remove(elementName);
                }
            }
            elementMap.remove(elementName);
        }
    
protected voidremoveObjectValue(java.lang.String elementName)
Disallows an Object reference from being stored in nodes implementing the named element.

param
elementName the name of the element.
exception
IllegalArgumentException if elementName is not a legal element name for this format.

        Element element = getElement(elementName);
        element.objectValue = null;
    
protected voidsetResourceBaseName(java.lang.String resourceBaseName)
Sets a new base name for locating ResourceBundles containing descriptions of elements and attributes for this format.

Prior to the first time this method is called, the base name will be equal to this.getClass().getName() + "Resources".

param
resourceBaseName a String containg the new base name.
exception
IllegalArgumentException if resourceBaseName is null.
see
#getResourceBaseName

        if (resourceBaseName == null) {
            throw new IllegalArgumentException("resourceBaseName == null!");
        }
        this.resourceBaseName = resourceBaseName;