org.pentaho.reporting.engine.classic.core.filter
Class DateFormatFilter

java.lang.Object
  extended by org.pentaho.reporting.engine.classic.core.filter.FormatFilter
      extended by org.pentaho.reporting.engine.classic.core.filter.DateFormatFilter
All Implemented Interfaces:
Serializable, Cloneable, DataFilter, DataSource, DataTarget, RawDataSource
Direct Known Subclasses:
SimpleDateFormatFilter

public class DateFormatFilter
extends FormatFilter

A filter that creates string from dates. This filter will format java.util. Date objects using a java.text.DateFormat to create the string representation for the date obtained from the datasource.

If the object read from the datasource is no date, the NullValue defined by setNullValue(Object) is returned.

Author:
Thomas Morgner
See Also:
DateFormat, Serialized Form

Constructor Summary
DateFormatFilter()
          Default constructor.
 
Method Summary
 DateFormat getDateFormat()
          Returns the date format object.
 FormatSpecification getFormatString(ExpressionRuntime runtime, Element element, FormatSpecification formatSpecification)
          Returns information about the formatstring that was used to transform a raw-value into a formatted text.
 Object getRawValue(ExpressionRuntime runtime, Element element)
          Returns the unformated raw value.
 Object getValue(ExpressionRuntime runtime, Element element)
          Returns the formatted string.
 void setDateFormat(DateFormat format)
          Sets the date format for the filter.
 void setFormatter(Format format)
          Sets the formatter.
 
Methods inherited from class org.pentaho.reporting.engine.classic.core.filter.FormatFilter
clone, getDataSource, getFormatter, getNullValue, setDataSource, setNullValue
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateFormatFilter

public DateFormatFilter()
Default constructor. Creates a new filter using the default date format for the current locale.

Method Detail

getDateFormat

public DateFormat getDateFormat()
Returns the date format object.

Returns:
The date format object.

setDateFormat

public void setDateFormat(DateFormat format)
Sets the date format for the filter.

Parameters:
format - The format.
Throws:
NullPointerException - if the format given is null

setFormatter

public void setFormatter(Format format)
Sets the formatter.

Overrides:
setFormatter in class FormatFilter
Parameters:
format - The format.
Throws:
ClassCastException - if the format given is no DateFormat
NullPointerException - if the format given is null

getRawValue

public Object getRawValue(ExpressionRuntime runtime,
                          Element 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
Overrides:
getRawValue in class FormatFilter
Parameters:
runtime - the expression runtime that is used to evaluate formulas and expressions when computing the value of this filter.
Returns:
the raw data.

getValue

public Object getValue(ExpressionRuntime runtime,
                       Element element)
Description copied from class: FormatFilter
Returns the formatted string. The value is read using the data source given and formated using the formatter of this object. The formating is guaranteed to completly form the object to an string or to return the defined NullValue.

If format, datasource or object are null, the NullValue is returned.

Specified by:
getValue in interface DataSource
Overrides:
getValue in class FormatFilter
Parameters:
runtime - the expression runtime that is used to evaluate formulas and expressions when computing the value of this filter.
element - the element for which the data is computed.
Returns:
The formatted value.

getFormatString

public FormatSpecification getFormatString(ExpressionRuntime runtime,
                                           Element 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 FormatSpecification.TYPE_UNDEFINED in that case.

Specified by:
getFormatString in interface RawDataSource
Overrides:
getFormatString in class FormatFilter
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.