lime
Class LimeTuple

java.lang.Object
  extended bylime.LimeTuple
Direct Known Subclasses:
MoteLimeTuple

public class LimeTuple
extends java.lang.Object

This class, LimeTuple, wraps all tuples returned by Lime to the user. It's main function is to allow method access to the tuple itself as well as to the additional fields of the tuples, e.g., the current and destination locations as well as the unique identifier assigned within Lime.

Author:
Amy L. Murphy
See Also:
LimeTupleSpace, LimeTemplate

Field Summary
(package private)  AgentLocation cur
           
(package private)  AgentLocation dest
           
(package private)  LimeTupleID id
           
(package private)  lights.interfaces.ITuple tuple
           
 
Constructor Summary
protected LimeTuple(AgentLocation cur, AgentLocation dest, LimeTupleID id, lights.interfaces.ITuple t)
          Construct a new LimeTuple from inside the Lime package ONLY.
  LimeTuple(lights.interfaces.ITuple t)
          Construct a new LimeTuple with the given contents.
 
Method Summary
(package private) static LimeTuple fromFlatToLimeTuple(lights.interfaces.ITuple flatT)
          Given a tuple, this method converts it to a LimeTuple.
 AgentLocation getCurrent()
          Get the current location associated with the tuple.
 AgentLocation getDestination()
          Get the destination of the tuple.
 LimeTupleID getID()
          get the tuple id.
 lights.interfaces.ITuple getTuple()
          Get the tuple.
 void setTuple(lights.interfaces.ITuple t)
          Set the tuple.
(package private)  lights.interfaces.ITuple toFlatTuple()
          Package only method to create the flat tuple for this LimeTuple.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tuple

lights.interfaces.ITuple tuple

id

LimeTupleID id

cur

AgentLocation cur

dest

AgentLocation dest
Constructor Detail

LimeTuple

protected LimeTuple(AgentLocation cur,
                    AgentLocation dest,
                    LimeTupleID id,
                    lights.interfaces.ITuple t)
Construct a new LimeTuple from inside the Lime package ONLY.

Parameters:
cur -
dest -
id -
t -

LimeTuple

public LimeTuple(lights.interfaces.ITuple t)
Construct a new LimeTuple with the given contents. current, and destination will be set to AgentLocation.UNSPECIFIED and ID will be set to null.

Parameters:
t - the tuple
Method Detail

getTuple

public lights.interfaces.ITuple getTuple()
Get the tuple.

Returns:
the tuple contents (a delimified tuple).

setTuple

public void setTuple(lights.interfaces.ITuple t)
Set the tuple. No copy is made.

Parameters:
t - the tuple to be used.

getID

public LimeTupleID getID()
get the tuple id.

Returns:
the tuple's unique ID, or null.

getCurrent

public AgentLocation getCurrent()
Get the current location associated with the tuple. Note, because the tuple being queried is "outside" Lime, this value is not necessarily the current locaiton of the tuple, but is instead the last known current location of the tuple.

Returns:
the last known current location of the tuple.

getDestination

public AgentLocation getDestination()
Get the destination of the tuple.

Returns:
the destination of the tuple

toFlatTuple

lights.interfaces.ITuple toFlatTuple()
Package only method to create the flat tuple for this LimeTuple. In a flat tuple, the first field is the TupleID, second is the current AgentLocation, third is the destination AgentLocation and the remaining fields are the contents of the tuple. Note: the tuple returned is a copy (however not a deep copy) of the tuple contained in LimeTuple

Returns:
a "limified" tuple

fromFlatToLimeTuple

static LimeTuple fromFlatToLimeTuple(lights.interfaces.ITuple flatT)
Given a tuple, this method converts it to a LimeTuple. If any of the fields are not of the proper type, (e.g., first field is LimeTupleID, second is AgentLocation, and third is AgentLocation), null is returned. Note: the tuple returned is a copy of the tuple passed as a parameter.

Parameters:
flatT - a limified tuple
Returns:
a delimified tuple inside a LimeTuple

toString

public java.lang.String toString()