org.pentaho.reporting.engine.classic.core.function
Class ExpressionCollection

java.lang.Object
  extended by org.pentaho.reporting.engine.classic.core.function.ExpressionCollection
All Implemented Interfaces:
Serializable, Cloneable

public class ExpressionCollection
extends Object
implements Cloneable, Serializable

Collects all expressions used in the report. Unlike earlier versions of this class, now expressions can have a null-name and more than one expression with the same name can exist in the collection. Expressions without a name will not appear in the datarow and expressions with duplicate names will only appear once (the last expression added will appear, according to the rules of duplicate entries in the datarow)

Author:
Thomas Morgner
See Also:
Serialized Form

Constructor Summary
ExpressionCollection()
          Creates a new expression collection (initially empty).
ExpressionCollection(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 add(int index, Expression e)
           
 void addAll(Collection expressions)
          Adds all expressions contained in the given collection to this expression collection.
 Object clone()
          Clones this expression collection and all expressions contained in the collection.
 boolean contains(Expression expression)
           
 Expression get(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.
 Expression[] getExpressions()
          Return all expressions contained in this collection as array.
 int indexOf(Expression element)
           
 boolean removeExpression(Expression e)
          Removes an expression from the collection.
 void removeExpression(int index)
          Removes an expression from the collection.
 Expression set(int index, Expression element)
           
 int size()
          Returns the number of active expressions in this collection.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionCollection

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


ExpressionCollection

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

Parameters:
expressions - a collection of expressions.
Throws:
ClassCastException - if the collection does not contain Expressions
Method Detail

addAll

public void addAll(Collection expressions)
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:
ClassCastException - if the collection does not contain expressions

get

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

Parameters:
name - the expression name (null not permitted).
Returns:
The expression.

add

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

Parameters:
e - the expression.

add

public void add(int index,
                Expression e)

removeExpression

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

Parameters:
e - the expression.
Returns:
true if the expression can be removed from (was present in) the list
Throws:
NullPointerException - if the given Expression is null.

removeExpression

public void removeExpression(int index)
Removes an expression from the collection.

Parameters:
index - the index of the expression ro remove

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:
IndexOutOfBoundsException - if the given position is invalid

indexOf

public int indexOf(Expression element)

set

public Expression set(int index,
                      Expression element)

clone

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

Overrides:
clone in class Object
Returns:
The clone.
Throws:
CloneNotSupportedException - should never happen.

getExpressions

public Expression[] getExpressions()
Return all expressions contained in this collection as array.

Returns:
the expressions as array.

contains

public boolean contains(Expression expression)