| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public abstract class IIOMetadataFormatImpl extends Object implements IIOMetadataFormat
A concrete class providing a reusable implementation of the
IIOMetadataFormat
interface. In addition, a static
instance representing the standard, plug-in neutral
javax_imageio_1.0
format is provided by the
getStandardFormatInstance
method.
In order to supply localized descriptions of elements and
attributes, a ResourceBundle
with a base name of
this.getClass().getName() + "Resources"
should be
supplied via the usual mechanism used by
ResourceBundle.getBundle
. Briefly, the subclasser
supplies one or more additional classes according to a naming
convention (by default, the fully-qualified name of the subclass
extending IIMetadataFormatImpl
, plus the string
"Resources", plus the country, language, and variant codes
separated by underscores). At run time, calls to
getElementDescription
or
getAttributeDescription
will attempt to load such
classes dynamically according to the supplied locale, and will use
either the element name, or the element name followed by a '/'
character followed by the attribute name as a key. This key will
be supplied to the ResourceBundle
's
getString
method, and the resulting localized
description of the node or attribute is returned.
The subclass may supply a different base name for the resource
bundles using the setResourceBaseName
method.
A subclass may choose its own localization mechanism, if so
desired, by overriding the supplied implementations of
getElementDescription
and
getAttributeDescription
.
Field Summary | |
---|---|
static String |
standardMetadataFormatName
A String constant containing the standard format
name, "javax_imageio_1.0" . |
Constructor Summary | |
---|---|
IIOMetadataFormatImpl(String rootName, int childPolicy) Constructs a blank IIOMetadataFormatImpl instance,
with a given root element name and child policy (other than
CHILD_POLICY_REPEAT ).
|
|
IIOMetadataFormatImpl(String rootName, int minChildren, int maxChildren) Constructs a blank IIOMetadataFormatImpl instance,
with a given root element name and a child policy of
CHILD_POLICY_REPEAT .
|
Method Summary | |
---|---|
protected void |
addAttribute(String elementName, 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. |
protected void |
addAttribute(String elementName, String attrName, int dataType, boolean required, String defaultValue) 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 enumeratedValues) Adds a new attribute to a previously defined element that will be defined by a set of enumerated values. |
protected void |
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) 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) 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) 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) Adds a new element type to this metadata document format with a child policy of CHILD_POLICY_REPEAT .
|
protected void |
addObjectValue(String elementName, Class classType, boolean required, Object defaultValue) Allows an Object reference of a given class type
to be stored in nodes implementing the named element.
|
protected void |
addObjectValue(String elementName, Class classType, boolean required, Object defaultValue, List enumeratedValues) Allows an Object reference of a given class type
to be stored in nodes implementing the named element.
|
protected void |
addObjectValue(String elementName, Class classType, int arrayMinLength, int arrayMaxLength) Allows an Object reference of a given class type
to be stored in nodes implementing the named element.
|
protected void |
addObjectValue(String elementName, Class classType, Object defaultValue, Comparable minValue, Comparable maxValue, boolean minInclusive, boolean maxInclusive) Allows an Object reference of a given class type
to be stored in nodes implementing the named element.
|
abstract boolean |
canNodeAppear(String elementName, ImageTypeSpecifier imageType) |
int |
getAttributeDataType(String elementName, String attrName) |
String |
getAttributeDefaultValue(String elementName, String attrName) |
String |
getAttributeDescription(String elementName, String attrName, Locale locale) Returns a String containing a description of the
named attribute, or null .
|
String[] |
getAttributeEnumerations(String elementName, String attrName) |
int |
getAttributeListMaxLength(String elementName, String attrName) |
int |
getAttributeListMinLength(String elementName, String attrName) |
String |
getAttributeMaxValue(String elementName, String attrName) |
String |
getAttributeMinValue(String elementName, String attrName) |
String[] |
getAttributeNames(String elementName) |
int |
getAttributeValueType(String elementName, String attrName) |
String[] |
getChildNames(String elementName) |
int |
getChildPolicy(String elementName) |
String |
getElementDescription(String elementName, Locale locale) Returns a String containing a description of the
named element, or null .
|
int |
getElementMaxChildren(String elementName) |
int |
getElementMinChildren(String elementName) |
int |
getObjectArrayMaxLength(String elementName) |
int |
getObjectArrayMinLength(String elementName) |
Class |
getObjectClass(String elementName) |
Object |
getObjectDefaultValue(String elementName) |
Object[] |
getObjectEnumerations(String elementName) |
Comparable |
getObjectMaxValue(String elementName) |
Comparable |
getObjectMinValue(String elementName) |
int |
getObjectValueType(String elementName) |
protected String |
Returns the currently set base name for locating ResourceBundle s.
|
String |
|
static IIOMetadataFormat |
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.
|
boolean |
isAttributeRequired(String elementName, String attrName) |
protected void |
removeAttribute(String elementName, String attrName) Removes an attribute from a previously defined element. |
protected void |
removeElement(String elementName) Removes an element from the format. |
protected void |
removeObjectValue(String elementName) Disallows an Object reference from being stored in
nodes implementing the named element.
|
protected void |
setResourceBaseName(String resourceBaseName) Sets a new base name for locating ResourceBundle s
containing descriptions of elements and attributes for this
format.
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String standardMetadataFormatName
String
constant containing the standard format
name, "javax_imageio_1.0"
.
Constructor Detail |
---|
public IIOMetadataFormatImpl(String rootName, int childPolicy)
IIOMetadataFormatImpl
instance,
with a given root element name and child policy (other than
CHILD_POLICY_REPEAT
). Additional elements, and
their attributes and Object
reference information
may be added using the various add
methods.
rootName
- the name of the root element.childPolicy
- one of the CHILD_POLICY_*
constants,
other than CHILD_POLICY_REPEAT
.public IIOMetadataFormatImpl(String rootName, int minChildren, int maxChildren)
IIOMetadataFormatImpl
instance,
with a given root element name and a child policy of
CHILD_POLICY_REPEAT
. Additional elements, and
their attributes and Object
reference information
may be added using the various add
methods.
rootName
- the name of the root element.minChildren
- the minimum number of children of the node.maxChildren
- the maximum number of children of the node.Method Detail |
---|
protected void addAttribute(String elementName, String attrName, int dataType, boolean required, int listMinLength, int listMaxLength)
elementName
- the name of the element.attrName
- the name of the attribute being added.dataType
- the data type (string format) of the attribute,
one of the DATATYPE_*
constants.required
- true
if the attribute must be present.listMinLength
- the smallest legal number of list items.listMaxLength
- the largest legal number of list items.protected void addAttribute(String elementName, String attrName, int dataType, boolean required, String defaultValue)
elementName
- the name of the element.attrName
- the name of the attribute being added.dataType
- the data type (string format) of the attribute,
one of the DATATYPE_*
constants.required
- true
if the attribute must be present.defaultValue
- the default value for the attribute, or
null
.protected void addAttribute(String elementName, String attrName, int dataType, boolean required, String defaultValue, List enumeratedValues)
elementName
- the name of the element.attrName
- the name of the attribute being added.dataType
- the data type (string format) of the attribute,
one of the DATATYPE_*
constants.required
- true
if the attribute must be present.defaultValue
- the default value for the attribute, or
null
.enumeratedValues
- a List
of
String
s containing the legal values for the
attribute.protected void addAttribute(String elementName, String attrName, int dataType, boolean required, String defaultValue, String minValue, String maxValue, boolean minInclusive, boolean maxInclusive)
elementName
- the name of the element.attrName
- the name of the attribute being added.dataType
- the data type (string format) of the attribute,
one of the DATATYPE_*
constants.required
- true
if the attribute must be present.defaultValue
- the default value for the attribute, or
null
.minValue
- the smallest (inclusive or exclusive depending
on the value of minInclusive
) legal value for the
attribute, as a String
.maxValue
- the largest (inclusive or exclusive depending
on the value of minInclusive
) legal value for the
attribute, as a String
.minInclusive
- true
if minValue
is inclusive.maxInclusive
- true
if maxValue
is inclusive.protected void addBooleanAttribute(String elementName, String attrName, boolean hasDefaultValue, boolean defaultValue)
TRUE
and
FALSE
, with a datatype of
DATATYPE_BOOLEAN
.
elementName
- the name of the element.attrName
- the name of the attribute being added.hasDefaultValue
- true
if a default value
should be present.defaultValue
- the default value for the attribute as a
boolean
, ignored if hasDefaultValue
is false
.protected void addChildElement(String elementName, String parentName)
elementName
- the name of the element to be addded as a
child.parentName
- the name of the element that will be the
new parent of the element.protected void addElement(String elementName, String parentName, int childPolicy)
CHILD_POLICY_REPEAT
.
elementName
- the name of the new element.parentName
- the name of the element that will be the
parent of the new element.childPolicy
- one of the CHILD_POLICY_*
constants, other than CHILD_POLICY_REPEAT
,
indicating the child policy of the new element.protected void addElement(String elementName, String parentName, int minChildren, int maxChildren)
CHILD_POLICY_REPEAT
.
elementName
- the name of the new element.parentName
- the name of the element that will be the
parent of the new element.minChildren
- the minimum number of children of the node.maxChildren
- the maximum number of children of the node.protected void addObjectValue(String elementName, Class classType, boolean required, Object defaultValue)
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.
elementName
- the name of the element.classType
- a Class
variable indicating the
legal class type for the object value.required
- true
if an object value must be present.defaultValue
- the default value for the
Object
reference, or null
.protected void addObjectValue(String elementName, Class classType, boolean required, Object defaultValue, List enumeratedValues)
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.
elementName
- the name of the element.classType
- a Class
variable indicating the
legal class type for the object value.required
- true
if an object value must be present.defaultValue
- the default value for the
Object
reference, or null
.enumeratedValues
- a List
of
Object
s containing the legal values for the
object reference.protected void addObjectValue(String elementName, Class classType, int arrayMinLength, int arrayMaxLength)
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.
elementName
- the name of the element.classType
- a Class
variable indicating the
legal class type for the object value.arrayMinLength
- the smallest legal length for the array.arrayMaxLength
- the largest legal length for the array.protected void addObjectValue(String elementName, Class classType, Object defaultValue, Comparable minValue, Comparable maxValue, boolean minInclusive, boolean maxInclusive)
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.
elementName
- the name of the element.classType
- a Class
variable indicating the
legal class type for the object value.defaultValue
- the default value for theminValue
- the smallest (inclusive or exclusive depending
on the value of minInclusive
) legal value for the
object value, as a String
.maxValue
- the largest (inclusive or exclusive depending
on the value of minInclusive
) legal value for the
object value, as a String
.minInclusive
- true
if minValue
is inclusive.maxInclusive
- true
if maxValue
is inclusive.public abstract boolean canNodeAppear(String elementName, ImageTypeSpecifier imageType)
elementName
imageType
public int getAttributeDataType(String elementName, String attrName)
elementName
attrName
public String getAttributeDefaultValue(String elementName, String attrName)
elementName
attrName
public String getAttributeDescription(String elementName, String attrName, Locale locale)
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.
elementName
- the name of the element.attrName
- the name of the attribute.locale
- the Locale
for which localization
will be attempted, or null
.public String[] getAttributeEnumerations(String elementName, String attrName)
elementName
attrName
public int getAttributeListMaxLength(String elementName, String attrName)
elementName
attrName
public int getAttributeListMinLength(String elementName, String attrName)
elementName
attrName
public String getAttributeMaxValue(String elementName, String attrName)
elementName
attrName
public String getAttributeMinValue(String elementName, String attrName)
elementName
attrName
public String[] getAttributeNames(String elementName)
elementName
public int getAttributeValueType(String elementName, String attrName)
elementName
attrName
public String[] getChildNames(String elementName)
elementName
public int getChildPolicy(String elementName)
elementName
public String getElementDescription(String elementName, Locale locale)
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.
elementName
- the name of the element.locale
- the Locale
for which localization
will be attempted.public int getElementMaxChildren(String elementName)
elementName
public int getElementMinChildren(String elementName)
elementName
public int getObjectArrayMaxLength(String elementName)
elementName
public int getObjectArrayMinLength(String elementName)
elementName
public Class getObjectClass(String elementName)
elementName
public Object getObjectDefaultValue(String elementName)
elementName
public Object[] getObjectEnumerations(String elementName)
elementName
public Comparable getObjectMaxValue(String elementName)
elementName
public Comparable getObjectMinValue(String elementName)
elementName
public int getObjectValueType(String elementName)
elementName
protected String getResourceBaseName()
ResourceBundle
s.
String
containing the base name.public String getRootName()
public static IIOMetadataFormat getStandardFormatInstance()
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.
IIOMetadataFormat
instance.public boolean isAttributeRequired(String elementName, String attrName)
elementName
attrName
protected void removeAttribute(String elementName, String attrName)
elementName
- the name of the element.attrName
- the name of the attribute being removed.protected void removeElement(String elementName)
elementName
- the name of the element to be removed.protected void removeObjectValue(String elementName)
Object
reference from being stored in
nodes implementing the named element.
elementName
- the name of the element.protected void setResourceBaseName(String resourceBaseName)
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"
.
resourceBaseName
- a String
containg the new
base name.
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |