|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The definition of a tuple, i.e., an ordered sequence of typed fields. The
type of a field can be any class implementing the
Serializable
interface. A field can either contain a value,
or be characterized just by its type. In Linda jargon, the former is
called an actual field, while the latter is called a formal
field. Tuples with formals are typically used as a template to
query the tuple space by pattern matching. Different matching rules can be
implemented by redefining the matches
method in
ITuple
or IField
. Tuple fields are accessed by
their index, with the first element conventionally set to index
0
.
The interface provides methods to manipulate the fields of a tuple in various ways. All methods return the tuple resulting from the manipulation, so that cascaded operations are possible, e.g.,
System.out.println(t.add(obj1).add(obj2).add(obj3).toString());
Method Summary | |
ITuple |
add(IField field)
Adds a field at the end of the tuple. |
ITuple |
addActual(java.io.Serializable obj)
Adds an actual field, whose value is the given object, at the end of the tuple. |
ITuple |
addFormal(java.lang.Class classObj)
Adds a formal field, whose type is the given class, at the end of the tuple. |
IField |
get(int index)
Returns the field at position index . |
IField[] |
getFields()
Returns all the fields in this tuple. |
ITuple |
insertAt(IField field,
int index)
Inserts the given field at position index . |
int |
length()
Returns the number of fields in the tuple. |
boolean |
matches(ITuple tuple)
Determines the rule used for pattern matching between tuples. |
ITuple |
removeAt(int index)
Removes the field at position index . |
ITuple |
set(IField field,
int index)
Replaces the field at position index with the given one. |
Method Detail |
public ITuple add(IField field)
public ITuple addActual(java.io.Serializable obj)
public ITuple addFormal(java.lang.Class classObj)
public ITuple set(IField field, int index)
index
with the given one.public IField get(int index)
index
.public ITuple insertAt(IField field, int index)
index
. All the fields
whose position is greater than index
are shifted downwards,
i.e., their index is increased by one.public ITuple removeAt(int index)
index
. The fields whose
position is greater than index
are shifted upwards, i.e.,
their index is decreased by one.public IField[] getFields()
public int length()
public boolean matches(ITuple tuple)
true
if the tuple passed as a parameter matches
this tuple, false
otherwise.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |