com.jrefinery.report.filter
Class DateFormatParser

java.lang.Object
  |
  +--com.jrefinery.report.filter.FormatParser
        |
        +--com.jrefinery.report.filter.DateFormatParser
All Implemented Interfaces:
java.lang.Cloneable, DataFilter, DataSource, DataTarget, java.io.Serializable
Direct Known Subclasses:
SimpleDateFormatParser

public class DateFormatParser
extends FormatParser

Parses a String into a java.util.Date. The string is read from the given datasource and then parsed by the dateformat contained in this FormatParser.

Author:
Thomas Morgner
See Also:
Serialized Form

Constructor Summary
DateFormatParser()
          Creates a new 'date format parser'.
 
Method Summary
 java.text.DateFormat getDateFormat()
          Returns the format for this filter.
protected  boolean isValidOutput(java.lang.Object o)
          Checks whether the given value is already a valid result.
 void setDateFormat(java.text.DateFormat format)
          Sets the format for the filter.
 void setFormatter(java.text.Format format)
          Sets the format for the filter.
 void setNullValue(java.lang.Object nullvalue)
          Sets the value that will be displayed if the data source supplies a null value.
 
Methods inherited from class com.jrefinery.report.filter.FormatParser
clone, getDataSource, getFormatter, getNullValue, getValue, setDataSource
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateFormatParser

public DateFormatParser()
Creates a new 'date format parser'.

Method Detail

getDateFormat

public java.text.DateFormat getDateFormat()
Returns the format for this filter. The format object is returned as DateFormat.

Returns:
the formatter.
Throws:
java.lang.NullPointerException - if the given format is null

setDateFormat

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

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

setFormatter

public void setFormatter(java.text.Format format)
Sets the format for the filter. The formater is required to be of type DateFormat.

Overrides:
setFormatter in class FormatParser
Parameters:
format - The format.
Throws:
java.lang.NullPointerException - if the given format is null
java.lang.ClassCastException - if an invalid formater is set.

setNullValue

public void setNullValue(java.lang.Object nullvalue)
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.

The null value for date format parsers is required to be either null or a java.util.Date.

Overrides:
setNullValue in class FormatParser
Parameters:
nullvalue - the nullvalue returned when parsing failed.
Throws:
java.lang.ClassCastException - if the value is no date or not null.

isValidOutput

protected boolean isValidOutput(java.lang.Object o)
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.

Overrides:
isValidOutput in class FormatParser
Parameters:
o - the value.
Returns:
true, if the given value is already an instance of date.