org.eclipse.ocl.internal.evaluation
Class QueryImpl<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>

java.lang.Object
  extended by org.eclipse.ocl.internal.evaluation.QueryImpl<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
All Implemented Interfaces:
Query<C,CLS,E>, ProblemAware

public class QueryImpl<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
extends java.lang.Object
implements Query<C,CLS,E>, ProblemAware

An implementation of the model object 'Query'.

The following features are implemented:

Generated

Constructor Summary
QueryImpl(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> environment, OCLExpression<C> expr, java.util.Map<CLS,? extends java.util.Set<? extends E>> extentMap)
           
 
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<C,O,P,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).
 java.util.Map<CLS,? extends java.util.Set<? extends E>> getExtentMap()
          Obtains the mapping of classes to their extents (sets of all instances).
 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.
 C 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(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> environment,
                 OCLExpression<C> expr,
                 java.util.Map<CLS,? extends java.util.Set<? extends E>> extentMap)
Parameters:
environment -
expr -
extentMap - may be null, in which case I will use my evaluation environment to create a dynamic extent map
Method Detail

getExtentMap

public java.util.Map<CLS,? extends java.util.Set<? extends E>> getExtentMap()
Description copied from interface: Query
Obtains the mapping of classes to their extents (sets of all instances).

Specified by:
getExtentMap in interface Query<C,CLS,E>
Returns:
the map of classes to their extents
See Also:
OCL.setExtentMap(java.util.Map>)

getExpression

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

Specified by:
getExpression in interface Query<C,CLS,E>
Returns:
my OCL expression

evaluate

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

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

evaluate

public java.lang.Object evaluate()
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<C,CLS,E>
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:
Query.resultType()

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<C,CLS,E>
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)

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<C,CLS,E>
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()

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<C,CLS,E>
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)

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<C,CLS,E>
Parameters:
objList - a list of objects to evaluate the constraint on
Returns:
the subset (possibly empty) of the objects that satisfy the constraint

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<C,CLS,E>
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 C 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<C,CLS,E>
Returns:
the query's result type

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<C,CLS,E>
Returns:
the text of the OCL query expression

getEvaluationEnvironment

public EvaluationEnvironment<C,O,P,CLS,E> getEvaluationEnvironment()
Description copied from interface: Query
Obtains the evaluation environment that I use to evaluate OCL expressions.

Specified by:
getEvaluationEnvironment in interface Query<C,CLS,E>
Returns:
my environment

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.

toString

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