org.opengts.dbtools
Class DBFieldValues

java.lang.Object
  extended by org.opengts.dbtools.DBFieldValues

public class DBFieldValues
extends java.lang.Object

DBFieldValues is a container class for field/column values for a DBRecord.


Constructor Summary
DBFieldValues(DBRecordKey rcdKey)
          Constructor
DBFieldValues(DBRecordKey rcdKey, DBFieldValues delegate)
          Constructor
 
Method Summary
protected  java.lang.Object _getFieldValue(java.lang.String fldName, boolean requiredField)
          Gets the value for the specified field name
protected  java.lang.Object _getFieldValue(java.lang.String fldName, boolean requiredField, boolean rtnDft)
          Gets the value for the specified field name
 boolean _setFieldValue(DBField fld, java.lang.Object newVal)
          Sets the value for the specified field name
protected  boolean _setFieldValue(java.lang.String fldName, boolean requiredField, java.lang.Object newVal)
          Sets the value for the specified field name
 void clearFieldValues()
          Clears all field values
 void clearFieldValues(DBField[] fldList)
          Clears field values
 DBField getField(java.lang.String fldName)
          Gets the DBField for the specified field name
 java.lang.String getFieldName(java.lang.String fldName)
          Converts the field name to the proper case
 java.lang.Object getFieldValue(java.lang.String fldName)
          Gets the value for the specified field name
 java.lang.Object getFieldValue(java.lang.String fldName, boolean rtnDft)
          Gets the value for the specified field name
 java.lang.String getFieldValueAsString(java.lang.String fldName)
          Gets the String representation of the field value
 boolean getIgnoreInvalidFields()
          Gets the state of reporting invalid field names.
 java.lang.String getName()
          Gets the name of this instance
 java.lang.Object getOptionalFieldValue(java.lang.String fldName)
          Gets the value for the specified optional field name
 java.lang.Object getOptionalFieldValue(java.lang.String fldName, boolean rtnDft)
          Gets the value for the specified optional field name
 java.lang.String getUntranslatedTableName()
          Gets the table name for this DBFieldValue instance
 boolean hasField(java.lang.String fldName)
          Returns true if the specified field name exists in this DBFieldValues instance
 boolean hasFieldValue(java.lang.String fldName)
          Returns true if a value has been set for the specified field name
static void main(java.lang.String[] argv)
           
 void setAllFieldValues(java.util.Map<java.lang.String,java.lang.String> valMap)
          Sets all field values from the specified value map (all fields required)
 void setAllFieldValues(java.util.Map<java.lang.String,java.lang.String> valMap, boolean setPrimaryKey)
          Sets all field values from the specified value map (all fields required)
 void setAllFieldValues(java.sql.ResultSet rs)
          Sets all field values from the specified ResultSet
 void setAllFieldValues(java.sql.ResultSet rs, boolean setPrimaryKey)
          Sets all field values from the specified ResultSet
 void setAllFieldValues(java.sql.ResultSet rs, boolean setPrimaryKey, DBField[] fldList)
          Sets all field values from the specified ResultSet
 boolean setFieldValue(java.lang.String fldName, boolean val)
          Sets the value for the specified field name
 boolean setFieldValue(java.lang.String fldName, byte[] val)
          Sets the value for the specified field name
 boolean setFieldValue(java.lang.String fldName, DateTime val)
          Sets the value for the specified field name
 boolean setFieldValue(java.lang.String fldName, double val)
          Sets the value for the specified field name
 boolean setFieldValue(java.lang.String fldName, float val)
          Sets the value for the specified field name
 boolean setFieldValue(java.lang.String fldName, int val)
          Sets the value for the specified field name
 boolean setFieldValue(java.lang.String fldName, long val)
          Sets the value for the specified field name
 boolean setFieldValue(java.lang.String fldName, java.lang.Object newVal)
          Sets the value for the specified field name
 boolean setFieldValue(java.lang.String fldName, java.lang.String val)
          Sets the value for the specified field name
 void setFieldValues(DBFieldValues fldVals, boolean setPrimaryKey, boolean requireAllFields)
          Sets the specified field values from the specified ResultSet.
 void setFieldValues(java.util.Map<java.lang.String,java.lang.String> valMap, boolean setPrimaryKey, boolean requireAllFields)
          Sets the specified field values from the specified ResultSet.
 void setIgnoreInvalidFields(boolean state)
          Sets the state for ignoring invalid field names.
 void setName(java.lang.String name)
          Sets the name of this instance
 boolean setOptionalFieldValue(java.lang.String fldName, boolean val)
          Sets the value for the specified optional field name
 boolean setOptionalFieldValue(java.lang.String fldName, byte[] val)
          Sets the value for the specified optional field name
 boolean setOptionalFieldValue(java.lang.String fldName, DateTime val)
          Sets the value for the specified optional field name
 boolean setOptionalFieldValue(java.lang.String fldName, double val)
          Sets the value for the specified optional field name
 boolean setOptionalFieldValue(java.lang.String fldName, float val)
          Sets the value for the specified optional field name
 boolean setOptionalFieldValue(java.lang.String fldName, int val)
          Sets the value for the specified optional field name
 boolean setOptionalFieldValue(java.lang.String fldName, long val)
          Sets the value for the specified optional field name
 boolean setOptionalFieldValue(java.lang.String fldName, java.lang.Object newVal)
          Sets the value for the specified optional field name
 boolean setOptionalFieldValue(java.lang.String fldName, java.lang.String val)
          Sets the value for the specified optional field name
static void setValidateFieldValues(boolean validate)
          Sets the global state for validating field values
 java.lang.String toString()
          Gets a string representation of this instance
static java.lang.String toStringValue(java.lang.Object obj)
          Converts the specified object to a String representation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DBFieldValues

public DBFieldValues(DBRecordKey rcdKey)
Constructor

Parameters:
rcdKey - The DBRecordKey associated with this field value container

DBFieldValues

public DBFieldValues(DBRecordKey rcdKey,
                     DBFieldValues delegate)
Constructor

Parameters:
rcdKey - The DBRecordKey associated with this field value container
Method Detail

setValidateFieldValues

public static void setValidateFieldValues(boolean validate)
Sets the global state for validating field values

Parameters:
validate - True to validate, false otherwise

getName

public java.lang.String getName()
Gets the name of this instance

Returns:
The name of this instance

setName

public void setName(java.lang.String name)
Sets the name of this instance

Parameters:
name - The name of this instance

setIgnoreInvalidFields

public void setIgnoreInvalidFields(boolean state)
Sets the state for ignoring invalid field names. True to ignore errors when setting/getting a field name that does not exist, False to emit any invalid field errors.

Parameters:
state - True to ignore invalid field names, false to emit errors.

getIgnoreInvalidFields

public boolean getIgnoreInvalidFields()
Gets the state of reporting invalid field names.

Returns:
False to report invalid field names, true to suppress/ignore errors.

getUntranslatedTableName

public java.lang.String getUntranslatedTableName()
Gets the table name for this DBFieldValue instance

Returns:
The table name

clearFieldValues

public void clearFieldValues()
Clears all field values


clearFieldValues

public void clearFieldValues(DBField[] fldList)
Clears field values


getField

public DBField getField(java.lang.String fldName)
Gets the DBField for the specified field name

Parameters:
fldName - The field name of the DBField to return
Returns:
The returned DBField

_setFieldValue

protected boolean _setFieldValue(java.lang.String fldName,
                                 boolean requiredField,
                                 java.lang.Object newVal)
Sets the value for the specified field name

Parameters:
fldName - The field name to set
requiredField - True to indicate that this field is required (warnings displayed if field is not found)
newVal - The 'Object' value to set for the field
Returns:
True if the field exists, false otherwise

_setFieldValue

public boolean _setFieldValue(DBField fld,
                              java.lang.Object newVal)
Sets the value for the specified field name

Parameters:
fld - The DBField to set
newVal - The 'Object' value to set for the field
Returns:
True if 'newVal' is proper field type, false otherwise

setOptionalFieldValue

public boolean setOptionalFieldValue(java.lang.String fldName,
                                     java.lang.Object newVal)
Sets the value for the specified optional field name

Parameters:
fldName - The field name to set
newVal - The 'Object' value to set for the field
Returns:
True if the field exists, false otherwise

setFieldValue

public boolean setFieldValue(java.lang.String fldName,
                             java.lang.Object newVal)
Sets the value for the specified field name

Parameters:
fldName - The field name to set
newVal - The 'Object' value to set for the field
Returns:
True if the field exists, false otherwise

setOptionalFieldValue

public boolean setOptionalFieldValue(java.lang.String fldName,
                                     java.lang.String val)
Sets the value for the specified optional field name

Parameters:
fldName - The field name to set
val - The 'String' value to set for the field
Returns:
True if the field exists, false otherwise

setFieldValue

public boolean setFieldValue(java.lang.String fldName,
                             java.lang.String val)
Sets the value for the specified field name

Parameters:
fldName - The field name to set
val - The 'String' value to set for the field
Returns:
True if the field exists, false otherwise

setOptionalFieldValue

public boolean setOptionalFieldValue(java.lang.String fldName,
                                     int val)
Sets the value for the specified optional field name

Parameters:
fldName - The field name to set
val - The 'int' value to set for the field
Returns:
True if the field exists, false otherwise

setFieldValue

public boolean setFieldValue(java.lang.String fldName,
                             int val)
Sets the value for the specified field name

Parameters:
fldName - The field name to set
val - The 'int' value to set for the field
Returns:
True if the field exists, false otherwise

setOptionalFieldValue

public boolean setOptionalFieldValue(java.lang.String fldName,
                                     long val)
Sets the value for the specified optional field name

Parameters:
fldName - The field name to set
val - The 'long' value to set for the field
Returns:
True if the field exists, false otherwise

setFieldValue

public boolean setFieldValue(java.lang.String fldName,
                             long val)
Sets the value for the specified field name

Parameters:
fldName - The field name to set
val - The 'long' value to set for the field
Returns:
True if the field exists, false otherwise

setOptionalFieldValue

public boolean setOptionalFieldValue(java.lang.String fldName,
                                     float val)
Sets the value for the specified optional field name

Parameters:
fldName - The field name to set
val - The 'float' value to set for the field
Returns:
True if the field exists, false otherwise

setFieldValue

public boolean setFieldValue(java.lang.String fldName,
                             float val)
Sets the value for the specified field name

Parameters:
fldName - The field name to set
val - The 'float' value to set for the field
Returns:
True if the field exists, false otherwise

setOptionalFieldValue

public boolean setOptionalFieldValue(java.lang.String fldName,
                                     double val)
Sets the value for the specified optional field name

Parameters:
fldName - The field name to set
val - The 'double' value to set for the field
Returns:
True if the field exists, false otherwise

setFieldValue

public boolean setFieldValue(java.lang.String fldName,
                             double val)
Sets the value for the specified field name

Parameters:
fldName - The field name to set
val - The 'double' value to set for the field
Returns:
True if the field exists, false otherwise

setOptionalFieldValue

public boolean setOptionalFieldValue(java.lang.String fldName,
                                     boolean val)
Sets the value for the specified optional field name

Parameters:
fldName - The field name to set
val - The 'boolean' value to set for the field
Returns:
True if the field exists, false otherwise

setFieldValue

public boolean setFieldValue(java.lang.String fldName,
                             boolean val)
Sets the value for the specified field name

Parameters:
fldName - The field name to set
val - The 'boolean' value to set for the field
Returns:
True if the field exists, false otherwise

setOptionalFieldValue

public boolean setOptionalFieldValue(java.lang.String fldName,
                                     byte[] val)
Sets the value for the specified optional field name

Parameters:
fldName - The field name to set
val - The 'byte[]' value to set for the field
Returns:
True if the field exists, false otherwise

setFieldValue

public boolean setFieldValue(java.lang.String fldName,
                             byte[] val)
Sets the value for the specified field name

Parameters:
fldName - The field name to set
val - The 'byte[]' value to set for the field
Returns:
True if the field exists, false otherwise

setOptionalFieldValue

public boolean setOptionalFieldValue(java.lang.String fldName,
                                     DateTime val)
Sets the value for the specified optional field name

Parameters:
fldName - The field name to set
val - The 'DateTime' value to set for the field
Returns:
True if the field exists, false otherwise

setFieldValue

public boolean setFieldValue(java.lang.String fldName,
                             DateTime val)
Sets the value for the specified field name

Parameters:
fldName - The field name to set
val - The 'boolean' value to set for the field
Returns:
True if the field exists, false otherwise

setAllFieldValues

public void setAllFieldValues(java.sql.ResultSet rs)
                       throws java.sql.SQLException
Sets all field values from the specified ResultSet

Parameters:
rs - The ResultSet from which field values are retrieved
Throws:
java.sql.SQLException - If field does not exist

setAllFieldValues

public void setAllFieldValues(java.sql.ResultSet rs,
                              boolean setPrimaryKey)
                       throws java.sql.SQLException
Sets all field values from the specified ResultSet

Parameters:
rs - The ResultSet from which field values are retrieved
setPrimaryKey - True to set primay key fields
Throws:
java.sql.SQLException - If field does not exist

setAllFieldValues

public void setAllFieldValues(java.sql.ResultSet rs,
                              boolean setPrimaryKey,
                              DBField[] fldList)
                       throws java.sql.SQLException
Sets all field values from the specified ResultSet

Parameters:
rs - The ResultSet from which field values are retrieved
setPrimaryKey - True to set primay key fields
Throws:
java.sql.SQLException - If field does not exist

setAllFieldValues

public void setAllFieldValues(java.util.Map<java.lang.String,java.lang.String> valMap)
                       throws DBException
Sets all field values from the specified value map (all fields required)

Parameters:
valMap - The Field==>Value map
Throws:
DBException - If field does not exist

setAllFieldValues

public void setAllFieldValues(java.util.Map<java.lang.String,java.lang.String> valMap,
                              boolean setPrimaryKey)
                       throws DBException
Sets all field values from the specified value map (all fields required)

Parameters:
valMap - The Field==>Value map
setPrimaryKey - True if key fields should also be set
Throws:
DBException - If field does not exist

setFieldValues

public void setFieldValues(java.util.Map<java.lang.String,java.lang.String> valMap,
                           boolean setPrimaryKey,
                           boolean requireAllFields)
                    throws DBException
Sets the specified field values from the specified ResultSet. (NOTE: field names specified in the value map, which do not exist in the actual field list, are quietly ignored).

Parameters:
valMap - The Field==>Value map
setPrimaryKey - True if key fields should also be set
Throws:
DBException - If field does not exist

setFieldValues

public void setFieldValues(DBFieldValues fldVals,
                           boolean setPrimaryKey,
                           boolean requireAllFields)
                    throws DBException
Sets the specified field values from the specified ResultSet. (NOTE: field names specified in the value map, which do not exist in the actual field list, are quietly ignored).

Parameters:
fldVals - The Field==>Value map
setPrimaryKey - True if primary key fields should also be set
Throws:
DBException - If field does not exist

getFieldName

public java.lang.String getFieldName(java.lang.String fldName)
Converts the field name to the proper case

Parameters:
fldName - The case-insensitive field name
Returns:
The field name in proper case.

hasField

public boolean hasField(java.lang.String fldName)
Returns true if the specified field name exists in this DBFieldValues instance

Parameters:
fldName - The field name to test
Returns:
True if the specified field name exists in this DBFieldValues instance

hasFieldValue

public boolean hasFieldValue(java.lang.String fldName)
Returns true if a value has been set for the specified field name

Parameters:
fldName - The field name to test for a set value
Returns:
True if ta value has been set for the specified field name

_getFieldValue

protected java.lang.Object _getFieldValue(java.lang.String fldName,
                                          boolean requiredField)
Gets the value for the specified field name

Parameters:
fldName - The field name for the value retrieved
requiredField - True to indicate that this field is required (warnings displayed if field is not found)
Returns:
The field value

_getFieldValue

protected java.lang.Object _getFieldValue(java.lang.String fldName,
                                          boolean requiredField,
                                          boolean rtnDft)
Gets the value for the specified field name

Parameters:
fldName - The field name for the value retrieved
requiredField - True to indicate that this field is required (warnings displayed if field is not found)
rtnDft - True to return a default value if a value has not been set
Returns:
The field value

getOptionalFieldValue

public java.lang.Object getOptionalFieldValue(java.lang.String fldName)
Gets the value for the specified optional field name

Parameters:
fldName - The field name for the value retrieved
Returns:
The optional field value, or null if the field has not been set, or does not exist

getOptionalFieldValue

public java.lang.Object getOptionalFieldValue(java.lang.String fldName,
                                              boolean rtnDft)
Gets the value for the specified optional field name

Parameters:
fldName - The field name for the value retrieved
Returns:
The optional field value, or null if the field has not been set, or does not exist

getFieldValue

public java.lang.Object getFieldValue(java.lang.String fldName)
Gets the value for the specified field name

Parameters:
fldName - The field name for the value retrieved
Returns:
The field value

getFieldValue

public java.lang.Object getFieldValue(java.lang.String fldName,
                                      boolean rtnDft)
Gets the value for the specified field name

Parameters:
fldName - The field name for the value retrieved
rtnDft - True to return a default value if a value has not been set
Returns:
The field value

getFieldValueAsString

public java.lang.String getFieldValueAsString(java.lang.String fldName)
Gets the String representation of the field value

Parameters:
fldName - The field name for the value retrieved
Returns:
The String representation of the field value

toString

public java.lang.String toString()
Gets a string representation of this instance

Overrides:
toString in class java.lang.Object

toStringValue

public static java.lang.String toStringValue(java.lang.Object obj)
Converts the specified object to a String representation

Parameters:
obj - The Object to converts to a String representation
Returns:
The String representation of the specified object

main

public static void main(java.lang.String[] argv)