public abstract class Expression extends Object implements Serializable, XMLSerializable
Modifier and Type | Field and Description |
---|---|
static int |
ADD |
static int |
AND |
static int |
ASTERISK |
static int |
BETWEEN |
static int |
BITWISE_AND |
static int |
BITWISE_LEFT_SHIFT |
static int |
BITWISE_NOT |
static int |
BITWISE_OR |
static int |
BITWISE_RIGHT_SHIFT |
static int |
BITWISE_XOR |
static int |
DB_PATH
Expression describes a path relative to a DbEntity.
|
static int |
DIVIDE |
static int |
EQUAL_TO |
static int |
FALSE |
static int |
FULL_OBJECT |
static int |
FUNCTION_CALL |
static int |
GREATER_THAN |
static int |
GREATER_THAN_EQUAL_TO |
static int |
IN |
static int |
LESS_THAN |
static int |
LESS_THAN_EQUAL_TO |
static int |
LIKE |
static int |
LIKE_IGNORE_CASE |
static int |
LIST
Interpreted as a comma-separated list of literals.
|
static int |
MULTIPLY |
static int |
NEGATIVE |
static int |
NOT |
static int |
NOT_BETWEEN |
static int |
NOT_EQUAL_TO |
static int |
NOT_IN |
static int |
NOT_LIKE |
static int |
NOT_LIKE_IGNORE_CASE |
static int |
OBJ_PATH
Expression describes a path relative to an ObjEntity.
|
static int |
OR |
static Object |
PRUNED_NODE
A value that a Transformer might return to indicate that a node has to be
pruned from the expression during the transformation.
|
static int |
SUBTRACT |
static int |
TRUE |
protected int |
type |
Constructor and Description |
---|
Expression() |
Modifier and Type | Method and Description |
---|---|
Expression |
andExp(Expression exp)
Chains this expression with another expression using "and".
|
Expression |
andExp(Expression exp,
Expression... expressions)
Chains this expression with other expressions using "and".
|
void |
appendAsEJBQL(Appendable out,
String rootId)
Stores a String representation of Expression as EJBQL using a provided
Appendable.
|
abstract void |
appendAsEJBQL(List<Object> parameterAccumulator,
Appendable out,
String rootId)
Stores a String representation of Expression as EJBQL using a provided
PrintWriter.
|
abstract void |
appendAsString(Appendable out)
Appends own content as a String to the provided Appendable.
|
Expression |
deepCopy()
Clones this expression.
|
abstract void |
encodeAsEJBQL(PrintWriter pw,
String rootId)
Deprecated.
since 4.0 use
appendAsEJBQL(Appendable, String) |
abstract void |
encodeAsString(PrintWriter pw)
Deprecated.
since 4.0 use
appendAsString(Appendable) . |
void |
encodeAsXML(XMLEncoder encoder)
Encodes itself, wrapping the string into XML CDATA section.
|
boolean |
equals(Object object) |
abstract Object |
evaluate(Object o)
Calculates expression value with object as a context for path
expressions.
|
String |
expName()
Returns String label for this expression.
|
Expression |
expWithParameters(Map<String,?> parameters)
Deprecated.
since 4.0 use
params(Map) |
Expression |
expWithParameters(Map<String,?> parameters,
boolean pruneMissing)
Deprecated.
since 4.0 use
params(Map, boolean) instead. |
<T> Collection<?> |
filter(Collection<T> source,
Collection<T> target)
Adds objects matching this expression from the source collection to the
target collection.
|
<T> List<T> |
filterObjects(Collection<T> objects)
Returns a list of objects that match the expression.
|
<T> T |
first(List<T> objects)
Returns the first object in the list that matches the expression.
|
protected abstract void |
flattenTree()
Restructures expression to make sure that there are no children of the
same type as this expression.
|
static Expression |
fromString(String expressionString)
Deprecated.
since 4.0 use
ExpressionFactory.exp(String, Object...) |
abstract Object |
getOperand(int index)
Returns a value of operand at
index . |
abstract int |
getOperandCount()
Returns a count of operands of this expression.
|
abstract Map<String,String> |
getPathAliases()
Returns a map of path aliases for this expression.
|
int |
getType()
Returns a type of expression.
|
int |
hashCode() |
Expression |
joinExp(int type,
Expression exp)
Creates a new expression that joins this object with another expression,
using specified join type.
|
Expression |
joinExp(int type,
Expression exp,
Expression... expressions)
Creates a new expression that joins this object with other expressions,
using specified join type.
|
boolean |
match(Object o)
Calculates expression boolean value with object as a context for path
expressions.
|
abstract Expression |
notExp()
Returns a logical NOT of current expression.
|
Expression |
orExp(Expression exp)
Chains this expression with another expression using "or".
|
Expression |
orExp(Expression exp,
Expression... expressions)
Chains this expression with other expressions using "or".
|
Expression |
params(Map<String,?> parameters)
Creates and returns a new Expression instance based on this expression,
but with named parameters substituted with provided values.
|
Expression |
params(Map<String,?> parameters,
boolean pruneMissing)
Creates and returns a new Expression instance based on this expression,
but with named parameters substituted with provided values.If any
subexpressions containing parameters not matching the "name" argument are
found, the behavior depends on "pruneMissing" argument.
|
Expression |
paramsArray(Object... parameters)
Creates and returns a new Expression instance based on this expression,
but with parameters substituted with provided values.
|
protected abstract boolean |
pruneNodeForPrunedChild(Object prunedChild)
Returns true if this node should be pruned from expression tree in the
event a child is removed.
|
abstract void |
setOperand(int index,
Object value)
Sets a value of operand at
index . |
void |
setType(int type) |
abstract Expression |
shallowCopy()
Creates a copy of this expression node, without copying children.
|
String |
toEJBQL(List<Object> parameterAccumulator,
String rootId)
Produces an EJBQL string that represents this expression.
|
String |
toEJBQL(String rootId)
Produces an EJBQL string that represents this expression.
|
String |
toString() |
Expression |
transform(org.apache.commons.collections.Transformer transformer)
Creates a transformed copy of this expression, applying transformation
provided by Transformer to all its nodes.
|
protected Object |
transformExpression(org.apache.commons.collections.Transformer transformer)
A recursive method called from "transform" to do the actual
transformation.
|
protected void |
traverse(Expression parentExp,
TraversalHandler visitor)
Traverses itself and child expressions, notifying visitor via callback
methods as it goes.
|
void |
traverse(TraversalHandler visitor)
Traverses itself and child expressions, notifying visitor via callback
methods as it goes.
|
public static final Object PRUNED_NODE
public static final int AND
public static final int OR
public static final int NOT
public static final int EQUAL_TO
public static final int NOT_EQUAL_TO
public static final int LESS_THAN
public static final int GREATER_THAN
public static final int LESS_THAN_EQUAL_TO
public static final int GREATER_THAN_EQUAL_TO
public static final int BETWEEN
public static final int IN
public static final int LIKE
public static final int LIKE_IGNORE_CASE
public static final int ADD
public static final int SUBTRACT
public static final int MULTIPLY
public static final int DIVIDE
public static final int NEGATIVE
public static final int TRUE
public static final int FALSE
public static final int OBJ_PATH
public static final int DB_PATH
public static final int LIST
public static final int NOT_BETWEEN
public static final int NOT_IN
public static final int NOT_LIKE
public static final int NOT_LIKE_IGNORE_CASE
public static final int BITWISE_NOT
public static final int BITWISE_AND
public static final int BITWISE_OR
public static final int BITWISE_XOR
public static final int BITWISE_LEFT_SHIFT
public static final int BITWISE_RIGHT_SHIFT
public static final int FUNCTION_CALL
public static final int ASTERISK
public static final int FULL_OBJECT
protected int type
@Deprecated public static Expression fromString(String expressionString)
ExpressionFactory.exp(String, Object...)
public abstract Map<String,String> getPathAliases()
public String expName()
public int getType()
public void setType(int type)
public Expression paramsArray(Object... parameters)
positional style would not allow subexpression pruning.
public Expression params(Map<String,?> parameters)
Note that if you want matching against nulls to be preserved, you must place NULL values for the corresponding keys in the map.
public Expression params(Map<String,?> parameters, boolean pruneMissing)
Note that if you want matching against nulls to be preserved, you must place NULL values for the corresponding keys in the map.
@Deprecated public Expression expWithParameters(Map<String,?> parameters)
params(Map)
expWithParams(params, true)
.@Deprecated public Expression expWithParameters(Map<String,?> parameters, boolean pruneMissing)
params(Map, boolean)
instead.params
map.
Null values in the params
map should be explicitly
created in the map for the corresponding key.
parameters
- a map of parameters, with each key being a string name of an
expression parameter, and value being the value that should be
used in the final expression.pruneMissing
- If true
, subexpressions that rely on missing
parameters will be pruned from the resulting tree. If
false
, any missing values will generate an
exception.public Expression joinExp(int type, Expression exp)
public Expression joinExp(int type, Expression exp, Expression... expressions)
public Expression andExp(Expression exp)
public Expression andExp(Expression exp, Expression... expressions)
public Expression orExp(Expression exp)
public Expression orExp(Expression exp, Expression... expressions)
public abstract Expression notExp()
public abstract int getOperandCount()
public abstract Object getOperand(int index)
index
. Operand indexing starts
at 0.public abstract void setOperand(int index, Object value)
index
. Operand indexing starts at
0.public abstract Object evaluate(Object o)
public boolean match(Object o)
public <T> T first(List<T> objects)
public <T> List<T> filterObjects(Collection<T> objects)
public <T> Collection<?> filter(Collection<T> source, Collection<T> target)
public Expression deepCopy()
public abstract Expression shallowCopy()
protected abstract boolean pruneNodeForPrunedChild(Object prunedChild)
protected abstract void flattenTree()
public void traverse(TraversalHandler visitor)
protected void traverse(Expression parentExp, TraversalHandler visitor)
public Expression transform(org.apache.commons.collections.Transformer transformer)
To force a node and its children to be pruned from the copy, Transformer should return Expression.PRUNED_NODE. Otherwise an expectation is that if a node is an Expression it must be transformed to null or another Expression. Any other object type would result in a ExpressionException.
protected Object transformExpression(org.apache.commons.collections.Transformer transformer)
public void encodeAsXML(XMLEncoder encoder)
encodeAsXML
in interface XMLSerializable
@Deprecated public abstract void encodeAsString(PrintWriter pw)
appendAsString(Appendable)
.public abstract void appendAsString(Appendable out) throws IOException
IOException
@Deprecated public abstract void encodeAsEJBQL(PrintWriter pw, String rootId)
appendAsEJBQL(Appendable, String)
public void appendAsEJBQL(Appendable out, String rootId) throws IOException
IOException
public abstract void appendAsEJBQL(List<Object> parameterAccumulator, Appendable out, String rootId) throws IOException
IOException
public String toEJBQL(List<Object> parameterAccumulator, String rootId)
Copyright © 2001–2019 Apache Cayenne. All rights reserved.