Class ExpressionCollection
- java.lang.Object
-
- 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
Constructors Constructor Description ExpressionCollection()
Creates a new expression collection (initially empty).ExpressionCollection(Collection expressions)
Creates a new expression collection, populated with the supplied expressions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, Expression e)
void
add(Expression e)
Adds an expression to the collection.void
addAll(Collection expressions)
Adds all expressions contained in the given collection to this expression collection.ExpressionCollection
clone()
Clones this expression collection and all expressions contained in the collection.boolean
contains(Expression expression)
Expression
get(String name)
Returns theExpression
with the specified name (ornull
).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)
void
removeExpression(int index)
Removes an expression from the collection.boolean
removeExpression(Expression e)
Removes an expression from the collection.Expression
set(int index, Expression element)
int
size()
Returns the number of active expressions in this collection.
-
-
-
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 theExpression
with the specified name (ornull
).- 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 ExpressionCollection clone()
Clones this expression collection and all expressions contained in the collection.
-
getExpressions
public Expression[] getExpressions()
Return all expressions contained in this collection as array.- Returns:
- the expressions as array.
-
contains
public boolean contains(Expression expression)
-
-