com.jrefinery.report.filter
Class DataRowDataSource

java.lang.Object
  extended bycom.jrefinery.report.filter.DataRowDataSource
All Implemented Interfaces:
java.lang.Cloneable, DataRowConnectable, DataSource, java.io.Serializable

public class DataRowDataSource
extends java.lang.Object
implements DataSource, DataRowConnectable, java.io.Serializable

A DataSource that can access values from the 'data-row'. The data-row contains all values from the current row of the report's TableModel, plus the current values of the defined expressions and functions for the report.

This class replaces the three classes: ExpressionDataSource, FunctionDataSource and ReportDataSource.

Author:
Thomas Morgner
See Also:
DataRow, Serialized Form

Constructor Summary
DataRowDataSource()
          Default constructor.
DataRowDataSource(java.lang.String column)
          Constructs a new data source.
 
Method Summary
 java.lang.Object clone()
          Clones the data source.
 void connectDataRow(DataRow row)
          Connects a data-row to the data source.
 void disconnectDataRow(DataRow row)
          Releases the connection to the data-row.
 DataRow getDataRow()
          Returns the current data-row.
 java.lang.String getDataSourceColumnName()
          Returns the data source column name.
 java.lang.Object getValue()
          Returns the current value of the data source, obtained from a particular column in the data-row.
 void setDataSourceColumnName(java.lang.String dataSourceColumnName)
          Defines the name of the column in the datarow to be queried.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataRowDataSource

public DataRowDataSource()
Default constructor.

The expression name is empty ("", not null), the value initially null.


DataRowDataSource

public DataRowDataSource(java.lang.String column)
Constructs a new data source.

Parameters:
column - the name of the field, function or expression in the data-row.
Method Detail

getDataSourceColumnName

public java.lang.String getDataSourceColumnName()
Returns the data source column name.

Returns:
the column name.

setDataSourceColumnName

public void setDataSourceColumnName(java.lang.String dataSourceColumnName)
Defines the name of the column in the datarow to be queried.

Parameters:
dataSourceColumnName - the name of the column in the datarow to be queried.
Throws:
java.lang.NullPointerException - if the name is null.
See Also:
DataRow.get(int)

getValue

public java.lang.Object getValue()
Returns the current value of the data source, obtained from a particular column in the data-row.

Specified by:
getValue in interface DataSource
Returns:
the value.
Throws:
java.lang.IllegalStateException - if there is no data-row connected.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clones the data source.

Specified by:
clone in interface DataSource
Returns:
a clone.
Throws:
java.lang.CloneNotSupportedException - if the cloning is not supported.

connectDataRow

public void connectDataRow(DataRow row)
                    throws java.lang.IllegalStateException
Connects a data-row to the data source.

Specified by:
connectDataRow in interface DataRowConnectable
Parameters:
row - the data-row (null not permitted).
Throws:
java.lang.NullPointerException - if the given row is null
java.lang.IllegalStateException - if there is a datarow already connected.

disconnectDataRow

public void disconnectDataRow(DataRow row)
                       throws java.lang.IllegalStateException
Releases the connection to the data-row.

If no datarow is connected, an IllegalStateException is thrown to indicate the programming error.

Specified by:
disconnectDataRow in interface DataRowConnectable
Parameters:
row - the datarow to be disconnected.
Throws:
java.lang.NullPointerException - if the given row is null
java.lang.IllegalStateException - if there is currently no datarow connected.

getDataRow

public DataRow getDataRow()
Returns the current data-row.

Returns:
the data-row.