Class StringFilter
- java.lang.Object
-
- org.pentaho.reporting.engine.classic.core.filter.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 isnull
. Initially the string 'null' is used.- Author:
- Thomas Morgner
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description StringFilter()
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringFilter
clone()
Clones the filter.DataSource
getDataSource()
Returns the data source for this filter.FormatSpecification
getFormatString(ExpressionRuntime runtime, ReportElement element, FormatSpecification formatSpecification)
Returns information about the formatstring that was used to transform a raw-value into a formatted text.String
getNullValue()
Returns the string used to represent a null value.Object
getRawValue(ExpressionRuntime runtime, ReportElement element)
Returns the unformated raw value.Object
getValue(ExpressionRuntime runtime, ReportElement element)
Returns the value obtained from the data source.void
setDataSource(DataSource ds)
Sets the data source for this filter.void
setNullValue(String nullvalue)
Sets the string used to represent a null value.
-
-
-
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 interfaceDataSource
- 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 interfaceDataTarget
- Returns:
- the data source.
-
setDataSource
public void setDataSource(DataSource ds)
Sets the data source for this filter.- Specified by:
setDataSource
in interfaceDataTarget
- Parameters:
ds
- the data source.
-
clone
public StringFilter clone() throws CloneNotSupportedException
Clones the filter.- Specified by:
clone
in interfaceDataSource
- Specified by:
clone
in interfaceDataTarget
- Overrides:
clone
in classObject
- Returns:
- a clone.
- Throws:
CloneNotSupportedException
- this should never happen.
-
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 toNumber
orDate
objects is a good idea.- Specified by:
getRawValue
in interfaceRawDataSource
- 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 interfaceRawDataSource
- 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 theformatSpecification
parameter was not null, this given instance is reused.
-
-