org.apache.oodt.cas.metadata
Class Metadata

java.lang.Object
  extended by org.apache.oodt.cas.metadata.Metadata
Direct Known Subclasses:
SerializableMetadata

public class Metadata
extends Object

Metadata is a Map of String keys mapped to Object values. So, each key can map to potentially many values, but also can map to null, or to a single value.

Version:
$Revision$
Author:
mattmann, bfoster

Nested Class Summary
protected  class Metadata.Group
           
 
Constructor Summary
Metadata()
           
Metadata(Metadata metadata)
           
 
Method Summary
 void addMetadata(Hashtable<String,Object> metadata)
           
 void addMetadata(Hashtable<String,Object> metadata, boolean replace)
          Takes a hashtable of String keys and Object values.
 void addMetadata(Metadata metadata)
          Adds (Appends if key exists) from given metadata into this metadata
 void addMetadata(String key, List<String> values)
          Adds key (Appends if key exists)
 void addMetadata(String group, Metadata metadata)
           
 void addMetadata(String key, String value)
          Adds key (Appends if key exists)
 boolean containsGroup(String group)
           
 boolean containsKey(String key)
          Checks if keys exists
protected  Metadata.Group createNewRoot()
           
 boolean equals(Object obj)
           
 List<String> getAllKeys()
          Gets all keys in this Metadata
protected  List<String> getAllKeys(Metadata.Group group)
           
 List<String> getAllKeys(String group)
          Gets All key in and below given group
 List<String> getAllKeysWithName(String key)
          Get all keys whose leaf key name is equal to the given arg
 List<String> getAllMetadata(String key)
          Gets all values for give key
 List<String> getAllValues()
          Gets all values in this Metadata
 List<String> getAllValues(String group)
          Gets All values in and below given group
protected  Metadata.Group getGroup(String key)
           
protected  Metadata.Group getGroup(String key, boolean create)
           
 List<String> getGroups()
           
protected  List<String> getGroups(Metadata.Group group)
           
 List<String> getGroups(String group)
           
 Hashtable<String,Object> getHashtable()
           
 List<String> getKeys()
          Gets all keys in this Metadata
protected  List<String> getKeys(Metadata.Group group)
           
 List<String> getKeys(String group)
          Gets All key in and below given group
 String getMetadata(String key)
          Gets the first value for the given key
 Metadata getSubMetadata(String group)
          Creates a Metadata from the given group
 List<String> getValues()
          Gets Values in root group
 List<String> getValues(String group)
          Gets values in given group
 boolean isMultiValued(String key)
          Checks if key has more than one value
 void removeMetadata(String key)
          Removes key
 void removeMetadataGroup(String group)
          Removes key
 void replaceMetadata(Hashtable<String,Object> metadata)
           
 void replaceMetadata(Metadata metadata)
          Adds (Replaces if key exists) from given Metadata into this Metadata
 void replaceMetadata(String key, List<String> values)
          Adds key (Replaces if key exists)
 void replaceMetadata(String group, Metadata metadata)
           
 void replaceMetadata(String key, String value)
          Adds key (Replaces if key exists)
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Metadata

public Metadata()

Metadata

public Metadata(Metadata metadata)
Method Detail

addMetadata

public void addMetadata(Metadata metadata)
Adds (Appends if key exists) from given metadata into this metadata

Parameters:
metadata - Metadata to add metadata from

addMetadata

public void addMetadata(String group,
                        Metadata metadata)

replaceMetadata

public void replaceMetadata(Metadata metadata)
Adds (Replaces if key exists) from given Metadata into this Metadata

Parameters:
metadata -

replaceMetadata

public void replaceMetadata(String group,
                            Metadata metadata)

addMetadata

public void addMetadata(String key,
                        String value)
Adds key (Appends if key exists)

Parameters:
key - Key to be added
value - Value of key to be added

replaceMetadata

public void replaceMetadata(String key,
                            String value)
Adds key (Replaces if key exists)

Parameters:
key - Key to be added
value - Value of key to be added

addMetadata

public void addMetadata(String key,
                        List<String> values)
Adds key (Appends if key exists)

Parameters:
key - Key to be added
values - Values of key to be added

replaceMetadata

public void replaceMetadata(String key,
                            List<String> values)
Adds key (Replaces if key exists)

Parameters:
key - Key to be added
values - Values of key to be added

removeMetadata

public void removeMetadata(String key)
Removes key

Parameters:
key - Key to remove

removeMetadataGroup

public void removeMetadataGroup(String group)
Removes key

Parameters:
key - Key to remove

containsKey

public boolean containsKey(String key)
Checks if keys exists

Parameters:
key - Key to check for
Returns:
True if key exists, false otherwise

isMultiValued

public boolean isMultiValued(String key)
Checks if key has more than one value

Parameters:
key - Key to check for
Returns:
True is key exists and has more than one value, false otherwise

getSubMetadata

public Metadata getSubMetadata(String group)
Creates a Metadata from the given group

Parameters:
group - The Group to grab
Returns:
Metadata containing group and all keys below it

getMetadata

public String getMetadata(String key)
Gets the first value for the given key

Parameters:
key - The key for which the first value will be returned
Returns:
First value for given key, or null if key does not exist

getAllMetadata

public List<String> getAllMetadata(String key)
Gets all values for give key

Parameters:
key - The key for which all values will be return
Returns:
All values for given key, or null if key does not exist

getKeys

public List<String> getKeys(String group)
Gets All key in and below given group

Parameters:
group - The group in question
Returns:
All keys for the given group and below

getKeys

public List<String> getKeys()
Gets all keys in this Metadata

Returns:
All keys in this Metadata

getKeys

protected List<String> getKeys(Metadata.Group group)

getAllKeys

public List<String> getAllKeys(String group)
Gets All key in and below given group

Parameters:
group - The group in question
Returns:
All keys for the given group and below

getAllKeys

public List<String> getAllKeys()
Gets all keys in this Metadata

Returns:
All keys in this Metadata

getAllKeys

protected List<String> getAllKeys(Metadata.Group group)

getAllKeysWithName

public List<String> getAllKeysWithName(String key)
Get all keys whose leaf key name is equal to the given arg

Parameters:
key - leaf key name
Returns:
list of keys with the given leaf key name

getValues

public List<String> getValues()
Gets Values in root group

Returns:
All Values in root group

getValues

public List<String> getValues(String group)
Gets values in given group

Parameters:
group - Group in question
Returns:
Values in given group

getAllValues

public List<String> getAllValues()
Gets all values in this Metadata

Returns:
All values in this Metadata

getAllValues

public List<String> getAllValues(String group)
Gets All values in and below given group

Parameters:
group - Group in question
Returns:
All values in and below given group

addMetadata

public void addMetadata(Hashtable<String,Object> metadata)

addMetadata

public void addMetadata(Hashtable<String,Object> metadata,
                        boolean replace)
Takes a hashtable of String keys and Object values. Values of type List must be a List of Strings; all other values will have its toString() method invoked.

Parameters:
metadata - Hashtable based metadata to add
replace - If true, existing keys will be replaced, other values will be combined.

replaceMetadata

public void replaceMetadata(Hashtable<String,Object> metadata)

containsGroup

public boolean containsGroup(String group)

getGroups

public List<String> getGroups()

getGroups

public List<String> getGroups(String group)

getGroups

protected List<String> getGroups(Metadata.Group group)

getGroup

protected Metadata.Group getGroup(String key)

getGroup

protected Metadata.Group getGroup(String key,
                                  boolean create)

createNewRoot

protected Metadata.Group createNewRoot()

getHashtable

public Hashtable<String,Object> getHashtable()

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © 1999-2011 Apache Incubator. All Rights Reserved.