org.jfree.report.filter
public class: DataRowDataSource [javadoc |
source]
java.lang.Object
org.jfree.report.filter.DataRowDataSource
All Implemented Interfaces:
DataSource
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.
The DataRowDataSource can either query the data-row directly using the specified field name or it can evaluate a
given formula (which must be compatible to the OpenFormula specifications) to compute the value.
Fields and formulas are mutually exclusive; defining a field name autmatically undefines the formula and vice versa.
| Method from org.jfree.report.filter.DataRowDataSource Detail: |
public Object clone() throws CloneNotSupportedException {
final DataRowDataSource drs = (DataRowDataSource) super.clone();
if (valueExpression != null)
{
drs.valueExpression = (FormulaExpression) valueExpression.clone();
}
return drs;
}
Clones the data source. A previously registered report definition is not inherited to the clone. |
public String getDataSourceColumnName() {
return field;
}
Returns the data source column name. |
public String getFormula() {
if (valueExpression == null)
{
return null;
}
return valueExpression.getFormula();
}
Returns the formula used to compute the value of the data source. |
public Object getValue(ExpressionRuntime runtime,
Element element) {
if (runtime == null)
{
return null;
}
if (field != null)
{
return runtime.getDataRow().get(field);
}
if (valueExpression == null)
{
return null;
}
valueExpression.setRuntime(runtime);
try
{
return valueExpression.getValue();
}
catch (Exception e)
{
// ignore ..
return null;
}
finally
{
valueExpression.setRuntime(null);
}
}
Returns the current value of the data source, obtained from a particular column in the data-row. |
public void setDataSourceColumnName(String dataSourceColumnName) {
if (dataSourceColumnName == null)
{
throw new NullPointerException();
}
this.field = dataSourceColumnName;
if (valueExpression != null)
{
this.valueExpression.setFormula(null);
}
}
Defines the name of the column in the datarow to be queried. |
public void setFormula(String formula) {
if (formula == null)
{
throw new NullPointerException();
}
this.field = null;
if (valueExpression == null)
{
valueExpression = new FormulaExpression();
}
this.valueExpression.setFormula(formula);
if ("field".equals(valueExpression.getFormulaNamespace()))
{
DataRowDataSource.logger.warn("Encountered formula with 'field' prefix. Direct access to field-data should not be done using a formula. Auto-Fixing.");
this.field = valueExpression.getFormulaExpression();
this.valueExpression.setFormula(null);
}
}
Defines the formula used to compute the value of this data source. |