Vordel SDK

com.vordel.es
Class Field

java.lang.Object
  extended by com.vordel.es.Field
All Implemented Interfaces:
java.lang.Comparable<Field>

public class Field
extends java.lang.Object
implements java.lang.Comparable<Field>

A Field is a typed component part of an Entity, containing zero, one or more values.
An Entity typically contains several Fields. A Field's type is defined by a corresponding FieldType, which is owned by the Entity's EntityType. A Field is uniquely identified in an Entity by its name. A Field's values' cardinality is defined in the EntityType.


Field Summary
protected  java.util.List<Value> vals
          The Values in the field
 
Constructor Summary
Field(Field field)
          Convenience constructor to create a duplicate field.
Field(FieldType type, java.lang.String name)
          Constructor for a field with no values.
Field(FieldType type, java.lang.String name, Value[] values)
          Constructor for a field with new values.
 
Method Summary
 void addValue(Value v)
          Add a new value to the Field.
 Field clone()
           
 int compareTo(Field other)
           
 boolean containsReference(ESPK refPK)
          Check this Field to see if it contains a reference to the specified Entity.
static java.lang.String describe(Field[] fvals)
          Convenience method to describe fields
 boolean equals(java.lang.Object other)
          Determine if this field is equal to the other specified field.
 java.lang.String getName()
          Get the name of this field
 ESPK getReference()
          Return the reference value for the field if it's a reference type field.
 java.util.Collection<ESPK> getRefs()
          Assume values are references, and fetch as an array.
 FieldType getType()
          Get the type of this field
 java.util.List<Value> getValueList()
          Get a copy of this Field's Values List
 Value[] getValues()
          Get the values for this field as an array
 boolean hasValue()
          Determine if this field has any values set.
 boolean isRefType()
          Is field a Reference Type
 void populateNonNullSoftRefs(java.util.Set<PortableESPK> set)
           
 void setReferenceValue(int index, ESPK targetPK)
           
 boolean setValues(java.util.List<Value> values)
          Set the values for this Field.
 void setValues(Value[] values)
          Set all the values in the Field
 java.lang.String toString()
          A user-friendly string description of this Field.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

vals

protected java.util.List<Value> vals
The Values in the field

Constructor Detail

Field

public Field(FieldType type,
             java.lang.String name)
Constructor for a field with no values.

Parameters:
type - The type of the Field.
name - The name of the field, uniquely identifying it in a given Entity.

Field

public Field(FieldType type,
             java.lang.String name,
             Value[] values)
      throws EntityStoreException
Constructor for a field with new values.

Parameters:
name -
values -
Throws:
EntityStoreException

Field

public Field(Field field)
      throws EntityStoreException
Convenience constructor to create a duplicate field.

Parameters:
field -
Throws:
EntityStoreException
Method Detail

clone

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

addValue

public void addValue(Value v)
              throws EntityStoreException
Add a new value to the Field.

Parameters:
v - The new Value to add to the Field.
Throws:
An - EntityStoreException if the Value contravenes the cardinality constraints for this Field.
EntityStoreException

setValues

public void setValues(Value[] values)
               throws EntityStoreException
Set all the values in the Field

Parameters:
values -
Throws:
EntityStoreException

setValues

public boolean setValues(java.util.List<Value> values)
                  throws EntityStoreException
Set the values for this Field.

Parameters:
values - A List of Values to be set. Cardinality constraints will be applied to the list.
Throws:
EntityStoreException - If the values contravene the cardinality constraints.

getValues

public Value[] getValues()
Get the values for this field as an array

Returns:
The array of Values in this field.

getValueList

public java.util.List<Value> getValueList()
Get a copy of this Field's Values List

Returns:
A list of Values.

getName

public java.lang.String getName()
Get the name of this field

Returns:
The name of the Field.

getType

public FieldType getType()
Get the type of this field

Returns:
The type of the Field.

isRefType

public boolean isRefType()
Is field a Reference Type


describe

public static final java.lang.String describe(Field[] fvals)
Convenience method to describe fields

Parameters:
fvals - An array of Fields.
Returns:
a human friendly String describing the fields.

getRefs

public java.util.Collection<ESPK> getRefs()
Assume values are references, and fetch as an array.


containsReference

public boolean containsReference(ESPK refPK)
Check this Field to see if it contains a reference to the specified Entity.

Parameters:
refPK - The referenced Entity's ESPK
Returns:
true if one of the references in this Field links to the specified Entity, otherwise false.
Throws:
java.lang.IllegalArgumentException - if the Field isn't of a reference type or the supplied ESPK is null.

getReference

public ESPK getReference()
Return the reference value for the field if it's a reference type field.

Returns:
The reference, or the null PK if the field is not set
Throws:
java.lang.IllegalArgumentException - if the field is not a reference type or the cardinality of the field is greater than one.

toString

public java.lang.String toString()
A user-friendly string description of this Field.

Overrides:
toString in class java.lang.Object
Returns:
String representation of the Field.

equals

public boolean equals(java.lang.Object other)
Determine if this field is equal to the other specified field.

Overrides:
equals in class java.lang.Object
Returns:
true if the fields are equal in type, name and values, otherwise false.

hasValue

public boolean hasValue()
Determine if this field has any values set.

Returns:
true if the field has at least one non-null value, false otherwise.

compareTo

public int compareTo(Field other)
Specified by:
compareTo in interface java.lang.Comparable<Field>

populateNonNullSoftRefs

public void populateNonNullSoftRefs(java.util.Set<PortableESPK> set)

setReferenceValue

public void setReferenceValue(int index,
                              ESPK targetPK)

Vordel SDK


This documentation and all its contents and graphics, copyright © 1999 - 2011 Vordel