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
-
isFormal
- The flag to indicate that this Field is formal.
-
theName
- The name of the Field.
-
theType
- The type of the Field, which can be any arbitrary Java Class.
-
theTypeString
-
-
theValue
- The value of the Field, which is any arbitrary Java Serializable instance.
-
Field(Class)
- Create a Field that has the Class as its type.
-
Field(Class, Serializable)
- Create a Field that has the value Object.
-
Field(double)
- Create a Field for the integral type "double" by wrapping it as a Double.
-
Field(Field)
- Create a Field from another Field.
-
Field(float)
- Create a Field for the integral type "float" by wrapping it as a Float.
-
Field(int)
- Create a Field for the integral type "int" by wrapping it as a Integer.
-
Field(long)
- Create a Field for the integral type "long" by wrapping it as a Long.
-
Field(Serializable)
- Create a Field that has the value Object.
-
Field(String, Class)
- Create a named Field that has the Class as its type.
-
Field(String, Class, Serializable)
- Create a named Field that has the Class as its type and the passed
Object as its value.
-
Field(String, double)
- Create a named Field for the integral type "double" by wrapping it as a
Double.
-
Field(String, float)
- Create a named Field for the integral type "float" by wrapping it as a
Float.
-
Field(String, int)
- Create a named Field for the integral type "int" by wrapping it as a
Integer.
-
Field(String, long)
- Create a named Field for the longegral type "long" by wrapping it as a
Long.
-
Field(String, Serializable)
-
Create a named Field that has the value Serializable.
-
assign(Field)
- Assign the type and value of another Field to this Field.
-
formal()
- Return true if the Field is "formal", meaning that it only
has a type and not a value.
-
main(String[])
- Test routine for Field
-
makeField(String)
- Construct a formal Field instance from the name of a class.
-
matches(Field)
- Return true if the specified Field matches this Field.
-
name()
- Return the name of the Field.
-
setFormal()
- Set this Field to be formal.
-
setName(String)
- Set the name of the Field.
-
setType(Class)
- Set the type of the Field.
-
setValue(Serializable)
- Set the value of the Field to be any Serializable.
-
toString()
- Return a String that represents the Field.
-
type()
- Return the Class instance that represents the type of the Field.
-
value()
- Return the value of the Field.
theName
protected String theName
- The name of the Field. A Field name is not mandatory.
theType
protected Class theType
- The type of the Field, which can be any arbitrary Java Class.
theTypeString
protected String theTypeString
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.
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.
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
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
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.
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
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
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
Field
public Field(Field f)
- Create a Field from another Field. The name is not copied.
- Parameters:
- f - The Field to copy.
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
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
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
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
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
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
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
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
setName
public void setName(String name)
- Set the name of the Field.
- Parameters:
- name - The new name of the Field.
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.
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
setFormal
public void setFormal()
- Set this Field to be formal. (Also sets theValue to null.)
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.
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..
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.
value
public Serializable value()
- Return the value of the Field.
- Returns:
- An Serializable instance that is the value of the Field.
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.
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.
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
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.
main
public static void main(String argv[])
- Test routine for Field
All Packages Class Hierarchy This Package Previous Next Index