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

java.lang.Object
  extended by org.pentaho.reporting.engine.classic.core.filter.MessageFormatFilter
All Implemented Interfaces:
Serializable, Cloneable, DataSource

public class MessageFormatFilter
extends Object
implements DataSource

A filter that formats values from a data source to a string representation.

This filter will format objects using a MessageFormat to create the string representation for the number obtained from the datasource.

Author:
Joerg Schaible, Thomas Morgner
See Also:
MessageFormat, Serialized Form

Constructor Summary
MessageFormatFilter()
          Default constructor.
 
Method Summary
 Object clone()
          Clones this DataSource.
 String getFormatString()
          Returns the format string used in the message format.
 String getNullString()
          Returns the replacement text if one of the referenced fields in the message is null.
 Object getValue(ExpressionRuntime runtime, Element element)
          Returns the formatted string.
 void setFormatString(String format)
          Defines the format string for the MessageFormat object used in this implementation.
 void setNullString(String nullString)
          Defines the replacement text that is used, if one of the referenced fields in the message is null.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageFormatFilter

public MessageFormatFilter()
Default constructor.

Uses a general number format for the current locale.

Method Detail

setFormatString

public void setFormatString(String format)
Defines the format string for the MessageFormat object used in this implementation.

Parameters:
format - the message format.

getFormatString

public String getFormatString()
Returns the format string used in the message format.

Returns:
the format string.

getValue

public Object getValue(ExpressionRuntime runtime,
                       Element 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 interface DataSource
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.

clone

public Object clone()
             throws CloneNotSupportedException
Clones this DataSource.

Specified by:
clone in interface DataSource
Overrides:
clone in class Object
Returns:
the clone.
Throws:
CloneNotSupportedException - this should never happen.

getNullString

public String getNullString()
Returns the replacement text if one of the referenced fields in the message is null.

Returns:
the replacement string for null-values.

setNullString

public void setNullString(String nullString)
Defines the replacement text that is used, if one of the referenced fields in the message is null.

Parameters:
nullString - the replacement string for null-values.