planetj.database
Class FieldCollection

java.lang.Object
  |
  +--planetj.database.FieldCollection
All Implemented Interfaces:
Cloneable, Serializable

public class FieldCollection
extends Object
implements Serializable, Cloneable

Contains a group of Fields. The contained fields can be retrieved by index (the first field added to this FieldCollection has an index of 1, the second has an index of 2, etc), or by name.

Author:
PlanetJ Corporation
See Also:
Serialized Form

Field Summary
static Comparator DISPLAY_ORDER_COMPARATOR
           
static Comparator NAME_COMPARATOR
           
 
Constructor Summary
FieldCollection()
          FieldCollection constructor comment.
 
Method Summary
 void add(Field pField)
          Adds the given field to this FieldCollection.
 void clearFields()
          Removes all the Fields from this FieldCollection.
 Map getAutoUpdateFields()
          Returns a Map of Fields (keyed by name) that have been updated.
 Map getCopiedFieldValues()
          Returns a Map of field values, keyed by field name.
 List getDisplayOrderedFields()
          Returns a list of the fields in display order specified in the Field Descriptors.
 Field getField(int pIndex)
          Returns the Field with the given index.
 Field getField(String pFieldName)
          Returns the Field with the given name.
 String getFieldName(int pIndex)
          Returns the Field name located at the specified index.
 List getFieldNames()
          Gets a List containing the names of the contained Fields.
 Map getFields()
          Returns a Map of Fields keyed by Field name.
 List getFields(Class pFieldClass)
          Returns a List with all the fields that are equal or subclasses to pFieldClass
 List getNamesOfUpdatedFields()
          Returns a List of names of Fields that have been updated.
 List getOrderedFields()
          Returns a list of the fields in order they were added to this FieldCollection Creation date: (12/11/2001 3:07:35 AM)
 List getPhysicalFieldNames()
          Gets a List containing the names of contained Fields excluding those that are not physically present in the database
 Map getUpdatedFields()
          Returns a Map of Fields (keyed by name) that have been updated.
 boolean isEmpty()
          Returns whether or not this FieldCollection has any Fields.
 Iterator iterator()
          Returns all the fields in an Iterator
 void replace(Field pField)
          Replaces the Field with the name of the given Field.
 List replaceFieldValues(Map nameValueMap)
          Replaces the values in one or more fields.
 int size()
          Returns the number of Fields contained in this FieldCollection.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DISPLAY_ORDER_COMPARATOR

public static final Comparator DISPLAY_ORDER_COMPARATOR

NAME_COMPARATOR

public static final Comparator NAME_COMPARATOR
Constructor Detail

FieldCollection

public FieldCollection()
FieldCollection constructor comment.

Method Detail

add

public void add(Field pField)
         throws DataEngineException
Adds the given field to this FieldCollection.

DataEngineException

clearFields

public void clearFields()
Removes all the Fields from this FieldCollection.


getAutoUpdateFields

public Map getAutoUpdateFields()
                        throws CMException
Returns a Map of Fields (keyed by name) that have been updated.

Returns:
Map
CMException

getCopiedFieldValues

public Map getCopiedFieldValues()
                         throws CMException
Returns a Map of field values, keyed by field name. The returned Map is independent of the Row - alterations of the fields in the Row or the values in the Row's fields will not affect the values in the Map. Logical fields are not returned in the Map.

CMException

getDisplayOrderedFields

public List getDisplayOrderedFields()
Returns a list of the fields in display order specified in the Field Descriptors. If no display order was specified, the getOrderedFields is returned which is the order the fields were added to the collection. Normall this is the same as the database order, unless you create a new row and then it really doesn't know its database order. Creation date: (6/5/2002 2:46:12 PM)


getField

public Field getField(int pIndex)
Returns the Field with the given index. The first Field added to this FieldCollection has an index of 1, the second Field added has an index of 2, etc.


getField

public Field getField(String pFieldName)
Returns the Field with the given name.

Parameters:
pFieldName - String
Returns:
Field

getFieldName

public String getFieldName(int pIndex)
Returns the Field name located at the specified index.

Parameters:
pIndex - int
Returns:
String

getFieldNames

public List getFieldNames()
Gets a List containing the names of the contained Fields.


getFields

public Map getFields()
Returns a Map of Fields keyed by Field name.

Returns:
Map

getFields

public List getFields(Class pFieldClass)
Returns a List with all the fields that are equal or subclasses to pFieldClass

Parameters:
pFieldClass - Class
Returns:
List of Fields

getNamesOfUpdatedFields

public List getNamesOfUpdatedFields()
                             throws CMException
Returns a List of names of Fields that have been updated.

Returns:
List
CMException

getOrderedFields

public List getOrderedFields()
Returns a list of the fields in order they were added to this FieldCollection Creation date: (12/11/2001 3:07:35 AM)


getPhysicalFieldNames

public List getPhysicalFieldNames()
                           throws CMException
Gets a List containing the names of contained Fields excluding those that are not physically present in the database

Returns:
List
CMException

getUpdatedFields

public Map getUpdatedFields()
                     throws CMException
Returns a Map of Fields (keyed by name) that have been updated.

Returns:
Map
CMException

isEmpty

public boolean isEmpty()
Returns whether or not this FieldCollection has any Fields.

Returns:
boolean

iterator

public Iterator iterator()
Returns all the fields in an Iterator


replace

public void replace(Field pField)
             throws DataEngineException
Replaces the Field with the name of the given Field. If no Field exists with the same name as the given Field, an exception is thrown.

Parameters:
pField - Field
DataEngineException

replaceFieldValues

public List replaceFieldValues(Map nameValueMap)
                        throws CMException
Replaces the values in one or more fields. You should avoid invoking this method unless you are fairly certain all of the replacement values will be accepted by their field - if setting a replacement value causes an exception to be thrown the fields may be left in an inconsistent state, some containing their original values, some containing their replacement values.

Parameters:
nameValueMap - A mapping of field names (String objects) to values. Every field whose name is in the key set of the Map has its value replaced by the corresponding value in the Map.
Returns:
A List containing the names in the Map for which there were no fields, and whose values were therefore not added.
CMException

size

public int size()
Returns the number of Fields contained in this FieldCollection.

Returns:
int