org.eclipse.emf.validation.service
Class ITraversalStrategy.Recursive

java.lang.Object
  extended by org.eclipse.emf.validation.service.AbstractTraversalStrategy
      extended by org.eclipse.emf.validation.service.ITraversalStrategy.Recursive
All Implemented Interfaces:
ITraversalStrategy
Enclosing interface:
ITraversalStrategy

public static final class ITraversalStrategy.Recursive
extends AbstractTraversalStrategy

An implementation of the ITraversalStrategy interface that is recursive: it iterates over the content trees of the roots, according to the basic EMF EObject.eAllContents() tree-iterator. One bit of value-add that it offers, though, is that it avoids duplication of sub-trees where one of the traversal roots is actually contained within another.

This traversal strategy assumes that only the root elements of the traversal may be in different client contexts, not any contents of their sub-trees.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eclipse.emf.validation.service.ITraversalStrategy
ITraversalStrategy.Flat, ITraversalStrategy.Recursive
 
Constructor Summary
ITraversalStrategy.Recursive()
          Initializes me.
 
Method Summary
protected  int countElements(Collection<? extends EObject> ignored)
          Implemented by subclasses to compute the number of elements that will be validated within the scope of the specified root elements.
protected  Iterator<? extends EObject> createIterator(Collection<? extends EObject> ignored)
          Implemented by subclasses to return an iterator that provides all of the elements to be validated, within the scope of the specified root elements.
 boolean isClientContextChanged()
          This implementation is pessimistic, always returning true to indicate that the client context should be recomputed for each object traversed.
 void startTraversal(Collection<? extends EObject> traversalRoots, IProgressMonitor progressMonitor)
          Initializes the traversal by asking the subclass to count the number of elements that will be validated and to create an iterator that will provide them all.
 
Methods inherited from class org.eclipse.emf.validation.service.AbstractTraversalStrategy
elementValidated, getProgressMonitor, getTaskLabel, hasNext, next
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ITraversalStrategy.Recursive

public ITraversalStrategy.Recursive()
Initializes me.

Method Detail

startTraversal

public void startTraversal(Collection<? extends EObject> traversalRoots,
                           IProgressMonitor progressMonitor)
Description copied from class: AbstractTraversalStrategy
Initializes the traversal by asking the subclass to count the number of elements that will be validated and to create an iterator that will provide them all. The progress monitor is initialized with a work unit per element (scaled to a reasonable maximum to avoid too many GUI updates).

Specified by:
startTraversal in interface ITraversalStrategy
Overrides:
startTraversal in class AbstractTraversalStrategy
Parameters:
traversalRoots - a collection of one or more EObjects. It is never empty, but neither is it modifiable
progressMonitor - the progress monitor used to track progress. The receiver may retain this progress monitor for the duration of the traversal

countElements

protected int countElements(Collection<? extends EObject> ignored)
Description copied from class: AbstractTraversalStrategy
Implemented by subclasses to compute the number of elements that will be validated within the scope of the specified root elements.

Specified by:
countElements in class AbstractTraversalStrategy
Parameters:
ignored - the roots of the traversal sub-trees
Returns:
the total number of elements to be validated within these sub-trees

createIterator

protected Iterator<? extends EObject> createIterator(Collection<? extends EObject> ignored)
Description copied from class: AbstractTraversalStrategy
Implemented by subclasses to return an iterator that provides all of the elements to be validated, within the scope of the specified root elements.

Specified by:
createIterator in class AbstractTraversalStrategy
Parameters:
ignored - the roots of the traversal sub-trees
Returns:
an iterator that covers all of the elements to be validated

isClientContextChanged

public boolean isClientContextChanged()
Description copied from class: AbstractTraversalStrategy
This implementation is pessimistic, always returning true to indicate that the client context should be recomputed for each object traversed.

Specified by:
isClientContextChanged in interface ITraversalStrategy
Overrides:
isClientContextChanged in class AbstractTraversalStrategy
Returns:
true if the next object to be returned by the ITraversalStrategy.next() method is potentially in a different client context than the previous (thereby requiring the validation framework to recompute the context); false if the object can be assumed to be in the same context as the previous

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