0N/A/*
2362N/A * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.imageio.metadata;
0N/A
0N/Aimport java.util.ArrayList;
0N/Aimport java.util.Collection;
0N/Aimport java.util.HashMap;
0N/Aimport java.util.Iterator;
0N/Aimport java.util.List;
0N/Aimport java.util.Locale;
0N/Aimport java.util.Map;
0N/Aimport java.util.MissingResourceException;
0N/Aimport java.util.ResourceBundle;
0N/Aimport javax.imageio.ImageTypeSpecifier;
0N/Aimport com.sun.imageio.plugins.common.StandardMetadataFormat;
0N/A
0N/A/**
0N/A * A concrete class providing a reusable implementation of the
0N/A * <code>IIOMetadataFormat</code> interface. In addition, a static
0N/A * instance representing the standard, plug-in neutral
0N/A * <code>javax_imageio_1.0</code> format is provided by the
0N/A * <code>getStandardFormatInstance</code> method.
0N/A *
0N/A * <p> In order to supply localized descriptions of elements and
0N/A * attributes, a <code>ResourceBundle</code> with a base name of
0N/A * <code>this.getClass().getName() + "Resources"</code> should be
0N/A * supplied via the usual mechanism used by
0N/A * <code>ResourceBundle.getBundle</code>. Briefly, the subclasser
0N/A * supplies one or more additional classes according to a naming
0N/A * convention (by default, the fully-qualified name of the subclass
0N/A * extending <code>IIMetadataFormatImpl</code>, plus the string
0N/A * "Resources", plus the country, language, and variant codes
0N/A * separated by underscores). At run time, calls to
0N/A * <code>getElementDescription</code> or
0N/A * <code>getAttributeDescription</code> will attempt to load such
0N/A * classes dynamically according to the supplied locale, and will use
0N/A * either the element name, or the element name followed by a '/'
0N/A * character followed by the attribute name as a key. This key will
0N/A * be supplied to the <code>ResourceBundle</code>'s
0N/A * <code>getString</code> method, and the resulting localized
0N/A * description of the node or attribute is returned.
0N/A *
0N/A * <p> The subclass may supply a different base name for the resource
0N/A * bundles using the <code>setResourceBaseName</code> method.
0N/A *
0N/A * <p> A subclass may choose its own localization mechanism, if so
0N/A * desired, by overriding the supplied implementations of
0N/A * <code>getElementDescription</code> and
0N/A * <code>getAttributeDescription</code>.
0N/A *
0N/A * @see ResourceBundle#getBundle(String,Locale)
0N/A *
0N/A */
0N/Apublic abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
0N/A
0N/A /**
0N/A * A <code>String</code> constant containing the standard format
0N/A * name, <code>"javax_imageio_1.0"</code>.
0N/A */
0N/A public static final String standardMetadataFormatName =
0N/A "javax_imageio_1.0";
0N/A
0N/A private static IIOMetadataFormat standardFormat = null;
0N/A
0N/A private String resourceBaseName = this.getClass().getName() + "Resources";
0N/A
0N/A private String rootName;
0N/A
0N/A // Element name (String) -> Element
0N/A private HashMap elementMap = new HashMap();
0N/A
0N/A class Element {
0N/A String elementName;
0N/A
0N/A int childPolicy;
0N/A int minChildren = 0;
0N/A int maxChildren = 0;
0N/A
0N/A // Child names (Strings)
0N/A List childList = new ArrayList();
0N/A
0N/A // Parent names (Strings)
0N/A List parentList = new ArrayList();
0N/A
0N/A // List of attribute names in the order they were added
0N/A List attrList = new ArrayList();
0N/A // Attr name (String) -> Attribute
0N/A Map attrMap = new HashMap();
0N/A
0N/A ObjectValue objectValue;
0N/A }
0N/A
0N/A class Attribute {
0N/A String attrName;
0N/A
0N/A int valueType = VALUE_ARBITRARY;
0N/A int dataType;
0N/A boolean required;
0N/A String defaultValue = null;
0N/A
0N/A // enumeration
0N/A List enumeratedValues;
0N/A
0N/A // range
0N/A String minValue;
0N/A String maxValue;
0N/A
0N/A // list
0N/A int listMinLength;
0N/A int listMaxLength;
0N/A }
0N/A
0N/A class ObjectValue {
0N/A int valueType = VALUE_NONE;
0N/A Class classType = null;
0N/A Object defaultValue = null;
0N/A
0N/A // Meaningful only if valueType == VALUE_ENUMERATION
0N/A List enumeratedValues = null;
0N/A
0N/A // Meaningful only if valueType == VALUE_RANGE
0N/A Comparable minValue = null;
0N/A Comparable maxValue = null;
0N/A
0N/A // Meaningful only if valueType == VALUE_LIST
0N/A int arrayMinLength = 0;
0N/A int arrayMaxLength = 0;
0N/A }
0N/A
0N/A /**
0N/A * Constructs a blank <code>IIOMetadataFormatImpl</code> instance,
0N/A * with a given root element name and child policy (other than
0N/A * <code>CHILD_POLICY_REPEAT</code>). Additional elements, and
0N/A * their attributes and <code>Object</code> reference information
0N/A * may be added using the various <code>add</code> methods.
0N/A *
0N/A * @param rootName the name of the root element.
0N/A * @param childPolicy one of the <code>CHILD_POLICY_*</code> constants,
0N/A * other than <code>CHILD_POLICY_REPEAT</code>.
0N/A *
0N/A * @exception IllegalArgumentException if <code>rootName</code> is
0N/A * <code>null</code>.
0N/A * @exception IllegalArgumentException if <code>childPolicy</code> is
0N/A * not one of the predefined constants.
0N/A */
0N/A public IIOMetadataFormatImpl(String rootName,
0N/A int childPolicy) {
0N/A if (rootName == null) {
0N/A throw new IllegalArgumentException("rootName == null!");
0N/A }
0N/A if (childPolicy < CHILD_POLICY_EMPTY ||
0N/A childPolicy > CHILD_POLICY_MAX ||
0N/A childPolicy == CHILD_POLICY_REPEAT) {
0N/A throw new IllegalArgumentException("Invalid value for childPolicy!");
0N/A }
0N/A
0N/A this.rootName = rootName;
0N/A
0N/A Element root = new Element();
0N/A root.elementName = rootName;
0N/A root.childPolicy = childPolicy;
0N/A
0N/A elementMap.put(rootName, root);
0N/A }
0N/A
0N/A /**
0N/A * Constructs a blank <code>IIOMetadataFormatImpl</code> instance,
0N/A * with a given root element name and a child policy of
0N/A * <code>CHILD_POLICY_REPEAT</code>. Additional elements, and
0N/A * their attributes and <code>Object</code> reference information
0N/A * may be added using the various <code>add</code> methods.
0N/A *
0N/A * @param rootName the name of the root element.
0N/A * @param minChildren the minimum number of children of the node.
0N/A * @param maxChildren the maximum number of children of the node.
0N/A *
0N/A * @exception IllegalArgumentException if <code>rootName</code> is
0N/A * <code>null</code>.
0N/A * @exception IllegalArgumentException if <code>minChildren</code>
0N/A * is negative or larger than <code>maxChildren</code>.
0N/A */
0N/A public IIOMetadataFormatImpl(String rootName,
0N/A int minChildren,
0N/A int maxChildren) {
0N/A if (rootName == null) {
0N/A throw new IllegalArgumentException("rootName == null!");
0N/A }
0N/A if (minChildren < 0) {
0N/A throw new IllegalArgumentException("minChildren < 0!");
0N/A }
0N/A if (minChildren > maxChildren) {
0N/A throw new IllegalArgumentException("minChildren > maxChildren!");
0N/A }
0N/A
0N/A Element root = new Element();
0N/A root.elementName = rootName;
0N/A root.childPolicy = CHILD_POLICY_REPEAT;
0N/A root.minChildren = minChildren;
0N/A root.maxChildren = maxChildren;
0N/A
0N/A this.rootName = rootName;
0N/A elementMap.put(rootName, root);
0N/A }
0N/A
0N/A /**
0N/A * Sets a new base name for locating <code>ResourceBundle</code>s
0N/A * containing descriptions of elements and attributes for this
0N/A * format.
0N/A *
0N/A * <p> Prior to the first time this method is called, the base
0N/A * name will be equal to <code>this.getClass().getName() +
0N/A * "Resources"</code>.
0N/A *
0N/A * @param resourceBaseName a <code>String</code> containg the new
0N/A * base name.
0N/A *
0N/A * @exception IllegalArgumentException if
0N/A * <code>resourceBaseName</code> is <code>null</code>.
0N/A *
0N/A * @see #getResourceBaseName
0N/A */
0N/A protected void setResourceBaseName(String resourceBaseName) {
0N/A if (resourceBaseName == null) {
0N/A throw new IllegalArgumentException("resourceBaseName == null!");
0N/A }
0N/A this.resourceBaseName = resourceBaseName;
0N/A }
0N/A
0N/A /**
0N/A * Returns the currently set base name for locating
0N/A * <code>ResourceBundle</code>s.
0N/A *
0N/A * @return a <code>String</code> containing the base name.
0N/A *
0N/A * @see #setResourceBaseName
0N/A */
0N/A protected String getResourceBaseName() {
0N/A return resourceBaseName;
0N/A }
0N/A
0N/A /**
0N/A * Utility method for locating an element.
0N/A *
0N/A * @param mustAppear if <code>true</code>, throw an
0N/A * <code>IllegalArgumentException</code> if no such node exists;
0N/A * if <code>false</code>, just return null.
0N/A */
0N/A private Element getElement(String elementName, boolean mustAppear) {
0N/A if (mustAppear && (elementName == null)) {
0N/A throw new IllegalArgumentException("element name is null!");
0N/A }
0N/A Element element = (Element)elementMap.get(elementName);
0N/A if (mustAppear && (element == null)) {
0N/A throw new IllegalArgumentException("No such element: " +
0N/A elementName);
0N/A }
0N/A return element;
0N/A }
0N/A
0N/A private Element getElement(String elementName) {
0N/A return getElement(elementName, true);
0N/A }
0N/A
0N/A // Utility method for locating an attribute
0N/A private Attribute getAttribute(String elementName, String attrName) {
0N/A Element element = getElement(elementName);
0N/A Attribute attr = (Attribute)element.attrMap.get(attrName);
0N/A if (attr == null) {
0N/A throw new IllegalArgumentException("No such attribute \"" +
0N/A attrName + "\"!");
0N/A }
0N/A return attr;
0N/A }
0N/A
0N/A // Setup
0N/A
0N/A /**
0N/A * Adds a new element type to this metadata document format with a
0N/A * child policy other than <code>CHILD_POLICY_REPEAT</code>.
0N/A *
0N/A * @param elementName the name of the new element.
0N/A * @param parentName the name of the element that will be the
0N/A * parent of the new element.
0N/A * @param childPolicy one of the <code>CHILD_POLICY_*</code>
0N/A * constants, other than <code>CHILD_POLICY_REPEAT</code>,
0N/A * indicating the child policy of the new element.
0N/A *
0N/A * @exception IllegalArgumentException if <code>parentName</code>
0N/A * is <code>null</code>, or is not a legal element name for this
0N/A * format.
0N/A * @exception IllegalArgumentException if <code>childPolicy</code>
0N/A * is not one of the predefined constants.
0N/A */
0N/A protected void addElement(String elementName,
0N/A String parentName,
0N/A int childPolicy) {
0N/A Element parent = getElement(parentName);
0N/A if (childPolicy < CHILD_POLICY_EMPTY ||
0N/A childPolicy > CHILD_POLICY_MAX ||
0N/A childPolicy == CHILD_POLICY_REPEAT) {
0N/A throw new IllegalArgumentException
0N/A ("Invalid value for childPolicy!");
0N/A }
0N/A
0N/A Element element = new Element();
0N/A element.elementName = elementName;
0N/A element.childPolicy = childPolicy;
0N/A
0N/A parent.childList.add(elementName);
0N/A element.parentList.add(parentName);
0N/A
0N/A elementMap.put(elementName, element);
0N/A }
0N/A
0N/A /**
0N/A * Adds a new element type to this metadata document format with a
0N/A * child policy of <code>CHILD_POLICY_REPEAT</code>.
0N/A *
0N/A * @param elementName the name of the new element.
0N/A * @param parentName the name of the element that will be the
0N/A * parent of the new element.
0N/A * @param minChildren the minimum number of children of the node.
0N/A * @param maxChildren the maximum number of children of the node.
0N/A *
0N/A * @exception IllegalArgumentException if <code>parentName</code>
0N/A * is <code>null</code>, or is not a legal element name for this
0N/A * format.
0N/A * @exception IllegalArgumentException if <code>minChildren</code>
0N/A * is negative or larger than <code>maxChildren</code>.
0N/A */
0N/A protected void addElement(String elementName,
0N/A String parentName,
0N/A int minChildren,
0N/A int maxChildren) {
0N/A Element parent = getElement(parentName);
0N/A if (minChildren < 0) {
0N/A throw new IllegalArgumentException("minChildren < 0!");
0N/A }
0N/A if (minChildren > maxChildren) {
0N/A throw new IllegalArgumentException("minChildren > maxChildren!");
0N/A }
0N/A
0N/A Element element = new Element();
0N/A element.elementName = elementName;
0N/A element.childPolicy = CHILD_POLICY_REPEAT;
0N/A element.minChildren = minChildren;
0N/A element.maxChildren = maxChildren;
0N/A
0N/A parent.childList.add(elementName);
0N/A element.parentList.add(parentName);
0N/A
0N/A elementMap.put(elementName, element);
0N/A }
0N/A
0N/A /**
0N/A * Adds an existing element to the list of legal children for a
0N/A * given parent node type.
0N/A *
0N/A * @param parentName the name of the element that will be the
0N/A * new parent of the element.
0N/A * @param elementName the name of the element to be addded as a
0N/A * child.
0N/A *
0N/A * @exception IllegalArgumentException if <code>elementName</code>
0N/A * is <code>null</code>, or is not a legal element name for this
0N/A * format.
0N/A * @exception IllegalArgumentException if <code>parentName</code>
0N/A * is <code>null</code>, or is not a legal element name for this
0N/A * format.
0N/A */
0N/A protected void addChildElement(String elementName, String parentName) {
0N/A Element parent = getElement(parentName);
0N/A Element element = getElement(elementName);
0N/A parent.childList.add(elementName);
0N/A element.parentList.add(parentName);
0N/A }
0N/A
0N/A /**
0N/A * Removes an element from the format. If no element with the
0N/A * given name was present, nothing happens and no exception is
0N/A * thrown.
0N/A *
0N/A * @param elementName the name of the element to be removed.
0N/A */
0N/A protected void removeElement(String elementName) {
0N/A Element element = getElement(elementName, false);
0N/A if (element != null) {
0N/A Iterator iter = element.parentList.iterator();
0N/A while (iter.hasNext()) {
0N/A String parentName = (String)iter.next();
0N/A Element parent = getElement(parentName, false);
0N/A if (parent != null) {
0N/A parent.childList.remove(elementName);
0N/A }
0N/A }
0N/A elementMap.remove(elementName);
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Adds a new attribute to a previously defined element that may
0N/A * be set to an arbitrary value.
0N/A *
0N/A * @param elementName the name of the element.
0N/A * @param attrName the name of the attribute being added.
0N/A * @param dataType the data type (string format) of the attribute,
0N/A * one of the <code>DATATYPE_*</code> constants.
0N/A * @param required <code>true</code> if the attribute must be present.
0N/A * @param defaultValue the default value for the attribute, or
0N/A * <code>null</code>.
0N/A *
0N/A * @exception IllegalArgumentException if <code>elementName</code>
0N/A * is <code>null</code>, or is not a legal element name for this
0N/A * format.
0N/A * @exception IllegalArgumentException if <code>attrName</code> is
0N/A * <code>null</code>.
0N/A * @exception IllegalArgumentException if <code>dataType</code> is
0N/A * not one of the predefined constants.
0N/A */
0N/A protected void addAttribute(String elementName,
0N/A String attrName,
0N/A int dataType,
0N/A boolean required,
0N/A String defaultValue) {
0N/A Element element = getElement(elementName);
0N/A if (attrName == null) {
0N/A throw new IllegalArgumentException("attrName == null!");
0N/A }
0N/A if (dataType < DATATYPE_STRING || dataType > DATATYPE_DOUBLE) {
0N/A throw new IllegalArgumentException("Invalid value for dataType!");
0N/A }
0N/A
0N/A Attribute attr = new Attribute();
0N/A attr.attrName = attrName;
0N/A attr.valueType = VALUE_ARBITRARY;
0N/A attr.dataType = dataType;
0N/A attr.required = required;
0N/A attr.defaultValue = defaultValue;
0N/A
0N/A element.attrList.add(attrName);
0N/A element.attrMap.put(attrName, attr);
0N/A }
0N/A
0N/A /**
0N/A * Adds a new attribute to a previously defined element that will
0N/A * be defined by a set of enumerated values.
0N/A *
0N/A * @param elementName the name of the element.
0N/A * @param attrName the name of the attribute being added.
0N/A * @param dataType the data type (string format) of the attribute,
0N/A * one of the <code>DATATYPE_*</code> constants.
0N/A * @param required <code>true</code> if the attribute must be present.
0N/A * @param defaultValue the default value for the attribute, or
0N/A * <code>null</code>.
0N/A * @param enumeratedValues a <code>List</code> of
0N/A * <code>String</code>s containing the legal values for the
0N/A * attribute.
0N/A *
0N/A * @exception IllegalArgumentException if <code>elementName</code>
0N/A * is <code>null</code>, or is not a legal element name for this
0N/A * format.
0N/A * @exception IllegalArgumentException if <code>attrName</code> is
0N/A * <code>null</code>.
0N/A * @exception IllegalArgumentException if <code>dataType</code> is
0N/A * not one of the predefined constants.
0N/A * @exception IllegalArgumentException if
0N/A * <code>enumeratedValues</code> is <code>null</code>.
0N/A * @exception IllegalArgumentException if
0N/A * <code>enumeratedValues</code> does not contain at least one
0N/A * entry.
0N/A * @exception IllegalArgumentException if
0N/A * <code>enumeratedValues</code> contains an element that is not a
0N/A * <code>String</code> or is <code>null</code>.
0N/A */
0N/A protected void addAttribute(String elementName,
0N/A String attrName,
0N/A int dataType,
0N/A boolean required,
0N/A String defaultValue,
0N/A List<String> enumeratedValues) {
0N/A Element element = getElement(elementName);
0N/A if (attrName == null) {
0N/A throw new IllegalArgumentException("attrName == null!");
0N/A }
0N/A if (dataType < DATATYPE_STRING || dataType > DATATYPE_DOUBLE) {
0N/A throw new IllegalArgumentException("Invalid value for dataType!");
0N/A }
0N/A if (enumeratedValues == null) {
0N/A throw new IllegalArgumentException("enumeratedValues == null!");
0N/A }
0N/A if (enumeratedValues.size() == 0) {
0N/A throw new IllegalArgumentException("enumeratedValues is empty!");
0N/A }
0N/A Iterator iter = enumeratedValues.iterator();
0N/A while (iter.hasNext()) {
0N/A Object o = iter.next();
0N/A if (o == null) {
0N/A throw new IllegalArgumentException
0N/A ("enumeratedValues contains a null!");
0N/A }
0N/A if (!(o instanceof String)) {
0N/A throw new IllegalArgumentException
0N/A ("enumeratedValues contains a non-String value!");
0N/A }
0N/A }
0N/A
0N/A Attribute attr = new Attribute();
0N/A attr.attrName = attrName;
0N/A attr.valueType = VALUE_ENUMERATION;
0N/A attr.dataType = dataType;
0N/A attr.required = required;
0N/A attr.defaultValue = defaultValue;
0N/A attr.enumeratedValues = enumeratedValues;
0N/A
0N/A element.attrList.add(attrName);
0N/A element.attrMap.put(attrName, attr);
0N/A }
0N/A
0N/A /**
0N/A * Adds a new attribute to a previously defined element that will
0N/A * be defined by a range of values.
0N/A *
0N/A * @param elementName the name of the element.
0N/A * @param attrName the name of the attribute being added.
0N/A * @param dataType the data type (string format) of the attribute,
0N/A * one of the <code>DATATYPE_*</code> constants.
0N/A * @param required <code>true</code> if the attribute must be present.
0N/A * @param defaultValue the default value for the attribute, or
0N/A * <code>null</code>.
0N/A * @param minValue the smallest (inclusive or exclusive depending
0N/A * on the value of <code>minInclusive</code>) legal value for the
0N/A * attribute, as a <code>String</code>.
0N/A * @param maxValue the largest (inclusive or exclusive depending
0N/A * on the value of <code>minInclusive</code>) legal value for the
0N/A * attribute, as a <code>String</code>.
0N/A * @param minInclusive <code>true</code> if <code>minValue</code>
0N/A * is inclusive.
0N/A * @param maxInclusive <code>true</code> if <code>maxValue</code>
0N/A * is inclusive.
0N/A *
0N/A * @exception IllegalArgumentException if <code>elementName</code>
0N/A * is <code>null</code>, or is not a legal element name for this
0N/A * format.
0N/A * @exception IllegalArgumentException if <code>attrName</code> is
0N/A * <code>null</code>.
0N/A * @exception IllegalArgumentException if <code>dataType</code> is
0N/A * not one of the predefined constants.
0N/A */
0N/A protected void addAttribute(String elementName,
0N/A String attrName,
0N/A int dataType,
0N/A boolean required,
0N/A String defaultValue,
0N/A String minValue,
0N/A String maxValue,
0N/A boolean minInclusive,
0N/A boolean maxInclusive) {
0N/A Element element = getElement(elementName);
0N/A if (attrName == null) {
0N/A throw new IllegalArgumentException("attrName == null!");
0N/A }
0N/A if (dataType < DATATYPE_STRING || dataType > DATATYPE_DOUBLE) {
0N/A throw new IllegalArgumentException("Invalid value for dataType!");
0N/A }
0N/A
0N/A Attribute attr = new Attribute();
0N/A attr.attrName = attrName;
0N/A attr.valueType = VALUE_RANGE;
0N/A if (minInclusive) {
0N/A attr.valueType |= VALUE_RANGE_MIN_INCLUSIVE_MASK;
0N/A }
0N/A if (maxInclusive) {
0N/A attr.valueType |= VALUE_RANGE_MAX_INCLUSIVE_MASK;
0N/A }
0N/A attr.dataType = dataType;
0N/A attr.required = required;
0N/A attr.defaultValue = defaultValue;
0N/A attr.minValue = minValue;
0N/A attr.maxValue = maxValue;
0N/A
0N/A element.attrList.add(attrName);
0N/A element.attrMap.put(attrName, attr);
0N/A }
0N/A
0N/A /**
0N/A * Adds a new attribute to a previously defined element that will
0N/A * be defined by a list of values.
0N/A *
0N/A * @param elementName the name of the element.
0N/A * @param attrName the name of the attribute being added.
0N/A * @param dataType the data type (string format) of the attribute,
0N/A * one of the <code>DATATYPE_*</code> constants.
0N/A * @param required <code>true</code> if the attribute must be present.
0N/A * @param listMinLength the smallest legal number of list items.
0N/A * @param listMaxLength the largest legal number of list items.
0N/A *
0N/A * @exception IllegalArgumentException if <code>elementName</code>
0N/A * is <code>null</code>, or is not a legal element name for this
0N/A * format.
0N/A * @exception IllegalArgumentException if <code>attrName</code> is
0N/A * <code>null</code>.
0N/A * @exception IllegalArgumentException if <code>dataType</code> is
0N/A * not one of the predefined constants.
0N/A * @exception IllegalArgumentException if
0N/A * <code>listMinLength</code> is negative or larger than
0N/A * <code>listMaxLength</code>.
0N/A */
0N/A protected void addAttribute(String elementName,
0N/A String attrName,
0N/A int dataType,
0N/A boolean required,
0N/A int listMinLength,
0N/A int listMaxLength) {
0N/A Element element = getElement(elementName);
0N/A if (attrName == null) {
0N/A throw new IllegalArgumentException("attrName == null!");
0N/A }
0N/A if (dataType < DATATYPE_STRING || dataType > DATATYPE_DOUBLE) {
0N/A throw new IllegalArgumentException("Invalid value for dataType!");
0N/A }
0N/A if (listMinLength < 0 || listMinLength > listMaxLength) {
0N/A throw new IllegalArgumentException("Invalid list bounds!");
0N/A }
0N/A
0N/A Attribute attr = new Attribute();
0N/A attr.attrName = attrName;
0N/A attr.valueType = VALUE_LIST;
0N/A attr.dataType = dataType;
0N/A attr.required = required;
0N/A attr.listMinLength = listMinLength;
0N/A attr.listMaxLength = listMaxLength;
0N/A
0N/A element.attrList.add(attrName);
0N/A element.attrMap.put(attrName, attr);
0N/A }
0N/A
0N/A /**
0N/A * Adds a new attribute to a previously defined element that will
0N/A * be defined by the enumerated values <code>TRUE</code> and
0N/A * <code>FALSE</code>, with a datatype of
0N/A * <code>DATATYPE_BOOLEAN</code>.
0N/A *
0N/A * @param elementName the name of the element.
0N/A * @param attrName the name of the attribute being added.
0N/A * @param hasDefaultValue <code>true</code> if a default value
0N/A * should be present.
0N/A * @param defaultValue the default value for the attribute as a
0N/A * <code>boolean</code>, ignored if <code>hasDefaultValue</code>
0N/A * is <code>false</code>.
0N/A *
0N/A * @exception IllegalArgumentException if <code>elementName</code>
0N/A * is <code>null</code>, or is not a legal element name for this
0N/A * format.
0N/A * @exception IllegalArgumentException if <code>attrName</code> is
0N/A * <code>null</code>.
0N/A */
0N/A protected void addBooleanAttribute(String elementName,
0N/A String attrName,
0N/A boolean hasDefaultValue,
0N/A boolean defaultValue) {
0N/A List values = new ArrayList();
0N/A values.add("TRUE");
0N/A values.add("FALSE");
0N/A
0N/A String dval = null;
0N/A if (hasDefaultValue) {
0N/A dval = defaultValue ? "TRUE" : "FALSE";
0N/A }
0N/A addAttribute(elementName,
0N/A attrName,
0N/A DATATYPE_BOOLEAN,
0N/A true,
0N/A dval,
0N/A values);
0N/A }
0N/A
0N/A /**
0N/A * Removes an attribute from a previously defined element. If no
0N/A * attribute with the given name was present in the given element,
0N/A * nothing happens and no exception is thrown.
0N/A *
0N/A * @param elementName the name of the element.
0N/A * @param attrName the name of the attribute being removed.
0N/A *
0N/A * @exception IllegalArgumentException if <code>elementName</code>
0N/A * is <code>null</code>, or is not a legal element name for this format.
0N/A */
0N/A protected void removeAttribute(String elementName, String attrName) {
0N/A Element element = getElement(elementName);
0N/A element.attrList.remove(attrName);
0N/A element.attrMap.remove(attrName);
0N/A }
0N/A
0N/A /**
0N/A * Allows an <code>Object</code> reference of a given class type
0N/A * to be stored in nodes implementing the named element. The
0N/A * value of the <code>Object</code> is unconstrained other than by
0N/A * its class type.
0N/A *
0N/A * <p> If an <code>Object</code> reference was previously allowed,
0N/A * the previous settings are overwritten.
0N/A *
0N/A * @param elementName the name of the element.
0N/A * @param classType a <code>Class</code> variable indicating the
0N/A * legal class type for the object value.
0N/A * @param required <code>true</code> if an object value must be present.
0N/A * @param defaultValue the default value for the
0N/A * <code>Object</code> reference, or <code>null</code>.
0N/A *
0N/A * @exception IllegalArgumentException if <code>elementName</code>
0N/A * is <code>null</code>, or is not a legal element name for this format.
0N/A */
0N/A protected <T> void addObjectValue(String elementName,
0N/A Class<T> classType,
0N/A boolean required,
0N/A T defaultValue)
0N/A {
0N/A Element element = getElement(elementName);
0N/A ObjectValue obj = new ObjectValue();
0N/A obj.valueType = VALUE_ARBITRARY;
0N/A obj.classType = classType;
0N/A obj.defaultValue = defaultValue;
0N/A
0N/A element.objectValue = obj;
0N/A }
0N/A
0N/A /**
0N/A * Allows an <code>Object</code> reference of a given class type
0N/A * to be stored in nodes implementing the named element. The
0N/A * value of the <code>Object</code> must be one of the values
0N/A * given by <code>enumeratedValues</code>.
0N/A *
0N/A * <p> If an <code>Object</code> reference was previously allowed,
0N/A * the previous settings are overwritten.
0N/A *
0N/A * @param elementName the name of the element.
0N/A * @param classType a <code>Class</code> variable indicating the
0N/A * legal class type for the object value.
0N/A * @param required <code>true</code> if an object value must be present.
0N/A * @param defaultValue the default value for the
0N/A * <code>Object</code> reference, or <code>null</code>.
0N/A * @param enumeratedValues a <code>List</code> of
0N/A * <code>Object</code>s containing the legal values for the
0N/A * object reference.
0N/A *
0N/A * @exception IllegalArgumentException if <code>elementName</code>
0N/A * is <code>null</code>, or is not a legal element name for this format.
0N/A * @exception IllegalArgumentException if
0N/A * <code>enumeratedValues</code> is <code>null</code>.
0N/A * @exception IllegalArgumentException if
0N/A * <code>enumeratedValues</code> does not contain at least one
0N/A * entry.
0N/A * @exception IllegalArgumentException if
0N/A * <code>enumeratedValues</code> contains an element that is not
0N/A * an instance of the class type denoted by <code>classType</code>
0N/A * or is <code>null</code>.
0N/A */
0N/A protected <T> void addObjectValue(String elementName,
0N/A Class<T> classType,
0N/A boolean required,
0N/A T defaultValue,
0N/A List<? extends T> enumeratedValues)
0N/A {
0N/A Element element = getElement(elementName);
0N/A if (enumeratedValues == null) {
0N/A throw new IllegalArgumentException("enumeratedValues == null!");
0N/A }
0N/A if (enumeratedValues.size() == 0) {
0N/A throw new IllegalArgumentException("enumeratedValues is empty!");
0N/A }
0N/A Iterator iter = enumeratedValues.iterator();
0N/A while (iter.hasNext()) {
0N/A Object o = iter.next();
0N/A if (o == null) {
0N/A throw new IllegalArgumentException("enumeratedValues contains a null!");
0N/A }
0N/A if (!classType.isInstance(o)) {
0N/A throw new IllegalArgumentException("enumeratedValues contains a value not of class classType!");
0N/A }
0N/A }
0N/A
0N/A ObjectValue obj = new ObjectValue();
0N/A obj.valueType = VALUE_ENUMERATION;
0N/A obj.classType = classType;
0N/A obj.defaultValue = defaultValue;
0N/A obj.enumeratedValues = enumeratedValues;
0N/A
0N/A element.objectValue = obj;
0N/A }
0N/A
0N/A /**
0N/A * Allows an <code>Object</code> reference of a given class type
0N/A * to be stored in nodes implementing the named element. The
0N/A * value of the <code>Object</code> must be within the range given
0N/A * by <code>minValue</code> and <code>maxValue</code>.
0N/A * Furthermore, the class type must implement the
0N/A * <code>Comparable</code> interface.
0N/A *
0N/A * <p> If an <code>Object</code> reference was previously allowed,
0N/A * the previous settings are overwritten.
0N/A *
0N/A * @param elementName the name of the element.
0N/A * @param classType a <code>Class</code> variable indicating the
0N/A * legal class type for the object value.
0N/A * @param defaultValue the default value for the
0N/A * @param minValue the smallest (inclusive or exclusive depending
0N/A * on the value of <code>minInclusive</code>) legal value for the
0N/A * object value, as a <code>String</code>.
0N/A * @param maxValue the largest (inclusive or exclusive depending
0N/A * on the value of <code>minInclusive</code>) legal value for the
0N/A * object value, as a <code>String</code>.
0N/A * @param minInclusive <code>true</code> if <code>minValue</code>
0N/A * is inclusive.
0N/A * @param maxInclusive <code>true</code> if <code>maxValue</code>
0N/A * is inclusive.
0N/A *
0N/A * @exception IllegalArgumentException if <code>elementName</code>
0N/A * is <code>null</code>, or is not a legal element name for this
0N/A * format.
0N/A */
0N/A protected <T extends Object & Comparable<? super T>> void
0N/A addObjectValue(String elementName,
0N/A Class<T> classType,
0N/A T defaultValue,
0N/A Comparable<? super T> minValue,
0N/A Comparable<? super T> maxValue,
0N/A boolean minInclusive,
0N/A boolean maxInclusive)
0N/A {
0N/A Element element = getElement(elementName);
0N/A ObjectValue obj = new ObjectValue();
0N/A obj.valueType = VALUE_RANGE;
0N/A if (minInclusive) {
0N/A obj.valueType |= VALUE_RANGE_MIN_INCLUSIVE_MASK;
0N/A }
0N/A if (maxInclusive) {
0N/A obj.valueType |= VALUE_RANGE_MAX_INCLUSIVE_MASK;
0N/A }
0N/A obj.classType = classType;
0N/A obj.defaultValue = defaultValue;
0N/A obj.minValue = minValue;
0N/A obj.maxValue = maxValue;
0N/A
0N/A element.objectValue = obj;
0N/A }
0N/A
0N/A /**
0N/A * Allows an <code>Object</code> reference of a given class type
0N/A * to be stored in nodes implementing the named element. The
0N/A * value of the <code>Object</code> must an array of objects of
0N/A * class type given by <code>classType</code>, with at least
0N/A * <code>arrayMinLength</code> and at most
0N/A * <code>arrayMaxLength</code> elements.
0N/A *
0N/A * <p> If an <code>Object</code> reference was previously allowed,
0N/A * the previous settings are overwritten.
0N/A *
0N/A * @param elementName the name of the element.
0N/A * @param classType a <code>Class</code> variable indicating the
0N/A * legal class type for the object value.
0N/A * @param arrayMinLength the smallest legal length for the array.
0N/A * @param arrayMaxLength the largest legal length for the array.
0N/A *
0N/A * @exception IllegalArgumentException if <code>elementName</code> is
0N/A * not a legal element name for this format.
0N/A */
0N/A protected void addObjectValue(String elementName,
0N/A Class<?> classType,
0N/A int arrayMinLength,
0N/A int arrayMaxLength) {
0N/A Element element = getElement(elementName);
0N/A ObjectValue obj = new ObjectValue();
0N/A obj.valueType = VALUE_LIST;
0N/A obj.classType = classType;
0N/A obj.arrayMinLength = arrayMinLength;
0N/A obj.arrayMaxLength = arrayMaxLength;
0N/A
0N/A element.objectValue = obj;
0N/A }
0N/A
0N/A /**
0N/A * Disallows an <code>Object</code> reference from being stored in
0N/A * nodes implementing the named element.
0N/A *
0N/A * @param elementName the name of the element.
0N/A *
0N/A * @exception IllegalArgumentException if <code>elementName</code> is
0N/A * not a legal element name for this format.
0N/A */
0N/A protected void removeObjectValue(String elementName) {
0N/A Element element = getElement(elementName);
0N/A element.objectValue = null;
0N/A }
0N/A
0N/A // Utility method
0N/A
0N/A // Methods from IIOMetadataFormat
0N/A
0N/A // Root
0N/A
0N/A public String getRootName() {
0N/A return rootName;
0N/A }
0N/A
0N/A // Multiplicity
0N/A
0N/A public abstract boolean canNodeAppear(String elementName,
0N/A ImageTypeSpecifier imageType);
0N/A
0N/A public int getElementMinChildren(String elementName) {
0N/A Element element = getElement(elementName);
0N/A if (element.childPolicy != CHILD_POLICY_REPEAT) {
0N/A throw new IllegalArgumentException("Child policy not CHILD_POLICY_REPEAT!");
0N/A }
0N/A return element.minChildren;
0N/A }
0N/A
0N/A public int getElementMaxChildren(String elementName) {
0N/A Element element = getElement(elementName);
0N/A if (element.childPolicy != CHILD_POLICY_REPEAT) {
0N/A throw new IllegalArgumentException("Child policy not CHILD_POLICY_REPEAT!");
0N/A }
0N/A return element.maxChildren;
0N/A }
0N/A
0N/A private String getResource(String key, Locale locale) {
0N/A if (locale == null) {
0N/A locale = Locale.getDefault();
0N/A }
0N/A
0N/A /**
0N/A * If an applet supplies an implementation of IIOMetadataFormat and
0N/A * resource bundles, then the resource bundle will need to be
0N/A * accessed via the applet class loader. So first try the context
0N/A * class loader to locate the resource bundle.
0N/A * If that throws MissingResourceException, then try the
0N/A * system class loader.
0N/A */
0N/A ClassLoader loader = (ClassLoader)
0N/A java.security.AccessController.doPrivileged(
0N/A new java.security.PrivilegedAction() {
0N/A public Object run() {
0N/A return Thread.currentThread().getContextClassLoader();
0N/A }
0N/A });
0N/A
0N/A ResourceBundle bundle = null;
0N/A try {
0N/A bundle = ResourceBundle.getBundle(resourceBaseName,
0N/A locale, loader);
0N/A } catch (MissingResourceException mre) {
0N/A try {
0N/A bundle = ResourceBundle.getBundle(resourceBaseName, locale);
0N/A } catch (MissingResourceException mre1) {
0N/A return null;
0N/A }
0N/A }
0N/A
0N/A try {
0N/A return bundle.getString(key);
0N/A } catch (MissingResourceException e) {
0N/A return null;
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Returns a <code>String</code> containing a description of the
0N/A * named element, or <code>null</code>. The desciption will be
0N/A * localized for the supplied <code>Locale</code> if possible.
0N/A *
0N/A * <p> The default implementation will first locate a
0N/A * <code>ResourceBundle</code> using the current resource base
0N/A * name set by <code>setResourceBaseName</code> and the supplied
0N/A * <code>Locale</code>, using the fallback mechanism described in
0N/A * the comments for <code>ResourceBundle.getBundle</code>. If a
0N/A * <code>ResourceBundle</code> is found, the element name will be
0N/A * used as a key to its <code>getString</code> method, and the
0N/A * result returned. If no <code>ResourceBundle</code> is found,
0N/A * or no such key is present, <code>null</code> will be returned.
0N/A *
0N/A * <p> If <code>locale</code> is <code>null</code>, the current
0N/A * default <code>Locale</code> returned by <code>Locale.getLocale</code>
0N/A * will be used.
0N/A *
0N/A * @param elementName the name of the element.
0N/A * @param locale the <code>Locale</code> for which localization
0N/A * will be attempted.
0N/A *
0N/A * @return the element description.
0N/A *
0N/A * @exception IllegalArgumentException if <code>elementName</code>
0N/A * is <code>null</code>, or is not a legal element name for this format.
0N/A *
0N/A * @see #setResourceBaseName
0N/A */
0N/A public String getElementDescription(String elementName,
0N/A Locale locale) {
0N/A Element element = getElement(elementName);
0N/A return getResource(elementName, locale);
0N/A }
0N/A
0N/A // Children
0N/A
0N/A public int getChildPolicy(String elementName) {
0N/A Element element = getElement(elementName);
0N/A return element.childPolicy;
0N/A }
0N/A
0N/A public String[] getChildNames(String elementName) {
0N/A Element element = getElement(elementName);
0N/A if (element.childPolicy == CHILD_POLICY_EMPTY) {
0N/A return null;
0N/A }
0N/A return (String[])element.childList.toArray(new String[0]);
0N/A }
0N/A
0N/A // Attributes
0N/A
0N/A public String[] getAttributeNames(String elementName) {
0N/A Element element = getElement(elementName);
0N/A List names = element.attrList;
0N/A
0N/A String[] result = new String[names.size()];
0N/A return (String[])names.toArray(result);
0N/A }
0N/A
0N/A public int getAttributeValueType(String elementName, String attrName) {
0N/A Attribute attr = getAttribute(elementName, attrName);
0N/A return attr.valueType;
0N/A }
0N/A
0N/A public int getAttributeDataType(String elementName, String attrName) {
0N/A Attribute attr = getAttribute(elementName, attrName);
0N/A return attr.dataType;
0N/A }
0N/A
0N/A public boolean isAttributeRequired(String elementName, String attrName) {
0N/A Attribute attr = getAttribute(elementName, attrName);
0N/A return attr.required;
0N/A }
0N/A
0N/A public String getAttributeDefaultValue(String elementName,
0N/A String attrName) {
0N/A Attribute attr = getAttribute(elementName, attrName);
0N/A return attr.defaultValue;
0N/A }
0N/A
0N/A public String[] getAttributeEnumerations(String elementName,
0N/A String attrName) {
0N/A Attribute attr = getAttribute(elementName, attrName);
0N/A if (attr.valueType != VALUE_ENUMERATION) {
0N/A throw new IllegalArgumentException
0N/A ("Attribute not an enumeration!");
0N/A }
0N/A
0N/A List values = attr.enumeratedValues;
0N/A Iterator iter = values.iterator();
0N/A String[] result = new String[values.size()];
0N/A return (String[])values.toArray(result);
0N/A }
0N/A
0N/A public String getAttributeMinValue(String elementName, String attrName) {
0N/A Attribute attr = getAttribute(elementName, attrName);
0N/A if (attr.valueType != VALUE_RANGE &&
0N/A attr.valueType != VALUE_RANGE_MIN_INCLUSIVE &&
0N/A attr.valueType != VALUE_RANGE_MAX_INCLUSIVE &&
0N/A attr.valueType != VALUE_RANGE_MIN_MAX_INCLUSIVE) {
0N/A throw new IllegalArgumentException("Attribute not a range!");
0N/A }
0N/A
0N/A return attr.minValue;
0N/A }
0N/A
0N/A public String getAttributeMaxValue(String elementName, String attrName) {
0N/A Attribute attr = getAttribute(elementName, attrName);
0N/A if (attr.valueType != VALUE_RANGE &&
0N/A attr.valueType != VALUE_RANGE_MIN_INCLUSIVE &&
0N/A attr.valueType != VALUE_RANGE_MAX_INCLUSIVE &&
0N/A attr.valueType != VALUE_RANGE_MIN_MAX_INCLUSIVE) {
0N/A throw new IllegalArgumentException("Attribute not a range!");
0N/A }
0N/A
0N/A return attr.maxValue;
0N/A }
0N/A
0N/A public int getAttributeListMinLength(String elementName, String attrName) {
0N/A Attribute attr = getAttribute(elementName, attrName);
0N/A if (attr.valueType != VALUE_LIST) {
0N/A throw new IllegalArgumentException("Attribute not a list!");
0N/A }
0N/A
0N/A return attr.listMinLength;
0N/A }
0N/A
0N/A public int getAttributeListMaxLength(String elementName, String attrName) {
0N/A Attribute attr = getAttribute(elementName, attrName);
0N/A if (attr.valueType != VALUE_LIST) {
0N/A throw new IllegalArgumentException("Attribute not a list!");
0N/A }
0N/A
0N/A return attr.listMaxLength;
0N/A }
0N/A
0N/A /**
0N/A * Returns a <code>String</code> containing a description of the
0N/A * named attribute, or <code>null</code>. The desciption will be
0N/A * localized for the supplied <code>Locale</code> if possible.
0N/A *
0N/A * <p> The default implementation will first locate a
0N/A * <code>ResourceBundle</code> using the current resource base
0N/A * name set by <code>setResourceBaseName</code> and the supplied
0N/A * <code>Locale</code>, using the fallback mechanism described in
0N/A * the comments for <code>ResourceBundle.getBundle</code>. If a
0N/A * <code>ResourceBundle</code> is found, the element name followed
0N/A * by a "/" character followed by the attribute name
0N/A * (<code>elementName + "/" + attrName</code>) will be used as a
0N/A * key to its <code>getString</code> method, and the result
0N/A * returned. If no <code>ResourceBundle</code> is found, or no
0N/A * such key is present, <code>null</code> will be returned.
0N/A *
0N/A * <p> If <code>locale</code> is <code>null</code>, the current
0N/A * default <code>Locale</code> returned by <code>Locale.getLocale</code>
0N/A * will be used.
0N/A *
0N/A * @param elementName the name of the element.
0N/A * @param attrName the name of the attribute.
0N/A * @param locale the <code>Locale</code> for which localization
0N/A * will be attempted, or <code>null</code>.
0N/A *
0N/A * @return the attribute description.
0N/A *
0N/A * @exception IllegalArgumentException if <code>elementName</code>
0N/A * is <code>null</code>, or is not a legal element name for this format.
0N/A * @exception IllegalArgumentException if <code>attrName</code> is
0N/A * <code>null</code> or is not a legal attribute name for this
0N/A * element.
0N/A *
0N/A * @see #setResourceBaseName
0N/A */
0N/A public String getAttributeDescription(String elementName,
0N/A String attrName,
0N/A Locale locale) {
0N/A Element element = getElement(elementName);
0N/A if (attrName == null) {
0N/A throw new IllegalArgumentException("attrName == null!");
0N/A }
0N/A Attribute attr = (Attribute)element.attrMap.get(attrName);
0N/A if (attr == null) {
0N/A throw new IllegalArgumentException("No such attribute!");
0N/A }
0N/A
0N/A String key = elementName + "/" + attrName;
0N/A return getResource(key, locale);
0N/A }
0N/A
0N/A private ObjectValue getObjectValue(String elementName) {
0N/A Element element = getElement(elementName);
0N/A ObjectValue objv = (ObjectValue)element.objectValue;
0N/A if (objv == null) {
0N/A throw new IllegalArgumentException("No object within element " +
0N/A elementName + "!");
0N/A }
0N/A return objv;
0N/A }
0N/A
0N/A public int getObjectValueType(String elementName) {
0N/A Element element = getElement(elementName);
0N/A ObjectValue objv = (ObjectValue)element.objectValue;
0N/A if (objv == null) {
0N/A return VALUE_NONE;
0N/A }
0N/A return objv.valueType;
0N/A }
0N/A
0N/A public Class<?> getObjectClass(String elementName) {
0N/A ObjectValue objv = getObjectValue(elementName);
0N/A return objv.classType;
0N/A }
0N/A
0N/A public Object getObjectDefaultValue(String elementName) {
0N/A ObjectValue objv = getObjectValue(elementName);
0N/A return objv.defaultValue;
0N/A }
0N/A
0N/A public Object[] getObjectEnumerations(String elementName) {
0N/A ObjectValue objv = getObjectValue(elementName);
0N/A if (objv.valueType != VALUE_ENUMERATION) {
0N/A throw new IllegalArgumentException("Not an enumeration!");
0N/A }
0N/A List vlist = objv.enumeratedValues;
0N/A Object[] values = new Object[vlist.size()];
0N/A return vlist.toArray(values);
0N/A }
0N/A
0N/A public Comparable<?> getObjectMinValue(String elementName) {
0N/A ObjectValue objv = getObjectValue(elementName);
0N/A if ((objv.valueType & VALUE_RANGE) != VALUE_RANGE) {
0N/A throw new IllegalArgumentException("Not a range!");
0N/A }
0N/A return objv.minValue;
0N/A }
0N/A
0N/A public Comparable<?> getObjectMaxValue(String elementName) {
0N/A ObjectValue objv = getObjectValue(elementName);
0N/A if ((objv.valueType & VALUE_RANGE) != VALUE_RANGE) {
0N/A throw new IllegalArgumentException("Not a range!");
0N/A }
0N/A return objv.maxValue;
0N/A }
0N/A
0N/A public int getObjectArrayMinLength(String elementName) {
0N/A ObjectValue objv = getObjectValue(elementName);
0N/A if (objv.valueType != VALUE_LIST) {
0N/A throw new IllegalArgumentException("Not a list!");
0N/A }
0N/A return objv.arrayMinLength;
0N/A }
0N/A
0N/A public int getObjectArrayMaxLength(String elementName) {
0N/A ObjectValue objv = getObjectValue(elementName);
0N/A if (objv.valueType != VALUE_LIST) {
0N/A throw new IllegalArgumentException("Not a list!");
0N/A }
0N/A return objv.arrayMaxLength;
0N/A }
0N/A
0N/A // Standard format descriptor
0N/A
0N/A private synchronized static void createStandardFormat() {
0N/A if (standardFormat == null) {
0N/A standardFormat = new StandardMetadataFormat();
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Returns an <code>IIOMetadataFormat</code> object describing the
0N/A * standard, plug-in neutral <code>javax.imageio_1.0</code>
0N/A * metadata document format described in the comment of the
0N/A * <code>javax.imageio.metadata</code> package.
0N/A *
0N/A * @return a predefined <code>IIOMetadataFormat</code> instance.
0N/A */
0N/A public static IIOMetadataFormat getStandardFormatInstance() {
0N/A createStandardFormat();
0N/A return standardFormat;
0N/A }
0N/A}