org.iids.aos.systemservices.lookupservice
Class LookupResult

java.lang.Object
  extended by org.iids.aos.systemservices.lookupservice.LookupResult

public class LookupResult
extends java.lang.Object

From the Lookupservice we receive an answer to a lookup() query in the form of a mapping of a 'key' to a bag of (expirytime, creationtime, value, userid) tuples. Each tuple corresponds to an entry in the lookup service that (a) matches the query and (b) whose 'key' field corresponds to the key of this mapping. The key->bag mapping is a Hashtable; the bag is a Vector; a tuple is also a Vector. This looks rather complicated (and it is) but is necessary to support multiple entries making different assertions about an ID, all with different expiry times or values. Note that the 'ID' field of a lookup service entry does not appear anywhere in the above. The find() and list() queries of the lookup service return another mapping in which the above mapping is embedded, namely a mapping of 'ID' field to the above key->bag mapping. This mapping is also a Hashtable. This utility class parses the key->bag mapping, and provides some accessor methods.


Field Summary
 java.util.Hashtable result
           
 
Constructor Summary
LookupResult(java.util.Hashtable _result)
           
 
Method Summary
 java.lang.String getEarliestExpiry(java.lang.String key)
           
 java.lang.String getLatestExpiry(java.lang.String key)
           
 java.lang.String getNewest(java.lang.String key)
          Get newest tuple with corresponding key from the lookup result.
 long getNewestExpiryTime(java.lang.String key)
          Returns the Expiry time in milliseconds since the UNIX epoch of the newest entry for the specified key.
 java.lang.String getOldest(java.lang.String key)
          Get oldest tuple with corresponding key from the lookup result.
 java.lang.Object getSorted(java.lang.String key, int sortKeyPosition, int valuePosition, boolean head)
          Sorts all the entries with 'key' in the result set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

result

public java.util.Hashtable result
Constructor Detail

LookupResult

public LookupResult(java.util.Hashtable _result)
Method Detail

getSorted

public java.lang.Object getSorted(java.lang.String key,
                                  int sortKeyPosition,
                                  int valuePosition,
                                  boolean head)
Sorts all the entries with 'key' in the result set. Returns either the head of the tail of the sort queue, depending on the value of the head parameter.

Parameters:
key - Key to filter the tuples. If it is null, then all tuples will match.
sortKeyPosition - Column in the resulting tuples to use for sorting.
valuePosition - Column in the resulting tuples containing results.
head - If true then returns head element of sorted result tuples, otherwise returns the tail element.
Returns:
The sorted head (or tail) element.

getOldest

public java.lang.String getOldest(java.lang.String key)
Get oldest tuple with corresponding key from the lookup result.

Parameters:
key - The key of the tuple to look for, or null if no key filtering is required for the result.
Returns:
The oldest tuple in the result set.

getNewest

public java.lang.String getNewest(java.lang.String key)
Get newest tuple with corresponding key from the lookup result.

Parameters:
key - The key of the tuple to look for, or null if no key filtering is required for the result.
Returns:
The newest tuple in the result set.

getNewestExpiryTime

public long getNewestExpiryTime(java.lang.String key)
Returns the Expiry time in milliseconds since the UNIX epoch of the newest entry for the specified key. Note: return milliseconds even though the lookup service returns a Double in seconds.


getEarliestExpiry

public java.lang.String getEarliestExpiry(java.lang.String key)

getLatestExpiry

public java.lang.String getLatestExpiry(java.lang.String key)


Copyright © 2003, 2004 IIDS Group. All Rights Reserved.