All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.tspaces.Field

java.lang.Object
   |
   +----com.ibm.tspaces.Field

public class Field
extends Object
implements Serializable
A Field is a type (Java Class) that may have an associated value (a Java class instance) and/or an associated name. If the Field is "formal" it has no value (for matching purposes). Note that this is different from having a null value.

Author:
Daniel Ford, Toby Lehman
See Also:
Tuple, TupleSpace

Variable Index

 o isFormal
The flag to indicate that this Field is formal.
 o theName
The name of the Field.
 o theType
The type of the Field, which can be any arbitrary Java Class.
 o theTypeString
 o theValue
The value of the Field, which is any arbitrary Java Serializable instance.

Constructor Index

 o Field(Class)
Create a Field that has the Class as its type.
 o Field(Class, Serializable)
Create a Field that has the value Object.
 o Field(double)
Create a Field for the integral type "double" by wrapping it as a Double.
 o Field(Field)
Create a Field from another Field.
 o Field(float)
Create a Field for the integral type "float" by wrapping it as a Float.
 o Field(int)
Create a Field for the integral type "int" by wrapping it as a Integer.
 o Field(long)
Create a Field for the integral type "long" by wrapping it as a Long.
 o Field(Serializable)
Create a Field that has the value Object.
 o Field(String, Class)
Create a named Field that has the Class as its type.
 o Field(String, Class, Serializable)
Create a named Field that has the Class as its type and the passed Object as its value.
 o Field(String, double)
Create a named Field for the integral type "double" by wrapping it as a Double.
 o Field(String, float)
Create a named Field for the integral type "float" by wrapping it as a Float.
 o Field(String, int)
Create a named Field for the integral type "int" by wrapping it as a Integer.
 o Field(String, long)
Create a named Field for the longegral type "long" by wrapping it as a Long.
 o Field(String, Serializable)
Create a named Field that has the value Serializable.

Method Index

 o assign(Field)
Assign the type and value of another Field to this Field.
 o formal()
Return true if the Field is "formal", meaning that it only has a type and not a value.
 o main(String[])
Test routine for Field
 o makeField(String)
Construct a formal Field instance from the name of a class.
 o matches(Field)
Return true if the specified Field matches this Field.
 o name()
Return the name of the Field.
 o setFormal()
Set this Field to be formal.
 o setName(String)
Set the name of the Field.
 o setType(Class)
Set the type of the Field.
 o setValue(Serializable)
Set the value of the Field to be any Serializable.
 o toString()
Return a String that represents the Field.
 o type()
Return the Class instance that represents the type of the Field.
 o value()
Return the value of the Field.

Variables

 o theName
 protected String theName
The name of the Field. A Field name is not mandatory.

 o theType
 protected Class theType
The type of the Field, which can be any arbitrary Java Class.

 o theTypeString
 protected String theTypeString
 o theValue
 protected Serializable theValue
The value of the Field, which is any arbitrary Java Serializable instance. The value can be null, provided that a Class is specified.

 o isFormal
 protected boolean isFormal
The flag to indicate that this Field is formal. Previously we checked that theValue was null, but that eliminates the possibility of passing null values through TupleSpace, which might be useful.

Constructors

 o Field
 public Field(Serializable v) throws TupleSpaceException
Create a Field that has the value Object. The type of the Field is the type (Class) of the value.

Parameters:
v - The value of the Field
Throws: TupleSpaceException
if there is a problem creating the field
 o Field
 public Field(Class t,
              Serializable v) throws TupleSpaceException
Create a Field that has the value Object. The Class parameter must be the same as the type of the Object. This method is used for Objects that might be null.

Parameters:
v - The value of the Field
Throws: TupleSpaceException
if there is a problem creating the field
 o Field
 public Field(String name,
              Class t,
              Serializable v) throws TupleSpaceException
Create a named Field that has the Class as its type and the passed Object as its value. Used for named Fields with possibly null values.

Parameters:
name - The name of the Field. null is allowed.
t - The type of the Field.
v - The value of the Field. null is allowed.
Throws: TupleSpaceException
If the type of the class does not match the type of the value.
 o Field
 public Field(Class t) throws TupleSpaceException
Create a Field that has the Class as its type. The Field does not have a value, this is used to specify a formal Field that can be used in a simple query to match another Field of this type that has any value.

Parameters:
t - The value of the class
Throws: TupleSpaceException
if there is a problem creating the field
 o Field
 public Field(String name,
              Class t) throws TupleSpaceException
Create a named Field that has the Class as its type. The Field does not have a value, this is used to specify a formal Field that can be used in a simple query to match another Field of this type that has any value.

Parameters:
name - The name of the Field.
t - The type of the Field.
Throws: TupleSpaceException
if there is a problem creating the field
 o Field
 public Field(String name,
              Serializable v) throws TupleSpaceException
Create a named Field that has the value Serializable. The type of the Field is the type (Class) of the value.

Parameters:
name - The name of the Field.
v - The value of the Field.
Throws: TupleSpaceException
if there is a problem creating the field
 o Field
 public Field(Field f)
Create a Field from another Field. The name is not copied.

Parameters:
f - The Field to copy.
 o Field
 public Field(float f_) throws TupleSpaceException
Create a Field for the integral type "float" by wrapping it as a Float.

Parameters:
f_ - The float that is the value of the new Field.
Throws: TupleSpaceException
if there is a problem creating the field
See Also:
Field, Float
 o Field
 public Field(String name,
              float f_) throws TupleSpaceException
Create a named Field for the integral type "float" by wrapping it as a Float.

Parameters:
name - The name of the Field.
f_ - The float that is the value of the new Field.
Throws: TupleSpaceException
if there is a problem creating the field
See Also:
Field, Float
 o Field
 public Field(double d_) throws TupleSpaceException
Create a Field for the integral type "double" by wrapping it as a Double.

Parameters:
d_ - The double that is the value of the new Field.
Throws: TupleSpaceException
if there is a problem creating the field
See Also:
Field, Double
 o Field
 public Field(String name,
              double d_) throws TupleSpaceException
Create a named Field for the integral type "double" by wrapping it as a Double.

Parameters:
name - The name of the Field.
d_ - The double that is the value of the new Field.
Throws: TupleSpaceException
if there is a problem creating the field
See Also:
Field, Double
 o Field
 public Field(int i_) throws TupleSpaceException
Create a Field for the integral type "int" by wrapping it as a Integer.

Parameters:
i_ - The int that is the value of the new Field.
Throws: TupleSpaceException
if there is a problem creating the field
See Also:
Field, Integer
 o Field
 public Field(String name,
              int i_) throws TupleSpaceException
Create a named Field for the integral type "int" by wrapping it as a Integer.

Parameters:
name - The name of the Field.
i_ - The int that is the value of the new Field.
Throws: TupleSpaceException
if there is a problem creating the field
See Also:
Field, Integer
 o Field
 public Field(long l_) throws TupleSpaceException
Create a Field for the integral type "long" by wrapping it as a Long.

Parameters:
l_ - The long that is the value of the new Field.
Throws: TupleSpaceException
if there is a problem creating the field
See Also:
Field, Long
 o Field
 public Field(String name,
              long l_) throws TupleSpaceException
Create a named Field for the longegral type "long" by wrapping it as a Long.

Parameters:
name - The name of the Field.
l_ - The long that is the value of the new Field.
Throws: TupleSpaceException
if there is a problem creating the field
See Also:
Field, Long

Methods

 o setName
 public void setName(String name)
Set the name of the Field.

Parameters:
name - The new name of the Field.
 o setType
 public void setType(Class t)
Set the type of the Field. This removes any value the Field may have had. This is used to specify a formal Field that can be used in a simple query to match a Field of this type with any value.

Parameters:
t - The new type of the Field.
 o setValue
 public void setValue(Serializable v) throws TupleSpaceException
Set the value of the Field to be any Serializable. The type of the Field is the type (Class) of the value.

Parameters:
v - The value of the Field.
Throws: TupleSpaceException
if there is a problem creating the field
 o setFormal
 public void setFormal()
Set this Field to be formal. (Also sets theValue to null.)

 o assign
 public void assign(Field f)
Assign the type and value of another Field to this Field. This does not assign the name.

Parameters:
f - The Field to be assigned.
 o name
 public String name()
Return the name of the Field. A Field is not required to have a name so the return value could be null.

Returns:
A String that is the name of the Field, or null if the Field doesn't have a name..
 o type
 public Class type()
Return the Class instance that represents the type of the Field.

Returns:
A Class instance that represents the type of the Field.
 o value
 public Serializable value()
Return the value of the Field.

Returns:
An Serializable instance that is the value of the Field.
 o formal
 public boolean formal()
Return true if the Field is "formal", meaning that it only has a type and not a value. A formal Field is used to do associative matching and is considered to be equal to any Field of the same type (Class).

Returns:
true if the Field has no value, false otherwise.
 o matches
 public boolean matches(Field f)
Return true if the specified Field matches this Field. Two Fields match if either is formal and they both have the same type. If neither is formal, then the two Fields match if they have the same type (Class) and their values are equal. Field names are not compared.

Override this method to change the matching behavior.

Parameters:
f - The Field to compare.
Returns:
true if the two Fields match, false otherwise.
 o toString
 public String toString()
Return a String that represents the Field. If the Field does not have a value then return the name of the Class that is the type of the Field. If the Field does have a value then return the string representation of the value of the Field.

Returns:
A String that represents the Field.
Overrides:
toString in class Object
 o makeField
 public static Field makeField(String className) throws TupleSpaceException
Construct a formal Field instance from the name of a class.

Parameters:
className - the name of the class that is the type of the Field.
Returns:
A formal Field whose type is the named class.
Throws: TupleSpaceException
if the named class is invalid or cannot be found.
 o main
 public static void main(String argv[])
Test routine for Field


All Packages  Class Hierarchy  This Package  Previous  Next  Index