Methods Summary |
---|
protected void | addAttribute(java.lang.String elementName, java.lang.String attrName, int dataType, boolean required, int listMinLength, int listMaxLength)Adds a new attribute to an existing element.
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!");
}
Element element = findElement(elementName);
Attlist attr = new Attlist();
attr.name = attrName;
attr.dataType = dataType;
attr.required = required;
attr.listMinLength = listMinLength;
attr.listMaxLength = listMaxLength;
attr.valueType = VALUE_LIST;
element.attributes.put(attrName, attr);
|
protected void | addAttribute(java.lang.String elementName, java.lang.String attrName, int dataType, boolean required, java.lang.String defaultValue)Adds a new attribute to an existing element.
if (attrName == null) {
throw new IllegalArgumentException("attrName == null!");
}
if (dataType < DATATYPE_STRING || dataType > DATATYPE_DOUBLE) {
throw new IllegalArgumentException("Invalid value for dataType!");
}
Element element = findElement(elementName);
Attlist attr = new Attlist();
attr.name = attrName;
attr.dataType = dataType;
attr.required = required;
attr.defaultValue = defaultValue;
attr.valueType = VALUE_ARBITRARY;
element.attributes.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 an existing element.
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 || enumeratedValues.isEmpty()) {
throw new IllegalArgumentException("enumeratedValues is empty or null");
}
try {
for (String enumeratedValue : enumeratedValues) {
if (enumeratedValue == null) {
throw new IllegalArgumentException("enumeratedValues contains a null!");
}
}
} catch (ClassCastException e) {
throw new IllegalArgumentException("enumeratedValues contains a non-String value!");
}
Element element = findElement(elementName);
Attlist attr = new Attlist();
attr.name = attrName;
attr.dataType = dataType;
attr.required = required;
attr.defaultValue = defaultValue;
attr.enumeratedValues = enumeratedValues;
attr.valueType = VALUE_ENUMERATION;
element.attributes.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 an existing element.
if (attrName == null) {
throw new IllegalArgumentException("attrName == null!");
}
if (dataType < DATATYPE_STRING || dataType > DATATYPE_DOUBLE) {
throw new IllegalArgumentException("Invalid value for dataType!");
}
Element element = findElement(elementName);
Attlist attr = new Attlist();
attr.name = attrName;
attr.dataType = dataType;
attr.required = required;
attr.defaultValue = defaultValue;
attr.minValue = minValue;
attr.maxValue = maxValue;
attr.minInclusive = minInclusive;
attr.maxInclusive = maxInclusive;
attr.valueType = VALUE_RANGE;
attr.valueType |= minInclusive ? VALUE_RANGE_MIN_INCLUSIVE_MASK : 0;
attr.valueType |= maxInclusive ? VALUE_RANGE_MAX_INCLUSIVE_MASK : 0;
element.attributes.put(attrName, attr);
|
protected void | addBooleanAttribute(java.lang.String elementName, java.lang.String attrName, boolean hasDefaultValue, boolean defaultValue)Adds a new attribute with boolean data type to an existing element.
String defaultVal = hasDefaultValue ? (defaultValue ? "TRUE" : "FALSE") : null;
ArrayList<String> values = new ArrayList<String>(2);
values.add("TRUE");
values.add("FALSE");
addAttribute(elementName, attrName, DATATYPE_BOOLEAN, true, defaultVal, values);
|
protected void | addChildElement(java.lang.String elementName, java.lang.String parentName)Adds an existing element to the list of child elements of the specified
parent element.
Element parent = findElement(parentName);
Element element = findElement(elementName);
parent.children.add(element.name);
|
protected void | addElement(java.lang.String elementName, java.lang.String parentName, int childPolicy)Adds a new element type to this IIOMetadataFormat with a child policy (if
policy is not CHILD_POLICY_REPEAT).
if (childPolicy < CHILD_POLICY_EMPTY || childPolicy > CHILD_POLICY_MAX
|| childPolicy == CHILD_POLICY_REPEAT) {
throw new IllegalArgumentException("childPolicy is not one of the predefined constants");
}
Element parent = findElement(parentName);
Element element = new Element();
element.name = elementName;
element.childPolicy = childPolicy;
elementHash.put(elementName, element);
parent.children.add(elementName);
|
protected void | addElement(java.lang.String elementName, java.lang.String parentName, int minChildren, int maxChildren)Adds a new element type to this IIOMetadataFormat with
CHILD_POLICY_REPEAT and the specified minimum and maximum number of child
elements.
if (minChildren < 0) {
throw new IllegalArgumentException("minChildren < 0!");
}
if (minChildren > maxChildren) {
throw new IllegalArgumentException("minChildren > maxChildren!");
}
Element parent = findElement(parentName);
Element element = new Element();
element.name = elementName;
element.childPolicy = CHILD_POLICY_REPEAT;
element.minChildren = minChildren;
element.maxChildren = maxChildren;
elementHash.put(elementName, element);
parent.children.add(elementName);
|
protected void | addObjectValue(java.lang.String elementName, java.lang.Class classType, int arrayMinLength, int arrayMaxLength)Adds an Object reference with the specified class type to be stored as
element's value.
Element element = findElement(elementName);
ObjectValue objVal = new ObjectValue();
objVal.classType = classType;
objVal.arrayMaxLength = arrayMaxLength;
objVal.arrayMinLength = arrayMinLength;
objVal.valueType = VALUE_LIST;
element.objectValue = objVal;
|
protected void | addObjectValue(java.lang.String elementName, java.lang.Class classType, boolean required, T defaultValue)Adds an Object reference with the specified class type to be stored as an
element's value.
// note: reqired is an unused parameter
Element element = findElement(elementName);
ObjectValue<T> objVal = new ObjectValue<T>();
objVal.classType = classType;
objVal.defaultValue = defaultValue;
objVal.valueType = VALUE_ARBITRARY;
element.objectValue = objVal;
|
protected void | addObjectValue(java.lang.String elementName, java.lang.Class classType, boolean required, T defaultValue, java.util.List enumeratedValues)Adds an Object reference with the specified class type to be stored as
the element's value.
// note: reqired is an unused parameter
if (enumeratedValues == null || enumeratedValues.isEmpty()) {
throw new IllegalArgumentException("enumeratedValues is empty or null");
}
try {
for (T enumeratedValue : enumeratedValues) {
if (enumeratedValue == null) {
throw new IllegalArgumentException("enumeratedValues contains a null!");
}
}
} catch (ClassCastException e) {
throw new IllegalArgumentException(
"enumeratedValues contains a value not of class classType!");
}
Element element = findElement(elementName);
ObjectValue<T> objVal = new ObjectValue<T>();
objVal.classType = classType;
objVal.defaultValue = defaultValue;
objVal.enumeratedValues = enumeratedValues;
objVal.valueType = VALUE_ENUMERATION;
element.objectValue = objVal;
|
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)Adds an Object reference with the specified class type to be stored as
the element's value.
Element element = findElement(elementName);
ObjectValue<T> objVal = new ObjectValue<T>();
objVal.classType = classType;
objVal.defaultValue = defaultValue;
objVal.minValue = minValue;
objVal.maxValue = maxValue;
objVal.minInclusive = minInclusive;
objVal.maxInclusive = maxInclusive;
objVal.valueType = VALUE_RANGE;
objVal.valueType |= minInclusive ? VALUE_RANGE_MIN_INCLUSIVE_MASK : 0;
objVal.valueType |= maxInclusive ? VALUE_RANGE_MAX_INCLUSIVE_MASK : 0;
element.objectValue = objVal;
|
public abstract boolean | canNodeAppear(java.lang.String elementName, javax.imageio.ImageTypeSpecifier imageType)
|
private javax.imageio.metadata.IIOMetadataFormatImpl$Attlist | findAttribute(java.lang.String elementName, java.lang.String attributeName)Find attribute.
Element element = findElement(elementName);
Attlist attribute;
if ((attribute = element.attributes.get(attributeName)) == null) {
throw new IllegalArgumentException("attribute name is null or no such attribute: "
+ attributeName);
}
return attribute;
|
private javax.imageio.metadata.IIOMetadataFormatImpl$Element | findElement(java.lang.String name)Find element.
Element element;
if ((element = elementHash.get(name)) == null) {
throw new IllegalArgumentException("element name is null or no such element: " + name);
}
return element;
|
private javax.imageio.metadata.IIOMetadataFormatImpl$ObjectValue | findObjectValue(java.lang.String elementName)Find object value.
Element element = findElement(elementName);
ObjectValue v = element.objectValue;
if (v == null) {
throw new IllegalArgumentException("No object within element");
}
return v;
|
public int | getAttributeDataType(java.lang.String elementName, java.lang.String attrName)
Attlist attr = findAttribute(elementName, attrName);
return attr.dataType;
|
public java.lang.String | getAttributeDefaultValue(java.lang.String elementName, java.lang.String attrName)
Attlist attr = findAttribute(elementName, attrName);
return attr.defaultValue;
|
public java.lang.String | getAttributeDescription(java.lang.String elementName, java.lang.String attrName, java.util.Locale locale)
findAttribute(elementName, attrName);
return getResourceString(elementName + "/" + attrName, locale);
|
public java.lang.String[] | getAttributeEnumerations(java.lang.String elementName, java.lang.String attrName)
Attlist attr = findAttribute(elementName, attrName);
if (attr.valueType != VALUE_ENUMERATION) {
throw new IllegalArgumentException("Attribute is not an enumeration!");
}
return attr.enumeratedValues.toArray(new String[attr.enumeratedValues.size()]);
|
public int | getAttributeListMaxLength(java.lang.String elementName, java.lang.String attrName)
Attlist attr = findAttribute(elementName, attrName);
if (attr.valueType != VALUE_LIST) {
throw new IllegalArgumentException("Attribute is not a list!");
}
return attr.listMaxLength;
|
public int | getAttributeListMinLength(java.lang.String elementName, java.lang.String attrName)
Attlist attr = findAttribute(elementName, attrName);
if (attr.valueType != VALUE_LIST) {
throw new IllegalArgumentException("Attribute is not a list!");
}
return attr.listMinLength;
|
public java.lang.String | getAttributeMaxValue(java.lang.String elementName, java.lang.String attrName)
Attlist attr = findAttribute(elementName, attrName);
if ((attr.valueType & VALUE_RANGE) == 0) {
throw new IllegalArgumentException("Attribute is not a range!");
}
return attr.maxValue;
|
public java.lang.String | getAttributeMinValue(java.lang.String elementName, java.lang.String attrName)
Attlist attr = findAttribute(elementName, attrName);
if ((attr.valueType & VALUE_RANGE) == 0) {
throw new IllegalArgumentException("Attribute is not a range!");
}
return attr.minValue;
|
public java.lang.String[] | getAttributeNames(java.lang.String elementName)
Element element = findElement(elementName);
return element.attributes.keySet().toArray(new String[element.attributes.size()]);
|
public int | getAttributeValueType(java.lang.String elementName, java.lang.String attrName)
Attlist attr = findAttribute(elementName, attrName);
return attr.valueType;
|
public java.lang.String[] | getChildNames(java.lang.String elementName)
Element element = findElement(elementName);
if (element.childPolicy == CHILD_POLICY_EMPTY) { // Element cannot have
// children
return null;
}
return element.children.toArray(new String[element.children.size()]);
|
public int | getChildPolicy(java.lang.String elementName)
Element element = findElement(elementName);
return element.childPolicy;
|
public java.lang.String | getElementDescription(java.lang.String elementName, java.util.Locale locale)
findElement(elementName); // Check if there is such element
return getResourceString(elementName, locale);
|
public int | getElementMaxChildren(java.lang.String elementName)
Element element = findElement(elementName);
if (element.childPolicy != CHILD_POLICY_REPEAT) {
throw new IllegalArgumentException("Child policy is not CHILD_POLICY_REPEAT!");
}
return element.maxChildren;
|
public int | getElementMinChildren(java.lang.String elementName)
Element element = findElement(elementName);
if (element.childPolicy != CHILD_POLICY_REPEAT) {
throw new IllegalArgumentException("Child policy is not CHILD_POLICY_REPEAT!");
}
return element.minChildren;
|
public int | getObjectArrayMaxLength(java.lang.String elementName)
Element element = findElement(elementName);
ObjectValue v = element.objectValue;
if (v == null || v.valueType != VALUE_LIST) {
throw new IllegalArgumentException("Not a list!");
}
return v.arrayMaxLength;
|
public int | getObjectArrayMinLength(java.lang.String elementName)
Element element = findElement(elementName);
ObjectValue v = element.objectValue;
if (v == null || v.valueType != VALUE_LIST) {
throw new IllegalArgumentException("Not a list!");
}
return v.arrayMinLength;
|
public java.lang.Class | getObjectClass(java.lang.String elementName)
ObjectValue v = findObjectValue(elementName);
return v.classType;
|
public java.lang.Object | getObjectDefaultValue(java.lang.String elementName)
ObjectValue v = findObjectValue(elementName);
return v.defaultValue;
|
public java.lang.Object[] | getObjectEnumerations(java.lang.String elementName)
Element element = findElement(elementName);
ObjectValue v = element.objectValue;
if (v == null || v.valueType != VALUE_ENUMERATION) {
throw new IllegalArgumentException("Not an enumeration!");
}
return v.enumeratedValues.toArray();
|
public java.lang.Comparable | getObjectMaxValue(java.lang.String elementName)
Element element = findElement(elementName);
ObjectValue v = element.objectValue;
if (v == null || (v.valueType & VALUE_RANGE) == 0) {
throw new IllegalArgumentException("Not a range!");
}
return v.maxValue;
|
public java.lang.Comparable | getObjectMinValue(java.lang.String elementName)
Element element = findElement(elementName);
ObjectValue v = element.objectValue;
if (v == null || (v.valueType & VALUE_RANGE) == 0) {
throw new IllegalArgumentException("Not a range!");
}
return v.minValue;
|
public int | getObjectValueType(java.lang.String elementName)
Element element = findElement(elementName);
if (element.objectValue == null) {
return VALUE_NONE;
}
return element.objectValue.valueType;
|
protected java.lang.String | getResourceBaseName()Gets the resource base name for locating ResourceBundles.
return resourceBaseName;
|
private java.lang.String | getResourceString(java.lang.String key, java.util.Locale locale)Gets the resource string.
if (locale == null) {
locale = Locale.getDefault();
}
// Get the context class loader and try to locate the bundle with it
// first
ClassLoader contextClassloader = AccessController
.doPrivileged(new PrivilegedAction<ClassLoader>() {
public ClassLoader run() {
return Thread.currentThread().getContextClassLoader();
}
});
// Now try to get the resource bundle
ResourceBundle rb;
try {
rb = ResourceBundle.getBundle(resourceBaseName, locale, contextClassloader);
} catch (MissingResourceException e) {
try {
rb = ResourceBundle.getBundle(resourceBaseName, locale);
} catch (MissingResourceException e1) {
return null;
}
}
try {
return rb.getString(key);
} catch (MissingResourceException e) {
return null;
} catch (ClassCastException e) {
return null; // Not a string resource
}
|
public java.lang.String | getRootName()
return rootName;
|
public static javax.imageio.metadata.IIOMetadataFormat | getStandardFormatInstance()Gets the standard format instance.
if (standardFormat == null) {
standardFormat = new IIOStandardMetadataFormat();
}
return standardFormat;
|
public boolean | isAttributeRequired(java.lang.String elementName, java.lang.String attrName)
return findAttribute(elementName, attrName).required;
|
protected void | removeAttribute(java.lang.String elementName, java.lang.String attrName)Removes the specified attribute from the specified element.
Element element = findElement(elementName);
element.attributes.remove(attrName);
|
protected void | removeElement(java.lang.String elementName)Removes the specified element from this format.
Element element;
if ((element = elementHash.get(elementName)) != null) {
elementHash.remove(elementName);
for (Element e : elementHash.values()) {
e.children.remove(element.name);
}
}
|
protected void | removeObjectValue(java.lang.String elementName)Removes the object value from the specified element.
Element element = findElement(elementName);
element.objectValue = null;
|
protected void | setResourceBaseName(java.lang.String resourceBaseName)Sets a new base name for ResourceBundles containing descriptions of
elements and attributes for this format.
if (resourceBaseName == null) {
throw new IllegalArgumentException("resourceBaseName == null!");
}
this.resourceBaseName = resourceBaseName;
|