org.jfree.report.function
Class TextFormatExpression

java.lang.Object
  extended byorg.jfree.report.function.AbstractExpression
      extended byorg.jfree.report.function.TextFormatExpression
All Implemented Interfaces:
java.lang.Cloneable, Expression, java.io.Serializable

public class TextFormatExpression
extends AbstractExpression
implements java.io.Serializable

A TextFormatExpression uses a java.text.MessageFormat to concat and format one or more values evaluated from an expression, function or report datasource.

The TextFormatExpression uses the pattern property to define the global format-pattern used when evaluating the expression. The dataRow fields used to fill the expressions placeholders are defined in a list of properties where the property-names are numbers. The property counting starts at "0".

The Syntax of the pattern property is explained in java.text.MessageFormat.

Example:

 
 
 Invoice for your order from {0, date, EEE, MMM d, yyyy}
 printdate
 
 
 

Author:
Thomas Morgner
See Also:
Serialized Form

Field Summary
static java.lang.String PATTERN_PROPERTY
          The property key for the pattern property.
 
Fields inherited from interface org.jfree.report.function.Expression
AUTOACTIVATE_PROPERTY
 
Constructor Summary
TextFormatExpression()
          Default constructor, creates a new unnamed TextFormatExpression.
 
Method Summary
 java.lang.Object clone()
          Clones the expression.
 java.lang.String getPattern()
          Returns the pattern defined for this expression.
 java.lang.Object getValue()
          Evaluates the expression by collecting all values defined in the fieldlist from the datarow.
 void initialize()
          Initializes the expression and creates the fieldlist.
 void setPattern(java.lang.String pattern)
          Defines the pattern for this expression.
 
Methods inherited from class org.jfree.report.function.AbstractExpression
getDataRow, getDependencyLevel, getInstance, getName, getProperties, getProperty, getProperty, isActive, setDataRow, setDependencyLevel, setName, setProperties, setProperty
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATTERN_PROPERTY

public static final java.lang.String PATTERN_PROPERTY
The property key for the pattern property.

See Also:
Constant Field Values
Constructor Detail

TextFormatExpression

public TextFormatExpression()
Default constructor, creates a new unnamed TextFormatExpression.

Method Detail

getValue

public java.lang.Object getValue()
Evaluates the expression by collecting all values defined in the fieldlist from the datarow. The collected values are then parsed and formated by the MessageFormat-object.

Specified by:
getValue in interface Expression
Returns:
a string containing the pattern inclusive the formatted values from the datarow

initialize

public void initialize()
                throws FunctionInitializeException
Initializes the expression and creates the fieldlist.

Specified by:
initialize in interface Expression
Overrides:
initialize in class AbstractExpression
Throws:
FunctionInitializeException - if the expression has no name set

getPattern

public java.lang.String getPattern()
Returns the pattern defined for this expression.

Returns:
the pattern.

setPattern

public void setPattern(java.lang.String pattern)
Defines the pattern for this expression. The pattern syntax is defined by the java.text.MessageFormat object and the given pattern string has to be valid according to the rules defined there.

Parameters:
pattern - the pattern string

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clones the expression.

Specified by:
clone in interface Expression
Overrides:
clone in class AbstractExpression
Returns:
a copy of this expression.
Throws:
java.lang.CloneNotSupportedException - this should never happen.