grinda.client
Class Tuple

java.lang.Object
  extended by grinda.client.Tuple
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
SpecialTuple

public class Tuple
extends java.lang.Object
implements java.lang.Cloneable

An array of fields. Tuples are used to store every kind of data that will be inserted in a tuple space. They are matched by the tuple space operations according to the so called "associative matching semantic". This matching is done in the following manner:


Field Summary
protected  Field[] fields
           
protected  int size
           
 
Constructor Summary
Tuple()
          Creates a tuple
Tuple(int size)
          Creates a tuple with the given size
Tuple(java.lang.Object v)
          Creates a tuple with one field.
Tuple(java.lang.Object v1, java.lang.Object v2)
          Creates a tuple with two fields.
Tuple(java.lang.Object v1, java.lang.Object v2, java.lang.Object v3)
          Creates a tuple with three fields.
Tuple(java.lang.Object v1, java.lang.Object v2, java.lang.Object v3, java.lang.Object v4)
          Creates a tuple with four fields.
Tuple(java.lang.Object v1, java.lang.Object v2, java.lang.Object v3, java.lang.Object v4, java.lang.Object v5)
          Creates a tuple with five fields.
Tuple(java.lang.Object v1, java.lang.Object v2, java.lang.Object v3, java.lang.Object v4, java.lang.Object v5, java.lang.Object v6)
          Creates a tuple with six fields.
 
Method Summary
protected  void addField(int pos, java.lang.Object value)
           
 Tuple addField(java.lang.Object f)
          Adds a new field to the end of this tuple.
 java.lang.Object clone()
           
 boolean equals(java.lang.Object o)
          Implements the associative mapping between tuples and template
 Tuple getAbsoluteTemplate()
          Returns the absolute template for this tuple, i.e. the most general template with no actual values at all.
 Field getField(int index)
          Gets the indexth field of this tuple
 java.lang.String getFieldClassName(int index)
          Gets the class name of the indexth field of this tuple
 int getFieldCount()
          Gets the number of fields in this tuple
 java.lang.Object getFieldValue(int index)
          Gets the value of the indexth field of this tuple
protected  void initialize(java.lang.Object[] args)
          Support function for constructors
 boolean isTemplate()
          Checks if this tuple is a template
 void removeField(int index)
          Removes a field from the tuple.
 void setField(int index, java.lang.Object value)
          Replaces the indexth field of this tuple
 InternalTuple toInternalTuple()
          Converts this tuple to an internal tuple used to communicate with the service
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fields

protected Field[] fields

size

protected int size
Constructor Detail

Tuple

public Tuple()
Creates a tuple


Tuple

public Tuple(java.lang.Object v)
Creates a tuple with one field. The parameter is interpreted as follow:

Parameters:
v - Object

Tuple

public Tuple(java.lang.Object v1,
             java.lang.Object v2)
Creates a tuple with two fields. Each parameter is interpreted as follow:

Parameters:
v1 - the first object
v2 - the second object

Tuple

public Tuple(java.lang.Object v1,
             java.lang.Object v2,
             java.lang.Object v3)
Creates a tuple with three fields. Each parameter is interpreted as follow:


Tuple

public Tuple(java.lang.Object v1,
             java.lang.Object v2,
             java.lang.Object v3,
             java.lang.Object v4)
Creates a tuple with four fields. Each parameter is interpreted as follow:


Tuple

public Tuple(java.lang.Object v1,
             java.lang.Object v2,
             java.lang.Object v3,
             java.lang.Object v4,
             java.lang.Object v5)
Creates a tuple with five fields. Each parameter is interpreted as follow:


Tuple

public Tuple(java.lang.Object v1,
             java.lang.Object v2,
             java.lang.Object v3,
             java.lang.Object v4,
             java.lang.Object v5,
             java.lang.Object v6)
Creates a tuple with six fields. Each parameter is interpreted as follow:


Tuple

public Tuple(int size)
Creates a tuple with the given size

Parameters:
size -
Method Detail

addField

public Tuple addField(java.lang.Object f)
Adds a new field to the end of this tuple.

Parameters:
f - the field to add
Returns:
this tuple

removeField

public void removeField(int index)
Removes a field from the tuple.

Parameters:
index - the index of the field to remove (between 0 and getFieldCount()-1)

getFieldCount

public int getFieldCount()
Gets the number of fields in this tuple

Returns:
the number of fields in this tuple

getField

public Field getField(int index)
Gets the indexth field of this tuple

Parameters:
index - the index
Returns:
the choosen field

getFieldValue

public java.lang.Object getFieldValue(int index)
Gets the value of the indexth field of this tuple

Parameters:
index - the index
Returns:
the value

getFieldClassName

public java.lang.String getFieldClassName(int index)
Gets the class name of the indexth field of this tuple

Parameters:
index - the index
Returns:
the class name

setField

public void setField(int index,
                     java.lang.Object value)
Replaces the indexth field of this tuple

Parameters:
index - the index
value - object inserted

getAbsoluteTemplate

public Tuple getAbsoluteTemplate()
Returns the absolute template for this tuple, i.e. the most general template with no actual values at all.

Returns:
the absolute template

isTemplate

public boolean isTemplate()
Checks if this tuple is a template

Returns:
true if it is a template

toInternalTuple

public InternalTuple toInternalTuple()
Converts this tuple to an internal tuple used to communicate with the service

Returns:
the corresponding internal tuple

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Implements the associative mapping between tuples and template

Overrides:
equals in class java.lang.Object
Parameters:
o - the object the compare
Returns:
true if the associative mapping was successfull

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

initialize

protected void initialize(java.lang.Object[] args)
Support function for constructors

Parameters:
args - Object[]

addField

protected void addField(int pos,
                        java.lang.Object value)


Copyright © 2006 Sirio Capizzi. All Rights Reserved.