|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.umber.bellows.Datum
A single unit of generic data. Each Datum object can contain an arbitrary set of properties with arbitrary values. By default, the Datum does no type or property name validation; setting a property implicitly creates that property in the Datum instance. That property can hold any value and any class type.
To better support mapping from XML documents, Datum properties can
also reside in namespaces. A single property name can legally
exist in more than one namespace, and is considered to be
different properties. Thus, the "size" property in the
"Dimensions" namespace might hold the value of new
Rectangle(3, 5)
, while the "size" property in the
"Descriptions" namespace might hold the value of "very large". The
getNamespaces() method returns an array of all namespaces in
current use in the Datum object.
A Datum may contain an optional parent. A Datum inherits all the
properties and type declarations in its parent that it doesn't
override locally. The getProperty()
method falls
back on parent properties if the property isn't locally defined;
the getLocalProperty()
only looks for the property in
the current Datum object, ignoring any parent properties.
Field Summary | |
static java.lang.String |
DEFAULT_NAMESPACE
Default namespace to use when none is specified. |
static Datum[] |
EMPTY_CHILDREN
Empty child array shared by all Datum objects. |
static java.lang.String |
NSURI_PROPERTY
The name of the property which contains the xmlns namespace mapping. |
Constructor Summary | |
Datum()
Creates a new instance of Datum |
|
Datum(Datum copyDatum)
Creates a new instance of Datum by copying the properties from the copyDatum into the new Datum. |
|
Datum(java.lang.String type)
Creates a new instance of Datum with the given type name. |
|
Datum(java.lang.String type,
java.lang.String id)
Creates a new instance of Datum with the given type and id names. |
Method Summary | |
java.lang.String |
extractPcdata(boolean collapseWhitespace)
Recursively extracts PCDATA content from the given Datum node. |
java.lang.String |
extractText(java.lang.String propertyName,
java.lang.String namespace,
boolean collapseWhitespace)
Recursively extracts the string values of the given property within the given namespace, in the supplied Datum and any child Datum objects, if present. |
java.lang.String[] |
findKeys(java.lang.String keyFilter,
java.lang.String namespace)
Retrieves an array of key names in this Datum object within the given namespace which match the regular expression in keyFilter . |
boolean |
getBooleanProperty(java.lang.String key,
boolean defaultValue)
Evaluates the property and converts it to a boolean value, using some simple heuristics. |
boolean |
getBooleanProperty(java.lang.String key,
java.lang.String namespace,
boolean defaultValue,
boolean inherited)
Evaluates the property within the given namespace and converts it to a boolean value, using some simple heuristics. |
Datum[] |
getChildren()
Getter for property children. |
int |
getEnumProperty(java.lang.String key,
java.lang.String[] enums,
int defaultValue)
Evaluates the value of the property in terms of an array of enumeration values. |
int |
getEnumProperty(java.lang.String key,
java.lang.String namespace,
java.lang.String[] enums,
int defaultValue,
boolean inherited)
Evaluates the value of the property within the given namespace in terms of an array of enumeration values. |
java.lang.String |
getId()
Getter for property id, the instance-specific identifier for this Datum object. |
int |
getIntegerProperty(java.lang.String key,
int defaultValue)
Evaluates the property and converts it to an integer value. |
int |
getIntegerProperty(java.lang.String key,
java.lang.String namespace,
int defaultValue,
boolean inherited)
Evaluates the property within the given namespace and converts it to an integer value. |
java.lang.String[] |
getKeyNames()
Retrieves a Set of all property keys in the default namespace of this Datum. |
java.lang.String[] |
getKeyNames(java.lang.String namespace)
Retrieves a Set of all property keys in the given namespace in this Datum. |
java.lang.Object |
getLocalProperty(java.lang.String name)
Retrieves a property for the given key value. |
java.lang.Object |
getLocalProperty(java.lang.String name,
java.lang.String namespace)
Retrieves a property for the given key value. |
java.lang.String |
getNamespace()
Getter for property namespace, the name of the namespace for the Datum as a whole. |
java.lang.String[] |
getNamespaces()
Returns an array of all namespaces currently in use in this Datum. |
Datum |
getParent()
Getter for property parent. |
java.lang.Object |
getProperty(java.lang.String name)
Retrieves a property for the given key value. |
java.lang.Object |
getProperty(java.lang.String name,
java.lang.String namespace)
Retrieves a property for the given key value. |
protected java.util.Map |
getPropertySpace(java.lang.String namespace)
Returns an entire namespace Map. |
java.lang.String |
getStringProperty(java.lang.String key,
java.lang.String defaultValue)
Extracts a String version of a property from the Datum. |
java.lang.String |
getStringProperty(java.lang.String key,
java.lang.String namespace,
java.lang.String defaultValue,
boolean inherited)
Extracts a String version of a property from the Datum within the given namespace. |
java.lang.String |
getType()
Getter for property type, the name of the type for the Datum and its contents, similar to a class name. |
boolean |
hasPcdataOnly()
Determines if the Datum contains only PCDATA content, with no element content. |
java.lang.String |
lookupUri(java.lang.String namespace)
Searches a Datum and its parents until it finds a URI declaration for the given namespace. |
void |
setNamespace(java.lang.String namespace)
Setter for property namespace, the name of the namespace for the Datum as a whole. |
void |
setParent(Datum parent)
Setter for property parent. |
void |
setProperty(java.lang.String name,
java.lang.Object value)
Assigns a value to the stated property. |
void |
setProperty(java.lang.String name,
java.lang.Object value,
java.lang.String namespace)
Assigns a value to the stated property in the given namespace. |
void |
setType(java.lang.String type)
Setter for property type, the name of the type for the Datum and its contents, similar to a class name. |
java.lang.String |
toString()
Creates a neatly formatted String version of the Datum object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final Datum[] EMPTY_CHILDREN
public static final java.lang.String DEFAULT_NAMESPACE
public static final java.lang.String NSURI_PROPERTY
<root xmlns:ns="http://mydomain.com"/>
would correspond to a Map with a key of "ns" and a value of
"http://mydomain.com".
Constructor Detail |
public Datum()
public Datum(java.lang.String type)
type
- the type name of this Datumpublic Datum(java.lang.String type, java.lang.String id)
type
- the type name of this Datumid
- the unique id of this Datumpublic Datum(Datum copyDatum)
copyDatum
- source Datum to copy into the new DatumMethod Detail |
public void setType(java.lang.String type)
type
- New value of property type.public java.lang.String getType()
public void setNamespace(java.lang.String namespace)
getNamespaces()
.
namespace
- New value of property namespace.public java.lang.String getNamespace()
getNamespaces()
.
public java.lang.String getId()
public Datum getParent()
public void setParent(Datum parent)
parent
- New value of property parent.public Datum[] getChildren()
EMPTY_CHILDREN
.
public java.lang.String[] getNamespaces()
public void setProperty(java.lang.String name, java.lang.Object value)
name
- the key name of the metadata propertyvalue
- the metadata valueprotected java.util.Map getPropertySpace(java.lang.String namespace)
namespace
- the namespace
public void setProperty(java.lang.String name, java.lang.Object value, java.lang.String namespace)
name
- the key name of the metadata propertyvalue
- the metadata valuenamespace
- the XML-style namespace for this propertypublic java.lang.Object getLocalProperty(java.lang.String name)
name
- the key name of the property
public java.lang.Object getLocalProperty(java.lang.String name, java.lang.String namespace)
name
- the key name of the propertynamespace
- the XML-style namespace for this property
public java.lang.Object getProperty(java.lang.String name)
name
- the key name of the property
public java.lang.Object getProperty(java.lang.String name, java.lang.String namespace)
name
- the key name of the propertynamespace
- the XML-style namespace for this property
public java.lang.String getStringProperty(java.lang.String key, java.lang.String namespace, java.lang.String defaultValue, boolean inherited)
key
- the property namenamespace
- the XML-style namespace for this propertydefaultValue
- default to return if the property cannot be foundinherited
- if true, search parent Datum for property if not in
child
public java.lang.String getStringProperty(java.lang.String key, java.lang.String defaultValue)
key
- the property namedefaultValue
- default to return if the property cannot be found
public boolean getBooleanProperty(java.lang.String key, java.lang.String namespace, boolean defaultValue, boolean inherited)
key
- the property namenamespace
- the XML-style namespace for this propertydefaultValue
- default to return if the property cannot be foundinherited
- if true, search parent Datum for property if not in
child
public boolean getBooleanProperty(java.lang.String key, boolean defaultValue)
key
- the property namedefaultValue
- default to return if the property cannot be found
public int getIntegerProperty(java.lang.String key, java.lang.String namespace, int defaultValue, boolean inherited)
key
- the property namenamespace
- the XML-style namespace for this propertydefaultValue
- default to return if the property cannot be foundinherited
- if true, search parent Datum for property if not in
child
public int getIntegerProperty(java.lang.String key, int defaultValue)
key
- the property namedefaultValue
- default to return if the property cannot be found
public int getEnumProperty(java.lang.String key, java.lang.String namespace, java.lang.String[] enums, int defaultValue, boolean inherited)
key
- the property namenamespace
- the XML-style namespace for this propertyenums
- an array of legal values for the enumerationdefaultValue
- default to return if the property cannot be foundinherited
- if true, search parent Datum for property if not in
child
public int getEnumProperty(java.lang.String key, java.lang.String[] enums, int defaultValue)
key
- the property nameenums
- an array of legal values for the enumerationdefaultValue
- default to return if the property cannot be found
public java.lang.String[] getKeyNames()
public java.lang.String[] getKeyNames(java.lang.String namespace)
namespace
- the XML-style namespace for this property
public java.lang.String[] findKeys(java.lang.String keyFilter, java.lang.String namespace)
keyFilter
.
keyFilter
- a regular expression pattern to match keys againstnamespace
- the XML-style namespace for this property
public java.lang.String lookupUri(java.lang.String namespace)
xmlns
declarations, for example:
<root xmlns:ns="http://mydomain.com"/>
namespace
- Datum namespace
public java.lang.String extractText(java.lang.String propertyName, java.lang.String namespace, boolean collapseWhitespace)
true
to collapseWhitespace.
propertyName
- the name of the property to search for text innamespace
- the XML-style namespace for this propertycollapseWhitespace
- whether to remove nonessential whitespace
public java.lang.String extractPcdata(boolean collapseWhitespace)
collapseWhitespace
- whether to remove nonessential whitespace
public boolean hasPcdataOnly()
public java.lang.String toString()
Object.toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |