Methods Summary |
---|
protected void | addAttribute(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.
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 void | addAttribute(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.
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 void | addAttribute(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.
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 void | addAttribute(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.
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 void | addBooleanAttribute(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 .
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 void | addChildElement(java.lang.String elementName, java.lang.String parentName)Adds an existing element to the list of legal children for a
given parent node type.
Element parent = getElement(parentName);
Element element = getElement(elementName);
parent.childList.add(elementName);
element.parentList.add(parentName);
|
protected void | addElement(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 .
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 void | addElement(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 .
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 void | addObjectValue(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.
Element element = getElement(elementName);
ObjectValue obj = new ObjectValue();
obj.valueType = VALUE_ARBITRARY;
obj.classType = classType;
obj.defaultValue = defaultValue;
element.objectValue = obj;
|
protected void | addObjectValue(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.
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 void | addObjectValue(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.
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 void | addObjectValue(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.
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 boolean | canNodeAppear(java.lang.String elementName, javax.imageio.ImageTypeSpecifier imageType)
|
private static synchronized void | createStandardFormat()
if (standardFormat == null) {
standardFormat = new StandardMetadataFormat();
}
|
private javax.imageio.metadata.IIOMetadataFormatImpl$Attribute | getAttribute(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 int | getAttributeDataType(java.lang.String elementName, java.lang.String attrName)
Attribute attr = getAttribute(elementName, attrName);
return attr.dataType;
|
public java.lang.String | getAttributeDefaultValue(java.lang.String elementName, java.lang.String attrName)
Attribute attr = getAttribute(elementName, attrName);
return attr.defaultValue;
|
public java.lang.String | getAttributeDescription(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.
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 int | getAttributeListMaxLength(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 int | getAttributeListMinLength(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.String | getAttributeMaxValue(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.String | getAttributeMinValue(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 int | getAttributeValueType(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 int | getChildPolicy(java.lang.String elementName)
Element element = getElement(elementName);
return element.childPolicy;
|
private javax.imageio.metadata.IIOMetadataFormatImpl$Element | getElement(java.lang.String elementName, boolean mustAppear)Utility method for locating an element.
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$Element | getElement(java.lang.String elementName)
return getElement(elementName, true);
|
public java.lang.String | getElementDescription(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.
Element element = getElement(elementName);
return getResource(elementName, locale);
|
public int | getElementMaxChildren(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 int | getElementMinChildren(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 int | getObjectArrayMaxLength(java.lang.String elementName)
ObjectValue objv = getObjectValue(elementName);
if (objv.valueType != VALUE_LIST) {
throw new IllegalArgumentException("Not a list!");
}
return objv.arrayMaxLength;
|
public int | getObjectArrayMinLength(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.Class | getObjectClass(java.lang.String elementName)
ObjectValue objv = getObjectValue(elementName);
return objv.classType;
|
public java.lang.Object | getObjectDefaultValue(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.Comparable | getObjectMaxValue(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.Comparable | getObjectMinValue(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$ObjectValue | getObjectValue(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 int | getObjectValueType(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.String | getResource(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.String | getResourceBaseName()Returns the currently set base name for locating
ResourceBundle s.
return resourceBaseName;
|
public java.lang.String | getRootName()
return rootName;
|
public static javax.imageio.metadata.IIOMetadataFormat | getStandardFormatInstance()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.
createStandardFormat();
return standardFormat;
|
public boolean | isAttributeRequired(java.lang.String elementName, java.lang.String attrName)
Attribute attr = getAttribute(elementName, attrName);
return attr.required;
|
protected void | removeAttribute(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.
Element element = getElement(elementName);
element.attrList.remove(attrName);
element.attrMap.remove(attrName);
|
protected void | removeElement(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.
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 void | removeObjectValue(java.lang.String elementName)Disallows an Object reference from being stored in
nodes implementing the named element.
Element element = getElement(elementName);
element.objectValue = null;
|
protected void | setResourceBaseName(java.lang.String resourceBaseName)Sets a new base name for locating ResourceBundle s
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" .
if (resourceBaseName == null) {
throw new IllegalArgumentException("resourceBaseName == null!");
}
this.resourceBaseName = resourceBaseName;
|