|
Eclipse Platform Release 3.6 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IExpressionFactory
This interface provides all the factory methods needed to create the nodes of the expression tree.
Field Summary | |
---|---|
static String |
FUNC_BOOLEAN
|
static String |
FUNC_CLASS
|
static String |
FUNC_FILTER
|
static String |
FUNC_RANGE
|
static String |
FUNC_VERSION
|
static IExpression[] |
NO_ARGS
|
Method Summary | ||
---|---|---|
IExpression |
all(IExpression collection,
IExpression lambda)
Create a collection filter that yields true if the lambda yields true for
all of the elements of the collection |
|
IExpression |
and(IExpression... operands)
Create a logical and of its operands . |
|
IExpression |
array(IExpression... elements)
Create an array of elements. |
|
IExpression |
assignment(IExpression variable,
IExpression expression)
Creates an expression that represents a variable assignment |
|
IExpression |
at(IExpression target,
IExpression key)
Create an lookup of key in the target . |
|
IExpression |
collect(IExpression collection,
IExpression lambda)
Create an expression that collects the result of evaluating each element in a new collection. |
|
IExpression |
condition(IExpression test,
IExpression ifTrue,
IExpression ifFalse)
Create an expression that first evaluates a test and then, depending on the outcome,
evaluates either ifTrue or ifFalse . |
|
IExpression |
constant(Object value)
Creates an expression that evaluates to the constant value . |
|
|
contextExpression(IExpression expr,
Object... parameters)
Creates a top level expression that represents a full query. |
|
IEvaluationContext |
createContext(IExpression[] variables,
Object... params)
Create an evaluation context with one single variable |
|
IEvaluationContext |
createContext(Object... params)
Create an evaluation context with one single variable |
|
IExpression |
equals(IExpression lhs,
IExpression rhs)
Create an expression that tests if lhs is equal to rhs . |
|
IExpression |
exists(IExpression collection,
IExpression lambda)
Create a collection filter that yields true if the lambda yields true for
at least one of the elements of the collection |
|
IFilterExpression |
filterExpression(IExpression expression)
Creates a top level expression suitable for predicate matching |
|
IExpression |
first(IExpression collection,
IExpression lambda)
Create an expression that yields the first element of the collection for which the lambda yields true . |
|
IExpression |
flatten(IExpression collection)
Intended to be applied on collections of collections. |
|
IExpression |
function(Object function,
IExpression... args)
Given one of the values in the map returned by getFunctionMap() , this method
returns a function expression. |
|
Map<String,? extends Object> |
getFunctionMap()
Returns a map of functions supported by this factory. |
|
IExpression |
greater(IExpression lhs,
IExpression rhs)
Create an expression that tests if lhs is greater than rhs . |
|
IExpression |
greaterEqual(IExpression lhs,
IExpression rhs)
Create an expression that tests if lhs is greater than or equal to rhs . |
|
IExpression |
indexedParameter(int index)
Creates an indexed parameter expression |
|
IExpression |
intersect(IExpression c1,
IExpression c2)
Create an intersection of c1 and c2 |
|
IExpression |
lambda(IExpression variable,
IExpression body)
Creates a lambda expression that takes exactly one variable. |
|
IExpression |
lambda(IExpression variable,
IExpression[] initialAssignments,
IExpression body)
Creates a lambda expression that takes more then one variable (currying). |
|
IExpression |
latest(IExpression collection)
Create an expression that yields a new collection consisting of the latest version of the elements of the collection . |
|
IExpression |
less(IExpression lhs,
IExpression rhs)
Create an expression that tests if lhs is less than rhs . |
|
IExpression |
lessEqual(IExpression lhs,
IExpression rhs)
Create an expression that tests if lhs is less than or equal to rhs . |
|
IExpression |
limit(IExpression collection,
IExpression limit)
Create an expression that yields a new collection consisting of the n first elements of the source collection where n is determined by limit . |
|
IExpression |
limit(IExpression collection,
int count)
Create an expression that yields a new collection consisting of the count first elements of the source collection. |
|
IExpression |
matches(IExpression lhs,
IExpression rhs)
Create an expression that tests if lhs matches rhs . |
|
|
matchExpression(IExpression expression,
Object... parameters)
Creates a parameterized top level expression suitable for predicate matching |
|
IExpression |
member(IExpression target,
String name)
Creates a member accessor expression. |
|
IExpression |
memberCall(IExpression target,
String name,
IExpression... args)
Creates a member call expression. |
|
IExpression |
normalize(List<? extends IExpression> operands,
int expressionType)
Performs boolean normalization on the expression to create a canonical form. |
|
IExpression |
not(IExpression operand)
Creates an expression that negates the result of evaluating its operand . |
|
IExpression |
or(IExpression... operands)
Create a logical or of its operands . |
|
IExpression |
pipe(IExpression... expressions)
Create a pipe of expressions. |
|
IExpression |
select(IExpression collection,
IExpression lambda)
Create an expression that yields a new collection consisting of all elements of the collection for which the lambda yields true . |
|
IExpression |
thisVariable()
Returns the variable that represents this in an expression |
|
IExpression |
toExpression(IQuery<?> query)
Wrap an IQuery as an expression. |
|
IExpression |
traverse(IExpression collection,
IExpression lambda)
Recursively traverse and collect elements based on a condition A common scenario in p2 is that you want to start with a set of roots and then find all items that fulfill the root requirements. |
|
IExpression |
union(IExpression c1,
IExpression c2)
Create a union of c1 and c2 |
|
IExpression |
unique(IExpression collection,
IExpression cache)
Create an expression that yields a new collection where each element is unique. |
|
IExpression |
variable(String name)
Creates an expression that represents a variable |
Field Detail |
---|
static final String FUNC_BOOLEAN
static final String FUNC_VERSION
static final String FUNC_CLASS
static final String FUNC_RANGE
static final String FUNC_FILTER
static final IExpression[] NO_ARGS
Method Detail |
---|
IExpression all(IExpression collection, IExpression lambda)
lambda
yields true for
all of the elements of the collection
collection
- The collection providing the elements to testlambda
- The lambda that performs the test
IExpression and(IExpression... operands)
operands
.
operands
- The boolean operands
IExpression assignment(IExpression variable, IExpression expression)
variable
- The variableexpression
- The expression that yields the value to assign to the variable
IExpression collect(IExpression collection, IExpression lambda)
collection
- The collection providing the elements to evaluatelambda
- The lambda that creates each new element
IExpression condition(IExpression test, IExpression ifTrue, IExpression ifFalse)
test
and then, depending on the outcome,
evaluates either ifTrue
or ifFalse
. The expression yields the result
of the ifTrue
or ifFalse
evaluation.
test
- The testifTrue
- The code to evaluate when the test evaluates to true
ifFalse
- The code to evaluate when the test evaluates to false
IExpression first(IExpression collection, IExpression lambda)
collection
for which the lambda
yields true
.
collection
- The collection providing the elements to testlambda
- The lambda that performs the test
IExpression flatten(IExpression collection)
collection
- The collection providing the collections that provides all elements
IExpression lambda(IExpression variable, IExpression[] initialAssignments, IExpression body)
variable
- The element variable that the lambda usesbody
- The body of the lambdainitialAssignments
- Assignments to evaluate once before calling the body for each element.
IExpression memberCall(IExpression target, String name, IExpression... args)
target
- The target for the member callname
- The name of the memberargs
- The arguments to use for the call
IExpression traverse(IExpression collection, IExpression lambda)
Recursively traverse and collect elements based on a condition
A common scenario in p2 is that you want to start with a set of roots and then find all items that fulfill the root requirements. Those items in turn introduce new requirements so you want to find them too. The process continues until no more requirements can be satisfied. This type of query can be performed using the traverse function.
The function will evaluate an expression, once for each element, collect elements for which the evaluation returned true, then then re-evaluate using the collected result as source of elements. No element is evaluated twice. This continues until no more elements are found.
collection
- The collection providing the elements to testlambda
- The lambda that collects the children for the next iteration
IExpression unique(IExpression collection, IExpression cache)
cache
can be provided if the uniqueness should span a larger
scope then just the source collection.
collection
- The source collectioncache
- Optional cache to use when uniqueness should span over several invocations
IExpression array(IExpression... elements)
elements
- The elements of the array
IExpression at(IExpression target, IExpression key)
key
in the target
.
The key expression should evaluate to a string or an integer.
target
- The target for the lookupkey
- The key to use for the lookup
IEvaluationContext createContext(Object... params)
params
- Indexed parameters to use in the expression
IEvaluationContext createContext(IExpression[] variables, Object... params)
params
- Indexed parameters to use in the expressionvariables
- The variables that will be maintained by the context
IExpression constant(Object value)
value
.
value
- The constant
<T> IContextExpression<T> contextExpression(IExpression expr, Object... parameters)
expr
- The queryparameters
- The parameters of the query
IExpression equals(IExpression lhs, IExpression rhs)
lhs
is equal to rhs
.
lhs
- The left hand side value.rhs
- The right hand side value.
IExpression exists(IExpression collection, IExpression lambda)
lambda
yields true for
at least one of the elements of the collection
collection
- The collection providing the elements to testlambda
- The lambda that performs the test
IFilterExpression filterExpression(IExpression expression)
expression
- The boolean expression
IExpression function(Object function, IExpression... args)
getFunctionMap()
, this method
returns a function expression.
function
- The value obtained from the map.args
- The arguments to evaluate and pass when evaluating the function.
Map<String,? extends Object> getFunctionMap()
function(Object, IExpression[])
method.
IExpression greater(IExpression lhs, IExpression rhs)
lhs
is greater than rhs
.
lhs
- The left hand side value.rhs
- The right hand side value.
IExpression greaterEqual(IExpression lhs, IExpression rhs)
lhs
is greater than or equal to rhs
.
lhs
- The left hand side value.rhs
- The right hand side value.
IExpression indexedParameter(int index)
index
- The index to use
IExpression intersect(IExpression c1, IExpression c2)
c1
and c2
c1
- first collectionc2
- second collection
IExpression lambda(IExpression variable, IExpression body)
variable
- The element variable that the lambda usesbody
- The body of the lambda
IExpression latest(IExpression collection)
collection
. Each element in collection
must implement the IVersionedId
interface.
collection
- The collection providing the versioned elements
IExpression less(IExpression lhs, IExpression rhs)
lhs
is less than rhs
.
lhs
- The left hand side value.rhs
- The right hand side value.
IExpression lessEqual(IExpression lhs, IExpression rhs)
lhs
is less than or equal to rhs
.
lhs
- The left hand side value.rhs
- The right hand side value.
IExpression limit(IExpression collection, int count)
collection
- The source collectioncount
- The element count limit
IExpression limit(IExpression collection, IExpression limit)
limit
.
collection
- The source collectionlimit
- The expression that evaluates to the element count limit
IExpression normalize(List<? extends IExpression> operands, int expressionType)
operands
- The operands to normalizeexpressionType
- The type (must be either IExpression.TYPE_AND
or IExpression.TYPE_OR
.
IExpression matches(IExpression lhs, IExpression rhs)
lhs
matches rhs
.
lhs
- The left hand side value.rhs
- The right hand side value.
<T> IMatchExpression<T> matchExpression(IExpression expression, Object... parameters)
expression
- The boolean expressionparameters
- The parameters to use in the call
IExpression member(IExpression target, String name)
target
- The target for the member accessname
- The name of the member
IExpression not(IExpression operand)
operand
.
operand
- The boolean expression to negate
IExpression or(IExpression... operands)
operands
.
operands
- The boolean operands
IExpression pipe(IExpression... expressions)
expressions
- The expressions that make out the pipe
IExpression select(IExpression collection, IExpression lambda)
collection
for which the lambda
yields true
.
collection
- The collection providing the elements to testlambda
- The lambda that performs the test
IExpression thisVariable()
this in an expression
- Returns:
- The
this variable.
IExpression toExpression(IQuery<?> query)
IQuery
as an expression.
query
-
IExpression union(IExpression c1, IExpression c2)
c1
and c2
c1
- first collectionc2
- second collection
IExpression variable(String name)
name
- The name of the variable
|
Eclipse Platform Release 3.6 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) Eclipse contributors and others 2000, 2010. All rights reserved.