org.eclipse.emf.query.handlers
Class PruneHandler

java.lang.Object
  extended by org.eclipse.emf.query.handlers.PruneHandler

public abstract class PruneHandler
extends Object

An abstract class that represents a prune handler. It is used by EObjectConditions to check if a given EObject has children -recursively- that are worth evaluating, or, if all the contained EObjects for the given EObject will never satisfy the EObjectCondition at all, and hence there is no need to check them at all. 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 get consulted- might not be honoured by the query -especially when having an EObjectCondition logically combined with another. Clearly this PruneHandler is an EObjectCondition and a metamodel specific, and that's why there is no default implementation other than the trivial cases of prune-always or never-prune. EObjectCondition that use a PruneHandler usually default to using the PruneHandler.NEVER so as to visit and evaluate every child in the EObject containment tree, in this sense, providing a PruneHandler by clients is optional, nevertheless, it is there to allow clients to provide their own implementation as a way to enhance performance of queries by not visiting useless branches. This class is intended to be subclassed by clients.


Field Summary
static PruneHandler ALWAYS
          A simple PruneHandler implementation that will always prune regardless of the nature of the EObjectCondition used or the argument eObject passed.
static PruneHandler NEVER
          A simple PruneHandler implementation that will never prune regardless of the nature of the EObjectCondition used or the argument eObject passed.
 
Constructor Summary
PruneHandler()
           
 
Method Summary
abstract  boolean shouldPrune(EObject eObject)
          Answers whether the children -recursively- of the argument EObject are not worth evaluating by a given EObjectCondition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALWAYS

public static final PruneHandler ALWAYS
A simple PruneHandler implementation that will always prune regardless of the nature of the EObjectCondition used or the argument eObject passed. The shouldPrune(EObject) will always return true.


NEVER

public static final PruneHandler NEVER
A simple PruneHandler implementation that will never prune regardless of the nature of the EObjectCondition used or the argument eObject passed. The shouldPrune(EObject) will always return false.

Constructor Detail

PruneHandler

public PruneHandler()
Method Detail

shouldPrune

public abstract boolean shouldPrune(EObject eObject)
Answers whether the children -recursively- of the argument EObject are not worth evaluating by a given EObjectCondition

Parameters:
eObject - The EObject whose children are being checked.
Returns:
boolean true if this prune handler finds out that the argument eObject's children -recursively- will always evaluate to false by the respective EObjectCondition that this PruneHandler is written to help.

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