Eclipse Platform
Release 3.6

org.eclipse.equinox.p2.ql
Interface IQLFactory

All Superinterfaces:
IExpressionFactory

public interface IQLFactory
extends IExpressionFactory

This inteface provides all the factory methods needed to create the all possible nodes of the expression tree.


Field Summary
 
Fields inherited from interface org.eclipse.equinox.p2.metadata.expression.IExpressionFactory
FUNC_BOOLEAN, FUNC_CLASS, FUNC_FILTER, FUNC_RANGE, FUNC_VERSION, NO_ARGS
 
Method Summary
 IExpression array(IExpression... elements)
          Create an array of elements.
 IExpression assignment(IExpression variable, IExpression expression)
          Creates an expression that represents a variable assignment
 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 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 lambda(IExpression variable, IExpression[] initialAssignments, IExpression body)
          Creates a lambda expression that takes more then one variable (currying).
 IExpression memberCall(IExpression target, String name, IExpression... args)
          Creates a member call 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 unique(IExpression collection, IExpression cache)
          Create an expression that yields a new collection where each element is unique.
 
Methods inherited from interface org.eclipse.equinox.p2.metadata.expression.IExpressionFactory
all, and, at, constant, contextExpression, createContext, createContext, equals, exists, filterExpression, greater, greaterEqual, indexedParameter, intersect, lambda, latest, less, lessEqual, limit, limit, matches, matchExpression, member, normalize, not, or, pipe, select, thisVariable, toExpression, union, variable
 

Method Detail

array

IExpression array(IExpression... elements)
Create an array of elements.

Parameters:
elements - The elements of the array
Returns:
An array expression

assignment

IExpression assignment(IExpression variable,
                       IExpression expression)
Creates an expression that represents a variable assignment

Parameters:
variable - The variable
expression - The expression that yields the value to assign to the variable
Returns:
An assignment expression

collect

IExpression collect(IExpression collection,
                    IExpression lambda)
Create an expression that collects the result of evaluating each element in a new collection.

Parameters:
collection - The collection providing the elements to evaluate
lambda - The lambda that creates each new element
Returns:
A collection expression

condition

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. The expression yields the result of the ifTrue or ifFalse evaluation.

Parameters:
test - The test
ifTrue - The code to evaluate when the test evaluates to true
ifFalse - The code to evaluate when the test evaluates to false
Returns:
The conditional expression

first

IExpression first(IExpression collection,
                  IExpression lambda)
Create an expression that yields the first element of the collection for which the lambda yields true.

Parameters:
collection - The collection providing the elements to test
lambda - The lambda that performs the test
Returns:
An element expression

flatten

IExpression flatten(IExpression collection)
Intended to be applied on collections of collections. Yields a single collection with all elements from the source collections, in the order they are evaluated.

Parameters:
collection - The collection providing the collections that provides all elements
Returns:
A collection expression

function

IExpression function(Object function,
                     IExpression... args)
Given one of the values in the map returned by getFunctionMap(), this method returns a function expression.

Parameters:
function - The value obtained from the map.
args - The arguments to evaluate and pass when evaluating the function.
Returns:
A function expression

getFunctionMap

Map<String,? extends Object> getFunctionMap()
Returns a map of functions supported by this factory. The map is keyed by function names and the value is an object suitable to pass to the function(Object, IExpression[]) method.

Returns:
A key/function map.

lambda

IExpression lambda(IExpression variable,
                   IExpression[] initialAssignments,
                   IExpression body)
Creates a lambda expression that takes more then one variable (currying). Suitable for use in most collection expressions.

Parameters:
variable - The element variable that the lambda uses
body - The body of the lambda
initialAssignments - Assignments to evaluate once before calling the body for each element.
Returns:
A lambda expression with currying

memberCall

IExpression memberCall(IExpression target,
                       String name,
                       IExpression... args)
Creates a member call expression.

Parameters:
target - The target for the member call
name - The name of the member
args - The arguments to use for the call
Returns:
A member expression

traverse

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.

Parameters:
collection - The collection providing the elements to test
lambda - The lambda that collects the children for the next iteration
Returns:
A collection expression

unique

IExpression unique(IExpression collection,
                   IExpression cache)
Create an expression that yields a new collection where each element is unique. An optional cache can be provided if the uniqueness should span a larger scope then just the source collection.

Parameters:
collection - The source collection
cache - Optional cache to use when uniqueness should span over several invocations
Returns:
A collection expression

Eclipse Platform
Release 3.6

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2010. All rights reserved.