Package org.eclipse.emf.cdo.util

## Class CDOUtil

- java.lang.Object
- - org.eclipse.emf.cdo.util.CDOUtil

-     public final class CDOUtil
      extends java.lang.Object

  Various static methods that may help in CDO client applications.
  Author:
    Eike Stepper

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static java.lang.String` | `CDO_ANNOTATION_URI` |
    `static java.lang.String` | `DOCUMENTATION_KEY` |
    `static java.lang.String` | `PROP_VIEW_CONFIGURATOR` |
    `static java.lang.String` | `PROP_VIEW_CONFIGURATOR_DESCRIPTION` |
    `static java.lang.String` | `PROP_VIEW_CONFIGURATOR_TYPE` |

  - ### Method Summary

    All Methods Static Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static void` | `cleanStaleReference​(org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EStructuralFeature eFeature)` |
    `static void` | `cleanStaleReference​(org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EStructuralFeature eFeature, int index)` |
    `static void` | `configureView​(CDOView view)` |
    `static CDOBranch` | `createBranch​(CDOBranchPoint base, java.lang.String name)` |
    `static CDOCollectionLoadingPolicy` | `createCollectionLoadingPolicy​(int initialChunkSize, int resolveChunkSize)` |
    `static CDOFeatureAnalyzer` | `createModelBasedFeatureAnalyzer()` |
    `static CDORevisionPrefetchingPolicy` | `createRevisionPrefetchingPolicy​(int chunkSize)` |
    `static CDOFetchRuleManager` | `createThreadLocalFetchRuleManager()` |
    `static CDOFeatureAnalyzer` | `createUIFeatureAnalyzer()` |
    `static CDOFeatureAnalyzer` | `createUIFeatureAnalyzer​(long maxTimeBetweenOperation)` |
    `static CDOXATransaction` | `createXATransaction​(org.eclipse.emf.common.notify.Notifier... notifiers)` |
    `static <T extends org.eclipse.emf.ecore.EObject> org.eclipse.emf.common.util.EList<T>` | `filterReadables​(java.util.Collection<T> collection)` |
    `static java.lang.String` | `getAnnotation​(ModelElement modelElement, java.lang.String sourceURI, java.lang.String key)` |
    `static CDOObject` | `getCDOObject​(org.eclipse.emf.ecore.EObject object)` |
    `static CDOObject` | `getCDOObject​(org.eclipse.emf.ecore.EObject object, boolean adaptLegacy)` |
    `static java.util.List<? extends CDOObject>` | `getCDOObjects​(java.util.Collection<? extends org.eclipse.emf.ecore.EObject> objects)` |
    `static java.util.List<? extends CDOObject>` | `getCDOObjects​(org.eclipse.emf.ecore.EObject... objects)` |
    `static java.lang.String` | `getDocumentation​(ModelElement modelElement)` |
    `static org.eclipse.emf.ecore.EObject` | `getEObject​(org.eclipse.emf.ecore.EObject object)` |
    `static java.util.Map<java.lang.String,​org.eclipse.emf.ecore.EObject>` | `getIntrinsicIDToEObjectMap​(CDOResource resource)` | Returns the map used to cache the EObject that is identified by the `value` of its ID feature.
    `static CDOBranchPointRange` | `getLifetime​(CDOObject object)` |
    `static org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.resource.Resource>` | `getResources​(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)` |
    `static CDORevision` | `getRevisionByVersion​(CDOObject object, int version)` |
    `static CDORevision` | `getRevisionByVersion​(CDOObject object, CDOBranch branch, int version)` |
    `static CDOSession` | `getSession​(java.lang.Object object)` |
    `static CDOView` | `getView​(org.eclipse.emf.common.notify.Notifier notifier)` |
    `static CDOView` | `getView​(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.common.util.URI uri)` |
    `static CDOViewSet` | `getViewSet​(org.eclipse.emf.common.notify.Notifier notifier)` |
    `static CDOXATransaction` | `getXATransaction​(CDOViewSet viewSet)` |
    `static boolean` | `isCDOObject​(org.eclipse.emf.ecore.EObject object)` |
    `static boolean` | `isInvalidationRunnerActive()` | Deprecated. As of 4.0 use CDOView.isInvalidationRunnerActive()
    `static boolean` | `isLegacyModeDefault()` | Deprecated. As of 4.2 the legacy mode is always enabled.
    `static boolean` | `isLegacyObject​(org.eclipse.emf.ecore.EObject object)` |
    `static boolean` | `isSessionDirty​(CDOSession session)` | Returns `true` if the given `session` contains a dirty `transaction`, `false` otherwise.
    `static boolean` | `isStaleObject​(java.lang.Object object)` |
    `static boolean` | `isWritableObject​(org.eclipse.emf.ecore.EObject eObject)` | Queries whether an object is writable (is permitted to be modified in the current view context).
    `static void` | `load​(org.eclipse.emf.ecore.EObject eObject, CDOView view)` |
    `static java.io.InputStream` | `openInputStream​(CDOLob<?> lob, java.lang.String encoding)` |
    `static java.io.InputStream` | `openInputStream​(CDOResourceLeaf leaf)` |
    `static boolean` | `prepareDynamicEPackage​(org.eclipse.emf.ecore.EPackage startPackage)` |
    `static boolean` | `registerResourceFactory​(org.eclipse.emf.ecore.resource.Resource.Factory.Registry registry)` |
    `static Annotation` | `setAnnotation​(ModelElement modelElement, java.lang.String sourceURI, java.lang.String key, java.lang.String value)` |
    `static void` | `setCredentialsProvider​(org.eclipse.emf.common.util.URI uri, org.eclipse.net4j.util.security.IPasswordCredentialsProvider provider)` |
    `static Annotation` | `setDocumentation​(ModelElement modelElement, java.lang.String value)` |
    `static void` | `setIntrinsicIDToEObjectMap​(CDOResource resource, java.util.Map<java.lang.String,​org.eclipse.emf.ecore.EObject> intrinsicIDToEObjectMap)` | Sets the map used to cache the EObject identified by the value of its ID feature.
    `static void` | `setLegacyModeDefault​(boolean on)` | Deprecated. As of 4.2 the legacy mode is always enabled.
    `static void` | `setNextViewLock​(java.util.concurrent.locks.Lock viewLock)` | Sets the `lock` to be used for the next view that is opened in the context of the current thread.
    `static CDOObject` | `wrapExternalObject​(org.eclipse.emf.ecore.EObject object, CDOView view)` |

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

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

- - ### Field Detail

    - #### PROP_VIEW_CONFIGURATOR

          public static final java.lang.String PROP_VIEW_CONFIGURATOR

      Since:
        4.14
      See Also:
        Constant Field Values

    - #### PROP_VIEW_CONFIGURATOR_TYPE

          public static final java.lang.String PROP_VIEW_CONFIGURATOR_TYPE

      Since:
        4.14
      See Also:
        Constant Field Values

    - #### PROP_VIEW_CONFIGURATOR_DESCRIPTION

          public static final java.lang.String PROP_VIEW_CONFIGURATOR_DESCRIPTION

      Since:
        4.14
      See Also:
        Constant Field Values

    - #### CDO_ANNOTATION_URI

          public static final java.lang.String CDO_ANNOTATION_URI

      Since:
        4.3
      See Also:
        Constant Field Values

    - #### DOCUMENTATION_KEY

          public static final java.lang.String DOCUMENTATION_KEY

      Since:
        4.3
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### registerResourceFactory

          public static boolean registerResourceFactory​(org.eclipse.emf.ecore.resource.Resource.Factory.Registry registry)

      Since:
        4.0

    - #### getIntrinsicIDToEObjectMap

          public static java.util.Map<java.lang.String,​org.eclipse.emf.ecore.EObject> getIntrinsicIDToEObjectMap​(CDOResource resource)

      Returns the map used to cache the EObject that is identified by the `value` of its ID feature.
      Returns:
        the map used to cache the EObject that is identified by the value of its ID feature.
      Since:
        4.2
      See Also:
        `setIntrinsicIDToEObjectMap(org.eclipse.emf.cdo.eresource.CDOResource, java.util.Map<java.lang.String, org.eclipse.emf.ecore.EObject>)`

    - #### setIntrinsicIDToEObjectMap

          public static void setIntrinsicIDToEObjectMap​(CDOResource resource,
                                                        java.util.Map<java.lang.String,​org.eclipse.emf.ecore.EObject> intrinsicIDToEObjectMap)

      Sets the map used to cache the EObject identified by the value of its ID feature. This cache is only activated if the map is not `null`. The map will be lazily loaded by the `getEObjectByID` method. It is up to the client to clear the cache when it becomes invalid, e.g., when the ID of a previously mapped EObject is changed.
      Parameters:
        `intrinsicIDToEObjectMap` - the new map or `null`.
      Since:
        4.2
      See Also:
        `getIntrinsicIDToEObjectMap(org.eclipse.emf.cdo.eresource.CDOResource)`

    - #### getSession

          public static CDOSession getSession​(java.lang.Object object)

      Since:
        3.0

    - #### setNextViewLock

          public static void setNextViewLock​(java.util.concurrent.locks.Lock viewLock)

      Sets the `lock` to be used for the next view that is opened in the context of the current thread.

      This method is useful, for example, if EMF `adapters` call `Display.syncExec()` in response to CDO notifications. In these cases a `DelegableReentrantLock` can be injected into the new `view`, which does not deadlock when both CDO's invalidation thread and the display thread acquire the view lock.

      This method involves a `ThreadLocal` variable to avoid method explosion in `CDOViewContainer` and `CDOTransactionContainer`. After calling this method make sure to either open a new `view` from the current thread or call `setNextViewLock(null)` to clear the `ThreadLocal` variable.

      Since:
        4.5
      See Also:
        `CDOSession.Options.setDelegableViewLockEnabled(boolean)`

    - #### configureView

          public static void configureView​(CDOView view)

      Since:
        4.4

    - #### prepareDynamicEPackage

          public static boolean prepareDynamicEPackage​(org.eclipse.emf.ecore.EPackage startPackage)

      Since:
        2.0

    - #### createCollectionLoadingPolicy

          public static CDOCollectionLoadingPolicy createCollectionLoadingPolicy​(int initialChunkSize,
                                                                                 int resolveChunkSize)

      Since:
        2.0

    - #### createRevisionPrefetchingPolicy

          public static CDORevisionPrefetchingPolicy createRevisionPrefetchingPolicy​(int chunkSize)

      Since:
        2.0

    - #### createThreadLocalFetchRuleManager

          public static CDOFetchRuleManager createThreadLocalFetchRuleManager()

      Since:
        4.1

    - #### createModelBasedFeatureAnalyzer

          public static CDOFeatureAnalyzer createModelBasedFeatureAnalyzer()

      Since:
        4.1

    - #### createUIFeatureAnalyzer

          public static CDOFeatureAnalyzer createUIFeatureAnalyzer()

      Since:
        4.1

    - #### createUIFeatureAnalyzer

          public static CDOFeatureAnalyzer createUIFeatureAnalyzer​(long maxTimeBetweenOperation)

      Since:
        4.1

    - #### createXATransaction

          public static CDOXATransaction createXATransaction​(org.eclipse.emf.common.notify.Notifier... notifiers)

      Since:
        4.0

    - #### getXATransaction

          public static CDOXATransaction getXATransaction​(CDOViewSet viewSet)

      Since:
        2.0

    - #### getViewSet

          public static CDOViewSet getViewSet​(org.eclipse.emf.common.notify.Notifier notifier)

      Since:
        4.0

    - #### getView

          public static CDOView getView​(org.eclipse.emf.common.notify.Notifier notifier)

      Since:
        4.4

    - #### getView

          public static CDOView getView​(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
                                        org.eclipse.emf.common.util.URI uri)

      Since:
        4.4

    - #### isStaleObject

          public static boolean isStaleObject​(java.lang.Object object)

      Since:
        3.0

    - #### cleanStaleReference

          public static void cleanStaleReference​(org.eclipse.emf.ecore.EObject eObject,
                                                 org.eclipse.emf.ecore.EStructuralFeature eFeature)

      Since:
        3.0

    - #### cleanStaleReference

          public static void cleanStaleReference​(org.eclipse.emf.ecore.EObject eObject,
                                                 org.eclipse.emf.ecore.EStructuralFeature eFeature,
                                                 int index)

      Since:
        3.0

    - #### load

          public static void load​(org.eclipse.emf.ecore.EObject eObject,
                                  CDOView view)

      Since:
        2.0

    - #### wrapExternalObject

          public static CDOObject wrapExternalObject​(org.eclipse.emf.ecore.EObject object,
                                                     CDOView view)

      Since:
        4.2

    - #### getEObject

          public static org.eclipse.emf.ecore.EObject getEObject​(org.eclipse.emf.ecore.EObject object)

      Since:
        2.0

    - #### getCDOObject

          public static CDOObject getCDOObject​(org.eclipse.emf.ecore.EObject object)

      Since:
        2.0

    - #### getCDOObject

          public static CDOObject getCDOObject​(org.eclipse.emf.ecore.EObject object,
                                               boolean adaptLegacy)

      Since:
        4.4

    - #### getCDOObjects

          public static java.util.List<? extends CDOObject> getCDOObjects​(org.eclipse.emf.ecore.EObject... objects)

      Since:
        4.6

    - #### getCDOObjects

          public static java.util.List<? extends CDOObject> getCDOObjects​(java.util.Collection<? extends org.eclipse.emf.ecore.EObject> objects)

      Since:
        4.6

    - #### isCDOObject

          public static boolean isCDOObject​(org.eclipse.emf.ecore.EObject object)

      Since:
        4.4

    - #### createBranch

          public static CDOBranch createBranch​(CDOBranchPoint base,
                                               java.lang.String name)

      Since:
        4.6

    - #### filterReadables

          public static <T extends org.eclipse.emf.ecore.EObject> org.eclipse.emf.common.util.EList<T> filterReadables​(java.util.Collection<T> collection)

      Since:
        4.3

    - #### getLifetime

          public static CDOBranchPointRange getLifetime​(CDOObject object)

      Since:
        4.4

    - #### getRevisionByVersion

          public static CDORevision getRevisionByVersion​(CDOObject object,
                                                         int version)

      Since:
        2.0

    - #### getRevisionByVersion

          public static CDORevision getRevisionByVersion​(CDOObject object,
                                                         CDOBranch branch,
                                                         int version)

      Since:
        3.0

    - #### getResources

          public static org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.resource.Resource> getResources​(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)

      Since:
        2.0

    - #### isSessionDirty

          public static boolean isSessionDirty​(CDOSession session)

      Returns `true` if the given `session` contains a dirty `transaction`, `false` otherwise.
      Since:
        2.0
      See Also:
        `CDOTransaction`

    - #### isInvalidationRunnerActive

          @Deprecated
          public static boolean isInvalidationRunnerActive()

      Deprecated.
      As of 4.0 use CDOView.isInvalidationRunnerActive()
      Since:
        3.0

    - #### isWritableObject

          public static boolean isWritableObject​(org.eclipse.emf.ecore.EObject eObject)

      Queries whether an object is writable (is permitted to be modified in the current view context).
      Parameters:
        `eObject` - an object
      Returns:
        `false` if the `eObject` is managed by CDO and does not have write permission; `true`, otherwise
      Since:
        4.3

    - #### isLegacyObject

          public static boolean isLegacyObject​(org.eclipse.emf.ecore.EObject object)

      Since:
        3.0

    - #### isLegacyModeDefault

          @Deprecated
          public static boolean isLegacyModeDefault()

      Deprecated.
      As of 4.2 the legacy mode is always enabled.
      Since:
        3.0

    - #### setLegacyModeDefault

          @Deprecated
          public static void setLegacyModeDefault​(boolean on)

      Deprecated.
      As of 4.2 the legacy mode is always enabled.
      Since:
        3.0

    - #### setCredentialsProvider

          public static void setCredentialsProvider​(org.eclipse.emf.common.util.URI uri,
                                                    org.eclipse.net4j.util.security.IPasswordCredentialsProvider provider)

      Since:
        4.0

    - #### getAnnotation

          public static java.lang.String getAnnotation​(ModelElement modelElement,
                                                       java.lang.String sourceURI,
                                                       java.lang.String key)

      Since:
        4.3

    - #### setAnnotation

          public static Annotation setAnnotation​(ModelElement modelElement,
                                                 java.lang.String sourceURI,
                                                 java.lang.String key,
                                                 java.lang.String value)

      Since:
        4.3

    - #### getDocumentation

          public static java.lang.String getDocumentation​(ModelElement modelElement)

      Since:
        4.3

    - #### setDocumentation

          public static Annotation setDocumentation​(ModelElement modelElement,
                                                    java.lang.String value)

      Since:
        4.3

    - #### openInputStream

          public static java.io.InputStream openInputStream​(CDOResourceLeaf leaf)
                                                     throws java.io.IOException

      Throws:
        `java.io.IOException`
      Since:
        4.13

    - #### openInputStream

          public static java.io.InputStream openInputStream​(CDOLob<?> lob,
                                                            java.lang.String encoding)
                                                     throws java.io.IOException

      Throws:
        `java.io.IOException`
      Since:
        4.13