lime
Class LimeTemplate

java.lang.Object
  extended bylime.LimeTemplate
Direct Known Subclasses:
MoteLimeTemplate

public class LimeTemplate
extends java.lang.Object

This class, LimeTemplate, is used to wrap the tuple along with the extra fields to be matched, e.g., the current, destination, and tuple id fields.

See Also:
LimeTuple, LimeTupleSpace

Field Summary
(package private)  Location cur
           
(package private)  AgentLocation dest
           
(package private)  LimeTupleID id
           
(package private)  lights.interfaces.ITuple tuple
           
 
Constructor Summary
LimeTemplate(lights.interfaces.ITuple t)
          Construct a new LimeTemplate with the cur, dest, and tuple id formal.
LimeTemplate(Location cur, AgentLocation dest, LimeTupleID id, lights.interfaces.ITuple t)
          Construct a new LimeTemplate.
 
Method Summary
(package private) static LimeTemplate fromFlatToLimeTemplate(lights.interfaces.ITuple flatT)
          Given a tuple, this method converts it to a LimeTuple.
 Location getCurrent()
          Get the current location associated with the tuple.
 AgentLocation getDestination()
          Get the destination of the tuple.
 void getDestination(AgentLocation loc)
           
 LimeTupleID getID()
          get the tuple id.
 void getID(LimeTupleID id)
          get the tuple id.
 lights.interfaces.ITuple getTuple()
          Get the tuple.
 void setCurrent(Location loc)
           
 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

Location cur

dest

AgentLocation dest
Constructor Detail

LimeTemplate

public LimeTemplate(Location cur,
                    AgentLocation dest,
                    LimeTupleID id,
                    lights.interfaces.ITuple t)
Construct a new LimeTemplate.

Parameters:
cur - current location
dest - destination location
id - tuple id, or null for formal
t - the tuple

LimeTemplate

public LimeTemplate(lights.interfaces.ITuple t)
Construct a new LimeTemplate with the cur, dest, and tuple id formal.

Parameters:
t - the tuple
Method Detail

getTuple

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

Returns:
the tuple contents

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.

getID

public void getID(LimeTupleID id)
get the tuple id.

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

getCurrent

public Location 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.

setCurrent

public void setCurrent(Location loc)

getDestination

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

Returns:
the destination of the tuple

getDestination

public void getDestination(AgentLocation loc)

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

fromFlatToLimeTemplate

static LimeTemplate fromFlatToLimeTemplate(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()