planetj.database
Class FieldCollection

java.lang.Object
  extended byplanetj.database.FieldCollection
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class FieldCollection
extends java.lang.Object
implements java.io.Serializable, java.lang.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 0, the second has an index of 1, etc), or by name.

See Also:
Serialized Form

Field Summary
static java.util.Comparator DISPLAY_ORDER_COMPARATOR
           
static java.util.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.
protected  FieldCollection cloneFieldCollection(Row pNewRow)
          Clones this FieldCollection
 java.util.Map getAutoUpdateFields()
          Returns a Map of Fields (keyed by name) that have been updated.
 java.util.Map getCopiedFieldValues()
          Returns a Map of field values, keyed by field name.
 java.util.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(java.lang.String pFieldName)
          Returns the Field with the given name.
 java.lang.String getFieldName(int pIndex)
          Returns the Field name located at the specified index.
 java.util.List getFieldNames()
          Gets a List containing the names of the contained Fields.
 java.util.Map getFields()
          Returns a Map of Fields keyed by Field name.
 java.util.List getFields(java.lang.Class pFieldClass)
          Returns a List with all the fields that are equal or subclasses to pFieldClass
 java.util.List getNamesOfUpdatedFields()
          Returns a List of names of Fields that have been updated.
 java.util.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)
 java.util.List getPhysicalFieldNames()
          Gets a List containing the names of contained Fields excluding those that are not physically present in the database
 java.util.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.
 java.util.Iterator iterator()
          Returns all the fields in an Iterator
 Field removeField(Field field)
          Removes the specified field from this FieldCollection.
 Field removeField(java.lang.String fieldName)
          Removes the field with the specified name from this FieldCollection.
 void replace(Field pField)
          Replaces the Field with the name of the given Field.
 java.util.List replaceFieldValues(java.util.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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DISPLAY_ORDER_COMPARATOR

public static final java.util.Comparator DISPLAY_ORDER_COMPARATOR

NAME_COMPARATOR

public static final java.util.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.

Throws:
DataEngineException

clearFields

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


cloneFieldCollection

protected FieldCollection cloneFieldCollection(Row pNewRow)
                                        throws CMException
Clones this FieldCollection

Throws:
CMException

getAutoUpdateFields

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

Returns:
Map
Throws:
CMException

getCopiedFieldValues

public java.util.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.

Throws:
CMException

getDisplayOrderedFields

public java.util.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 0, the second Field added has an index of 1, etc.


getField

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

Parameters:
pFieldName - String
Returns:
Field

getFieldName

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

Parameters:
pIndex - int
Returns:
String

getFieldNames

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


getFields

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

Returns:
Map

getFields

public java.util.List getFields(java.lang.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 java.util.List getNamesOfUpdatedFields()
                                       throws CMException
Returns a List of names of Fields that have been updated.

Returns:
List
Throws:
CMException

getOrderedFields

public java.util.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 java.util.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
Throws:
CMException

getUpdatedFields

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

Returns:
Map
Throws:
CMException

isEmpty

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

Returns:
boolean

iterator

public java.util.Iterator iterator()
Returns all the fields in an Iterator


removeField

public Field removeField(Field field)
Removes the specified field from this FieldCollection. The removed field is returned (or null if no such field was found)


removeField

public Field removeField(java.lang.String fieldName)
Removes the field with the specified name from this FieldCollection. The removed field is returned (or null if no such field was found)


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
Throws:
DataEngineException

replaceFieldValues

public java.util.List replaceFieldValues(java.util.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.
Throws:
CMException

size

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

Returns:
int