Package org.eclipse.emf.cdo.common.util

# Class EObjectCrawler

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

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 EObjectCrawler extends org.eclipse.net4j.util.lifecycle.Lifecycle
A crawler for arbitrary `EObjects` that creates `CDORevisions` on the fly and feeds them to a `CDORevisionCrawler`.

The `EObjectCrawler.ModelScope` inner class allows to register EObjects and then create an `EObjectCrawler` for the registered objects.

Example usage:

     MessageDigest digest = MessageDigest.getInstance("SHA-1");
     Handler handler = new CDORevisionCrawler.MessageDigestHandler(digest);

     ModelScope scope = new ModelScope();
     scope.registerObject(EcorePackage.eINSTANCE, true);

     EObjectCrawler crawler = scope.createCrawler().handler(handler);
     crawler.begin();
     crawler.addObject(EcorePackage.Literals.EOBJECT);
     crawler.finish();

     System.out.println(HexUtil.bytesToHex(digest.digest()));

The example above registers the `EcorePackage` and all its contents in a model scope, creates an `EObjectCrawler` for the scope, sets a handler that computes a SHA-1 message digest, begins the crawling session, adds the `EObject` `class` (which causes it to be crawled according to the default feature strategy), and finally finishes the crawling session.

At this point, the `digest` contains the SHA-1 message digest of the binary representation of all the CDORevisions that were crawled.

Since:
  4.27
Author:
  Eike Stepper

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static final class`
`EObjectCrawler.ModelScope`
A model scope for registering EObjects and creating an `EObjectCrawler` for them.

## 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`

## Method Summary

Modifier and Type
Method
Description
`EObjectCrawler`
`addObject(EObject object)`
`EObjectCrawler`
`begin()`
`CDORevisionCrawler.ContainmentProxyStrategy`
`containmentProxyStrategy()`
`EObjectCrawler`
`containmentProxyStrategy(CDORevisionCrawler.ContainmentProxyStrategy containmentProxyStrategy)`
`protected void`
`doActivate()`
`protected void`
`doDeactivate()`
`CDORevisionCrawler.FeatureStrategy`
`featureStrategy()`
`EObjectCrawler`
`featureStrategy(CDORevisionCrawler.FeatureStrategy featureStrategy)`
`EObjectCrawler`
`finish()`
`CDORevisionCrawler.Handler`
`handler()`
`EObjectCrawler`
`handler(CDORevisionCrawler.Handler handler)`
`long`
`objectCount()`

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

`activate, checkActive, checkArg, checkArg, checkInactive, checkNull, checkState, checkState, deactivate, deferredActivate, doAfterActivate, doBeforeActivate, 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`

## Method Details

### handler

public CDORevisionCrawler.Handler handler()

### handler

public EObjectCrawler handler(CDORevisionCrawler.Handler handler)

### containmentProxyStrategy

public CDORevisionCrawler.ContainmentProxyStrategy containmentProxyStrategy()

### containmentProxyStrategy

public EObjectCrawler containmentProxyStrategy(CDORevisionCrawler.ContainmentProxyStrategy containmentProxyStrategy)

### featureStrategy

public CDORevisionCrawler.FeatureStrategy featureStrategy()

### featureStrategy

public EObjectCrawler featureStrategy(CDORevisionCrawler.FeatureStrategy featureStrategy)

### objectCount

public long objectCount()

### addObject

public EObjectCrawler addObject(EObject object)

### begin

public EObjectCrawler begin()

### finish

public EObjectCrawler finish()

### doActivate

protected void doActivate() throws Exception

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

### doDeactivate

protected void doDeactivate() throws Exception

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