⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iiometadataformatimpl.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* IIOMetadataFormatImpl.java --   Copyright (C) 2004  Free Software Foundation, Inc.This file is part of GNU Classpath.GNU Classpath is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Classpath is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Classpath; see the file COPYING.  If not, write to theFree Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA02110-1301 USA.Linking this library statically or dynamically with other modules ismaking a combined work based on this library.  Thus, the terms andconditions of the GNU General Public License cover the wholecombination.As a special exception, the copyright holders of this library give youpermission to link this library with independent modules to produce anexecutable, regardless of the license terms of these independentmodules, and to copy and distribute the resulting executable underterms of your choice, provided that you also meet, for each linkedindependent module, the terms and conditions of the license of thatmodule.  An independent module is a module which is not derived fromor based on this library.  If you modify this library, you may extendthis exception to your version of the library, but you are notobligated to do so.  If you do not wish to do so, delete thisexception statement from your version. */package javax.imageio.metadata;import org.w3c.dom.Attr;import org.w3c.dom.DOMException;import org.w3c.dom.Document;import org.w3c.dom.Element;import org.w3c.dom.NamedNodeMap;import org.w3c.dom.Node;import org.w3c.dom.NodeList;import org.w3c.dom.TypeInfo;import org.w3c.dom.UserDataHandler;import java.util.ArrayList;import java.util.HashMap;import java.util.Map;import java.util.Iterator;import java.util.List;import java.util.Locale;import java.util.ResourceBundle;import java.util.MissingResourceException;import javax.imageio.ImageTypeSpecifier;public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat{  /**   * The standard metadata format name constant set to   * "javax_imageio_1.0".   */  public static final String standardMetadataFormatName = "javax_imageio_1.0";  private String rootName;  // These maps assume that each element name is unique.  private Map nodes = new HashMap();  // A mapping from element name to child policy.  private Map childPolicies = new HashMap();  // A mapping from element name to the permissible number of  // children.  Values in this map are length-two integer arrays; the  // first index is the minimum bound, the second index is the maximum  // bound.  private Map childRanges = new HashMap();  private String resourceBaseName;  // Package-private so that it may be used in IIOMetadataNode.  static class IIOMetadataNodeAttr extends IIOMetadataNode    implements Attr  {    protected Element owner;    protected String name;    protected int dataType;    protected boolean required;    protected String defaultValue;    public IIOMetadataNodeAttr (Element owner,				String name,				String defaultValue)    {      this (owner, name, IIOMetadataFormat.DATATYPE_STRING,            true, defaultValue);    }    public IIOMetadataNodeAttr (Element owner,				String name,				int dataType,				boolean required,				String defaultValue)    {      this.owner = owner;      this.name = name;      this.dataType = dataType;      this.required = required;      this.defaultValue = defaultValue;    }    public String getName ()    {      return name;    }    public Element getOwnerElement ()    {      return owner;    }    public int getDataType ()    {      return dataType;    }    public TypeInfo getSchemaTypeInfo ()    {      return null;    }    public boolean getSpecified ()    {      return false;    }    public String getValue ()    {      return defaultValue;    }    public boolean isId()    {      return false;    }    public void setValue (String value)    {    }    // new methods    public boolean isRequired ()    {      return required;    }  }  private class IIOMetadataNodeAttrEnumerated extends IIOMetadataNodeAttr  {    protected List enumeratedValues;    public IIOMetadataNodeAttrEnumerated (Element owner,					  String name,					  int dataType,					  boolean required,					  String defaultValue,					  List enumeratedValues)    {      super (owner, name, dataType, required, defaultValue);      this.enumeratedValues = new ArrayList (enumeratedValues);    }    public Object[] getEnumerations ()    {      return enumeratedValues.toArray ();    }  }  private class IIOMetadataNodeAttrBounded extends IIOMetadataNodeAttr  {    protected String minValue;    protected String maxValue;    protected boolean minInclusive;    protected boolean maxInclusive;    public IIOMetadataNodeAttrBounded (Element owner,				       String name,				       int dataType,				       boolean required,				       String defaultValue,				       String minValue,				       String maxValue,				       boolean minInclusive,				       boolean maxInclusive)    {      super (owner, name, dataType, required, defaultValue);      this.minValue = minValue;      this.maxValue = maxValue;      this.minInclusive = minInclusive;      this.maxInclusive = maxInclusive;    }    public String getMinValue ()    {      return minValue;    }    public String getMaxValue ()    {      return maxValue;    }  }  private class IIOMetadataNodeAttrList extends IIOMetadataNodeAttr  {    protected int listMinLength;    protected int listMaxLength;    public IIOMetadataNodeAttrList (Element owner,				    String name,				    int dataType,				    boolean required,				    int listMinLength,				    int listMaxLength)    {      super (owner, name, dataType, required, null);      this.listMinLength = listMinLength;      this.listMaxLength = listMaxLength;    }    public int getListMinLength ()    {      return listMinLength;    }    public int getListMaxLength ()    {      return listMaxLength;    }  }  private class NodeObject  {    protected Element owner;    protected Class classType;    protected boolean required;    protected Object defaultValue;    protected int valueType;    public NodeObject (Element owner,                       Class classType,                       boolean required,                       Object defaultValue)    {      this.owner = owner;      this.classType = classType;      this.required = required;      this.defaultValue = defaultValue;      valueType = IIOMetadataFormat.VALUE_ARBITRARY;    }    public int getValueType ()    {      return valueType;    }    public Class getClassType ()    {      return classType;    }    public Element getOwnerElement ()    {      return owner;    }    public Object getDefaultValue ()    {      return defaultValue;    }    public boolean isRequired ()    {      return required;    }  }  private class NodeObjectEnumerated extends NodeObject  {    protected List enumeratedValues;    public NodeObjectEnumerated (Element owner,                                 Class classType,                                 boolean required,                                 Object defaultValue,                                 List enumeratedValues)    {      super (owner, classType, false, defaultValue);      this.enumeratedValues = enumeratedValues;      valueType = IIOMetadataFormat.VALUE_ENUMERATION;    }    public Object[] getEnumerations ()    {      return enumeratedValues.toArray();    }  }  private class NodeObjectBounded extends NodeObject  {    protected Comparable minValue;    protected Comparable maxValue;    protected boolean minInclusive;    protected boolean maxInclusive;    public NodeObjectBounded (Element owner,                              Class classType,                              Object defaultValue,                              Comparable minValue,                              Comparable maxValue,                              boolean minInclusive,                              boolean maxInclusive)    {      super (owner, classType, false, defaultValue);      this.minValue = minValue;      this.maxValue = maxValue;      this.minInclusive = minInclusive;      this.maxInclusive = maxInclusive;      if (minInclusive)        {          if (maxInclusive)            valueType = IIOMetadataFormat.VALUE_RANGE_MIN_MAX_INCLUSIVE;          else            valueType = IIOMetadataFormat.VALUE_RANGE_MIN_INCLUSIVE;        }      else        {          if (maxInclusive)            valueType = IIOMetadataFormat.VALUE_RANGE_MAX_INCLUSIVE;          else            valueType = IIOMetadataFormat.VALUE_RANGE;        }    }    public Comparable getMinValue ()    {      return minValue;    }    public Comparable getMaxValue ()    {      return maxValue;    }  }  private class NodeObjectArray extends NodeObject  {    protected Integer arrayMinLength;    protected Integer arrayMaxLength;    public NodeObjectArray (Element owner,                            Class classType,                            int arrayMinLength,                            int arrayMaxLength)    {      super (owner, classType, false, null);      this.arrayMinLength = new Integer (arrayMinLength);      this.arrayMaxLength = new Integer (arrayMaxLength);      valueType = IIOMetadataFormat.VALUE_LIST;    }    public Comparable getArrayMinLength ()    {      return arrayMinLength;    }    public Comparable getArrayMaxLength ()    {      return arrayMaxLength;    }  }  /**   * Construct a blank IIOMetadataFormatImpl with the given root name   * and child policy.   *   * @param rootName the root element name   * @param childPolicy the child policy of the root element   *   * @exception IllegalArgumentException if rootName is null   * @exception IllegalArgumentException if childPolicy is   * CHILD_POLICY_REPEAT or if childPolicy is not a CHILD_POLICY   * constant   */  public IIOMetadataFormatImpl (String rootName, int childPolicy)  {    if (rootName == null)      throw new IllegalArgumentException ("null argument");    if (childPolicy < IIOMetadataFormat.CHILD_POLICY_ALL	|| childPolicy > IIOMetadataFormat.CHILD_POLICY_SOME	|| childPolicy == IIOMetadataFormat.CHILD_POLICY_REPEAT)      throw new IllegalArgumentException ("wrong child policy");    nodes.put (rootName, new IIOMetadataNode (rootName));    childPolicies.put (rootName, new Integer (childPolicy));    this.rootName = rootName;  }  /**   * Construct a blank IIOMetadataFormatImpl with the given root name,   * a child policy of CHILD_POLICY_REPEAT and the given minimum and   * maximum limits on the number of root element children.   *   * @param rootName the root element name   * @param minChildren the minimum number of children that this node   * can have   * @param maxChildren the maximum number of children that this node   * can have   *   * @exception IllegalArgumentException if rootName is null   * @exception IllegalArgumentException if minChildren is less than   * zero or greater than maxChildren   */  public IIOMetadataFormatImpl (String rootName,				int minChildren,				int maxChildren)  {    if (rootName == null)      throw new IllegalArgumentException ("null argument");    if (minChildren < 0 || maxChildren < minChildren)      throw new IllegalArgumentException ("invalid min or max children argument");    nodes.put (rootName, new IIOMetadataNode (rootName));    childPolicies.put (rootName, new Integer (IIOMetadataFormat.CHILD_POLICY_REPEAT));    childRanges.put (rootName, new int [] { minChildren, maxChildren });    this.rootName = rootName;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -