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

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

public class QueryBaseImpl
extends java.lang.Object
implements QueryBase, ProblemAware

An implementation of the model object 'Query'.

The following features are implemented:

Generated

Constructor Summary
QueryBaseImpl(Environment environment, ExpressionInOcl specification, ModelManager modelManager)
           
 
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.
 Value evaluate()
          Evaluates the query.
 java.util.List<?> evaluate(java.util.List<?> objList)
          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).
 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

QueryBaseImpl

public QueryBaseImpl(Environment environment,
                     ExpressionInOcl specification,
                     ModelManager modelManager)
Parameters:
environment -
expr -
modelManager - may be null, in which case I will use my evaluation environment to create a dynamic extent map
Method Detail

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)

getExpression

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

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

evaluate

public Value evaluate(java.lang.Object obj)
               throws EvaluationException
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
Throws:
EvaluationException
See Also:
QueryBase.evaluate(), QueryBase.evaluate(List), QueryBase.resultType()

evaluate

public Value evaluate()
               throws EvaluationException
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
Throws:
EvaluationException
See Also:
QueryBase.resultType()

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.util.List<?> evaluate(java.util.List<?> objList)
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:
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:
QueryBase.evaluate(Object), QueryBase.resultType()

check

public boolean check(java.util.List<?> objList)
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:
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:
QueryBase.check(Object)

select

public <T> java.util.List<T> select(java.util.List<T> objList)
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:
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: 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:
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: 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

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

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

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