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

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

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

An implementation of the model object 'Query'.

The following features are implemented:

Generated

Constructor Summary
QueryImpl(OCL ocl, ExpressionInOCL specification)
           
 
Method Summary
 boolean check(java.util.List<?> objList)
          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<?> objList)
          Evaluates the query on the input list.
 java.lang.Object 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).
 DomainModelManager 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> objList)
          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> objList)
          Determines the subset of input objects that satisfy the query.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QueryImpl

public QueryImpl(@NonNull
                 OCL ocl,
                 @NonNull
                 ExpressionInOCL specification)
Method Detail

check

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

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

check

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

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

evaluate

public java.lang.Object evaluate()
                          throws DomainException
Description copied from interface: Query
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 Query
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
Throws:
DomainException
See Also:
Query.resultType()

evaluate

public java.lang.Object evaluate(java.lang.Object obj)
                          throws DomainException
Description copied from interface: Query
Evaluates the query on the object.

Specified by:
evaluate in interface Query
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
Throws:
DomainException
See Also:
Query.evaluate(), Query.evaluate(List), Query.resultType()

evaluate

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

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

getEvaluationEnvironment

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

Specified by:
getEvaluationEnvironment in interface Query
Returns:
my environment

getExpression

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

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

getModelManager

@NonNull
public DomainModelManager getModelManager()
Description copied from interface: Query
Obtains the mapping of classes to their extents (sets of all instances).

Specified by:
getModelManager in interface Query
Returns:
the map of classes to their extents

getOCL

@NonNull
public OCL getOCL()
Description copied from interface: Query

Obtains the OCL that created me.

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

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.

queryText

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

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

reject

public <T> java.util.List<T> reject(java.util.List<T> objList)
Description copied from interface: Query
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 Query
Parameters:
objList - 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: Query
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 Query
Returns:
the query's result type

select

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

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

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object