IBM Rational Software Modeler
Release 6.0

com.ibm.xtools.emf.query.ocl.conditions
Class OclCondition

java.lang.Object
  extended bycom.ibm.xtools.emf.query.conditions.Condition
      extended bycom.ibm.xtools.emf.query.conditions.eobjects.EObjectCondition
          extended bycom.ibm.xtools.emf.query.ocl.conditions.OclCondition
Direct Known Subclasses:
OclConstraintCondition

public abstract class OclCondition
extends EObjectCondition

A base abstract OCL condition class, it is used to apply OCL expression on EObjects. It allows the integration of OCL expression with other EObjectConditions. This class could be used to apply a context-free OCL expression if the contextEClass (type) passed to the constructor is null.


Field Summary
 
Fields inherited from class com.ibm.xtools.emf.query.conditions.eobjects.EObjectCondition
E_FALSE, E_TRUE
 
Fields inherited from class com.ibm.xtools.emf.query.conditions.Condition
FALSE, TRUE
 
Constructor Summary
protected OclCondition(String oclExpressionString, EClass contextEObjectType, IEStructuralFeatureValueGetter eStructuralFeatureValueGetter)
          A constructor that takes an OCL expression string, an EClass representing the EObject type which the OCL expression uses as a context, an IEStructuralFeatureValueGetter to use to get values of EStructuralFeature referenced by the OCL expression.
protected OclCondition(String oclExpressionString, EClass contextEObjectType, IEStructuralFeatureValueGetter eStructuralFeatureValueGetter, PruneHandler pruneHandler)
          A constructor that takes an OCL expression string, an EClass representing the EObject type which the OCL expression uses as a context, an IEStructuralFeatureValueGetter to use to get values of EStructuralFeature referenced by the OCL expression and a PruneHandler to consult for pruning.
 
Method Summary
 Object evaluate(EObject eObject)
          Evaluates the OCL condition.
protected  EClass getContextEObjectType()
          Return the context EClass.
 IEStructuralFeatureValueGetter getEStructuralFeatureValueGetter()
          A getter function that returns the IEStructuralFeatureValueGetter used by this OclCondition
protected  Query getOclQuery()
          A getter function to get the Query object generated by the OCL interpreter for the initialization ocl expression string.
 EClassifier getResultType(EObject eObject)
          Returns the type of the ocl expression.
protected  boolean isContextFree()
          Answers whether or not this OclCondition is a context-free.
 boolean isSatisfied(EObject eObject)
          Checks to see if the argument eObject is of a conformant type to be used by this OclCondition.
 void setEStructuralFeatureValueGetter(IEStructuralFeatureValueGetter eStructuralFeatureValueGetter)
          A setter function that sets the IEStructuralFeatureValueGetter to be used by this OclCondition
 
Methods inherited from class com.ibm.xtools.emf.query.conditions.eobjects.EObjectCondition
AND, EQUIVALENT, getPruneHandler, IMPLIES, isSatisfied, OR, shouldPrune, XOR
 
Methods inherited from class com.ibm.xtools.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

OclCondition

protected OclCondition(String oclExpressionString,
                       EClass contextEObjectType,
                       IEStructuralFeatureValueGetter eStructuralFeatureValueGetter)
A constructor that takes an OCL expression string, an EClass representing the EObject type which the OCL expression uses as a context, an IEStructuralFeatureValueGetter to use to get values of EStructuralFeature referenced by the OCL expression. It defaults to using PruneHandler.NEVER to consult for pruning. NOTE: if contextEObjectType is null, then this becomes a context-free ocl-condition

Parameters:
oclExpressionString - The OCL expression to apply when evaluating this OclCondition
contextEObjectType - The EClass representing the type of the EObject being evaluated by this OclCondition. If it is null, then this becomes a context-free OclCondition.
eStructuralFeatureValueGetter - The IEStructuralFeatureValueGetter to be used by this OclCondition to extract the value of the EStructuralFeatures of interest. It serves as a layer of indirection to allow clients to intervene between this condition object and the way it extracts the EStructuralFeatures' values so as to allow for possible messaging of such values before subjecting them to evaluation by the OCL interpreter.

OclCondition

protected OclCondition(String oclExpressionString,
                       EClass contextEObjectType,
                       IEStructuralFeatureValueGetter eStructuralFeatureValueGetter,
                       PruneHandler pruneHandler)
A constructor that takes an OCL expression string, an EClass representing the EObject type which the OCL expression uses as a context, an IEStructuralFeatureValueGetter to use to get values of EStructuralFeature referenced by the OCL expression and a PruneHandler to consult for pruning. NOTE: if contextEObjectType is null, then this becomes a context-free ocl-condition

Parameters:
oclExpressionString - The OCL expression to apply when evaluating this OclCondition
contextEObjectType - The EClass representing the type of the EObject being evaluated by this OclCondition. If it is null, then this becomes a context-free OclCondition.
eStructuralFeatureValueGetter - The IEStructuralFeatureValueGetter to be used by this OclCondition to extract the value of the EStructuralFeatures of interest. It serves as a layer of indirection to allow clients to intervene between this condition object and the way it extracts the EStructuralFeatures' values so as to allow for possible messaging 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 getOclQuery()
A getter function to get the Query object generated by the OCL interpreter for the initialization ocl expression string.

Returns:
Query the oclQuey, could be null if it a context-free and not been initialized by calling isSatisfied/getOclQueryRecord

isSatisfied

public boolean isSatisfied(EObject eObject)
Checks to see if the argument eObject is of a conformant type to be used by this OclCondition.

Specified by:
isSatisfied in class EObjectCondition
Parameters:
eObject - the EObject to check
Returns:
boolean true if the argument eObject satisfies this EObjectCondition
See Also:
EObjectCondition.isSatisfied(org.eclipse.emf.ecore.EObject)

getResultType

public EClassifier getResultType(EObject eObject)
Returns the type of the ocl expression. IMPORTANT: the returned value could be null especially in the case of context-free ocl-condition

Parameters:
eObject - a context EObject to pass in case of context-free ocl-expression, otherwise, null would be fine.
Returns:
EClassifier The type of returned value when evaluating the ocl-expression

isContextFree

protected final boolean isContextFree()
Answers whether or not this OclCondition is a context-free.

Returns:
boolean indicating if this OclCondition is a context-free one

getEStructuralFeatureValueGetter

public final IEStructuralFeatureValueGetter getEStructuralFeatureValueGetter()
A getter function that returns the IEStructuralFeatureValueGetter used by this OclCondition

Returns:
IEStructuralFeatureValueGetter The IEStructuralFeatureValueGetter used by this OclCondition

setEStructuralFeatureValueGetter

public final void setEStructuralFeatureValueGetter(IEStructuralFeatureValueGetter eStructuralFeatureValueGetter)
A setter function that sets the IEStructuralFeatureValueGetter to be used by this OclCondition

Parameters:
eStructuralFeatureValueGetter - The IEStructuralFeatureValueGetter to set

evaluate

public Object evaluate(EObject eObject)
Evaluates the OCL condition. Uses context object, if there is any.

Parameters:
eObject - Context for evaluation; can be null
Returns:
Result of evaluation

getContextEObjectType

protected final EClass getContextEObjectType()
Return the context EClass. Could be null if this is a context-free OCL condition

Returns:
EClass The initialization context EClass

IBM Rational Software Modeler
Release 6.0


Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2004. All rights reserved.