Class DataRowDataSource

  • All Implemented Interfaces:
    Serializable, Cloneable, DataSource

    public class DataRowDataSource
    extends Object
    implements 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.

    Author:
    Thomas Morgner
    See Also:
    DataRow, Serialized Form
    • Constructor Detail

      • DataRowDataSource

        public DataRowDataSource()
        Default constructor.

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

      • DataRowDataSource

        public DataRowDataSource​(String column)
        Constructs a new data source.
        Parameters:
        column - the name of the field, function or expression in the data-row.
    • Method Detail

      • getField

        public String getField()
        Deprecated.
        Required for legacy-parsing, do not use elsewhere.
      • setField

        public void setField​(String field)
        Deprecated.
        Required for legacy-parsing, do not use elsewhere.
        Parameters:
        field -
      • getDataSourceColumnName

        public String getDataSourceColumnName()
        Returns the data source column name.
        Returns:
        the column name.
      • setDataSourceColumnName

        public void setDataSourceColumnName​(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:
        NullPointerException - if the name is null.
        See Also:
        DataRow.get(java.lang.String)
      • getFormula

        public String getFormula()
        Returns the formula used to compute the value of the data source.
        Returns:
        the formula.
      • setFormula

        public void setFormula​(String formula)
        Defines the formula used to compute the value of this data source.
        Parameters:
        formula - the formula for the data source.
      • getValue

        public Object getValue​(ExpressionRuntime runtime,
                               ReportElement element)
        Returns the current value of the data source, obtained from a particular column in the data-row.
        Specified by:
        getValue in interface DataSource
        Parameters:
        runtime - the expression runtime that is used to evaluate formulas and expressions when computing the value of this filter.
        element -
        Returns:
        the value.