org.ujac.util.table
Class BaseRow

java.lang.Object
  extended by org.ujac.util.table.BaseRow
All Implemented Interfaces:
Serializable, Row
Direct Known Subclasses:
DataRow, HeaderRow

public abstract class BaseRow
extends Object
implements Row, Serializable

Name: BaseRow
Description: A base class for row implementations.

Author:
lauerc
See Also:
Serialized Form

Field Summary
protected  List rowData
          The list which holds the row data.
protected  Table table
          The table, which contains this row.
 
Constructor Summary
BaseRow(Table table)
          Constructs a BaseRow instance with specific attributes.
BaseRow(Table table, Row srcRow)
          Constructs a BaseRow instance with specific attributes.
 
Method Summary
 List asList()
          Gets the list of elements from this row.
protected  void expandRow()
          Expands the length of the row to the number of columns of the table.
 String formatValue(int columnIdx)
          Formats the given column's value for output.
 String formatValue(String columnName)
          Formats the given column's value for output.
 int getAlign(int columnIdx)
          Gets the alignment of the given field.
 int getAlign(String columnName)
          Gets the alignment of the given field.
protected  int getFieldAlignment(LayoutHints lh)
          Gets the field alignment.
 Format getFormat(int columnIdx)
          Gets the format of the given field.
 Format getFormat(String columnName)
          Gets the format of the given field.
 Table getTable()
          Gets the table the row is member of.
 boolean isEndsBlock()
          Tells whether or not this row ends the current row block.
 boolean isStartNewPage()
          Tells whether or not to start a new page before printing this row.
 boolean isStartsBlock()
          Tells whether or not this row starts a new row block.
 boolean isVisible(int columnIdx)
          Checks whether the given field is visible or not.
 boolean isVisible(String columnName)
          Checks whether the given field is visible or not.
protected  void readData(ObjectInputStream s)
          Reads the object's data from the given stream.
 void setAlign(int columnIdx, int alignment)
          Sets the row specific alignment for the given field.
 void setAlign(String columnName, int alignment)
          Sets the row specific alignment for the given field.
 void setEndsBlock(boolean endsBlock)
          Sets the endsBlock flag.
 void setFormat(int columnIdx, Format format)
          Sets the row specific format for the given field.
 void setFormat(String columnName, Format format)
          Sets the row specific format for the given field.
 void setStartNewPage(boolean startNewPage)
          Sets the startNewPage flag.
 void setStartsBlock(boolean startsBlock)
          Sets the startsBlock flag.
 void setVisible(int columnIdx, boolean visible)
          Sets the row specific visibility flag for the given field.
 void setVisible(String columnName, boolean visible)
          Sets the row specific visibility flag for the given field.
 String toString()
           
protected  void writeData(ObjectOutputStream s)
          Writes the object's data to the given stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ujac.util.table.Row
getBoolean, getBoolean, getDate, getDate, getDouble, getDouble, getFloat, getFloat, getIndex, getInt, getInt, getLong, getLong, getObject, getObject, getString, getString, getTime, getTime, getTimestamp, getTimestamp, getType, setBoolean, setBoolean, setDate, setDate, setDouble, setDouble, setFloat, setFloat, setInt, setInt, setLong, setLong, setObject, setObject, setString, setString, setTime, setTime, setTimestamp, setTimestamp
 

Field Detail

table

protected Table table
The table, which contains this row.


rowData

protected List rowData
The list which holds the row data.

Constructor Detail

BaseRow

public BaseRow(Table table)
Constructs a BaseRow instance with specific attributes.

Parameters:
table - The row's table.

BaseRow

public BaseRow(Table table,
               Row srcRow)
Constructs a BaseRow instance with specific attributes.

Parameters:
table - The row's table.
srcRow - the row to copy.
Method Detail

getTable

public Table getTable()
Gets the table the row is member of.

Specified by:
getTable in interface Row
Returns:
The table that contains this row.

asList

public List asList()
Gets the list of elements from this row.

Specified by:
asList in interface Row
Returns:
The row data as a List.

formatValue

public String formatValue(String columnName)
                   throws ColumnNotDefinedException,
                          TypeMismatchException
Formats the given column's value for output.

Specified by:
formatValue in interface Row
Parameters:
columnName - The name of the desired column.
Returns:
The formatted value.
Throws:
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the data conversion failed.

formatValue

public String formatValue(int columnIdx)
                   throws ColumnNotDefinedException,
                          TypeMismatchException
Formats the given column's value for output.

Specified by:
formatValue in interface Row
Parameters:
columnIdx - The index of the desired column.
Returns:
The detected value.
Throws:
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the data conversion failed.

isVisible

public boolean isVisible(String columnName)
                  throws ColumnNotDefinedException
Checks whether the given field is visible or not.

Specified by:
isVisible in interface Row
Parameters:
columnName - The name of the desired column.
Returns:
The visibility flag.
Throws:
ColumnNotDefinedException - In case the requested column does not exist.

isVisible

public boolean isVisible(int columnIdx)
                  throws ColumnNotDefinedException
Checks whether the given field is visible or not.

Specified by:
isVisible in interface Row
Parameters:
columnIdx - The index of the desired column.
Returns:
The visibility flag.
Throws:
ColumnNotDefinedException - In case the requested column does not exist.

setVisible

public void setVisible(String columnName,
                       boolean visible)
                throws ColumnNotDefinedException
Sets the row specific visibility flag for the given field.

Specified by:
setVisible in interface Row
Parameters:
columnName - The name of the desired column.
visible - The visibility flag.
Throws:
ColumnNotDefinedException - In case the requested column does not exist.

setVisible

public void setVisible(int columnIdx,
                       boolean visible)
                throws ColumnNotDefinedException
Sets the row specific visibility flag for the given field.

Specified by:
setVisible in interface Row
Parameters:
columnIdx - The index of the desired column.
visible - The visibility flag.
Throws:
ColumnNotDefinedException - In case the requested column does not exist.

getFormat

public Format getFormat(String columnName)
                 throws ColumnNotDefinedException
Gets the format of the given field.

Specified by:
getFormat in interface Row
Parameters:
columnName - The name of the desired column.
Returns:
The field's format.
Throws:
ColumnNotDefinedException - In case the requested column does not exist.

getFormat

public Format getFormat(int columnIdx)
                 throws ColumnNotDefinedException
Gets the format of the given field.

Specified by:
getFormat in interface Row
Parameters:
columnIdx - The index of the desired column.
Returns:
The field's format.
Throws:
ColumnNotDefinedException - In case the requested column does not exist.

setFormat

public void setFormat(String columnName,
                      Format format)
               throws ColumnNotDefinedException
Sets the row specific format for the given field.

Specified by:
setFormat in interface Row
Parameters:
columnName - The name of the desired column.
format - The format to set.
Throws:
ColumnNotDefinedException - In case the requested column does not exist.

setFormat

public void setFormat(int columnIdx,
                      Format format)
               throws ColumnNotDefinedException
Sets the row specific format for the given field.

Specified by:
setFormat in interface Row
Parameters:
columnIdx - The index of the desired column.
format - The format to set.
Throws:
ColumnNotDefinedException - In case the requested column does not exist.

getAlign

public int getAlign(String columnName)
             throws ColumnNotDefinedException
Gets the alignment of the given field.

Specified by:
getAlign in interface Row
Parameters:
columnName - The name of the desired column.
Returns:
The field's alignment.
Throws:
ColumnNotDefinedException - In case the requested column does not exist.

getAlign

public int getAlign(int columnIdx)
             throws ColumnNotDefinedException
Gets the alignment of the given field.

Specified by:
getAlign in interface Row
Parameters:
columnIdx - The index of the desired column.
Returns:
The field's alignment.
Throws:
ColumnNotDefinedException - In case the requested column does not exist.

getFieldAlignment

protected int getFieldAlignment(LayoutHints lh)
Gets the field alignment.

Parameters:
lh - The layout hints.
Returns:
The field alignment from the given layout hints.

setAlign

public void setAlign(String columnName,
                     int alignment)
              throws ColumnNotDefinedException
Sets the row specific alignment for the given field.

Specified by:
setAlign in interface Row
Parameters:
columnName - The name of the desired column.
alignment - The format to set.
Throws:
ColumnNotDefinedException - In case the requested column does not exist.

setAlign

public void setAlign(int columnIdx,
                     int alignment)
              throws ColumnNotDefinedException
Sets the row specific alignment for the given field.

Specified by:
setAlign in interface Row
Parameters:
columnIdx - The index of the desired column.
alignment - The format to set.
Throws:
ColumnNotDefinedException - In case the requested column does not exist.

isStartNewPage

public boolean isStartNewPage()
Tells whether or not to start a new page before printing this row.

Specified by:
isStartNewPage in interface Row
Returns:
true, if a page break is required here, else false.

setStartNewPage

public void setStartNewPage(boolean startNewPage)
Sets the startNewPage flag.

Specified by:
setStartNewPage in interface Row
Parameters:
startNewPage - The new value for the startNewPage attribute.

isStartsBlock

public boolean isStartsBlock()
Tells whether or not this row starts a new row block.

Specified by:
isStartsBlock in interface Row
Returns:
true, if this row starts a new row block, else false.

setStartsBlock

public void setStartsBlock(boolean startsBlock)
Sets the startsBlock flag.

Specified by:
setStartsBlock in interface Row
Parameters:
startsBlock - The new value for the startsBlock attribute.

isEndsBlock

public boolean isEndsBlock()
Tells whether or not this row ends the current row block.

Specified by:
isEndsBlock in interface Row
Returns:
true, if this row ends the current row block, else false.

setEndsBlock

public void setEndsBlock(boolean endsBlock)
Sets the endsBlock flag.

Specified by:
setEndsBlock in interface Row
Parameters:
endsBlock - The new value for the endsBlock attribute.

expandRow

protected void expandRow()
Expands the length of the row to the number of columns of the table.


toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()

writeData

protected void writeData(ObjectOutputStream s)
                  throws IOException
Writes the object's data to the given stream.

Parameters:
s - The stream to write to
Throws:
IOException - In case the data output failed.

readData

protected void readData(ObjectInputStream s)
                 throws IOException,
                        ClassNotFoundException
Reads the object's data from the given stream.

Parameters:
s - The stream to read from.
Throws:
IOException - In case the data reading failed.
ClassNotFoundException - In case the class to deserialize could not be found


Copyright © 2003-2004 UJAC.org. All Rights Reserved.