Package org.eclipse.emf.cdo.common.revision

# Class CDORevisionCrawler

java.lang.Object
org.eclipse.net4j.util.event.Notifier
org.eclipse.net4j.util.lifecycle.Lifecycle
org.eclipse.emf.cdo.common.revision.CDORevisionCrawler

All Implemented Interfaces:
  `org.eclipse.net4j.util.event.INotifier`, `org.eclipse.net4j.util.event.INotifier.INotifier2`, `org.eclipse.net4j.util.lifecycle.IDeactivateable`, `org.eclipse.net4j.util.lifecycle.ILifecycle`, `org.eclipse.net4j.util.lifecycle.ILifecycle.DeferrableActivation`

public final class CDORevisionCrawler extends org.eclipse.net4j.util.lifecycle.Lifecycle
A crawler that visits CDO revisions and their features according to a `feature strategy` and passes them to a `handler`.

Example usage:

     MessageDigest digest = MessageDigest.getInstance("SHA-256");
     new CDORevisionCrawler()
        .handler(new CDORevisionCrawler.MessageDigestHandler(digest))
        .revisionProvider(revisionProvider)
        .featureStrategy(CDORevisionCrawler.FeatureStrategy.TREE)
        .containmentProxyStrategy(CDORevisionCrawler.ContainmentProxyStrategy.Physical)
        .begin()
        .addRevision(rootRevision)
        .finish();
     byte[] hash = digest.digest();

Since:
  4.26
Author:
  Eike Stepper
See Also:
  - `EObjectCrawler`

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static enum`
`CDORevisionCrawler.ContainmentProxyStrategy`
Strategy for handling containment proxies during crawling.
`static interface`
`CDORevisionCrawler.FeatureStrategy`
Strategy for deciding how to handle features during crawling.
`static interface`
`CDORevisionCrawler.Handler`
Handler interface for receiving crawl events.
`static class`
`CDORevisionCrawler.MessageDigestHandler`
Handler implementation that calculates a message digest over crawled data.
`static class`
`CDORevisionCrawler.OutputStreamHandler`
Handler implementation that writes crawl data to an output stream.

## Nested classes/interfaces inherited from class org.eclipse.net4j.util.event.Notifier

`org.eclipse.net4j.util.event.Notifier.Cancelation`

## Nested classes/interfaces inherited from interface org.eclipse.net4j.util.lifecycle.ILifecycle

`org.eclipse.net4j.util.lifecycle.ILifecycle.DeferrableActivation`

## Nested classes/interfaces inherited from interface org.eclipse.net4j.util.event.INotifier

`org.eclipse.net4j.util.event.INotifier.INotifier2`

## Field Summary

### Fields inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle

`USE_LABEL`

## Constructor Summary

Constructors
Constructor
Description
`CDORevisionCrawler()`
Creates a new CDO revision crawler.

## Method Summary

Modifier and Type
Method
Description
`CDORevisionCrawler`
`addRevision(CDORevision revision)`
Adds a revision to the crawl queue and processes reachable revisions.
`CDORevisionCrawler`
`begin()`
Activates the crawler and prepares it for crawling.
`CDORevisionCrawler.ContainmentProxyStrategy`
`containmentProxyStrategy()`
Returns the current containment proxy strategy.
`CDORevisionCrawler`
`containmentProxyStrategy(CDORevisionCrawler.ContainmentProxyStrategy containmentProxyStrategy)`
Sets the containment proxy strategy.
`protected void`
`doActivate()`
Performs activation logic.
`protected void`
`doBeforeActivate()`
Checks the state of required fields before activation.
`protected void`
`doDeactivate()`
Performs deactivation logic.
`CDORevisionCrawler.FeatureStrategy`
`featureStrategy()`
Returns the current feature strategy.
`CDORevisionCrawler`
`featureStrategy(CDORevisionCrawler.FeatureStrategy featureStrategy)`
Sets the feature strategy.
`CDORevisionCrawler`
`finish()`
Deactivates the crawler and finalizes crawling.
`CDORevisionCrawler.Handler`
`handler()`
Returns the current handler used by this crawler.
`CDORevisionCrawler`
`handler(CDORevisionCrawler.Handler handler)`
Sets the handler to be used by this crawler.
`long`
`revisionCount()`
Returns the number of revisions crawled so far.
`CDORevisionProvider`
`revisionProvider()`
Returns the current revision provider.
`CDORevisionCrawler`
`revisionProvider(CDORevisionProvider revisionProvider)`
Sets the revision provider.

### Methods inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle

`activate, checkActive, checkArg, checkArg, checkInactive, checkNull, checkState, checkState, deactivate, deferredActivate, doAfterActivate, doBeforeDeactivate, dump, getLifecycleState, isActive, isDeferredActivation, toString`

### Methods inherited from class org.eclipse.net4j.util.event.Notifier

`addListener, addUniqueListener, fireEvent, fireEvent, fireEvent, fireThrowable, firstListenerAdded, getListeners, getNotificationService, hasListener, hasListeners, lastListenerRemoved, listenerAdded, listenerRemoved, removeListener`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.eclipse.net4j.util.event.INotifier

`addListener, getListeners, hasListeners, removeListener`

## Constructor Details

### CDORevisionCrawler

public CDORevisionCrawler()
Creates a new CDO revision crawler.

## Method Details

### handler

public CDORevisionCrawler.Handler handler()
Returns the current handler used by this crawler.

### handler

public CDORevisionCrawler handler(CDORevisionCrawler.Handler handler)
Sets the handler to be used by this crawler.

Parameters:
  `handler` - the handler implementation
Returns:
  this crawler instance for chaining

### containmentProxyStrategy

public CDORevisionCrawler.ContainmentProxyStrategy containmentProxyStrategy()
Returns the current containment proxy strategy.

### containmentProxyStrategy

public CDORevisionCrawler containmentProxyStrategy(CDORevisionCrawler.ContainmentProxyStrategy containmentProxyStrategy)
Sets the containment proxy strategy.

Parameters:
  `containmentProxyStrategy` - the strategy to use
Returns:
  this crawler instance for chaining

### featureStrategy

public CDORevisionCrawler.FeatureStrategy featureStrategy()
Returns the current feature strategy.

### featureStrategy

public CDORevisionCrawler featureStrategy(CDORevisionCrawler.FeatureStrategy featureStrategy)
Sets the feature strategy.

Parameters:
  `featureStrategy` - the strategy to use
Returns:
  this crawler instance for chaining

### revisionProvider

public CDORevisionProvider revisionProvider()
Returns the current revision provider.

### revisionProvider

public CDORevisionCrawler revisionProvider(CDORevisionProvider revisionProvider)
Sets the revision provider.

Parameters:
  `revisionProvider` - the provider to use
Returns:
  this crawler instance for chaining

### revisionCount

public long revisionCount()
Returns the number of revisions crawled so far.

### addRevision

public CDORevisionCrawler addRevision(CDORevision revision)
Adds a revision to the crawl queue and processes reachable revisions.

Parameters:
  `revision` - the root revision to start crawling from
Returns:
  this crawler instance for chaining

### begin

public CDORevisionCrawler begin()
Activates the crawler and prepares it for crawling.

Returns:
  this crawler instance for chaining

### finish

public CDORevisionCrawler finish()
Deactivates the crawler and finalizes crawling.

Returns:
  this crawler instance for chaining

### doBeforeActivate

protected void doBeforeActivate() throws Exception
Checks the state of required fields before activation.

Overrides:
  `doBeforeActivate` in class `org.eclipse.net4j.util.lifecycle.Lifecycle`
Throws:
  `Exception`

### doActivate

protected void doActivate() throws Exception
Performs activation logic.

Overrides:
  `doActivate` in class `org.eclipse.net4j.util.lifecycle.Lifecycle`
Throws:
  `Exception`

### doDeactivate

protected void doDeactivate() throws Exception
Performs deactivation logic.

Overrides:
  `doDeactivate` in class `org.eclipse.net4j.util.lifecycle.Lifecycle`
Throws:
  `Exception`