com.sibvisions.rad.model.mem
Class DataRow

java.lang.Object
  extended by com.sibvisions.rad.model.mem.DataRow
All Implemented Interfaces:
Serializable, Comparable<IDataRow>, IDataRow
Direct Known Subclasses:
ChangeableDataRow

public class DataRow
extends Object
implements IDataRow, Serializable

An DataRow is a list of table column's.
The DataRow is also a storage independent row.

Example:

 
 // construct a RowDefinition
 RowDefinition rdRowDefinition = new RowDefinition();
 
 // construct some ColumnDefinitions
 ColumnDefinition cdId   = new ColumnDefinition("id");
 ColumnDefinition cdName = new ColumnDefinition("name");
 
 rdRowDefinition.addColumnDefinition(cdId);             
 rdRowDefinition.addColumnDefinition(cdName);

 // construct DataRow
 DataRow drDataRow = new DataRow(rdRowDefinition);
 
 drDataRow.setValue("id", new BigDecimal(1));
 drDataRow.setValue("name", "The name");  
 
 

See Also:
IDataRow, RowDefinition, RemoteDataBook, MemDataPage, Serialized Form

Field Summary
protected  Object[] oaStorage
          The storage for this DataRow.
protected  IRowDefinition rdRowDefinition
          The RowDefinition of this DataRow.
 
Constructor Summary
  DataRow()
          Constructs a DataRow without a new instance of IRowDefinition.
  DataRow(IRowDefinition pRowDefinition)
          Constructs a DataRow with a given IRowDefinition.
protected DataRow(IRowDefinition pRowDefinition, Object[] pData)
          Constructs a DataRow with a given IRowDefinition and initialize it a copy of the Object[]<> data.
 
Method Summary
 void addControl(IControl pControl)
          Adds a IControl to the IDataRow.
 void cancelEditingControls()
          Its invokes for each IComponent the cancelEditing() method.
 int compareTo(IDataRow pDataRow)
          
 int compareTo(IDataRow pDataRow, SortDefinition pSortDefinition)
          It compares the drDataRow with this IDataRow and it uses the columns and order information (asc, desc) in the SortDefintion.
 IDataRow createDataRow(String[] pColumnNames)
          Returns a cloned IDataRow with only a subset of specified column names.
 IDataRow createEmptyRow(String[] pColumnNames)
          Returns a new empty IDataRow with only a subset of column's, specified by a String[] of column names.
 boolean equals(IDataRow pDataRow, String[] pColumnNames)
          Compares the drDataRow with this IDataRow, but it only compares the specified columns.
 boolean equals(Object pObject)
          
 DataRowHandler eventValuesChanged()
          Gets the EventHandler for values changed event.
 IControl[] getControls()
          Returns all IControl's from the IDataRow.
 IRowDefinition getRowDefinition()
          Returns the IRowDefinition of the IDataRow.
 Object getValue(int pColumnIndex)
          Returns the value of the column by index.
 Object getValue(String pColumnName)
          Returns the value of the named column.
 String getValueAsString(String pColumnName)
          Returns the value of the named column as String.
 Object[] getValues(String[] pColumnNames)
          Returns a Object[] of values from the specified columns in this IDataRow.
 String[] getValuesAsString(String[] pColumnNames)
          Returns the values of the named columns as String[].
 int hashCode()
          
protected  void invokeCancelEditingControls()
          Its invokes for each IComponent the cancelEditing() method.
protected  void invokeRepaintListeners()
          Its invokes for each IComponent the notifyRepaint() method.
protected  void invokeSaveEditingControls()
          Its invokes for each IComponent the saveEditing() method.
 void notifyRepaintControls()
          Its invokes for each IComponent the notifyRepaint() method.
 void removeControl(IControl pControl)
          Removes the IControl from the IDataRow.
 void saveEditingControls()
          Its invokes for each IComponent the saveEditing() method.
 void setDefaultValues()
          Sets the Default Values from the RowDefinition to the DataRow.
 void setValue(String pColumnName, Object pValue)
          Sets the value of the named column in this IDataRow.
protected  void setValueDRInternal(String pColumnName, Object pValue)
          Sets the value of the named column in this IDataRow.
 void setValues(String[] pColumnNames, Object[] pValues)
          Sets the column's values from the pValues Object[] to the this IDataRow.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

rdRowDefinition

protected IRowDefinition rdRowDefinition
The RowDefinition of this DataRow.


oaStorage

protected Object[] oaStorage
The storage for this DataRow.

Constructor Detail

DataRow

public DataRow()
Constructs a DataRow without a new instance of IRowDefinition.


DataRow

public DataRow(IRowDefinition pRowDefinition)
Constructs a DataRow with a given IRowDefinition.

Parameters:
pRowDefinition - the IRowDefinition

DataRow

protected DataRow(IRowDefinition pRowDefinition,
                  Object[] pData)
Constructs a DataRow with a given IRowDefinition and initialize it a copy of the Object[]<> data.

Parameters:
pRowDefinition - the IRowDefinition
pData - the Object[]<> with data of the DataRow.
Method Detail

getRowDefinition

public IRowDefinition getRowDefinition()
Returns the IRowDefinition of the IDataRow.

Specified by:
getRowDefinition in interface IDataRow
Returns:
the IRowDefinition of the IDataRow.

getValue

public Object getValue(int pColumnIndex)
                throws ModelException
Returns the value of the column by index.

Specified by:
getValue in interface IDataRow
Parameters:
pColumnIndex - the column index
Returns:
the value of the column.
Throws:
ModelException - if the column index is not in this IDataRow

getValue

public Object getValue(String pColumnName)
                throws ModelException
Returns the value of the named column.

Specified by:
getValue in interface IDataRow
Parameters:
pColumnName - the name of the column
Returns:
the value of the named column.
Throws:
ModelException - if the ColumnDefinition name is not in this IDataRow

getValueAsString

public String getValueAsString(String pColumnName)
                        throws ModelException
Returns the value of the named column as String.

Specified by:
getValueAsString in interface IDataRow
Parameters:
pColumnName - the name of the column
Returns:
the value of the named column as String.
Throws:
ModelException - if the ColumnDefinition name is not in this IDataRow

setValue

public void setValue(String pColumnName,
                     Object pValue)
              throws ModelException
Sets the value of the named column in this IDataRow.

Events:
After the value is changed, the IDataRowListener.changed(this, new String[] { pColumnName }, drOldRow) method is called.
After the value is changed, all registered IControls get called the notifyRepaint() method.

Specified by:
setValue in interface IDataRow
Parameters:
pColumnName - the column name
pValue - the new value for the column in this IDataRow
Throws:
ModelException - if the ColumnDefinition name is not in this IDataRow or the pValue is not convertible/too large to/for the IDataType of the column

getValues

public Object[] getValues(String[] pColumnNames)
                   throws ModelException
Returns a Object[] of values from the specified columns in this IDataRow.

Specified by:
getValues in interface IDataRow
Parameters:
pColumnNames - a String[] of column names
Returns:
a Object[] of values from the specified columns in this IDataRow
Throws:
ModelException - if the ColumnDefinition name is not in this IDataRow

getValuesAsString

public String[] getValuesAsString(String[] pColumnNames)
                           throws ModelException
Returns the values of the named columns as String[].

Specified by:
getValuesAsString in interface IDataRow
Parameters:
pColumnNames - the names of the columns
Returns:
the values of the named columns as String[].
Throws:
ModelException - if one the ColumnDefinition name is not in this IDataRow

setValues

public void setValues(String[] pColumnNames,
                      Object[] pValues)
               throws ModelException
Sets the column's values from the pValues Object[] to the this IDataRow.
It finds the corresponding target column over the column name in the pColumnNames String[].

Events:
After the value is changed, the IDataRowListener.changed(this, pColumnNames, drOldRow) method is called.
After the value is changed, all registered IControls get called the notifyRepaint() method.

Specified by:
setValues in interface IDataRow
Parameters:
pColumnNames - a String[] of column names
pValues - a Object[] of values to set in the corresponding columns of the IDataRow
Throws:
ModelException - if the ColumnDefinition name is not in this IDataRow or the pValue is not convertible/too large to/for the DataType of the column

createDataRow

public IDataRow createDataRow(String[] pColumnNames)
                       throws ModelException
Returns a cloned IDataRow with only a subset of specified column names.

Specified by:
createDataRow in interface IDataRow
Parameters:
pColumnNames - a String[] of column names
Returns:
a cloned IDataRow with only a subset of specified column names.
Throws:
ModelException - if the IDataRow couldn't constructed

createEmptyRow

public IDataRow createEmptyRow(String[] pColumnNames)
                        throws ModelException
Returns a new empty IDataRow with only a subset of column's, specified by a String[] of column names.

Specified by:
createEmptyRow in interface IDataRow
Parameters:
pColumnNames - a String[] of column names
Returns:
a new empty IDataRow with only a subset of columns, specified by a String[] of column names.
Throws:
ModelException - if the IDataRow couldn't constructed

equals

public boolean equals(Object pObject)

Overrides:
equals in class Object

compareTo

public int compareTo(IDataRow pDataRow)

Specified by:
compareTo in interface Comparable<IDataRow>

compareTo

public int compareTo(IDataRow pDataRow,
                     SortDefinition pSortDefinition)
It compares the drDataRow with this IDataRow and it uses the columns and order information (asc, desc) in the SortDefintion. It reacts like a normal compareTo with specific columns, but if in the SortDefinition the order is descending for a columns it multiplies the result with -1. -> invert the result.

Specified by:
compareTo in interface IDataRow
Parameters:
pDataRow - the DataRow to compare with this IDataRow
pSortDefinition - the SortDefinition to us in the compare
Returns:
a negative integer, zero, or a positive integer as this IDataRow is less than, equal to, or greater than the specified DataRow.

equals

public boolean equals(IDataRow pDataRow,
                      String[] pColumnNames)
Compares the drDataRow with this IDataRow, but it only compares the specified columns.

Specified by:
equals in interface IDataRow
Parameters:
pDataRow - the DataRow to compare with this IDataRow
pColumnNames - a String[] of column names to compare
Returns:
true if equals.

addControl

public void addControl(IControl pControl)
Adds a IControl to the IDataRow.
The registered IControl methods will be called if IDataRow has changed, restored or stored.

Specified by:
addControl in interface IDataRow
Parameters:
pControl - the IControl
See Also:
IControl

removeControl

public void removeControl(IControl pControl)
Removes the IControl from the IDataRow.

Specified by:
removeControl in interface IDataRow
Parameters:
pControl - the IControl
See Also:
IControl

getControls

public IControl[] getControls()
Returns all IControl's from the IDataRow.

Specified by:
getControls in interface IDataRow
Returns:
all IControl's from the IDataRow.

eventValuesChanged

public DataRowHandler eventValuesChanged()
Gets the EventHandler for values changed event.

Specified by:
eventValuesChanged in interface IDataRow
Returns:
the EventHandler for values changed events.

toString

public String toString()

Overrides:
toString in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

setValueDRInternal

protected void setValueDRInternal(String pColumnName,
                                  Object pValue)
                           throws ModelException
Sets the value of the named column in this IDataRow.

Parameters:
pColumnName - the column name
pValue - the new value for the column in this IDataRow
Throws:
ModelException - if the column name is not in this IDataRow or the pValue is not convertible/too large to/for the IDataType of the column

notifyRepaintControls

public void notifyRepaintControls()
Its invokes for each IComponent the notifyRepaint() method.


saveEditingControls

public void saveEditingControls()
                         throws ModelException
Its invokes for each IComponent the saveEditing() method.

Throws:
ModelException - if saving the editors fails.

cancelEditingControls

public void cancelEditingControls()
Its invokes for each IComponent the cancelEditing() method.


invokeRepaintListeners

protected void invokeRepaintListeners()
Its invokes for each IComponent the notifyRepaint() method.


invokeSaveEditingControls

protected void invokeSaveEditingControls()
                                  throws ModelException
Its invokes for each IComponent the saveEditing() method.

Throws:
ModelException - if saving the editors fails.

invokeCancelEditingControls

protected void invokeCancelEditingControls()
Its invokes for each IComponent the cancelEditing() method.


setDefaultValues

public void setDefaultValues()
                      throws ModelException
Sets the Default Values from the RowDefinition to the DataRow.

Throws:
ModelException - if the set value fails


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.