public class Metadata extends Object implements Serializable, Iterable
| Modifier and Type | Field and Description |
|---|---|
static String |
DELIMITER
Denotes the character used to delimit the components of a metadata key.
|
| Constructor and Description |
|---|
Metadata()
Constructs a new Metadata node with an empty string for a key
and an empty string for a value.
|
Metadata(String key)
Constructs a new Metadata node with the specified key.
|
Metadata(String key,
String value)
Constructs a new Metadata node with the specified key and value.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Removes all child metadata nodes from this metadata node.
|
boolean |
contains(String key)
Determines if this metadata contains a child with the specified key.
|
static boolean |
containsDelimiter(String key)
Tests a key to see if it contains a
DELIMITER. |
void |
delete(Metadata child)
Removes the specified child node from this metadata node.
|
void |
delete(String key)
Removes a child node from this metadata node.
|
boolean |
equals(Object o)
Indicates whether some other object is "equal to" this one.
|
Metadata |
get(String key)
Retrieves a child node specified by a key.
|
Metadata |
getCopy()
Creates a deep copy of this metadata node.
|
Iterator |
getDictionaryIterator()
Returns an iterator over the entire set of metadata mappings between keys
and values represented by this metadata node.
|
Iterator |
getDictionaryIterator(boolean bAllMappings)
Returns an iterator over the entire set of metadata mappings between keys
and values represented by this metadata node.
|
String |
getKey()
Returns the key for this metadata node.
|
Iterator |
getMetadataIterator()
Returns an iterator over the child metadata nodes in this metadata node.
|
int |
getNumberChildren()
Indicates the number of child nodes this metadata node has.
|
Metadata |
getUnmodifiableMetadata()
Returns a read-only Metadata instance for this object.
|
String |
getValue()
Returns the value for this metadata node.
|
int |
hashCode()
Returns a hash code value for the object.
|
Iterator |
iterator()
Returns an iterator over the child metadata nodes in this metadata node.
|
void |
put(Metadata value)
Adds the specified metadata to the current node's list of child nodes.
|
void |
put(String key,
Metadata value)
Associates the specified metadata node with the specified key in this metadata.
|
String |
put(String key,
String value)
Associates the specified value with the specified key in this metadata.
|
void |
putAll(Metadata metadata)
Adds copies of all of the child metadata nodes of the supplied metadata as
children of this metadata node.
|
void |
setKey(String key)
Sets the key for this metadata node.
|
void |
setValue(String value)
Sets the value for this metadata node.
|
static String[] |
tokenizeKey(String key)
Parses a key into a collection of component keys using
DELIMITER
as the delimiter character. |
String |
toString() |
forEach, spliteratorpublic static final String DELIMITER
public Metadata()
public Metadata(String key)
key - is the key to associate with this new metadata node.IllegalArgumentException - if the key is null.public Metadata(String key, String value)
key - is the key to associate with this new metadata node.value - is the value to associate with this new metadata node.IllegalArgumentException - if the key is null.public boolean equals(Object o)
public int hashCode()
public static String[] tokenizeKey(String key)
DELIMITER
as the delimiter character. The component keys will be returned as an array of strings.
Leading and trailing delimiters will be stripped off and ignored. Multiple,
consecutive occurrences of the delimiter within the key will be treated as a single
delimiter. A key specified as null or the empty string ("") will return
an array of length zero. See Package Summary
for more details.key - is the string to be parsed.public static boolean containsDelimiter(String key)
DELIMITER. If the key is null
or the empty string, then false is returned.key - is the string to test.true if the key contains a delimiter, false if not.public Metadata getUnmodifiableMetadata()
public String getKey()
public String getValue()
public void setKey(String key)
DELIMITER. The key cannot
be null but may be empty.key - is the new key to associate with this metadata.IllegalArgumentException - if the key is null or contains a delimiter.public void setValue(String value)
null, the metadata value will be set to
an empty string ("").value - is the new value to associate with this metadata.public boolean contains(String key)
DELIMITER, then the test does not consider this node's key. If the
key parameter does start with a delimiter, then the first component key in the parameter
must match the key for this metadata node.
Consider a Metadata hierarchy shown in the Package Description.
// The following calls all return true. metadata.contains("Use Constraints"); metadata.contains("\\Identification\\Use Constraints"); metadata.contains("Keywords\\Theme\\Geography"); // The following calls return false. metadata.contains("\\Use Constraints"); metadata.contains("Theme\\Geography");
key - is the key to test.true if the key is found; false otherwise.public int getNumberChildren()
public Metadata get(String key)
key - the key that indicates the node to return.null is returned.public String put(String key, String value)
key - key with which the specified value is to be associated.value - value to be associated with the specified key.IllegalArgumentException - if the key is null or empty.public void put(String key, Metadata value)
key - key with which the specified value is to be associated.value - metadata to be associated with the specified key.IllegalArgumentException - if the key is null or empty or if value is null.public void put(Metadata value)
value - the metadata to add.IllegalArgumentException - if value is null.public void putAll(Metadata metadata)
metadata - Parent of the metadata nodes to be copied and stored as child nodes of this node.public void delete(Metadata child)
child - the Metadata child to remove from this node's list of child nodes.public void delete(String key)
key - specifies the child metadata node to remove.IllegalArgumentException - if the key is null or othewrwise malformed.public void clear()
public Metadata getCopy()
public Iterator iterator()
getMetadataIterator().public Iterator getMetadataIterator()
public Iterator getDictionaryIterator()
getDictionaryIterator(false).public Iterator getDictionaryIterator(boolean bAllMappings)
Package Description.
The following block of code:
|
"\Identification" = "" "\Identification\Use Constraints" = "For use with MapXtreme" "\Identification\Description" = "" "\Identification\Description\Memo" = "Edited India boundaries - 3/10/1999" "\Identification\Time Period" = "" "\Identification\Time Period\Currentness" = "1995" "\Identification\Keywords" = "" "\Identification\Keywords\Theme" = "" "\Identification\Keywords\Theme\Geography" = "World" |
true to false, the following output would
be generated:
"\Identification\Use Constraints" = "For use with MapXtreme" "\Identification\Description\Memo" = "Edited India boundaries - 3/10/1999" "\Identification\Time Period\Currentness" = "1995" "\Identification\Keywords\Theme\Geography" = "World" |
bAllMappings - true indicates that all key mappings, including those
with empty values, will be returned by the iterator; false indicates
that only mappings with non-empty values will be returned.© 2007, 2022 Precisely. All rights reserved.