## org.eclipse.emf.query.ocl.conditions
Class AbstractOCLCondition<C,CLS,E>

    java.lang.Object
      org.eclipse.emf.query.conditions.Condition
          org.eclipse.emf.query.conditions.eobjects.EObjectCondition
              org.eclipse.emf.query.ocl.conditions.AbstractOCLCondition<C,CLS,E>

Direct Known Subclasses:
  BooleanOCLCondition

    public abstract class AbstractOCLCondition<C,CLS,E>

extends EObjectCondition

An abstract OCL condition class, used to apply OCL expressions to `EObject`s. It allows the integration of OCL expressions with other `EObjectCondition`s.

This supports OCL expressions with or without an OCL classifier context. Expressions that have no OCL classifier context are context-free. Such conditions are useful in situations where either the elements on which the expressions will be evaluated are of an unknown type or where the same expression might be applicable to multiple, unrelated context types.

Note that this class is not intended to be extended "directly" by clients. Clients may extend the `BooleanOCLCondition` class.

See Also:
  `BooleanOCLCondition`

Field Summary

Fields inherited from class org.eclipse.emf.query.conditions.eobjects.EObjectCondition
`E_FALSE, E_TRUE`

Fields inherited from class org.eclipse.emf.query.conditions.Condition
`FALSE, TRUE`

Constructor Summary

`protected`

`AbstractOCLCondition(Environment<?,C,?,?,?,?,?,?,?,?,CLS,E> env, Query<C,CLS,E> oclQuery, C contextClassifier, IEStructuralFeatureValueGetter eStructuralFeatureValueGetter, PruneHandler pruneHandler)`
Initializes a query condition with compiled OCL query, a context classifier representing the type of "self" in the OCL expression, and an `IEStructuralFeatureValueGetter` to use to resolve the context element for safe access to structural features, and a `PruneHandler` to consult for pruning the content tree.

`protected`

`AbstractOCLCondition(Environment<?,C,?,?,?,?,?,?,?,?,CLS,E> env, String oclExpressionString, C contextClassifier, IEStructuralFeatureValueGetter eStructuralFeatureValueGetter)`
Initializes a query condition with an OCL expression string, a context classifier representing the type of "self" in the OCL expression, and an `IEStructuralFeatureValueGetter` to use to resolve the context element for safe access to structural features.

`protected`

`AbstractOCLCondition(Environment<?,C,?,?,?,?,?,?,?,?,CLS,E> env, String oclExpressionString, C contextClassifier, IEStructuralFeatureValueGetter eStructuralFeatureValueGetter, PruneHandler pruneHandler)`
Initializes a query condition with an OCL expression string, a context classifier representing the type of "self" in the OCL expression, and an `IEStructuralFeatureValueGetter` to use to resolve the context element for safe access to structural features, and a prune-handler to consult for pruning the object tree.

Method Summary
`void` `dispose()` Disposes the OCL environment that I constructed for parsing and evaluation.
`Object` `evaluate(EObject eObject)` Evaluates the OCL condition.
`protected C` `getContextClassifier()` Return the context classifier.
`IEStructuralFeatureValueGetter` `getEStructuralFeatureValueGetter()` Retrieves the strategy used by this OCL condition to access the values of structural featuress of model elements.
`protected Query<C,CLS,E>` `getOCLQuery()` Obtains the query compiled by the OCL interpreter, which represents the OCL expression.
`C` `getResultType(EObject eObject)` Returns the type of the ocl expression.
`protected boolean` `isContextFree()` Queries whether this OCL condition is context-free.
`boolean` `isSatisfied(EObject eObject)` Checks to see if an `eObject` is of a type conformant to the context classifier of this condition.
`void` `setEStructuralFeatureValueGetter(IEStructuralFeatureValueGetter eStructuralFeatureValueGetter)` Assigns the strategy to be used by this OCL Condition to access the values of structural features of model elements.

Methods inherited from class org.eclipse.emf.query.conditions.eobjects.EObjectCondition
`AND, EQUIVALENT, getPruneHandler, IMPLIES, isSatisfied, OR, shouldPrune, XOR`

Methods inherited from class org.eclipse.emf.query.conditions.Condition
`AND, EQUIVALENT, IMPLIES, OR, XOR`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### AbstractOCLCondition

    protected AbstractOCLCondition(Environment<?,C,?,?,?,?,?,?,?,?,CLS,E> env,
                                   String oclExpressionString,
                                   C contextClassifier,
                                   IEStructuralFeatureValueGetter eStructuralFeatureValueGetter)
                            throws ParserException

  Initializes a query condition with an OCL expression string, a context classifier representing the type of "self" in the OCL expression, and an `IEStructuralFeatureValueGetter` to use to resolve the context element for safe access to structural features. It defaults to using `PruneHandler.NEVER` to consult for pruning.

  NOTE: if `contextClassifier` is `null`, then this becomes a context-free OCL condition.

  Parameters:
    `env` - an OCL environment in which to parse the expression. Must not be `null`
    `oclExpressionString` - The OCL expression to apply when evaluating this `OCLCondition`
    `contextClassifier` - The OCL context classifier. Use `null` to create a context-free condition.
    `eStructuralFeatureValueGetter` - The strategy for accessing structural feature values. It serves as a layer of indirection to allow clients to intervene between this condition object and the way it extracts the structural features' values so as to allow for manipulation of such values before subjecting them to evaluation by the OCL interpreter.
  Throws:
    `ParserException` - on failure to parse the specified expression in the given classifier context, if this is not a context-free query

### AbstractOCLCondition

    protected AbstractOCLCondition(Environment<?,C,?,?,?,?,?,?,?,?,CLS,E> env,
                                   String oclExpressionString,
                                   C contextClassifier,
                                   IEStructuralFeatureValueGetter eStructuralFeatureValueGetter,
                                   PruneHandler pruneHandler)
                            throws ParserException

  Initializes a query condition with an OCL expression string, a context classifier representing the type of "self" in the OCL expression, and an `IEStructuralFeatureValueGetter` to use to resolve the context element for safe access to structural features, and a prune-handler to consult for pruning the object tree.

  NOTE: if `contextClassifier` is `null`, then this becomes a context-free OCL condition.

  Parameters:
    `env` - an OCL environment in which to parse the expression. Must not be `null`
    `oclExpressionString` - The OCL expression to apply when evaluating this `OCLCondition`
    `contextClassifier` - The OCL context classifier. Use `null` to create a context-free condition.
    `eStructuralFeatureValueGetter` - The strategy for accessing structural feature values. It serves as a layer of indirection to allow clients to intervene between this condition object and the way it extracts the structural features' values so as to allow for manipulation of such values before subjecting them to evaluation by the OCL interpreter.
    `pruneHandler` - The `PruneHandler` to consult when pruning
  Throws:
    `ParserException` - on failure to parse the specified expression in the given classifier context, if this is not a context-free query

### AbstractOCLCondition

    protected AbstractOCLCondition(Environment<?,C,?,?,?,?,?,?,?,?,CLS,E> env,
                                   Query<C,CLS,E> oclQuery,
                                   C contextClassifier,
                                   IEStructuralFeatureValueGetter eStructuralFeatureValueGetter,
                                   PruneHandler pruneHandler)

  Initializes a query condition with compiled OCL query, a context classifier representing the type of "self" in the OCL expression, and an `IEStructuralFeatureValueGetter` to use to resolve the context element for safe access to structural features, and a `PruneHandler` to consult for pruning the content tree.

  Parameters:
    `env` - the OCL environment in which the OCL query was parsed. Must not be `null`
    `oclQuery` - The OCL query to apply when evaluating this condition
    `contextClassifier` - The OCL context classifier. Must not be `null`.
    `eStructuralFeatureValueGetter` - The strategy for accessing structural feature values. It serves as a layer of indirection to allow clients to intervene between this condition object and the way it extracts the structural features' values so as to allow for manipulation of such values before subjecting them to evaluation by the OCL interpreter.
    `pruneHandler` - The `PruneHandler` to consult when pruning

Method Detail

### getOCLQuery

    protected final Query<C,CLS,E> getOCLQuery()

  Obtains the query compiled by the OCL interpreter, which represents the OCL expression.

  Returns:
    the compiled OCL expression. This can be `null` if the condition is context-free and has not been initialized by invocation of the `isSatisfied(EObject)` method
  See Also:
    `isContextFree()`, `isSatisfied(EObject)`, `getResultType(EObject)`

### isSatisfied

    public boolean isSatisfied(EObject eObject)

  Checks to see if an `eObject` is of a type conformant to the context classifier of this condition.

  Specified by:
    `isSatisfied` in class `EObjectCondition`
  Parameters:
    `eObject` - the `EObject` to check
  Returns:
    boolean `true` if the argument eObject satisfies this `EObjectCondition`
  See Also:
    `getContextClassifier()`, `isContextFree()`

### getResultType

    public C getResultType(EObject eObject)

  Returns the type of the ocl expression. Note that the result can be `null` in the case of a context-free OCL condition.

  In the case of a context-free OCL condition, a context `eObject` is required to guess the result type of the expression. It is expected that the condition would subsequently be evaluated on objects of the same type as the `eObject`.

  Parameters:
    `eObject` - required in the case of a context-free OCL condition, to specify a context object. Otherwise, it is ignored and a `null` value is acceptable
  Returns:
    The type of the OCL expression (that is, the type of objects returned). This may be any classifier from the appropriate metamodel
  See Also:
    `isContextFree()`, `evaluate(EObject)`

### isContextFree

    protected final boolean isContextFree()

  Queries whether this OCL condition is context-free.

  Returns:
    `true` if this is a context-free OCL condition; `false`, otherwise
  See Also:
    `getResultType(EObject)`, `isSatisfied(EObject)`

### getEStructuralFeatureValueGetter

    public final IEStructuralFeatureValueGetter getEStructuralFeatureValueGetter()

  Retrieves the strategy used by this OCL condition to access the values of structural featuress of model elements.

  Returns:
    the structural feature value accessor

### setEStructuralFeatureValueGetter

    public final void setEStructuralFeatureValueGetter(IEStructuralFeatureValueGetter eStructuralFeatureValueGetter)

  Assigns the strategy to be used by this OCL Condition to access the values of structural features of model elements.

  Parameters:
    `eStructuralFeatureValueGetter` - the structural feature value accessor to use

### evaluate

    public Object evaluate(EObject eObject)

  Evaluates the OCL condition. Uses a context object, if there is any needed.

  Parameters:
    `eObject` - context for evaluation; can be `null` if the OCL expression has no "self" object
  Returns:
    the result of evaluation: could be null, a single object (either an `EObject` or a Java object), or any kind of collection of such objects

### getContextClassifier

    protected final C getContextClassifier()

  Return the context classifier. Could be `null` if this is a context-free OCL condition.

  Returns:
    the context OCL classifier
  See Also:
    `isContextFree()`

### dispose

    public void dispose()

  Disposes the OCL environment that I constructed for parsing and evaluation. This is necessary in order to ensure that `EObject` constructed by the parser are correctly disposed.

  Since:
    1.2
  See Also:
    `OCL.dispose()`

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