Class StringFilter

  • All Implemented Interfaces:
    Serializable, Cloneable, DataFilter, DataSource, DataTarget, RawDataSource

    public class StringFilter
    extends Object
    implements DataFilter, RawDataSource
    A filter that returns the value from a data source as a String. The value is converted to an String using String.valueOf () which uses Object.toString() to convert the object into the string.

    You can specify a default string to return when the value from the data source is null. Initially the string 'null' is used.

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

      • StringFilter

        public StringFilter()
        Default constructor.
    • Method Detail

      • setNullValue

        public void setNullValue​(String nullvalue)
        Sets the string used to represent a null value.
        Parameters:
        nullvalue - the null value.
      • getNullValue

        public String getNullValue()
        Returns the string used to represent a null value.
        Returns:
        the string.
      • getValue

        public Object getValue​(ExpressionRuntime runtime,
                               ReportElement element)
        Returns the value obtained from the data source.

        The filter ensures that the returned value is a String, even though the return type is Object (as required by the DataSource interface).

        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 string.
      • getDataSource

        public DataSource getDataSource()
        Returns the data source for this filter.
        Specified by:
        getDataSource in interface DataTarget
        Returns:
        the data source.
      • setDataSource

        public void setDataSource​(DataSource ds)
        Sets the data source for this filter.
        Specified by:
        setDataSource in interface DataTarget
        Parameters:
        ds - the data source.
      • getRawValue

        public Object getRawValue​(ExpressionRuntime runtime,
                                  ReportElement element)
        Description copied from interface: RawDataSource
        Returns the unformated raw value. Whether that raw value is useable for the export is beyond the scope of this API definition, but providing access to Number or Date objects is a good idea.
        Specified by:
        getRawValue in interface RawDataSource
        Parameters:
        runtime - the expression runtime that is used to evaluate formulas and expressions when computing the value of this filter.
        Returns:
        the raw data.
      • getFormatString

        public FormatSpecification getFormatString​(ExpressionRuntime runtime,
                                                   ReportElement element,
                                                   FormatSpecification formatSpecification)
        Description copied from interface: RawDataSource
        Returns information about the formatstring that was used to transform a raw-value into a formatted text. Not all elements will make use of a format-string. These elements will return .classic.core.filter.FormatSpecification#TYPE_UNDEFINED in that case.
        Specified by:
        getFormatString in interface RawDataSource
        Parameters:
        runtime - the Expression runtime used to possibly compute the raw-value.
        element - the element to which this datasource is added.
        formatSpecification - the format specification (can be null). @return a filled format specififcation. If the formatSpecification parameter was not null, this given instance is reused.