| java.lang.Object org.jfree.report.filter.FormatParser
All known Subclasses: org.jfree.report.filter.NumberFormatParser, org.jfree.report.filter.DateFormatParser,
FormatParser | public class FormatParser implements DataFilter(Code) | | A format parser tries to parse a string into an object. If the value returned by the datasource is no string, a
string is formed using String.valueOf (Object). This string is fed into the java.text.Format of this FormatParser and
the parsed object is returned.
What class of object is returned, is determined by the given format. If parsing failed, the defined NullValue is
returned.
author: Thomas Morgner |
Constructor Summary | |
public | FormatParser() DefaultConstructor. |
FormatParser | public FormatParser()(Code) | | DefaultConstructor.
|
getDataSource | public DataSource getDataSource()(Code) | | Returns the data source for the filter.
The data source. |
getFormatter | public Format getFormatter()(Code) | | Returns the format for the filter.
The format. |
getNullValue | public Object getNullValue()(Code) | | Returns the object representing a null value from the data source. This value will also be returned when parsing
failed or no parser or datasource is set at all.
The value returned when the parsing failed. |
getValue | public Object getValue(ExpressionRuntime runtime)(Code) | | Returns the parsed object. The value is read using the data source given and parsed using the formatter of this
object. The parsing is guaranteed to completly form the target object or to return the defined NullValue.
If the given datasource does not return a string, the returned object is transformed into a string using
String.valueOf (Object) and then parsed.
If format, datasource or object are null, the NullValue is returned.
Parameters: runtime - the expression runtime that is used to evaluate formulas and expressions when computing the value ofthis filter. The formatted value. |
isValidOutput | protected boolean isValidOutput(Object o)(Code) | | Checks whether the given value is already a valid result. IF the datasource already returned a valid value, and no
parsing is required, a parser can skip the parsing process by returning true in this function.
Parameters: o - the object to parse. false as this class does not know anything about the format of input or result objects. |
setDataSource | public void setDataSource(DataSource ds)(Code) | | Sets the data source.
Parameters: ds - The data source. |
setFormatter | public void setFormatter(Format format)(Code) | | Sets the format for the filter.
Parameters: format - The format. throws: NullPointerException - if the given format is null |
setNullValue | public void setNullValue(Object nullvalue)(Code) | | Sets the value that will be displayed if the data source supplies a null value. The nullValue itself can be null to
cover the case when no reasonable default value can be defined.
Parameters: nullvalue - The value returned when the parsing failed. |
|
|