com.xerox.bantam
Class FieldDescriptor

java.lang.Object
  |
  +--com.xerox.bantam.FieldDescriptor
All Implemented Interfaces:
Serializable

public class FieldDescriptor
extends Object
implements Serializable

A FieldDescriptor is an immutable representation of a Bantam property constraint. FieldDescriptors form the body of schemas as they describe constraints on properties in a schema. Storage implementations use this information to implement schema enforcement and possibly to optimize storage and query processing.

To enable efficient Schema validation, FieldDescriptors must be immutable. This is the reason why most methods may not be overridden in subclasses. In general, subclassing FieldDescriptor is discouraged.

Version:
$Revision: 1.11 $, $Date: 2000/11/27 21:16:19 $
Author:
Tom Rodriguez
See Also:
Serialized Form

Constructor Summary
FieldDescriptor(String name, Class t)
          Simple form constructor for required fields limited to a single value.
FieldDescriptor(String n, Class clazz, boolean optional)
          Abbreviated constructor for fields limited to a single value but possibly optional.
FieldDescriptor(String n, Class clazz, int maxValues, boolean optional)
          Full constructor taking Class object.
FieldDescriptor(String n, String[] values, boolean optional)
          Abbreviated constructor for enumeration field limited to a single value but possibly optional.
FieldDescriptor(String n, String[] values, int maxValues, boolean optional)
          Full constructor for enumeration field.
 
Method Summary
 boolean equals(Object o)
           
 boolean equalsType(FieldDescriptor other)
          Restricted equivalence test that returns true if the supplied descriptor imposes the same value type restriction as this descriptor.
 Class getBaseType()
           
static FieldDescriptor getDescriptor(String name)
          Retrieve the canonical instance of a descriptor by name.
 int getMaxValues()
           
 String getName()
           
 TypeDescriptor getType()
           
 long getVersion()
          Return a version stamp which is a signature value for this descriptor.
 int hashCode()
           
 boolean isNegated()
           
 boolean isOptional()
           
 boolean isValid(Object value)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FieldDescriptor

public FieldDescriptor(String name,
                       Class t)
Simple form constructor for required fields limited to a single value. Throws no regular exceptions so that it may be used in a static initializer.
Parameters:
name - the property name
t - the Class of value

FieldDescriptor

public FieldDescriptor(String n,
                       Class clazz,
                       boolean optional)
Abbreviated constructor for fields limited to a single value but possibly optional. Throws no regular exceptions so that it may be used in a static initializer.
Parameters:
n - the property name
clazz - the Class of property values
optional - true if property is optional

FieldDescriptor

public FieldDescriptor(String n,
                       String[] values,
                       boolean optional)
Abbreviated constructor for enumeration field limited to a single value but possibly optional. Throws no regular exceptions so that it may be used in a static initializer. The Class of an enumeration value is String, but only the specified Strings are legal values
Parameters:
n - the property name
values - the list of legal values
maxValues - the maximum number of values, -1=unlimited, 0=property not permitted
optional - true if property is optional

FieldDescriptor

public FieldDescriptor(String n,
                       Class clazz,
                       int maxValues,
                       boolean optional)
Full constructor taking Class object. Throws no regular exceptions so that it may be used in a static initializer.
Parameters:
n - the property name
clazz - the Class of property values
maxValues - the maximum number of values, -1=unlimited, 0=property not permitted
optional - true if property is optional

FieldDescriptor

public FieldDescriptor(String n,
                       String[] values,
                       int maxValues,
                       boolean optional)
Full constructor for enumeration field. Throws no regular exceptions so that it may be used in a static initializer. The Class of an enumeration value is String, but only the specified Strings are legal values
Parameters:
n - the property name
values - the list of legal values
maxValues - the maximum number of values, -1=unlimited, 0=property not permitted
optional - true if property is optional
Method Detail

getName

public final String getName()

getType

public final TypeDescriptor getType()

getBaseType

public final Class getBaseType()

getMaxValues

public final int getMaxValues()

isOptional

public final boolean isOptional()

isNegated

public final boolean isNegated()

isValid

public final boolean isValid(Object value)

equals

public boolean equals(Object o)
Overrides:
equals in class Object

equalsType

public boolean equalsType(FieldDescriptor other)
Restricted equivalence test that returns true if the supplied descriptor imposes the same value type restriction as this descriptor. The value type includes the legal set of values and the legal number of values but does not include optional or negated which are features of the relationship to a particular schema not the allowable values.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getDescriptor

public static FieldDescriptor getDescriptor(String name)
Retrieve the canonical instance of a descriptor by name.
Parameters:
name - the name of the descriptor to retrieve

getVersion

public long getVersion()
Return a version stamp which is a signature value for this descriptor. The signature is computed similarly to the computation of Java serialVersionUIDs.

toString

public final String toString()
Overrides:
toString in class Object

Project Harland