org.eclipse.emf.query.conditions.eobjects
Class EObjectCondition

java.lang.Object
  extended by org.eclipse.emf.query.conditions.Condition
      extended by org.eclipse.emf.query.conditions.eobjects.EObjectCondition
Direct Known Subclasses:
AbstractOCLCondition, ENot, EObjectConditionAdapter, EObjectConditionDelegator, EObjectContainmentFeatureCondition, EObjectReferencerCondition, EObjectStructuralFeatureCondition, EObjectTypeRelationCondition, IN, OCLCondition

public abstract class EObjectCondition
extends Condition

A subclass and the counterpart of a Condition object to be used on EObject arguments. It is the abstract base class for all EObjectCondition objects. It provides the basic functionality and support for EObject conditions and their logical connectives to combine other EObjectCondition object together. It answers whether a given EObject satisfies it or not. An EObjectCondition object also answers whether the contents/children of a given EObject argument are to be pruned -never visited- or not, in other words, an EObjectCondition is consulted on whether or not to apply it on the children of a given EObject, if the answer is false, then this EObject will not be applied on the children of that particular EObject. It is important for clients to know that pruning is treated as a hint only and is used solely to improve query performance and should not be relied on for correctness of the EObjectCondition evaluation. An EObjectCondition could not be consulted at all on pruning issue, and, its response -if it gets consulted- might not be honoured by the query -especially when having an EObjectCondition logically combined with another. This class is intended to be subclassed by clients.

See Also:
PruneHandler

Field Summary
static EObjectCondition E_FALSE
          A constant EObjectCondition object used to indicate a never satisfied condition
static EObjectCondition E_TRUE
          A constant EObjectCondition object used to indicate an always satisfied condition
 
Fields inherited from class org.eclipse.emf.query.conditions.Condition
FALSE, TRUE
 
Constructor Summary
EObjectCondition()
          A simple constructor.
EObjectCondition(PruneHandler pruneHandler)
          A constructor that takes in a PruneHandler instance to use for pruning.
 
Method Summary
 EObjectCondition AND(EObjectCondition condition)
          This operation acts like a logical AND between this EObjectCondition and the argument EObjectCondition.
 EObjectCondition EQUIVALENT(EObjectCondition condition)
          This operation acts like a logical Equivalent (if-and-only-if)/( <->) between this EObjectCondition and the argument EObjectCondition.
 PruneHandler getPruneHandler()
          A getter for the PrunHandler
 EObjectCondition IMPLIES(EObjectCondition condition)
          This operation acts like a logical Implies (if-then)/(->) between this EObjectCondition and the argument EObjectCondition.
abstract  boolean isSatisfied(EObject eObject)
          Answers whether the argument eObject satisfies this EObjectCondition
 boolean isSatisfied(Object object)
          Overrides the parent's implementation by simply checking if the argument object is an instance of EObject first, and if so, it forwards the actual evaluation to the appropriate overloaded version.
 EObjectCondition OR(EObjectCondition condition)
          This operation acts like a logical OR between this EObjectCondition and the argument EObjectCondition.
 boolean shouldPrune(EObject eObject)
          Answers whether or not we should apply this EObjectCondition on the children of the argument eObject.
 EObjectCondition XOR(EObjectCondition condition)
          This operation acts like a logical XOR between this EObjectCondition and the argument EObjectCondition.
 
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
 

Field Detail

E_TRUE

public static final EObjectCondition E_TRUE
A constant EObjectCondition object used to indicate an always satisfied condition


E_FALSE

public static final EObjectCondition E_FALSE
A constant EObjectCondition object used to indicate a never satisfied condition

Constructor Detail

EObjectCondition

public EObjectCondition()
A simple constructor. It defaults to using the PruneHandler.NEVER and matches any EObject.

See Also:
PruneHandler

EObjectCondition

public EObjectCondition(PruneHandler pruneHandler)
A constructor that takes in a PruneHandler instance to use for pruning. This constructor will match any kind of EObject, so it is only safe for conditions with E == EObject.

Parameters:
pruneHandler - The PruneHandler to use for pruning
See Also:
PruneHandler
Method Detail

getPruneHandler

public final PruneHandler getPruneHandler()
A getter for the PrunHandler

Returns:
PruneHandler the prune handler used by this EObjectCondition

shouldPrune

public boolean shouldPrune(EObject eObject)
Answers whether or not we should apply this EObjectCondition on the children of the argument eObject. This call is forwarded to the installed PruneHandler.

Parameters:
eObject - the EObject to check to see whether to visit its children or not
Returns:
boolean true if we should prune and false otherwise

isSatisfied

public boolean isSatisfied(Object object)
Overrides the parent's implementation by simply checking if the argument object is an instance of EObject first, and if so, it forwards the actual evaluation to the appropriate overloaded version. If the argument object does not conform to an EObject it will return false as a result.

Specified by:
isSatisfied in class Condition
Parameters:
object - an Object to check if it satisfies this Condition
Returns:
true if the argument Object satisfies this Condition,false otherwise.
See Also:
Condition.isSatisfied(java.lang.Object)

isSatisfied

public abstract boolean isSatisfied(EObject eObject)
Answers whether the argument eObject satisfies this EObjectCondition

Parameters:
eObject - the EObject to check
Returns:
boolean true if the argument eObject satisfies this EObjectCondition

AND

public EObjectCondition AND(EObjectCondition condition)
This operation acts like a logical AND between this EObjectCondition and the argument EObjectCondition. The returned EObjectCondition is a newly created EObjectCondition which is satisfied only if both its constituent EObjectCondition are. Please note that the newly compounded Condition will evaluate this EObjectCondition first, and if the result is true, it will evaluate the argument EObjectCondition: ANDing both results as its own final result. This means that the argument EObjectCondition could be short-circuited and might not be evaluated at all.

Parameters:
condition - a EObjectCondition to be ANDed with this one.
Returns:
a new compounded EObjectCondition object that represents the ANDing of this EObjectCondition with the argument EObjectCondition.

OR

public EObjectCondition OR(EObjectCondition condition)
This operation acts like a logical OR between this EObjectCondition and the argument EObjectCondition. The returned EObjectCondition is a newly created EObjectCondition which is satisfied if either of its constituent EObjectCondition is. Please note that the newly compounded EObjectCondition will evaluate this EObjectCondition first, and if the result is true, it won't evaluate the argument EObjectCondition and it will return true as its final result, if, on the other hand the evaluation of the first EObjectCondition is false, the argument EObjectCondition will be evaluated and its returned result will be ORed with this one's and the resulting boolean will be returned as the compounded EObjectCondition own final result. This means that the argument EObjectCondition could be short-circuited and might not be evaluated at all.

Parameters:
condition - a EObjectCondition to be ORed with this one.
Returns:
a new compounded EObjectCondition object that represents the ORing of this EObjectCondition with the argument EObjectCondition.

XOR

public EObjectCondition XOR(EObjectCondition condition)
This operation acts like a logical XOR between this EObjectCondition and the argument EObjectCondition. The returned EObjectCondition is a newly created EObjectCondition which is satisfied if XORing its constituent EObjectCondition is.

Parameters:
condition - a EObjectCondition to be XORed with this one.
Returns:
a new compounded EObjectCondition object that represents the XORing of this EObjectCondition with the argument EObjectCondition.

IMPLIES

public EObjectCondition IMPLIES(EObjectCondition condition)
This operation acts like a logical Implies (if-then)/(->) between this EObjectCondition and the argument EObjectCondition. The returned EObjectCondition is a newly created EObjectCondition which is satisfied if the result of this EObjectCondition's evaluation is false, in which case the argument EObjectCondition will not be evaluated at all, or, if the both its constituent EObjectCondition evaluate to true.

Parameters:
condition - a EObjectCondition to be used in the Imply relation with this one.
Returns:
a new compounded EObjectCondition object that represents the Imply logical relation between this EObjectCondition and the argument EObjectCondition.

EQUIVALENT

public EObjectCondition EQUIVALENT(EObjectCondition condition)
This operation acts like a logical Equivalent (if-and-only-if)/( <->) between this EObjectCondition and the argument EObjectCondition. The returned EObjectCondition is a newly created Condition which is satisfied if the result of both its constituent EObjectConditions evaluate to the same value.(both are true, or both are false)

Parameters:
condition - a EObjectCondition to be used in the Equivalent relation with this one.
Returns:
a new compounded EObjectCondition object that represents the Equivalent logical relation between this EObjectCondition and the argument EObjectCondition.

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