Class SimpleDateFormatFilter
- java.lang.Object
-
- org.pentaho.reporting.engine.classic.core.filter.FormatFilter
-
- org.pentaho.reporting.engine.classic.core.filter.DateFormatFilter
-
- org.pentaho.reporting.engine.classic.core.filter.SimpleDateFormatFilter
-
- All Implemented Interfaces:
Serializable
,Cloneable
,DataFilter
,DataSource
,DataTarget
,RawDataSource
public class SimpleDateFormatFilter extends DateFormatFilter
A filter that creates string from dates. This filter will format java.util. Date objects using a java.text.SimpleDateFormat 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. This implementation uses a SimpleDateFormat and grants more control over the parsing results.- Author:
- Thomas Morgner
- See Also:
SimpleDateFormat
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SimpleDateFormatFilter()
DefaultConstructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getFormatString()
Returns the formatString for this SimpleDateFormat.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
getLocalizedFormatString()
Returns a localized formatString for this SimpleDateFormat.SimpleDateFormat
getSimpleDateFormat()
Returns the SimpleDateFormat object used in this filter.Object
getValue(ExpressionRuntime runtime, ReportElement element)
Returns the formatted string.boolean
isKeepState()
Defines, whether the filter should keep its state, if a locale change is detected.void
setFormatString(String format)
defines the formatString for this SimpleDateFormat.void
setFormatter(Format format)
Sets the date format for the filter.void
setKeepState(boolean keepState)
Defines, whether the filter should keep its state, if a locale change is detected.void
setLocalizedFormatString(String format)
defines the localized formatString for this SimpleDateFormat.void
setSimpleDateFormat(SimpleDateFormat format)
Sets the date format for the filter.-
Methods inherited from class org.pentaho.reporting.engine.classic.core.filter.DateFormatFilter
getDateFormat, getRawValue, setDateFormat
-
Methods inherited from class org.pentaho.reporting.engine.classic.core.filter.FormatFilter
clone, getDataSource, getFormatter, getNullValue, invalidateCache, setDataSource, setNullValue
-
-
-
-
Method Detail
-
getSimpleDateFormat
public SimpleDateFormat getSimpleDateFormat()
Returns the SimpleDateFormat object used in this filter.- Returns:
- The date format object.
-
setSimpleDateFormat
public void setSimpleDateFormat(SimpleDateFormat 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 date format for the filter. This narrows the allows formats down to SimpleDateFormat.- Overrides:
setFormatter
in classDateFormatFilter
- Parameters:
format
- The format.- Throws:
NullPointerException
- if the format given is nullClassCastException
- if the format given is no DateFormat
-
getFormatString
public String getFormatString()
Returns the formatString for this SimpleDateFormat. For a more detailed explaination of SimpleDateFormat formatstrings see java.text.SimpleDateFormat.- Returns:
- the format string for the used DateFormat.
- See Also:
SimpleDateFormat
-
setFormatString
public void setFormatString(String format)
defines the formatString for this SimpleDateFormat.- Parameters:
format
- the formatString- Throws:
IllegalArgumentException
- if the string is invalid
-
getLocalizedFormatString
public String getLocalizedFormatString()
Returns a localized formatString for this SimpleDateFormat. For a more detailed explaination of SimpleDateFormat formatstrings see java.text.SimpleDateFormat.- Returns:
- the localized format string.
- See Also:
SimpleDateFormat
-
setLocalizedFormatString
public void setLocalizedFormatString(String format)
defines the localized formatString for this SimpleDateFormat.- Parameters:
format
- the formatString- Throws:
IllegalArgumentException
- if the string is invalid
-
isKeepState
public boolean isKeepState()
Defines, whether the filter should keep its state, if a locale change is detected. This will effectivly disable the locale update.- Returns:
- true, if the locale should not update the DateSymbols, false otherwise.
-
setKeepState
public void setKeepState(boolean keepState)
Defines, whether the filter should keep its state, if a locale change is detected. This will effectivly disable the locale update.- Parameters:
keepState
- set to true, if the locale should not update the DateSymbols, false otherwise.
-
getValue
public Object getValue(ExpressionRuntime runtime, ReportElement element)
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 interfaceDataSource
- Overrides:
getValue
in classDateFormatFilter
- Parameters:
runtime
- the expression runtime that is used to evaluate formulas and expressions when computing the value of this filter.element
-- Returns:
- The formatted value.
-
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
- Overrides:
getFormatString
in classDateFormatFilter
- 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.
-
-