org.eclipse.ocl.examples.pivot.utilities
Class QueryImpl

java.lang.Object
  extended by org.eclipse.ocl.examples.pivot.utilities.QueryImpl
All Implemented Interfaces:
OCL.Query, ProblemAware, QueryBase

public class QueryImpl
extends java.lang.Object
implements OCL.Query, ProblemAware

Implementation of the OCLBase.QueryBase convenience interface.

Author:
Christian W. Damus (cdamus)

Constructor Summary
QueryImpl(QueryBase delegate, OCL ocl)
           
 
Method Summary
 boolean check(java.util.List<?> objects)
          Determines whether all of the input objects satisfy the query.
 boolean check(java.lang.Object obj)
          Evaluates the query on an object.
 java.lang.Object evaluate()
          Evaluates the query.
 java.util.List<?> evaluate(java.util.List<?> objects)
          Evaluates the query on the input list.
 Value evaluate(java.lang.Object obj)
          Evaluates the query on the object.
 EvaluationEnvironment getEvaluationEnvironment()
          Obtains the evaluation environment that I use to evaluate OCL expressions.
 OclExpression getExpression()
          Obtains the expression that I evaluate (or check as a boolean constraint).
 ModelManager getModelManager()
          Obtains the mapping of classes to their extents (sets of all instances).
 OCL getOCL()
           Obtains the OCL that created me.
 org.eclipse.emf.common.util.Diagnostic getProblems()
          Retrieves the problems available on this problem aware object
 java.lang.String queryText()
          Translates the query back to an OCL text string.
<T> java.util.List<T>
reject(java.util.List<T> objects)
          Determines the subset of input objects that do not satisfy the query.
 Type resultType()
          Obtains the OCL result type of the query.
<T> java.util.List<T>
select(java.util.List<T> objects)
          Determines the subset of input objects that satisfy the query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryImpl

public QueryImpl(QueryBase delegate,
                 OCL ocl)
Method Detail

getOCL

public OCL getOCL()
Description copied from interface: OCL.Query

Obtains the OCL that created me.

Specified by:
getOCL in interface OCL.Query
Returns:
my originating OCL instance

check

public boolean check(java.util.List<?> objects)
Description copied from interface: QueryBase
Determines whether all of the input objects satisfy the query. The query must be a boolean-valued constraint.

Specified by:
check in interface QueryBase
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:
QueryBase.check(Object)

check

public boolean check(java.lang.Object obj)
Description copied from interface: QueryBase
Evaluates the query on an object. The query must be a boolean valued constraint.

Specified by:
check in interface QueryBase
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:
QueryBase.check(List)

evaluate

public java.lang.Object evaluate()
Description copied from interface: QueryBase
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.

Specified by:
evaluate in interface QueryBase
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:
QueryBase.resultType()

evaluate

public java.util.List<?> evaluate(java.util.List<?> objects)
Description copied from interface: QueryBase
Evaluates the query on the input list. The results are returned in a corresponding list of results.

Specified by:
evaluate in interface QueryBase
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:
QueryBase.evaluate(Object), QueryBase.resultType()

evaluate

public Value evaluate(java.lang.Object obj)
Description copied from interface: QueryBase
Evaluates the query on the object.

Specified by:
evaluate in interface QueryBase
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:
QueryBase.evaluate(), QueryBase.evaluate(List), QueryBase.resultType()

getEvaluationEnvironment

public EvaluationEnvironment getEvaluationEnvironment()
Description copied from interface: QueryBase
Obtains the evaluation environment that I use to evaluate OCL expressions.

Specified by:
getEvaluationEnvironment in interface QueryBase
Returns:
my environment

getExpression

public OclExpression getExpression()
Description copied from interface: OCL.Query
Obtains the expression that I evaluate (or check as a boolean constraint).

The return type is narrowed to the Ecore binding for the generic OCLExpression<C> type.

Specified by:
getExpression in interface OCL.Query
Specified by:
getExpression in interface QueryBase
Returns:
my OCL expression

getModelManager

public ModelManager getModelManager()
Description copied from interface: QueryBase
Obtains the mapping of classes to their extents (sets of all instances).

Specified by:
getModelManager in interface QueryBase
Returns:
the map of classes to their extents
See Also:
OCLBase.setModelManager(org.eclipse.ocl.examples.pivot.evaluation.ModelManager)

queryText

public java.lang.String queryText()
Description copied from interface: QueryBase
Translates the query back to an OCL text string.

Specified by:
queryText in interface QueryBase
Returns:
the text of the OCL query expression

reject

public <T> java.util.List<T> reject(java.util.List<T> objects)
Description copied from interface: QueryBase
Determines the subset of input objects that do not satisfy the query. The query must be a boolean valued constraint.

Specified by:
reject in interface QueryBase
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

public Type resultType()
Description copied from interface: QueryBase
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.

Specified by:
resultType in interface QueryBase
Returns:
the query's result type

select

public <T> java.util.List<T> select(java.util.List<T> objects)
Description copied from interface: QueryBase
Determines the subset of input objects that satisfy the query. The query must be a boolean valued constraint.

Specified by:
select in interface QueryBase
Parameters:
objects - a list of objects to evaluate the constraint on
Returns:
the subset (possibly empty) of the objects that satisfy the constraint

getProblems

public org.eclipse.emf.common.util.Diagnostic getProblems()
Description copied from interface: ProblemAware
Retrieves the problems available on this problem aware object

Specified by:
getProblems in interface ProblemAware
Returns:
the diagnostic object representing the problems or null in case that no problems are available.