com.ibm.tspaces.examples.handler
Class StaleTuple

java.lang.Object
  |
  +--com.ibm.tspaces.SuperTuple
        |
        +--com.ibm.tspaces.SubclassableTuple
              |
              +--com.ibm.tspaces.examples.handler.StaleTuple

public class StaleTuple
extends SubclassableTuple

A StaleTuple is an ordered sequence of Fields where the first field is a TimeToDie timestamp that is stored at the time that the Tuple is written. This first field is hidden from the application.

For the purposes of this example the 2nd field is a string and and is indexed. The 3rd field is also a String but is not indexed. Other applications would define these differently.

Author:
Pete Wyckoff, John Thomas
See Also:
Tuple, SuperTuple, Field, TupleSpace, Serialized Form

Constructor Summary
StaleTuple()
          constructor with no arguments builds a template tuple
StaleTuple(StaleTimestamp timestamp)
          constructor with StaleTimestamp specified.
StaleTuple(java.lang.String key)
          constructor with one String argument builds a template tuple to do simple match retrieve based on Field2
StaleTuple(java.lang.String key, java.lang.String data)
          constructor just calls the super tuple constructor
 
Method Summary
 java.lang.String getData()
          This method will return the data Field from the tuple.
 java.lang.String getKey()
          This method will return the key Field from the tuple.
 void setData(java.lang.String data)
          This method will set the data Field from the tuple.
 void setKey(java.lang.String key)
          This method will set the Key Field from the tuple.
 void setTimeToLive(long time)
          Sets the time to live value
 void updateExpirationDate()
          Sets the first Field to the date/time stanp when the object is elgible for deletion.
 
Methods inherited from class com.ibm.tspaces.SuperTuple
add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, addFieldType, changeName, clone, equals, fieldExists, fields, getExpire, getField, getField, getFieldType, getTimeStamp, getTupleID, isExpired, matches, numberOfFields, putField, setExpire, setField, setFields, setFormal, setFormal, setFormal, setFormal, setName, setTimeStamp, setTupleID, setType, setType, setValue, setValue, structureName, template, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StaleTuple

public StaleTuple()
           throws TupleSpaceException
constructor with no arguments builds a template tuple

StaleTuple

public StaleTuple(StaleTimestamp timestamp)
           throws TupleSpaceException
constructor with StaleTimestamp specified. It will return a template with the timestamp specified

StaleTuple

public StaleTuple(java.lang.String key)
           throws TupleSpaceException
constructor with one String argument builds a template tuple to do simple match retrieve based on Field2

StaleTuple

public StaleTuple(java.lang.String key,
                  java.lang.String data)
           throws TupleSpaceException
constructor just calls the super tuple constructor
Parameters:
obj1 - an object that will be in a field
obj2 - an object that will be in a field
Method Detail

getData

public java.lang.String getData()
                         throws TupleSpaceException
This method will return the data Field from the tuple.
Returns:
String that contains the "Data" field from Tuple

setData

public void setData(java.lang.String data)
             throws TupleSpaceException
This method will set the data Field from the tuple.
Parameters:
data - String that should be placed in the "Data" field of Tuple

getKey

public java.lang.String getKey()
                        throws TupleSpaceException
This method will return the key Field from the tuple.
Returns:
String that contains the "Key" field from Tuple

setKey

public void setKey(java.lang.String key)
            throws TupleSpaceException
This method will set the Key Field from the tuple.
Parameters:
key - String that should be placed in the "Key" field of Tuple

setTimeToLive

public void setTimeToLive(long time)
Sets the time to live value
Parameters:
timetolive - The time in MS that should expire before the Tuple is elgible for deletion..

updateExpirationDate

public void updateExpirationDate()
                          throws TupleSpaceException
Sets the first Field to the date/time stanp when the object is elgible for deletion.

This method is used by the StaleTupleSpaceHandler to update field 0 when the Write command is invoked in the server.