org.eclipse.ocl
Interface Query<C,CLS,E>

All Known Subinterfaces:
OCL.Query, OCL.Query

public interface Query<C,CLS,E>

An OCL constraint or query. The query is validated for correctness when it is created. The query can subsequently be evaluated on a single object or on multiple objects in one operation.

See the Environment class for a description of the generic type parameters of this class.


Method Summary
 boolean check(List<?> objects)
          Determines whether all of the input objects satisfy the query.
 boolean check(Object obj)
          Evaluates the query on an object.
 Object evaluate()
          Evaluates the query.
 List<?> evaluate(List<?> objects)
          Evaluates the query on the input list.
 Object evaluate(Object obj)
          Evaluates the query on the object.
 EvaluationEnvironment<C,?,?,CLS,E> getEvaluationEnvironment()
          Obtains the evaluation environment that I use to evaluate OCL expressions.
 OCLExpression<C> getExpression()
          Obtains the expression that I evaluate (or check as a boolean constraint).
 Map<CLS,? extends Set<? extends E>> getExtentMap()
          Obtains the mapping of classes to their extents (sets of all instances).
 String queryText()
          Translates the query back to an OCL text string.
<T> List<T>
reject(List<T> objects)
          Determines the subset of input objects that do not satisfy the query.
 C resultType()
          Obtains the OCL result type of the query.
<T> List<T>
select(List<T> objects)
          Determines the subset of input objects that satisfy the query.
 

Method Detail

getEvaluationEnvironment

EvaluationEnvironment<C,?,?,CLS,E> getEvaluationEnvironment()
Obtains the evaluation environment that I use to evaluate OCL expressions.

Returns:
my environment

evaluate

Object evaluate(Object obj)
Evaluates the query on the object.

Parameters:
obj - an Object
Returns:
the result of the query, which may be one or more EObjects, Java objects, a mixture, or even null. In any case, the results conform to the expression's result type
See Also:
evaluate(), evaluate(List), resultType()

evaluate

Object evaluate()
Evaluates the query. This method is used when there is no 'self' context required by the query. Either the query is constant, or uses allInstances() exclusively for evaluation.

Returns:
the result of the query, which may be one or more EObjects, Java objects, a mixture, or even null. In any case, the results conform to the expression's result type
See Also:
resultType()

check

boolean check(Object obj)
Evaluates the query on an object. The query must be a boolean valued constraint.

Parameters:
obj - an Object or null if the query does not require an OCL 'self' context
Returns:
boolean true or false according to whether the constraint is met
See Also:
check(List)

evaluate

List<?> evaluate(List<?> objects)
Evaluates the query on the input list. The results are returned in a corresponding list of results.

Parameters:
objects - a list of objects to evaluate the query on
Returns:
a list of results, corresponding one-for-one with the objects. Note that result elements may, themselves, be collections of multiple results for a single input object. In any case, the results conform to the expression's result type
See Also:
evaluate(Object), resultType()

check

boolean check(List<?> objects)
Determines whether all of the input objects satisfy the query. The query must be a boolean-valued constraint.

Parameters:
objects - a list of objects to evaluate the constraint on
Returns:
true if all of the objects satisfy the constraint (including the trivial case of an empty input list); false, otherwise
See Also:
check(Object)

select

<T> List<T> select(List<T> objects)
Determines the subset of input objects that satisfy the query. The query must be a boolean valued constraint.

Parameters:
objects - a list of objects to evaluate the constraint on
Returns:
the subset (possibly empty) of the objects that satisfy the constraint

reject

<T> List<T> reject(List<T> objects)
Determines the subset of input objects that do not satisfy the query. The query must be a boolean valued constraint.

Parameters:
objects - a list of objects to evaluate the constraint on
Returns:
the subset (possibly empty) of the objects that do not satisfy the constraint

resultType

C resultType()
Obtains the OCL result type of the query. This may be a classifier in the user model, or it may represent a pre-defined OCL data type such as Boolean.

Returns:
the query's result type

queryText

String queryText()
Translates the query back to an OCL text string.

Returns:
the text of the OCL query expression

getExtentMap

Map<CLS,? extends Set<? extends E>> getExtentMap()
Obtains the mapping of classes to their extents (sets of all instances).

Returns:
the map of classes to their extents
See Also:
OCL.setExtentMap(java.util.Map>)

getExpression

OCLExpression<C> getExpression()
Obtains the expression that I evaluate (or check as a boolean constraint).

Returns:
my OCL expression

Copyright 2002, 2007 IBM Corporation and others.
All Rights Reserved.