org.formaria.aria.data.table
Class RowModel

java.lang.Object
  extended by org.formaria.aria.data.DataModel
      extended by org.formaria.aria.data.table.RowModel
Direct Known Subclasses:
DatabaseRowModel

public class RowModel
extends DataModel

Provides a model for table rows. The attributes are equivalent to the row fields. The row will have no children. As a Java object the fields and rows indices are zero based in contrast to the JDBC indexing setup.

The class is not intended to be used directly except in rare circumstances, instead most access will be via the model and bindings or via the TableModel class

Copyright (c) Formaria Ltd. 2008

$Revision: 2.7 $ License: see license.txt


Field Summary
protected  int rowIdx
           
protected  TableModel sourceData
           
 
Fields inherited from class org.formaria.aria.data.DataModel
parentModel, tagName
 
Constructor Summary
RowModel()
          Default constructor, no table or row is referenced
RowModel(TableModel table, int row)
          Construct a model node for a table
 
Method Summary
 void append(DataModel newObject)
          Append a node.
 java.lang.Object append(java.lang.String id)
          This method does not nothing it is provided merely as an implementation of the DataModel interface.
 java.lang.Object get()
          Gets the value attribute
 DataModel get(int i)
          Gets the value attribute - a field value
 java.lang.Object get(java.lang.String attribName)
          Get a field value
 java.lang.String getAttribName(int i)
          Get the name of an attribute
 int getAttribute(java.lang.String attribName)
          returns the index of the attribiteNames array whose value is the same as the attribName
 java.lang.Object getAttribValue(int i)
          Get the value of an attribute
 double getAttribValueAsDouble(int i)
          Deprecated. use getAttribValueAsDouble( i, decimalSeparator, groupingSeparator ) instead, if the locale is different from the locale used to write the values to the model, then the parsed value may be incorrect.
 double getAttribValueAsDouble(int i, char decimalSeparator, char groupSeparator)
          Get an attribute value as a double
 int getAttribValueAsInt(int i)
          Get an attribute value as a string
 java.lang.String getAttribValueAsString(int i)
          Get an attribute as a string
 double getDouble(java.lang.String attribName)
          Get a field value as an double
 java.lang.String getFieldValue(int fieldIdx)
          Gets an individual field value
 java.lang.String getId()
          Get the ID of this row
 int getInt(java.lang.String attribName)
          Get a field value as an int
 int getNumChildren()
          Gets the number of fields for this row
 java.lang.String getString(java.lang.String attribName)
          Get a field value as an String
 TableModel getTable()
          Get the referenced table
 java.lang.String getTagName()
          Gets the model element tag name, e.g.
 java.lang.String getValue()
          Get the value of the first field in this row
 DataModel getValue(int i)
          Get the value of a field as a model node
 double getValueAsDouble(java.lang.String elementName)
          Get a field as a double value
 int getValueAsInt(java.lang.String elementName)
          Get an attribute as an int value
 java.lang.String getValueAsString(java.lang.String elementName)
          Gets the value attribute of the specified node as a string.
 int hashCode()
          Get the hashcode for this row
 void remove(DataModel node)
          Remove a node
 void set(java.lang.Object s)
          Sets the model value
 void set(java.lang.String attribName, java.lang.Object newObject)
          Set the value of the DataModel located at the elementName
 void setAttribValue(int i, java.lang.Object value)
          Sets the attribute (field) value
 void setAttribValue(int i, java.lang.String attribName, java.lang.Object value)
          Sets the attribute (field) value
 void setFieldValue(int colIdx, java.lang.String newValue)
          Set the value of a field
 void setRowReference(TableModel table, int row)
          Set the row to reference
 
Methods inherited from class org.formaria.aria.data.DataModel
addModelListener, clear, fireModelUpdated, getNumAttributes, getParent, hasAutoId, hasAutoId, prefixOutputPath, removeChildren, reset, resetAttributes, setId, setNumAttributes, setNumChildren, setParent, setTagName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rowIdx

protected int rowIdx

sourceData

protected TableModel sourceData
Constructor Detail

RowModel

public RowModel()
Default constructor, no table or row is referenced


RowModel

public RowModel(TableModel table,
                int row)
Construct a model node for a table

Parameters:
table - the table to reference
row - the row to reference
Method Detail

getTable

public TableModel getTable()
Get the referenced table

Returns:
the TableModel holding the data

setRowReference

public void setRowReference(TableModel table,
                            int row)
Set the row to reference

Parameters:
table - the table to reference
row - the row to reference

getValueAsDouble

public double getValueAsDouble(java.lang.String elementName)
Get a field as a double value

This method is required by the DataModel interface but in this case it is not implemented as it is inappropriate in the context of the class

Try getDouble instead

Specified by:
getValueAsDouble in class DataModel
Parameters:
elementName - the field name
Returns:
the field value

get

public java.lang.Object get(java.lang.String attribName)
Get a field value

Overrides:
get in class DataModel
Parameters:
attribName - the field name
Returns:
the field (FieldModel) value

getTagName

public java.lang.String getTagName()
Gets the model element tag name, e.g. 'Component' from the XML fragment
Overrides:
getTagName in class DataModel
Returns:
the model element name

append

public void append(DataModel newObject)
Append a node. Not implemented in this instance as it is not logical

Specified by:
append in class DataModel
Parameters:
newObject - the object to append

getInt

public int getInt(java.lang.String attribName)
Get a field value as an int

Parameters:
attribName - the fieldName
Returns:
the value

getDouble

public double getDouble(java.lang.String attribName)
Get a field value as an double

Parameters:
attribName - the fieldName
Returns:
the value

getString

public java.lang.String getString(java.lang.String attribName)
Get a field value as an String

Parameters:
attribName - the fieldName
Returns:
the value

getValue

public java.lang.String getValue()
Get the value of the first field in this row

Returns:
the field value

getFieldValue

public java.lang.String getFieldValue(int fieldIdx)
Gets an individual field value

Parameters:
fieldIdx - the field index
Returns:
the value

getAttribValue

public java.lang.Object getAttribValue(int i)
Get the value of an attribute

Specified by:
getAttribValue in class DataModel
Parameters:
i - the index of the attribute
Returns:
the attribute value

getAttribValueAsString

public java.lang.String getAttribValueAsString(int i)
Get an attribute as a string

Specified by:
getAttribValueAsString in class DataModel
Parameters:
i - the index of the attribute
Returns:
the attribute value

getValueAsString

public java.lang.String getValueAsString(java.lang.String elementName)
Gets the value attribute of the specified node as a string.

Specified by:
getValueAsString in class DataModel
Parameters:
elementName - the child element name
Returns:
the value as a string

getId

public java.lang.String getId()
Get the ID of this row

Specified by:
getId in class DataModel
Returns:
the row index as a string value

getAttribName

public java.lang.String getAttribName(int i)
Get the name of an attribute

Specified by:
getAttribName in class DataModel
Parameters:
i - the index of the attribute
Returns:
the attribute name

getAttribute

public int getAttribute(java.lang.String attribName)
returns the index of the attribiteNames array whose value is the same as the attribName

Specified by:
getAttribute in class DataModel
Parameters:
attribName - The name of the attribute we are trying to locate
Returns:
The index of the attributeNames array containg the name

set

public void set(java.lang.String attribName,
                java.lang.Object newObject)
Set the value of the DataModel located at the elementName

Specified by:
set in class DataModel
Parameters:
attribName - The path to the DataModel in the format 'base/foo
newObject - The new value of the DataModel

set

public void set(java.lang.Object s)
Sets the model value

Specified by:
set in class DataModel
Parameters:
s - the new value

get

public DataModel get(int i)
Gets the value attribute - a field value

Specified by:
get in class DataModel
Parameters:
i - the field index
Returns:
the value of the model

get

public java.lang.Object get()
Gets the value attribute

Specified by:
get in class DataModel
Returns:
the value of the model

append

public java.lang.Object append(java.lang.String id)
This method does not nothing it is provided merely as an implementation of the DataModel interface. A child or attribute can be logically appended to a table node.

Specified by:
append in class DataModel
Parameters:
id - the node id
Returns:
null as nothing is appended

getValueAsInt

public int getValueAsInt(java.lang.String elementName)
Get an attribute as an int value

This method is required by the DataModel interface but in this case it is not implemented as it is inappropriate in the context of the class

Specified by:
getValueAsInt in class DataModel
Parameters:
elementName - The name of the element whose value we want
Returns:
The string value of the attributeValues array at position i

getValue

public DataModel getValue(int i)
Get the value of a field as a model node

Parameters:
i - the field index
Returns:
the new field model node

setAttribValue

public void setAttribValue(int i,
                           java.lang.Object value)
Sets the attribute (field) value

Specified by:
setAttribValue in class DataModel
Parameters:
i - The index of the attributeValues array whose value we want
value - the value object

setAttribValue

public void setAttribValue(int i,
                           java.lang.String attribName,
                           java.lang.Object value)
Sets the attribute (field) value

Specified by:
setAttribValue in class DataModel
Parameters:
i - The index of the attributeValues array whose value we want
attribName - - ignored
value - the value object

setFieldValue

public void setFieldValue(int colIdx,
                          java.lang.String newValue)
Set the value of a field

Parameters:
colIdx - the field index
newValue - the new field value

hashCode

public int hashCode()
Get the hashcode for this row

Specified by:
hashCode in class DataModel
Returns:
the row id

getNumChildren

public int getNumChildren()
Gets the number of fields for this row

Overrides:
getNumChildren in class DataModel
Returns:
the number of fields

getAttribValueAsDouble

public double getAttribValueAsDouble(int i)
Deprecated. use getAttribValueAsDouble( i, decimalSeparator, groupingSeparator ) instead, if the locale is different from the locale used to write the values to the model, then the parsed value may be incorrect.

Get an attribute value as a double

Specified by:
getAttribValueAsDouble in class DataModel
Parameters:
i - The index of the attributeValues array whose value we want
Returns:
The double value of the attributeValues array at position i

getAttribValueAsDouble

public double getAttribValueAsDouble(int i,
                                     char decimalSeparator,
                                     char groupSeparator)
Get an attribute value as a double

Specified by:
getAttribValueAsDouble in class DataModel
Parameters:
i - The index of the attributeValues array whose value we want
decimalSeparator - the decimal separator
groupingSeparator - the grouping (thousands) separator
Returns:
The double value of the attributeValues array at position i

getAttribValueAsInt

public int getAttribValueAsInt(int i)
Get an attribute value as a string

Specified by:
getAttribValueAsInt in class DataModel
Parameters:
i - The index of the attributeValues array whose value we want
Returns:
The int value of the attributeValues array at position i

remove

public void remove(DataModel node)
Remove a node

This method is required by the DataModel interface but in this case it is not implemented as it is inappropriate in the context of the class

Parameters:
node - - ignored