org.jfree.report.function
Class ExpressionCollection

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

public class ExpressionCollection
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

Collects all expressions used in the report. There exist 2 states of the ExpressionCollection. In the first, modifiable state, expressions can be added to the collection. During the adding the expressions get initialized. An ExpressionCollection in this state is not able to connect to an DataRow.

The second state is an immutable state of this collection, no expressions can be added or removed. This ReadOnlyExpressionCollection can be created by calling getCopy() on the first-state expression collection. The ReadOnlyExpressionCollection is able to connect to a DataRow.

Author:
Thomas Morgner
See Also:
Serialized Form

Constructor Summary
ExpressionCollection()
          Creates a new expression collection (initially empty).
ExpressionCollection(java.util.Collection expressions)
          Creates a new expression collection, populated with the supplied expressions.
 
Method Summary
 void add(Expression e)
          Adds an expression to the collection.
 void addAll(java.util.Collection expressions)
          Adds all expressions contained in the given collection to this expression collection.
 java.lang.Object clone()
          Clones this expression collection and all expressions contained in the collection.
 Expression get(java.lang.String name)
          Returns the Expression with the specified name (or null).
 Expression getExpression(int pos)
          Returns the expression on the given position in the list.
protected  void privateAdd(Expression e)
          Adds an expression to the collection.
 void removeExpression(Expression e)
          Removes an expression from the collection.
 int size()
          Returns the number of active expressions in this collection.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionCollection

public ExpressionCollection()
Creates a new expression collection (initially empty).


ExpressionCollection

public ExpressionCollection(java.util.Collection expressions)
                     throws FunctionInitializeException
Creates a new expression collection, populated with the supplied expressions.

Parameters:
expressions - a collection of expressions.
Throws:
FunctionInitializeException - if any of the expressions cannot be initialized.
java.lang.ClassCastException - if the collection does not contain Expressions
Method Detail

addAll

public void addAll(java.util.Collection expressions)
            throws FunctionInitializeException
Adds all expressions contained in the given collection to this expression collection. The expressions get initialized during the adding process.

Parameters:
expressions - the expressions to be added.
Throws:
java.lang.ClassCastException - if the collection does not contain expressions
FunctionInitializeException - if a contained expression could not be initialized.

get

public Expression get(java.lang.String name)
Returns the Expression with the specified name (or null).

Parameters:
name - the expression name (null not permitted).
Returns:
The expression.
Throws:
java.lang.NullPointerException - if the name given is null.

add

public void add(Expression e)
         throws FunctionInitializeException
Adds an expression to the collection. The expression is initialized before it is added to this collection.

Parameters:
e - the expression.
Throws:
FunctionInitializeException - if the Expression could not be initialized correctly

privateAdd

protected void privateAdd(Expression e)
Adds an expression to the collection.

Parameters:
e - the expression.
Throws:
java.lang.NullPointerException - if the given Expression is null.

removeExpression

public void removeExpression(Expression e)
Removes an expression from the collection.

Parameters:
e - the expression.
Throws:
java.lang.NullPointerException - if the given Expression is null.

size

public int size()
Returns the number of active expressions in this collection.

Returns:
the number of expressions in this collection

getExpression

public Expression getExpression(int pos)
Returns the expression on the given position in the list.

Parameters:
pos - the position in the list.
Returns:
the expression.
Throws:
java.lang.IndexOutOfBoundsException - if the given position is invalid

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clones this expression collection and all expressions contained in the collection.

Returns:
The clone.
Throws:
java.lang.CloneNotSupportedException - should never happen.