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 * 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 * 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 * 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. 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 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 * <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 * <p> The subclass may supply a different base name for the resource 0N/A * bundles using the <code>setResourceBaseName</code> method. 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 * @see ResourceBundle#getBundle(String,Locale) 0N/A * A <code>String</code> constant containing the standard format 0N/A * name, <code>"javax_imageio_1.0"</code>. 0N/A "javax_imageio_1.0";
0N/A // Element name (String) -> Element 0N/A // Child names (Strings) 0N/A // Parent names (Strings) 0N/A // List of attribute names in the order they were added 0N/A // Attr name (String) -> Attribute 0N/A // Meaningful only if valueType == VALUE_ENUMERATION 0N/A // Meaningful only if valueType == VALUE_RANGE 0N/A // Meaningful only if valueType == VALUE_LIST 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 * @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 * @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 * 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 * @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 * @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 * Sets a new base name for locating <code>ResourceBundle</code>s 0N/A * containing descriptions of elements and attributes for this 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 * @param resourceBaseName a <code>String</code> containg the new 0N/A * @exception IllegalArgumentException if 0N/A * <code>resourceBaseName</code> is <code>null</code>. 0N/A * @see #getResourceBaseName 0N/A * Returns the currently set base name for locating 0N/A * <code>ResourceBundle</code>s. 0N/A * @return a <code>String</code> containing the base name. 0N/A * @see #setResourceBaseName 0N/A * Utility method for locating an element. 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 // Utility method for locating an attribute 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 * @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 * @exception IllegalArgumentException if <code>parentName</code> 0N/A * is <code>null</code>, or is not a legal element name for this 0N/A * @exception IllegalArgumentException if <code>childPolicy</code> 0N/A * is not one of the predefined constants. 0N/A (
"Invalid value for childPolicy!");
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 * @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 * @exception IllegalArgumentException if <code>parentName</code> 0N/A * is <code>null</code>, or is not a legal element name for this 0N/A * @exception IllegalArgumentException if <code>minChildren</code> 0N/A * is negative or larger than <code>maxChildren</code>. 0N/A * Adds an existing element to the list of legal children for a 0N/A * given parent node type. 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 * @exception IllegalArgumentException if <code>elementName</code> 0N/A * is <code>null</code>, or is not a legal element name for this 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 * 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 * @param elementName the name of the element to be removed. 0N/A * Adds a new attribute to a previously defined element that may 0N/A * be set to an arbitrary value. 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 * @exception IllegalArgumentException if <code>elementName</code> 0N/A * is <code>null</code>, or is not a legal element name for this 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 * Adds a new attribute to a previously defined element that will 0N/A * be defined by a set of enumerated values. 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 * @exception IllegalArgumentException if <code>elementName</code> 0N/A * is <code>null</code>, or is not a legal element name for this 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 * @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 (
"enumeratedValues contains a null!");
0N/A (
"enumeratedValues contains a non-String value!");
0N/A * Adds a new attribute to a previously defined element that will 0N/A * be defined by a range of values. 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 * @param maxInclusive <code>true</code> if <code>maxValue</code> 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 * @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 * Adds a new attribute to a previously defined element that will 0N/A * be defined by a list of values. 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 * @exception IllegalArgumentException if <code>elementName</code> 0N/A * is <code>null</code>, or is not a legal element name for this 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 * 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 * @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 * @exception IllegalArgumentException if <code>elementName</code> 0N/A * is <code>null</code>, or is not a legal element name for this 0N/A * @exception IllegalArgumentException if <code>attrName</code> is 0N/A * <code>null</code>. 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 * @param elementName the name of the element. 0N/A * @param attrName the name of the attribute being removed. 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 * 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 * <p> If an <code>Object</code> reference was previously allowed, 0N/A * the previous settings are overwritten. 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 * @exception IllegalArgumentException if <code>elementName</code> 0N/A * is <code>null</code>, or is not a legal element name for this format. 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 * <p> If an <code>Object</code> reference was previously allowed, 0N/A * the previous settings are overwritten. 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 * @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 * @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 * 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 * <p> If an <code>Object</code> reference was previously allowed, 0N/A * the previous settings are overwritten. 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 * @param maxInclusive <code>true</code> if <code>maxValue</code> 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 * 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 * <p> If an <code>Object</code> reference was previously allowed, 0N/A * the previous settings are overwritten. 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 * @exception IllegalArgumentException if <code>elementName</code> is 0N/A * not a legal element name for this format. 0N/A * Disallows an <code>Object</code> reference from being stored in 0N/A * nodes implementing the named element. 0N/A * @param elementName the name of the element. 0N/A * @exception IllegalArgumentException if <code>elementName</code> is 0N/A * not a legal element name for this format. 0N/A // Methods from IIOMetadataFormat 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 * 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 * <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 * <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 * @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 * @return the element description. 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 * @see #setResourceBaseName 0N/A (
"Attribute not an enumeration!");
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 * <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 * <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 * @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 * @return the attribute description. 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 * @see #setResourceBaseName 0N/A // Standard format descriptor 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 * @return a predefined <code>IIOMetadataFormat</code> instance.