com.archibus.datasource.data
Class DataRecord

java.lang.Object
  extended by com.archibus.datasource.data.DataRecord

public class DataRecord
extends java.lang.Object

Encapsulates a single database record. Holds record values as instances of DataValue. Contains field definitions for all data values.


Constructor Summary
DataRecord()
          No-arg constructor.
DataRecord(boolean isNew)
          Constructor.
 
Method Summary
 void addField(com.archibus.db.ViewField.Immutable fieldDef)
          Adds a field definition to the record.
static DataRecord createRecordFromJSON(org.json.JSONObject json)
          Creates new DataRecord and populates its values from specified JSON object.
static DataRecord createRecordFromJSON(org.json.JSONObject fieldValues, org.json.JSONObject oldFieldValues, boolean isNew)
          Creates new DataRecord and populates its values from specified JSON object.
static java.util.List<DataRecord> createRecordsFromJSON(org.json.JSONArray json)
          Creates a list of DataRecords and populates their values from specified JSON array.
 DataValue findField(java.lang.String name)
          Finds and returns field by full name.
 void fromJSON(org.json.JSONObject json)
          De-serializes this data record from JSON, using the same JSON format as produced by toJSON().
 void fromJSON(org.json.JSONObject fieldValues, org.json.JSONObject oldFieldValues, boolean isNewRecord)
          De-serializes this data record from JSON, using older 16.3 JSON format.
 java.util.Date getDate(java.lang.String name)
          Returns date value of specified field.
 double getDouble(java.lang.String name)
          Returns double value of specified field.
 java.util.List<DataValue> getFields()
          Returns list of fields.
 java.util.Map<java.lang.String,java.lang.Object> getFieldValues()
          Returns map of field object values.
 int getInt(java.lang.String name)
          Returns integer value of specified field.
 java.lang.Object getNeutralValue(java.lang.String name)
          Returns ARCHIBUS locale-neutral value of specified field.
 java.lang.Object getNeutralValueForChart(EventHandlerContext context, java.lang.String name)
          Returns the value formatted as ARCHIBUS locale-neutral string without data separator for numbers.
 java.util.Map<java.lang.String,java.lang.Object> getOldFieldValues()
          Returns map of old object values.
 java.util.Map<java.lang.String,java.lang.Object> getOldValues()
          Returns map of old object values.
 java.lang.String getString(java.lang.String name)
          Returns string value of specified field.
 java.lang.Object getValue(java.lang.String name)
          Returns object value for specified field.
 java.util.Map<java.lang.String,java.lang.Object> getValues()
          Returns map of field object values.
 boolean isNew()
          Returns true if this record is new (unsaved).
 void setDbValue(java.lang.String name, java.lang.String value)
          Sets the object value as a result of parsing the raw database string value.
 void setFieldValues(java.util.Map<java.lang.String,java.lang.Object> fieldValues)
          Sets field values for the record serialized from the client.
 void setNew(boolean isNew)
          Sets isNew property.
 void setOldFieldValues(java.util.Map<java.lang.String,java.lang.Object> fieldValues)
          Sets field values for the record serialized from the client.
 void setOldValue(java.lang.String name, java.lang.Object value)
          Sets old object value for specified field.
 void setUiOldValue(java.lang.String name, java.lang.String value)
          Sets the old object value as a result of parsing the locale-neutral value obtained from the UI.
 void setUiValue(java.lang.String name, java.lang.String value)
          Sets the object value as a result of parsing the locale-neutral value obtained from the UI.
 void setValue(java.lang.String name, double value)
          Sets double value of specified field.
 void setValue(java.lang.String name, int value)
          Sets integer value of specified field.
 void setValue(java.lang.String name, java.lang.Object value)
          Sets object value of specified field.
 org.json.JSONObject toJSON()
          Serializes this data record to JSON format.
 java.lang.String toString()
           
 boolean valueExists(java.lang.String name)
          Returns true if specified field value is in the record.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataRecord

public DataRecord()
No-arg constructor.


DataRecord

public DataRecord(boolean isNew)
Constructor.

Parameters:
isNew -
Method Detail

addField

public void addField(com.archibus.db.ViewField.Immutable fieldDef)
Adds a field definition to the record.

Parameters:
fieldDef - ARCHIBUS view field definition.

valueExists

public boolean valueExists(java.lang.String name)
Returns true if specified field value is in the record.

Parameters:
name -
Returns:

getValue

public java.lang.Object getValue(java.lang.String name)
Returns object value for specified field.

Parameters:
name - Full field name.
Returns:
Parsed field value.

getInt

public int getInt(java.lang.String name)
Returns integer value of specified field.

Parameters:
name -
Returns:
integer value

getDouble

public double getDouble(java.lang.String name)
Returns double value of specified field.

Parameters:
name -
Returns:
double value

getString

public java.lang.String getString(java.lang.String name)
Returns string value of specified field.

Parameters:
name -
Returns:
string value

getDate

public java.util.Date getDate(java.lang.String name)
Returns date value of specified field.

Parameters:
name -
Returns:
date value

getNeutralValue

public java.lang.Object getNeutralValue(java.lang.String name)
Returns ARCHIBUS locale-neutral value of specified field. This is the transport format used to send field values between the browser and the server.

Parameters:
name -
Returns:

getNeutralValueForChart

public java.lang.Object getNeutralValueForChart(EventHandlerContext context,
                                                java.lang.String name)
Returns the value formatted as ARCHIBUS locale-neutral string without data separator for numbers. This is used solely for the Chart control.

Parameters:
name -
Returns:

setValue

public void setValue(java.lang.String name,
                     java.lang.Object value)
Sets object value of specified field.

Parameters:
name - Full field name.
value - Parsed field value.

setValue

public void setValue(java.lang.String name,
                     int value)
Sets integer value of specified field.

Parameters:
name -
value -

setValue

public void setValue(java.lang.String name,
                     double value)
Sets double value of specified field.

Parameters:
name -
value -

setOldValue

public void setOldValue(java.lang.String name,
                        java.lang.Object value)
Sets old object value for specified field. The old value is used by the DataSource to find and update existing database records.

Parameters:
name - Full field name.
value - Parsed field value.

setDbValue

public void setDbValue(java.lang.String name,
                       java.lang.String value)
Sets the object value as a result of parsing the raw database string value.

Parameters:
name - Full field name.
value - String returned by calling JDBC ResultSet.getString().

setUiValue

public void setUiValue(java.lang.String name,
                       java.lang.String value)
Sets the object value as a result of parsing the locale-neutral value obtained from the UI.

Parameters:
name - Full field name.
value - in ARCHIBUS neutral format.

setUiOldValue

public void setUiOldValue(java.lang.String name,
                          java.lang.String value)
Sets the old object value as a result of parsing the locale-neutral value obtained from the UI.

Parameters:
name - Full field name.
value - in ARCHIBUS neutral format.

findField

public DataValue findField(java.lang.String name)
Finds and returns field by full name.

Returns:
DataValue.

getFields

public java.util.List<DataValue> getFields()
Returns list of fields.

Returns:
UnmodifiableList

getValues

public java.util.Map<java.lang.String,java.lang.Object> getValues()
Returns map of field object values. Null values are not returned.

Returns:
Map

getOldValues

public java.util.Map<java.lang.String,java.lang.Object> getOldValues()
Returns map of old object values. Null values are not returned.

Returns:
Map

getFieldValues

public java.util.Map<java.lang.String,java.lang.Object> getFieldValues()
Returns map of field object values.

Returns:
Map

getOldFieldValues

public java.util.Map<java.lang.String,java.lang.Object> getOldFieldValues()
Returns map of old object values.

Returns:
Map

setFieldValues

public void setFieldValues(java.util.Map<java.lang.String,java.lang.Object> fieldValues)
Sets field values for the record serialized from the client.

Parameters:
fieldValues -

setOldFieldValues

public void setOldFieldValues(java.util.Map<java.lang.String,java.lang.Object> fieldValues)
Sets field values for the record serialized from the client.

Parameters:
fieldValues -

isNew

public boolean isNew()
Returns true if this record is new (unsaved).

Returns:

setNew

public void setNew(boolean isNew)
Sets isNew property.

Parameters:
isNew -

toJSON

public org.json.JSONObject toJSON()
Serializes this data record to JSON format.

Returns:
JSON object:
 {
     name1: {
         n: string,
         l: string
     },
     name2: {
         n: string,
         l: string
     }
     ...
 }
 

fromJSON

public void fromJSON(org.json.JSONObject json)
De-serializes this data record from JSON, using the same JSON format as produced by toJSON().

Parameters:
json -

fromJSON

public void fromJSON(org.json.JSONObject fieldValues,
                     org.json.JSONObject oldFieldValues,
                     boolean isNewRecord)
De-serializes this data record from JSON, using older 16.3 JSON format.

Parameters:
jsonRecord -

createRecordFromJSON

public static DataRecord createRecordFromJSON(org.json.JSONObject json)
Creates new DataRecord and populates its values from specified JSON object.

Parameters:
json -

createRecordFromJSON

public static DataRecord createRecordFromJSON(org.json.JSONObject fieldValues,
                                              org.json.JSONObject oldFieldValues,
                                              boolean isNew)
Creates new DataRecord and populates its values from specified JSON object.

Parameters:
json -

createRecordsFromJSON

public static java.util.List<DataRecord> createRecordsFromJSON(org.json.JSONArray json)
Creates a list of DataRecords and populates their values from specified JSON array.

Parameters:
json -

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2009 ARCHIBUS, Inc. All Rights Reserved.