net.xoetrope.xui.data.table
Class XRowModel

java.lang.Object
  extended by net.xoetrope.xui.data.XModel
      extended by net.xoetrope.xui.data.table.XRowModel
Direct Known Subclasses:
DatabaseRowModel

public class XRowModel
extends XModel

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 XTableModel class

Copyright (c) Xoetrope Ltd. 2001-2003

$Revision: 2.7 $ License: see license.txt


Field Summary
protected  int rowIdx
           
protected  XTableModel sourceData
           
 
Fields inherited from class net.xoetrope.xui.data.XModel
parentModel, tagName
 
Constructor Summary
XRowModel()
          Default constructor, no table or row is referenced
XRowModel(XTableModel table, int row)
          Construct a model node for a table
 
Method Summary
 java.lang.Object append(java.lang.String id)
          This method does not nothing it is provided merely as an implementation of the XModel interface.
 void append(XModel newObject)
          Append a node.
 java.lang.Object get()
          Gets the value attribute
 XModel 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
 XTableModel 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
 XModel 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 This method is required by the XModel interface but in this case it is not implemented as it is inappropriate in the context of the class Try getDouble instead
 int getValueAsInt(java.lang.String elementName)
          Get an attribute as an int value This method is required by the XModel interface but in this case it is not implemented as it is inappropriate in the context of the class
 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(XModel node)
          Remove a node This method is required by the XModel interface but in this case it is not implemented as it is inappropriate in the context of the class
 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 XModel 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(XTableModel table, int row)
          Set the row to reference
 
Methods inherited from class net.xoetrope.xui.data.XModel
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 XTableModel sourceData
Constructor Detail

XRowModel

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


XRowModel

public XRowModel(XTableModel 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 XTableModel getTable()
Get the referenced table

Returns:
the XTableModel holding the data

setRowReference

public void setRowReference(XTableModel 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 XModel 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 XModel
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 XModel
Parameters:
attribName - the field name
Returns:
the field (XFieldModel) value

getTagName

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

append

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

Specified by:
append in class XModel
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 XModel
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 XModel
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 XModel
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 XModel
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 XModel
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 XModel
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 XModel located at the elementName

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

set

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

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

get

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

Specified by:
get in class XModel
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 XModel
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 XModel interface. A child or attribute can be logically appended to a table node.

Specified by:
append in class XModel
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 XModel interface but in this case it is not implemented as it is inappropriate in the context of the class

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

getValue

public XModel 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 XModel
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 XModel
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 XModel
Returns:
the row id

getNumChildren

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

Overrides:
getNumChildren in class XModel
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 XModel
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 XModel
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 XModel
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(XModel node)
Remove a node

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

Parameters:
node - - ignored