org.sixdml.query
Class SixdmlQueryResultsMap

java.lang.Object
  |
  +--org.sixdml.query.SixdmlQueryResultsMap
All Implemented Interfaces:
SixdmlConstants

public class SixdmlQueryResultsMap
extends Object
implements SixdmlConstants

  
 SixdmlQueryResultsMap.java

 A hashtable containing mappings between the results of an XPath query 
 over a collection and the resources the query results came from. The 
 primary benefit of this class is its ability to convert itself to 
 XML if it conatins nodes or nodesets. 
 
This class is not thread-safe. Created: Wed Jan 16 00:39:15 2002

Version:
1.0
Author:
Dare Obasanjo

Field Summary
private  String colName
          The name or path to the collection that was queried to obtain this data.
private  String query
          The query whose results are being used to populate this collection
private  HashMap resultsTable
          This is the table of containing mappings of resource names to query results.
 
Fields inherited from interface org.sixdml.SixdmlConstants
SIXDML_NS, SIXDML_VERSION
 
Constructor Summary
SixdmlQueryResultsMap(String colName, String query)
          Default constructor initializes class.
 
Method Summary
 void clear()
          Removes all mappings from this map.
 boolean containsKey(String key)
          Returns true if this map contains a mapping for the specified key.
 boolean containsValue(String value)
          Returns true if this map contains a mapping for the specified value.
 Set entrySet()
          Returns a collection view of the mappings contained in this map.
 String get(String key)
          Returns the value to which the specified key is mapped in this identity hash map, or null if the map contains no mapping for this key.
 String getCollectionName()
          Get the value of name of the collection that was queried to create this object.
 String getQuery()
          Get the value of query.
 String getXML()
          Returns an XML representation of the data in this object as a string.
 boolean isEmpty()
          Returns true if this map contains no key-value mappings.
 String put(String resource, String queryResults)
          Associates the specified value with the specified key in this map.
 String remove(String resource)
          Removes the mapping for this key from this map if present.
 int size()
          Returns the number of key-value mappings in this map.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

resultsTable

private HashMap resultsTable
This is the table of containing mappings of resource names to query results.

query

private String query
The query whose results are being used to populate this collection

colName

private String colName
The name or path to the collection that was queried to obtain this data.
Constructor Detail

SixdmlQueryResultsMap

public SixdmlQueryResultsMap(String colName,
                             String query)
Default constructor initializes class.
Parameters:
colName - the name of the collection that this query result object holds data for.
query - the query string that generated the results.
Method Detail

getCollectionName

public String getCollectionName()
Get the value of name of the collection that was queried to create this object.
Returns:
the name or path to the collection. .

getQuery

public String getQuery()
Get the value of query.
Returns:
Value of query.

clear

public void clear()
Removes all mappings from this map.

containsKey

public boolean containsKey(String key)
Returns true if this map contains a mapping for the specified key.
Parameters:
key - The key whose presence in this map is to be tested. The key should be the name or path to a resource in the collection that was queried to populate this object.
Returns:
true if this map contains a mapping for the specified key.

containsValue

public boolean containsValue(String value)
Returns true if this map contains a mapping for the specified value.
Parameters:
value - The value whose presence in this map is to be tested. The value should be a String.
Returns:
true if this map contains a mapping for the specified value.

isEmpty

public boolean isEmpty()
Returns true if this map contains no key-value mappings.
Returns:
true if this map contains no key-value mappings

size

public int size()
Returns the number of key-value mappings in this map.
Returns:
the number of key-value mappings in this map.

entrySet

public Set entrySet()
Returns a collection view of the mappings contained in this map. Each element in the returned collection is a Map.Entry. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa.
Returns:
collection view of the mappings contained in this map.
See Also:
Map.Entry

get

public String get(String key)
Returns the value to which the specified key is mapped in this identity hash map, or null if the map contains no mapping for this key. A return value of null does not necessarily indicate that the map contains no mapping for the key; it is also possible that the map explicitly maps the key to null. The containsKey method may be used to distinguish these two cases.
Parameters:
key - the key whose associated value is to be returned. The key should be the name or path to a resource in the collection that was queried to populate this object.
Returns:
the value to which this map maps the specified key, or null if the map contains no mapping for this key.

put

public String put(String resource,
                  String queryResults)
Associates the specified value with the specified key in this map. If the map previously contained a mapping for this key, the old value is replaced.
Parameters:
resource - key with which the specified value is to be associated.
queryResults - value to be associated with the specified key.
Returns:
previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the Map previously associated null with the specified key.

remove

public String remove(String resource)
Removes the mapping for this key from this map if present.
Parameters:
resource - key whose mapping is to be removed from the map.
Returns:
previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key.

getXML

public String getXML()
Returns an XML representation of the data in this object as a string. The XML returned by the node conforms to the following DTD.
 <!ELEMENT query-results (query)+ > 
 <!ATTLIST query-results collection-name CDATA #REQUIRED >
 <!ATTLIST query-results query CDATA #REQUIRED >
 <!ELEMENT query-result (#PCDATA)>   
 <!ATTLIST query-result resource-name CDATA #REQUIRED >
 
Returns:
an XML representation of the data in the map.