Method from javax.imageio.metadata.IIOMetadataFormatImpl Detail: |
protected void addAttribute(String elementName,
String attrName,
int dataType,
boolean required,
String defaultValue) {
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);
}
Adds a new attribute to a previously defined element that may
be set to an arbitrary value. |
protected void addAttribute(String elementName,
String attrName,
int dataType,
boolean required,
String defaultValue,
List<String> enumeratedValues) {
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);
}
Adds a new attribute to a previously defined element that will
be defined by a set of enumerated values. |
protected void addAttribute(String elementName,
String attrName,
int dataType,
boolean required,
int listMinLength,
int listMaxLength) {
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);
}
Adds a new attribute to a previously defined element that will
be defined by a list of values. |
protected void addAttribute(String elementName,
String attrName,
int dataType,
boolean required,
String defaultValue,
String minValue,
String maxValue,
boolean minInclusive,
boolean maxInclusive) {
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);
}
Adds a new attribute to a previously defined element that will
be defined by a range of values. |
protected void addBooleanAttribute(String elementName,
String attrName,
boolean hasDefaultValue,
boolean defaultValue) {
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);
}
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 . |
protected void addChildElement(String elementName,
String parentName) {
Element parent = getElement(parentName);
Element element = getElement(elementName);
parent.childList.add(elementName);
element.parentList.add(parentName);
}
Adds an existing element to the list of legal children for a
given parent node type. |
protected void addElement(String elementName,
String parentName,
int childPolicy) {
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);
}
Adds a new element type to this metadata document format with a
child policy other than CHILD_POLICY_REPEAT . |
protected void addElement(String elementName,
String parentName,
int minChildren,
int maxChildren) {
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);
}
Adds a new element type to this metadata document format with a
child policy of CHILD_POLICY_REPEAT . |
protected void addObjectValue(String elementName,
Class<T> classType,
boolean required,
T defaultValue) {
Element element = getElement(elementName);
ObjectValue obj = new ObjectValue();
obj.valueType = VALUE_ARBITRARY;
obj.classType = classType;
obj.defaultValue = defaultValue;
element.objectValue = obj;
}
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. |
protected void addObjectValue(String elementName,
Class<?> classType,
int arrayMinLength,
int arrayMaxLength) {
Element element = getElement(elementName);
ObjectValue obj = new ObjectValue();
obj.valueType = VALUE_LIST;
obj.classType = classType;
obj.arrayMinLength = arrayMinLength;
obj.arrayMaxLength = arrayMaxLength;
element.objectValue = obj;
}
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. |
protected void addObjectValue(String elementName,
Class<T> classType,
boolean required,
T defaultValue,
List<? extends T> enumeratedValues) {
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;
}
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. |
protected void addObjectValue(String elementName,
Class<T> classType,
T defaultValue,
Comparable<? super T> minValue,
Comparable<? super T> maxValue,
boolean minInclusive,
boolean maxInclusive) {
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;
}
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. |
abstract public boolean canNodeAppear(String elementName,
ImageTypeSpecifier imageType)
|
public int getAttributeDataType(String elementName,
String attrName) {
Attribute attr = getAttribute(elementName, attrName);
return attr.dataType;
}
|
public String getAttributeDefaultValue(String elementName,
String attrName) {
Attribute attr = getAttribute(elementName, attrName);
return attr.defaultValue;
}
|
public String getAttributeDescription(String elementName,
String attrName,
Locale locale) {
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);
}
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. |
public String[] getAttributeEnumerations(String elementName,
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(String elementName,
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(String elementName,
String attrName) {
Attribute attr = getAttribute(elementName, attrName);
if (attr.valueType != VALUE_LIST) {
throw new IllegalArgumentException("Attribute not a list!");
}
return attr.listMinLength;
}
|
public String getAttributeMaxValue(String elementName,
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 String getAttributeMinValue(String elementName,
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 String[] getAttributeNames(String elementName) {
Element element = getElement(elementName);
List names = element.attrList;
String[] result = new String[names.size()];
return (String[])names.toArray(result);
}
|
public int getAttributeValueType(String elementName,
String attrName) {
Attribute attr = getAttribute(elementName, attrName);
return attr.valueType;
}
|
public String[] getChildNames(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(String elementName) {
Element element = getElement(elementName);
return element.childPolicy;
}
|
public String getElementDescription(String elementName,
Locale locale) {
Element element = getElement(elementName);
return getResource(elementName, 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. |
public int getElementMaxChildren(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(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(String elementName) {
ObjectValue objv = getObjectValue(elementName);
if (objv.valueType != VALUE_LIST) {
throw new IllegalArgumentException("Not a list!");
}
return objv.arrayMaxLength;
}
|
public int getObjectArrayMinLength(String elementName) {
ObjectValue objv = getObjectValue(elementName);
if (objv.valueType != VALUE_LIST) {
throw new IllegalArgumentException("Not a list!");
}
return objv.arrayMinLength;
}
|
public Class<?> getObjectClass(String elementName) {
ObjectValue objv = getObjectValue(elementName);
return objv.classType;
}
|
public Object getObjectDefaultValue(String elementName) {
ObjectValue objv = getObjectValue(elementName);
return objv.defaultValue;
}
|
public Object[] getObjectEnumerations(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 Comparable<?> getObjectMaxValue(String elementName) {
ObjectValue objv = getObjectValue(elementName);
if ((objv.valueType & VALUE_RANGE) != VALUE_RANGE) {
throw new IllegalArgumentException("Not a range!");
}
return objv.maxValue;
}
|
public Comparable<?> getObjectMinValue(String elementName) {
ObjectValue objv = getObjectValue(elementName);
if ((objv.valueType & VALUE_RANGE) != VALUE_RANGE) {
throw new IllegalArgumentException("Not a range!");
}
return objv.minValue;
}
|
public int getObjectValueType(String elementName) {
Element element = getElement(elementName);
ObjectValue objv = (ObjectValue)element.objectValue;
if (objv == null) {
return VALUE_NONE;
}
return objv.valueType;
}
|
protected String getResourceBaseName() {
return resourceBaseName;
}
Returns the currently set base name for locating
ResourceBundle s. |
public String getRootName() {
return rootName;
}
|
public static IIOMetadataFormat getStandardFormatInstance() {
createStandardFormat();
return standardFormat;
}
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. |
public boolean isAttributeRequired(String elementName,
String attrName) {
Attribute attr = getAttribute(elementName, attrName);
return attr.required;
}
|
protected void removeAttribute(String elementName,
String attrName) {
Element element = getElement(elementName);
element.attrList.remove(attrName);
element.attrMap.remove(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. |
protected void removeElement(String elementName) {
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);
}
}
Removes an element from the format. If no element with the
given name was present, nothing happens and no exception is
thrown. |
protected void removeObjectValue(String elementName) {
Element element = getElement(elementName);
element.objectValue = null;
}
Disallows an Object reference from being stored in
nodes implementing the named element. |
protected void setResourceBaseName(String resourceBaseName) {
if (resourceBaseName == null) {
throw new IllegalArgumentException("resourceBaseName == null!");
}
this.resourceBaseName = 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" . |