src/share/classes/javax/imageio/metadata/IIOMetadataFormatImpl.java

Print this page


   1 /*
   2  * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


1164      * @see #setResourceBaseName
1165      */
1166     public String getAttributeDescription(String elementName,
1167                                           String attrName,
1168                                           Locale locale) {
1169         Element element = getElement(elementName);
1170         if (attrName == null) {
1171             throw new IllegalArgumentException("attrName == null!");
1172         }
1173         Attribute attr = (Attribute)element.attrMap.get(attrName);
1174         if (attr == null) {
1175             throw new IllegalArgumentException("No such attribute!");
1176         }
1177 
1178         String key = elementName + "/" + attrName;
1179         return getResource(key, locale);
1180     }
1181 
1182     private ObjectValue getObjectValue(String elementName) {
1183         Element element = getElement(elementName);
1184         ObjectValue objv = (ObjectValue)element.objectValue;
1185         if (objv == null) {
1186             throw new IllegalArgumentException("No object within element " +
1187                                                elementName + "!");
1188         }
1189         return objv;
1190     }
1191 
1192     public int getObjectValueType(String elementName) {
1193         Element element = getElement(elementName);
1194         ObjectValue objv = (ObjectValue)element.objectValue;
1195         if (objv == null) {
1196             return VALUE_NONE;
1197         }
1198         return objv.valueType;
1199     }
1200 
1201     public Class<?> getObjectClass(String elementName) {
1202         ObjectValue objv = getObjectValue(elementName);
1203         return objv.classType;
1204     }
1205 
1206     public Object getObjectDefaultValue(String elementName) {
1207         ObjectValue objv = getObjectValue(elementName);
1208         return objv.defaultValue;
1209     }
1210 
1211     public Object[] getObjectEnumerations(String elementName) {
1212         ObjectValue objv = getObjectValue(elementName);
1213         if (objv.valueType != VALUE_ENUMERATION) {
1214             throw new IllegalArgumentException("Not an enumeration!");


   1 /*
   2  * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


1164      * @see #setResourceBaseName
1165      */
1166     public String getAttributeDescription(String elementName,
1167                                           String attrName,
1168                                           Locale locale) {
1169         Element element = getElement(elementName);
1170         if (attrName == null) {
1171             throw new IllegalArgumentException("attrName == null!");
1172         }
1173         Attribute attr = (Attribute)element.attrMap.get(attrName);
1174         if (attr == null) {
1175             throw new IllegalArgumentException("No such attribute!");
1176         }
1177 
1178         String key = elementName + "/" + attrName;
1179         return getResource(key, locale);
1180     }
1181 
1182     private ObjectValue getObjectValue(String elementName) {
1183         Element element = getElement(elementName);
1184         ObjectValue objv = element.objectValue;
1185         if (objv == null) {
1186             throw new IllegalArgumentException("No object within element " +
1187                                                elementName + "!");
1188         }
1189         return objv;
1190     }
1191 
1192     public int getObjectValueType(String elementName) {
1193         Element element = getElement(elementName);
1194         ObjectValue objv = element.objectValue;
1195         if (objv == null) {
1196             return VALUE_NONE;
1197         }
1198         return objv.valueType;
1199     }
1200 
1201     public Class<?> getObjectClass(String elementName) {
1202         ObjectValue objv = getObjectValue(elementName);
1203         return objv.classType;
1204     }
1205 
1206     public Object getObjectDefaultValue(String elementName) {
1207         ObjectValue objv = getObjectValue(elementName);
1208         return objv.defaultValue;
1209     }
1210 
1211     public Object[] getObjectEnumerations(String elementName) {
1212         ObjectValue objv = getObjectValue(elementName);
1213         if (objv.valueType != VALUE_ENUMERATION) {
1214             throw new IllegalArgumentException("Not an enumeration!");