Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal')
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/CDOQueryInfoImpl.java320
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchImpl.java684
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchManagerImpl.java502
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchPointImpl.java170
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchPointRangeImpl.java96
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchVersionImpl.java146
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/bundle/OM.java116
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetDataImpl.java450
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetImpl.java96
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitDataImpl.java94
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoImpl.java306
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoManagerImpl.java174
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/DelegatingCommitInfo.java222
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/FailureCommitInfo.java232
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDExternalImpl.java262
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDNullImpl.java250
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectLongImpl.java166
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectLongWithClassifierImpl.java290
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectStringImpl.java162
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectStringWithClassifierImpl.java276
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectUUIDImpl.java208
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectExternalImpl.java66
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectImpl.java140
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockAreaImpl.java212
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockChangeInfoImpl.java186
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockOwnerImpl.java182
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockStateImpl.java382
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/messages/Messages.java82
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/messages/messages.properties78
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java252
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageInfoImpl.java320
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageRegistryImpl.java1326
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageUnitImpl.java786
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOTypeImpl.java1886
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/GenUtil.java426
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/protocol/CDODataInputImpl.java1302
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/protocol/CDODataOutputImpl.java1120
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/AbstractCDORevisionCache.java312
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOElementProxyImpl.java90
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOFeatureMapEntryImpl.java126
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndBranchImpl.java156
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndVersionImpl.java150
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListImpl.java374
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListWithElementProxiesImpl.java182
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisableImpl.java180
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheAuditing.java886
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheBranching.java262
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheNonAuditing.java434
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java286
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionKeyImpl.java132
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionManagerImpl.java1078
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/EvictionEventImpl.java134
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/NOOPRevisionCache.java202
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOAddFeatureDeltaImpl.java158
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOClearFeatureDeltaImpl.java146
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOContainerFeatureDeltaImpl.java346
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDODetachedRevisionDeltaImpl.java178
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOFeatureDeltaImpl.java180
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOListFeatureDeltaImpl.java928
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOMoveFeatureDeltaImpl.java414
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORemoveFeatureDeltaImpl.java198
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java1102
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOSetFeatureDeltaImpl.java194
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOSingleValueFeatureDeltaImpl.java370
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOUnsetFeatureDeltaImpl.java146
65 files changed, 11656 insertions, 11656 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/CDOQueryInfoImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/CDOQueryInfoImpl.java
index 0ae3d4b9e9..1053c06e5f 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/CDOQueryInfoImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/CDOQueryInfoImpl.java
@@ -1,160 +1,160 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.common;
-
-import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.util.CDOQueryInfo;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-/**
- * @author Simon McDuff
- */
-public class CDOQueryInfoImpl implements CDOQueryInfo
-{
- protected String queryLanguage;
-
- protected String queryString;
-
- protected Object context;
-
- protected Map<String, Object> parameters = new HashMap<String, Object>();
-
- protected int maxResults = UNLIMITED_RESULTS;
-
- protected boolean legacyModeEnabled;
-
- protected CDOChangeSetData changeSetData;
-
- public CDOQueryInfoImpl(String queryLanguage, String queryString, Object context)
- {
- this.queryLanguage = queryLanguage;
- this.queryString = queryString;
- this.context = context;
- }
-
- public CDOQueryInfoImpl(CDODataInput in) throws IOException
- {
- queryLanguage = in.readString();
- queryString = in.readString();
- context = in.readCDORevisionOrPrimitiveOrClassifier();
- maxResults = in.readInt();
- legacyModeEnabled = in.readBoolean();
-
- if (in.readBoolean())
- {
- changeSetData = in.readCDOChangeSetData();
- }
-
- int size = in.readInt();
- for (int i = 0; i < size; i++)
- {
- String key = in.readString();
- Object object = in.readCDORevisionOrPrimitiveOrClassifier();
- parameters.put(key, object);
- }
- }
-
- public void write(CDODataOutput out) throws IOException
- {
- out.writeString(queryLanguage);
- out.writeString(queryString);
- out.writeCDORevisionOrPrimitiveOrClassifier(context);
- out.writeInt(maxResults);
- out.writeBoolean(legacyModeEnabled);
-
- if (changeSetData != null)
- {
- out.writeBoolean(true);
- out.writeCDOChangeSetData(changeSetData);
- }
- else
- {
- out.writeBoolean(false);
- }
-
- out.writeInt(parameters.size());
- for (Entry<String, Object> entry : parameters.entrySet())
- {
- out.writeString(entry.getKey());
- out.writeCDORevisionOrPrimitiveOrClassifier(entry.getValue());
- }
- }
-
- public String getQueryString()
- {
- return queryString;
- }
-
- public String getQueryLanguage()
- {
- return queryLanguage;
- }
-
- public Map<String, Object> getParameters()
- {
- return Collections.unmodifiableMap(parameters);
- }
-
- public Object getContext()
- {
- return context;
- }
-
- public CDOQueryInfoImpl setContext(Object context)
- {
- this.context = context;
- return this;
- }
-
- public void addParameter(String key, Object value)
- {
- parameters.put(key, value);
- }
-
- public int getMaxResults()
- {
- return maxResults;
- }
-
- public CDOQueryInfoImpl setMaxResults(int maxResults)
- {
- this.maxResults = maxResults;
- return this;
- }
-
- public boolean isLegacyModeEnabled()
- {
- return legacyModeEnabled;
- }
-
- public void setLegacyModeEnabled(boolean legacyModeEnabled)
- {
- this.legacyModeEnabled = legacyModeEnabled;
- }
-
- public CDOChangeSetData getChangeSetData()
- {
- return changeSetData;
- }
-
- public void setChangeSetData(CDOChangeSetData changeSetData)
- {
- this.changeSetData = changeSetData;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.common;
+
+import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.common.util.CDOQueryInfo;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+/**
+ * @author Simon McDuff
+ */
+public class CDOQueryInfoImpl implements CDOQueryInfo
+{
+ protected String queryLanguage;
+
+ protected String queryString;
+
+ protected Object context;
+
+ protected Map<String, Object> parameters = new HashMap<String, Object>();
+
+ protected int maxResults = UNLIMITED_RESULTS;
+
+ protected boolean legacyModeEnabled;
+
+ protected CDOChangeSetData changeSetData;
+
+ public CDOQueryInfoImpl(String queryLanguage, String queryString, Object context)
+ {
+ this.queryLanguage = queryLanguage;
+ this.queryString = queryString;
+ this.context = context;
+ }
+
+ public CDOQueryInfoImpl(CDODataInput in) throws IOException
+ {
+ queryLanguage = in.readString();
+ queryString = in.readString();
+ context = in.readCDORevisionOrPrimitiveOrClassifier();
+ maxResults = in.readInt();
+ legacyModeEnabled = in.readBoolean();
+
+ if (in.readBoolean())
+ {
+ changeSetData = in.readCDOChangeSetData();
+ }
+
+ int size = in.readInt();
+ for (int i = 0; i < size; i++)
+ {
+ String key = in.readString();
+ Object object = in.readCDORevisionOrPrimitiveOrClassifier();
+ parameters.put(key, object);
+ }
+ }
+
+ public void write(CDODataOutput out) throws IOException
+ {
+ out.writeString(queryLanguage);
+ out.writeString(queryString);
+ out.writeCDORevisionOrPrimitiveOrClassifier(context);
+ out.writeInt(maxResults);
+ out.writeBoolean(legacyModeEnabled);
+
+ if (changeSetData != null)
+ {
+ out.writeBoolean(true);
+ out.writeCDOChangeSetData(changeSetData);
+ }
+ else
+ {
+ out.writeBoolean(false);
+ }
+
+ out.writeInt(parameters.size());
+ for (Entry<String, Object> entry : parameters.entrySet())
+ {
+ out.writeString(entry.getKey());
+ out.writeCDORevisionOrPrimitiveOrClassifier(entry.getValue());
+ }
+ }
+
+ public String getQueryString()
+ {
+ return queryString;
+ }
+
+ public String getQueryLanguage()
+ {
+ return queryLanguage;
+ }
+
+ public Map<String, Object> getParameters()
+ {
+ return Collections.unmodifiableMap(parameters);
+ }
+
+ public Object getContext()
+ {
+ return context;
+ }
+
+ public CDOQueryInfoImpl setContext(Object context)
+ {
+ this.context = context;
+ return this;
+ }
+
+ public void addParameter(String key, Object value)
+ {
+ parameters.put(key, value);
+ }
+
+ public int getMaxResults()
+ {
+ return maxResults;
+ }
+
+ public CDOQueryInfoImpl setMaxResults(int maxResults)
+ {
+ this.maxResults = maxResults;
+ return this;
+ }
+
+ public boolean isLegacyModeEnabled()
+ {
+ return legacyModeEnabled;
+ }
+
+ public void setLegacyModeEnabled(boolean legacyModeEnabled)
+ {
+ this.legacyModeEnabled = legacyModeEnabled;
+ }
+
+ public CDOChangeSetData getChangeSetData()
+ {
+ return changeSetData;
+ }
+
+ public void setChangeSetData(CDOChangeSetData changeSetData)
+ {
+ this.changeSetData = changeSetData;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchImpl.java
index 0317b3a974..6d3986dff0 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchImpl.java
@@ -1,342 +1,342 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.branch;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.SubBranchInfo;
-
-import org.eclipse.net4j.util.container.Container;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class CDOBranchImpl extends Container<CDOBranch> implements InternalCDOBranch
-{
- public static final int ILLEGAL_BRANCH_ID = Integer.MIN_VALUE;
-
- private InternalCDOBranchManager branchManager;
-
- private int id;
-
- private String name;
-
- private CDOBranchPoint base;
-
- private CDOBranchPoint head = getPoint(CDOBranchPoint.UNSPECIFIED_DATE);
-
- private InternalCDOBranch[] branches;
-
- public CDOBranchImpl(InternalCDOBranchManager branchManager, int id, String name, CDOBranchPoint base)
- {
- this.branchManager = branchManager;
- this.id = id;
- this.name = name;
- this.base = base;
- activate();
- }
-
- public boolean isMainBranch()
- {
- return false;
- }
-
- public boolean isLocal()
- {
- return id < 0;
- }
-
- public InternalCDOBranchManager getBranchManager()
- {
- return branchManager;
- }
-
- public int getID()
- {
- return id;
- }
-
- public synchronized String getName()
- {
- if (name == null)
- {
- load();
- }
-
- return name;
- }
-
- public boolean isProxy()
- {
- return name == null || base == null;
- }
-
- public String getPathName()
- {
- StringBuilder builder = new StringBuilder();
- computePathName(this, builder);
- return builder.toString();
- }
-
- private void computePathName(CDOBranch branch, StringBuilder builder)
- {
- CDOBranchPoint base = branch.getBase();
- CDOBranch parent = base.getBranch();
- if (parent != null)
- {
- computePathName(parent, builder);
- builder.append(PATH_SEPARATOR);
- }
-
- builder.append(branch.getName());
- }
-
- public CDOBranchPoint[] getBasePath()
- {
- List<CDOBranchPoint> path = new ArrayList<CDOBranchPoint>();
- computeBasePath(this, path);
- return path.toArray(new CDOBranchPoint[path.size()]);
- }
-
- private void computeBasePath(CDOBranch branch, List<CDOBranchPoint> path)
- {
- CDOBranchPoint base = branch.getBase();
- CDOBranch parent = base.getBranch();
- if (parent != null)
- {
- computeBasePath(parent, path);
- }
-
- path.add(base);
- }
-
- public synchronized CDOBranchPoint getBase()
- {
- if (base == null)
- {
- load();
- }
-
- return base;
- }
-
- public CDOBranchPoint getHead()
- {
- return head;
- }
-
- public CDOBranchPoint getPoint(long timeStamp)
- {
- return new CDOBranchPointImpl(this, timeStamp);
- }
-
- public CDOBranchVersion getVersion(int version)
- {
- return new CDOBranchVersionImpl(this, version);
- }
-
- public InternalCDOBranch createBranch(String name, long timeStamp)
- {
- return getBranchManager().createBranch(BranchLoader.NEW_BRANCH, name, this, timeStamp);
- }
-
- public InternalCDOBranch createBranch(String name)
- {
- return createBranch(name, CDOBranchPoint.UNSPECIFIED_DATE);
- }
-
- public InternalCDOBranch[] getElements()
- {
- return getBranches();
- }
-
- public InternalCDOBranch[] getBranches(boolean loadOnDemand)
- {
- if (branches == null && loadOnDemand)
- {
- InternalCDOBranchManager branchManager = getBranchManager();
- SubBranchInfo[] infos = branchManager.getBranchLoader().loadSubBranches(id);
- branches = new InternalCDOBranch[infos.length];
- for (int i = 0; i < infos.length; i++)
- {
- SubBranchInfo info = infos[i];
- branches[i] = branchManager.getBranch(info.getID(), info.getName(), this, info.getBaseTimeStamp());
- }
- }
-
- return branches;
- }
-
- public synchronized InternalCDOBranch[] getBranches()
- {
- return getBranches(true);
- }
-
- public InternalCDOBranch getBranch(String path)
- {
- while (path.startsWith(PATH_SEPARATOR))
- {
- path = path.substring(1);
- }
-
- while (path.endsWith(PATH_SEPARATOR))
- {
- path = path.substring(0, path.length() - PATH_SEPARATOR.length());
- }
-
- int sep = path.indexOf(PATH_SEPARATOR);
- if (sep == -1)
- {
- return getChild(path);
- }
-
- String name = path.substring(0, sep);
- InternalCDOBranch child = getChild(name);
- if (child == null)
- {
- return null;
- }
-
- // Recurse
- String rest = path.substring(sep + 1);
- return child.getBranch(rest);
- }
-
- private InternalCDOBranch getChild(String name)
- {
- InternalCDOBranch[] branches = getBranches();
- for (InternalCDOBranch branch : branches)
- {
- if (name.equals(branch.getName()))
- {
- return branch;
- }
- }
-
- return null;
- }
-
- public BranchInfo getBranchInfo()
- {
- CDOBranchPoint base = getBase();
- return new BranchInfo(getName(), base.getBranch().getID(), base.getTimeStamp());
- }
-
- public void setBranchInfo(String name, InternalCDOBranch baseBranch, long baseTimeStamp)
- {
- this.name = name;
- base = baseBranch.getPoint(baseTimeStamp);
- }
-
- public void addChild(InternalCDOBranch branch)
- {
- synchronized (this)
- {
- if (branches == null)
- {
- branches = new InternalCDOBranch[] { branch };
- }
- else
- {
- InternalCDOBranch[] newBranches = new InternalCDOBranch[branches.length + 1];
- System.arraycopy(branches, 0, newBranches, 0, branches.length);
- newBranches[branches.length] = branch;
- branches = newBranches;
- }
- }
-
- fireElementAddedEvent(branch);
- }
-
- public int compareTo(CDOBranch o)
- {
- int otherID = o.getID();
- return id < otherID ? -1 : id == otherID ? 0 : 1;
- }
-
- @Override
- public int hashCode()
- {
- return id;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj instanceof CDOBranch)
- {
- CDOBranch that = (CDOBranch)obj;
- return id == that.getID();
- }
-
- return false;
- }
-
- @Override
- public String toString()
- {
- if (isProxy())
- {
- return MessageFormat.format("Branch[id={0}, PROXY]", id); //$NON-NLS-1$
- }
-
- return MessageFormat.format("Branch[id={0}, name={1}]", id, name); //$NON-NLS-1$
- }
-
- private synchronized void load()
- {
- BranchInfo branchInfo = branchManager.getBranchLoader().loadBranch(id);
- CDOBranch baseBranch = branchManager.getBranch(branchInfo.getBaseBranchID());
-
- name = branchInfo.getName();
- base = baseBranch.getPoint(branchInfo.getBaseTimeStamp());
- }
-
- /**
- * @author Eike Stepper
- */
- public static class Main extends CDOBranchImpl
- {
- private boolean local;
-
- public Main(InternalCDOBranchManager branchManager, boolean local, long timeStamp)
- {
- super(branchManager, MAIN_BRANCH_ID, MAIN_BRANCH_NAME, new CDOBranchPointImpl(null, timeStamp));
- this.local = local;
- }
-
- @Override
- public boolean isMainBranch()
- {
- return true;
- }
-
- @Override
- public boolean isLocal()
- {
- return local;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.branch;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.SubBranchInfo;
+
+import org.eclipse.net4j.util.container.Container;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOBranchImpl extends Container<CDOBranch> implements InternalCDOBranch
+{
+ public static final int ILLEGAL_BRANCH_ID = Integer.MIN_VALUE;
+
+ private InternalCDOBranchManager branchManager;
+
+ private int id;
+
+ private String name;
+
+ private CDOBranchPoint base;
+
+ private CDOBranchPoint head = getPoint(CDOBranchPoint.UNSPECIFIED_DATE);
+
+ private InternalCDOBranch[] branches;
+
+ public CDOBranchImpl(InternalCDOBranchManager branchManager, int id, String name, CDOBranchPoint base)
+ {
+ this.branchManager = branchManager;
+ this.id = id;
+ this.name = name;
+ this.base = base;
+ activate();
+ }
+
+ public boolean isMainBranch()
+ {
+ return false;
+ }
+
+ public boolean isLocal()
+ {
+ return id < 0;
+ }
+
+ public InternalCDOBranchManager getBranchManager()
+ {
+ return branchManager;
+ }
+
+ public int getID()
+ {
+ return id;
+ }
+
+ public synchronized String getName()
+ {
+ if (name == null)
+ {
+ load();
+ }
+
+ return name;
+ }
+
+ public boolean isProxy()
+ {
+ return name == null || base == null;
+ }
+
+ public String getPathName()
+ {
+ StringBuilder builder = new StringBuilder();
+ computePathName(this, builder);
+ return builder.toString();
+ }
+
+ private void computePathName(CDOBranch branch, StringBuilder builder)
+ {
+ CDOBranchPoint base = branch.getBase();
+ CDOBranch parent = base.getBranch();
+ if (parent != null)
+ {
+ computePathName(parent, builder);
+ builder.append(PATH_SEPARATOR);
+ }
+
+ builder.append(branch.getName());
+ }
+
+ public CDOBranchPoint[] getBasePath()
+ {
+ List<CDOBranchPoint> path = new ArrayList<CDOBranchPoint>();
+ computeBasePath(this, path);
+ return path.toArray(new CDOBranchPoint[path.size()]);
+ }
+
+ private void computeBasePath(CDOBranch branch, List<CDOBranchPoint> path)
+ {
+ CDOBranchPoint base = branch.getBase();
+ CDOBranch parent = base.getBranch();
+ if (parent != null)
+ {
+ computeBasePath(parent, path);
+ }
+
+ path.add(base);
+ }
+
+ public synchronized CDOBranchPoint getBase()
+ {
+ if (base == null)
+ {
+ load();
+ }
+
+ return base;
+ }
+
+ public CDOBranchPoint getHead()
+ {
+ return head;
+ }
+
+ public CDOBranchPoint getPoint(long timeStamp)
+ {
+ return new CDOBranchPointImpl(this, timeStamp);
+ }
+
+ public CDOBranchVersion getVersion(int version)
+ {
+ return new CDOBranchVersionImpl(this, version);
+ }
+
+ public InternalCDOBranch createBranch(String name, long timeStamp)
+ {
+ return getBranchManager().createBranch(BranchLoader.NEW_BRANCH, name, this, timeStamp);
+ }
+
+ public InternalCDOBranch createBranch(String name)
+ {
+ return createBranch(name, CDOBranchPoint.UNSPECIFIED_DATE);
+ }
+
+ public InternalCDOBranch[] getElements()
+ {
+ return getBranches();
+ }
+
+ public InternalCDOBranch[] getBranches(boolean loadOnDemand)
+ {
+ if (branches == null && loadOnDemand)
+ {
+ InternalCDOBranchManager branchManager = getBranchManager();
+ SubBranchInfo[] infos = branchManager.getBranchLoader().loadSubBranches(id);
+ branches = new InternalCDOBranch[infos.length];
+ for (int i = 0; i < infos.length; i++)
+ {
+ SubBranchInfo info = infos[i];
+ branches[i] = branchManager.getBranch(info.getID(), info.getName(), this, info.getBaseTimeStamp());
+ }
+ }
+
+ return branches;
+ }
+
+ public synchronized InternalCDOBranch[] getBranches()
+ {
+ return getBranches(true);
+ }
+
+ public InternalCDOBranch getBranch(String path)
+ {
+ while (path.startsWith(PATH_SEPARATOR))
+ {
+ path = path.substring(1);
+ }
+
+ while (path.endsWith(PATH_SEPARATOR))
+ {
+ path = path.substring(0, path.length() - PATH_SEPARATOR.length());
+ }
+
+ int sep = path.indexOf(PATH_SEPARATOR);
+ if (sep == -1)
+ {
+ return getChild(path);
+ }
+
+ String name = path.substring(0, sep);
+ InternalCDOBranch child = getChild(name);
+ if (child == null)
+ {
+ return null;
+ }
+
+ // Recurse
+ String rest = path.substring(sep + 1);
+ return child.getBranch(rest);
+ }
+
+ private InternalCDOBranch getChild(String name)
+ {
+ InternalCDOBranch[] branches = getBranches();
+ for (InternalCDOBranch branch : branches)
+ {
+ if (name.equals(branch.getName()))
+ {
+ return branch;
+ }
+ }
+
+ return null;
+ }
+
+ public BranchInfo getBranchInfo()
+ {
+ CDOBranchPoint base = getBase();
+ return new BranchInfo(getName(), base.getBranch().getID(), base.getTimeStamp());
+ }
+
+ public void setBranchInfo(String name, InternalCDOBranch baseBranch, long baseTimeStamp)
+ {
+ this.name = name;
+ base = baseBranch.getPoint(baseTimeStamp);
+ }
+
+ public void addChild(InternalCDOBranch branch)
+ {
+ synchronized (this)
+ {
+ if (branches == null)
+ {
+ branches = new InternalCDOBranch[] { branch };
+ }
+ else
+ {
+ InternalCDOBranch[] newBranches = new InternalCDOBranch[branches.length + 1];
+ System.arraycopy(branches, 0, newBranches, 0, branches.length);
+ newBranches[branches.length] = branch;
+ branches = newBranches;
+ }
+ }
+
+ fireElementAddedEvent(branch);
+ }
+
+ public int compareTo(CDOBranch o)
+ {
+ int otherID = o.getID();
+ return id < otherID ? -1 : id == otherID ? 0 : 1;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return id;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+
+ if (obj instanceof CDOBranch)
+ {
+ CDOBranch that = (CDOBranch)obj;
+ return id == that.getID();
+ }
+
+ return false;
+ }
+
+ @Override
+ public String toString()
+ {
+ if (isProxy())
+ {
+ return MessageFormat.format("Branch[id={0}, PROXY]", id); //$NON-NLS-1$
+ }
+
+ return MessageFormat.format("Branch[id={0}, name={1}]", id, name); //$NON-NLS-1$
+ }
+
+ private synchronized void load()
+ {
+ BranchInfo branchInfo = branchManager.getBranchLoader().loadBranch(id);
+ CDOBranch baseBranch = branchManager.getBranch(branchInfo.getBaseBranchID());
+
+ name = branchInfo.getName();
+ base = baseBranch.getPoint(branchInfo.getBaseTimeStamp());
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class Main extends CDOBranchImpl
+ {
+ private boolean local;
+
+ public Main(InternalCDOBranchManager branchManager, boolean local, long timeStamp)
+ {
+ super(branchManager, MAIN_BRANCH_ID, MAIN_BRANCH_NAME, new CDOBranchPointImpl(null, timeStamp));
+ this.local = local;
+ }
+
+ @Override
+ public boolean isMainBranch()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isLocal()
+ {
+ return local;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchManagerImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchManagerImpl.java
index 5f46a60958..94e69d80aa 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchManagerImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchManagerImpl.java
@@ -1,251 +1,251 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.branch;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchCreatedEvent;
-import org.eclipse.emf.cdo.common.branch.CDOBranchHandler;
-import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.util.CDOTimeProvider;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo;
-
-import org.eclipse.net4j.util.collection.Pair;
-import org.eclipse.net4j.util.container.Container;
-import org.eclipse.net4j.util.event.Event;
-import org.eclipse.net4j.util.ref.ReferenceValueMap;
-import org.eclipse.net4j.util.ref.ReferenceValueMap.Soft;
-
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class CDOBranchManagerImpl extends Container<CDOBranch> implements InternalCDOBranchManager
-{
- private BranchLoader branchLoader;
-
- private CDOTimeProvider timeProvider;
-
- private InternalCDOBranch mainBranch;
-
- private Map<Integer, InternalCDOBranch> branches = createMap();
-
- public CDOBranchManagerImpl()
- {
- }
-
- public BranchLoader getBranchLoader()
- {
- return branchLoader;
- }
-
- public void setBranchLoader(BranchLoader branchLoader)
- {
- checkInactive();
- this.branchLoader = branchLoader;
- }
-
- public CDOTimeProvider getTimeProvider()
- {
- return timeProvider;
- }
-
- public void setTimeProvider(CDOTimeProvider timeProvider)
- {
- this.timeProvider = timeProvider;
- }
-
- public void initMainBranch(boolean local, long timeStamp)
- {
- mainBranch = new CDOBranchImpl.Main(this, local, timeStamp);
- }
-
- public void handleBranchCreated(InternalCDOBranch branch)
- {
- CDOBranchPoint base = branch.getBase();
- InternalCDOBranch baseBranch = (InternalCDOBranch)base.getBranch();
- baseBranch.addChild(branch);
-
- fireEvent(new BranchCreatedEvent(branch));
- }
-
- public CDOBranch[] getElements()
- {
- return new CDOBranch[] { getMainBranch() };
- }
-
- public InternalCDOBranch getMainBranch()
- {
- checkActive();
- return mainBranch;
- }
-
- public InternalCDOBranch getBranch(int branchID)
- {
- checkActive();
- if (branchID == CDOBranch.MAIN_BRANCH_ID)
- {
- return mainBranch;
- }
-
- InternalCDOBranch branch;
- synchronized (branches)
- {
- branch = branches.get(branchID);
- if (branch == null)
- {
- branch = new CDOBranchImpl(this, branchID, null, null);
- putBranch(branch);
- }
- }
-
- return branch;
- }
-
- public InternalCDOBranch getBranch(int id, String name, InternalCDOBranch baseBranch, long baseTimeStamp)
- {
- synchronized (branches)
- {
- InternalCDOBranch branch = branches.get(id);
- if (branch == null)
- {
- branch = new CDOBranchImpl(this, id, name, baseBranch.getPoint(baseTimeStamp));
- putBranch(branch);
- }
- else if (branch.isProxy())
- {
- branch.setBranchInfo(name, baseBranch, baseTimeStamp);
- }
-
- return branch;
- }
- }
-
- public InternalCDOBranch getBranch(int id, BranchInfo branchInfo)
- {
- String name = branchInfo.getName();
- InternalCDOBranch baseBranch = getBranch(branchInfo.getBaseBranchID());
- long baseTimeStamp = branchInfo.getBaseTimeStamp();
- return getBranch(id, name, baseBranch, baseTimeStamp);
- }
-
- public InternalCDOBranch getBranch(String path)
- {
- if (path.startsWith(CDOBranch.PATH_SEPARATOR))
- {
- path = path.substring(1);
- }
-
- int sep = path.indexOf(CDOBranch.PATH_SEPARATOR);
- if (sep == -1)
- {
- if (CDOBranch.MAIN_BRANCH_NAME.equals(path))
- {
- return mainBranch;
- }
-
- return null;
- }
-
- String name = path.substring(0, sep);
- if (CDOBranch.MAIN_BRANCH_NAME.equals(name))
- {
- String rest = path.substring(sep + 1);
- return mainBranch.getBranch(rest);
- }
-
- return null;
- }
-
- public int getBranches(int startID, int endID, CDOBranchHandler handler)
- {
- checkActive();
- return branchLoader.loadBranches(startID, endID, handler);
- }
-
- public InternalCDOBranch createBranch(int branchID, String name, InternalCDOBranch baseBranch, long baseTimeStamp)
- {
- checkActive();
-
- Pair<Integer, Long> result = branchLoader.createBranch(branchID, new BranchInfo(name, baseBranch.getID(),
- baseTimeStamp));
- branchID = result.getElement1();
- baseTimeStamp = result.getElement2();
-
- CDOBranchPoint base = baseBranch.getPoint(baseTimeStamp);
- InternalCDOBranch branch = new CDOBranchImpl(this, branchID, name, base);
- synchronized (branches)
- {
- putBranch(branch);
- }
-
- handleBranchCreated(branch);
- return branch;
- }
-
- /**
- * {@link #branches} must be synchronized by caller!
- */
- private boolean putBranch(InternalCDOBranch branch)
- {
- int id = branch.getID();
- if (branches.containsKey(id))
- {
- return false;
- }
-
- branches.put(id, branch);
- return true;
- }
-
- protected Soft<Integer, InternalCDOBranch> createMap()
- {
- return new ReferenceValueMap.Soft<Integer, InternalCDOBranch>();
- }
-
- @Override
- protected void doBeforeActivate() throws Exception
- {
- super.doBeforeActivate();
- checkState(branchLoader, "branchLoader"); //$NON-NLS-1$
- checkState(timeProvider, "timeProvider"); //$NON-NLS-1$
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class BranchCreatedEvent extends Event implements CDOBranchCreatedEvent
- {
- private static final long serialVersionUID = 1L;
-
- private CDOBranch branch;
-
- public BranchCreatedEvent(CDOBranch branch)
- {
- super(branch.getBranchManager());
- this.branch = branch;
- }
-
- @Override
- public CDOBranchManager getSource()
- {
- return (CDOBranchManager)super.getSource();
- }
-
- public CDOBranch getBranch()
- {
- return branch;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.branch;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchCreatedEvent;
+import org.eclipse.emf.cdo.common.branch.CDOBranchHandler;
+import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.util.CDOTimeProvider;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo;
+
+import org.eclipse.net4j.util.collection.Pair;
+import org.eclipse.net4j.util.container.Container;
+import org.eclipse.net4j.util.event.Event;
+import org.eclipse.net4j.util.ref.ReferenceValueMap;
+import org.eclipse.net4j.util.ref.ReferenceValueMap.Soft;
+
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOBranchManagerImpl extends Container<CDOBranch> implements InternalCDOBranchManager
+{
+ private BranchLoader branchLoader;
+
+ private CDOTimeProvider timeProvider;
+
+ private InternalCDOBranch mainBranch;
+
+ private Map<Integer, InternalCDOBranch> branches = createMap();
+
+ public CDOBranchManagerImpl()
+ {
+ }
+
+ public BranchLoader getBranchLoader()
+ {
+ return branchLoader;
+ }
+
+ public void setBranchLoader(BranchLoader branchLoader)
+ {
+ checkInactive();
+ this.branchLoader = branchLoader;
+ }
+
+ public CDOTimeProvider getTimeProvider()
+ {
+ return timeProvider;
+ }
+
+ public void setTimeProvider(CDOTimeProvider timeProvider)
+ {
+ this.timeProvider = timeProvider;
+ }
+
+ public void initMainBranch(boolean local, long timeStamp)
+ {
+ mainBranch = new CDOBranchImpl.Main(this, local, timeStamp);
+ }
+
+ public void handleBranchCreated(InternalCDOBranch branch)
+ {
+ CDOBranchPoint base = branch.getBase();
+ InternalCDOBranch baseBranch = (InternalCDOBranch)base.getBranch();
+ baseBranch.addChild(branch);
+
+ fireEvent(new BranchCreatedEvent(branch));
+ }
+
+ public CDOBranch[] getElements()
+ {
+ return new CDOBranch[] { getMainBranch() };
+ }
+
+ public InternalCDOBranch getMainBranch()
+ {
+ checkActive();
+ return mainBranch;
+ }
+
+ public InternalCDOBranch getBranch(int branchID)
+ {
+ checkActive();
+ if (branchID == CDOBranch.MAIN_BRANCH_ID)
+ {
+ return mainBranch;
+ }
+
+ InternalCDOBranch branch;
+ synchronized (branches)
+ {
+ branch = branches.get(branchID);
+ if (branch == null)
+ {
+ branch = new CDOBranchImpl(this, branchID, null, null);
+ putBranch(branch);
+ }
+ }
+
+ return branch;
+ }
+
+ public InternalCDOBranch getBranch(int id, String name, InternalCDOBranch baseBranch, long baseTimeStamp)
+ {
+ synchronized (branches)
+ {
+ InternalCDOBranch branch = branches.get(id);
+ if (branch == null)
+ {
+ branch = new CDOBranchImpl(this, id, name, baseBranch.getPoint(baseTimeStamp));
+ putBranch(branch);
+ }
+ else if (branch.isProxy())
+ {
+ branch.setBranchInfo(name, baseBranch, baseTimeStamp);
+ }
+
+ return branch;
+ }
+ }
+
+ public InternalCDOBranch getBranch(int id, BranchInfo branchInfo)
+ {
+ String name = branchInfo.getName();
+ InternalCDOBranch baseBranch = getBranch(branchInfo.getBaseBranchID());
+ long baseTimeStamp = branchInfo.getBaseTimeStamp();
+ return getBranch(id, name, baseBranch, baseTimeStamp);
+ }
+
+ public InternalCDOBranch getBranch(String path)
+ {
+ if (path.startsWith(CDOBranch.PATH_SEPARATOR))
+ {
+ path = path.substring(1);
+ }
+
+ int sep = path.indexOf(CDOBranch.PATH_SEPARATOR);
+ if (sep == -1)
+ {
+ if (CDOBranch.MAIN_BRANCH_NAME.equals(path))
+ {
+ return mainBranch;
+ }
+
+ return null;
+ }
+
+ String name = path.substring(0, sep);
+ if (CDOBranch.MAIN_BRANCH_NAME.equals(name))
+ {
+ String rest = path.substring(sep + 1);
+ return mainBranch.getBranch(rest);
+ }
+
+ return null;
+ }
+
+ public int getBranches(int startID, int endID, CDOBranchHandler handler)
+ {
+ checkActive();
+ return branchLoader.loadBranches(startID, endID, handler);
+ }
+
+ public InternalCDOBranch createBranch(int branchID, String name, InternalCDOBranch baseBranch, long baseTimeStamp)
+ {
+ checkActive();
+
+ Pair<Integer, Long> result = branchLoader.createBranch(branchID, new BranchInfo(name, baseBranch.getID(),
+ baseTimeStamp));
+ branchID = result.getElement1();
+ baseTimeStamp = result.getElement2();
+
+ CDOBranchPoint base = baseBranch.getPoint(baseTimeStamp);
+ InternalCDOBranch branch = new CDOBranchImpl(this, branchID, name, base);
+ synchronized (branches)
+ {
+ putBranch(branch);
+ }
+
+ handleBranchCreated(branch);
+ return branch;
+ }
+
+ /**
+ * {@link #branches} must be synchronized by caller!
+ */
+ private boolean putBranch(InternalCDOBranch branch)
+ {
+ int id = branch.getID();
+ if (branches.containsKey(id))
+ {
+ return false;
+ }
+
+ branches.put(id, branch);
+ return true;
+ }
+
+ protected Soft<Integer, InternalCDOBranch> createMap()
+ {
+ return new ReferenceValueMap.Soft<Integer, InternalCDOBranch>();
+ }
+
+ @Override
+ protected void doBeforeActivate() throws Exception
+ {
+ super.doBeforeActivate();
+ checkState(branchLoader, "branchLoader"); //$NON-NLS-1$
+ checkState(timeProvider, "timeProvider"); //$NON-NLS-1$
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class BranchCreatedEvent extends Event implements CDOBranchCreatedEvent
+ {
+ private static final long serialVersionUID = 1L;
+
+ private CDOBranch branch;
+
+ public BranchCreatedEvent(CDOBranch branch)
+ {
+ super(branch.getBranchManager());
+ this.branch = branch;
+ }
+
+ @Override
+ public CDOBranchManager getSource()
+ {
+ return (CDOBranchManager)super.getSource();
+ }
+
+ public CDOBranch getBranch()
+ {
+ return branch;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchPointImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchPointImpl.java
index e80fc10d22..48341226a1 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchPointImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchPointImpl.java
@@ -1,85 +1,85 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.branch;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
-
-import org.eclipse.net4j.util.ObjectUtil;
-
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public class CDOBranchPointImpl implements CDOBranchPoint, Comparable<CDOBranchPoint>
-{
- private CDOBranch branch;
-
- private long timeStamp;
-
- public CDOBranchPointImpl(CDOBranch branch, long timeStamp)
- {
- this.branch = branch;
- this.timeStamp = timeStamp;
- }
-
- public CDOBranch getBranch()
- {
- return branch;
- }
-
- public long getTimeStamp()
- {
- return timeStamp;
- }
-
- public int compareTo(CDOBranchPoint o)
- {
- int result = branch.compareTo(o.getBranch());
- if (result == 0)
- {
- result = CDOCommonUtil.compareTimeStamps(timeStamp, o.getTimeStamp());
- }
-
- return result;
- }
-
- @Override
- public int hashCode()
- {
- return branch.hashCode() ^ new Long(timeStamp).hashCode();
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj instanceof CDOBranchPoint)
- {
- CDOBranchPoint that = (CDOBranchPoint)obj;
- return ObjectUtil.equals(branch, that.getBranch()) && timeStamp == that.getTimeStamp();
- }
-
- return false;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("BranchPoint[{0}, {1}]", branch, CDOCommonUtil.formatTimeStamp(timeStamp)); //$NON-NLS-1$
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.branch;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
+
+import org.eclipse.net4j.util.ObjectUtil;
+
+import java.text.MessageFormat;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOBranchPointImpl implements CDOBranchPoint, Comparable<CDOBranchPoint>
+{
+ private CDOBranch branch;
+
+ private long timeStamp;
+
+ public CDOBranchPointImpl(CDOBranch branch, long timeStamp)
+ {
+ this.branch = branch;
+ this.timeStamp = timeStamp;
+ }
+
+ public CDOBranch getBranch()
+ {
+ return branch;
+ }
+
+ public long getTimeStamp()
+ {
+ return timeStamp;
+ }
+
+ public int compareTo(CDOBranchPoint o)
+ {
+ int result = branch.compareTo(o.getBranch());
+ if (result == 0)
+ {
+ result = CDOCommonUtil.compareTimeStamps(timeStamp, o.getTimeStamp());
+ }
+
+ return result;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return branch.hashCode() ^ new Long(timeStamp).hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+
+ if (obj instanceof CDOBranchPoint)
+ {
+ CDOBranchPoint that = (CDOBranchPoint)obj;
+ return ObjectUtil.equals(branch, that.getBranch()) && timeStamp == that.getTimeStamp();
+ }
+
+ return false;
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("BranchPoint[{0}, {1}]", branch, CDOCommonUtil.formatTimeStamp(timeStamp)); //$NON-NLS-1$
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchPointRangeImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchPointRangeImpl.java
index 709d77c4b9..c980e44c84 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchPointRangeImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchPointRangeImpl.java
@@ -1,48 +1,48 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.branch;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPointRange;
-
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public class CDOBranchPointRangeImpl implements CDOBranchPointRange
-{
- private CDOBranchPoint startPoint;
-
- private CDOBranchPoint endPoint;
-
- public CDOBranchPointRangeImpl(CDOBranchPoint startPoint, CDOBranchPoint endPoint)
- {
- this.startPoint = startPoint;
- this.endPoint = endPoint;
- }
-
- public CDOBranchPoint getStartPoint()
- {
- return startPoint;
- }
-
- public CDOBranchPoint getEndPoint()
- {
- return endPoint;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("Range[{0}, {1}]", startPoint, endPoint); //$NON-NLS-1$
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.branch;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPointRange;
+
+import java.text.MessageFormat;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOBranchPointRangeImpl implements CDOBranchPointRange
+{
+ private CDOBranchPoint startPoint;
+
+ private CDOBranchPoint endPoint;
+
+ public CDOBranchPointRangeImpl(CDOBranchPoint startPoint, CDOBranchPoint endPoint)
+ {
+ this.startPoint = startPoint;
+ this.endPoint = endPoint;
+ }
+
+ public CDOBranchPoint getStartPoint()
+ {
+ return startPoint;
+ }
+
+ public CDOBranchPoint getEndPoint()
+ {
+ return endPoint;
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("Range[{0}, {1}]", startPoint, endPoint); //$NON-NLS-1$
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchVersionImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchVersionImpl.java
index 369de1d147..dc04d2ad0e 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchVersionImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchVersionImpl.java
@@ -1,73 +1,73 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.branch;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
-
-import org.eclipse.net4j.util.ObjectUtil;
-
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public class CDOBranchVersionImpl implements CDOBranchVersion
-{
- private CDOBranch branch;
-
- private int version;
-
- public CDOBranchVersionImpl(CDOBranch branch, int version)
- {
- this.branch = branch;
- this.version = version;
- }
-
- public CDOBranch getBranch()
- {
- return branch;
- }
-
- public int getVersion()
- {
- return version;
- }
-
- @Override
- public int hashCode()
- {
- return branch.hashCode() ^ version;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj instanceof CDOBranchVersion)
- {
- CDOBranchVersion that = (CDOBranchVersion)obj;
- return ObjectUtil.equals(branch, that.getBranch()) && version == that.getVersion();
- }
-
- return false;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("BranchVersion[{0}, v{1}]", branch, version); //$NON-NLS-1$
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.branch;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+
+import org.eclipse.net4j.util.ObjectUtil;
+
+import java.text.MessageFormat;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOBranchVersionImpl implements CDOBranchVersion
+{
+ private CDOBranch branch;
+
+ private int version;
+
+ public CDOBranchVersionImpl(CDOBranch branch, int version)
+ {
+ this.branch = branch;
+ this.version = version;
+ }
+
+ public CDOBranch getBranch()
+ {
+ return branch;
+ }
+
+ public int getVersion()
+ {
+ return version;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return branch.hashCode() ^ version;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+
+ if (obj instanceof CDOBranchVersion)
+ {
+ CDOBranchVersion that = (CDOBranchVersion)obj;
+ return ObjectUtil.equals(branch, that.getBranch()) && version == that.getVersion();
+ }
+
+ return false;
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("BranchVersion[{0}, v{1}]", branch, version); //$NON-NLS-1$
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/bundle/OM.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/bundle/OM.java
index e14625a66a..90481c4df5 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/bundle/OM.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/bundle/OM.java
@@ -1,58 +1,58 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.bundle;
-
-import org.eclipse.net4j.util.om.OMBundle;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.OSGiActivator;
-import org.eclipse.net4j.util.om.log.OMLogger;
-import org.eclipse.net4j.util.om.trace.OMTracer;
-
-/**
- * The <em>Operations & Maintenance</em> class of this bundle.
- *
- * @author Eike Stepper
- */
-public abstract class OM
-{
- public static final String BUNDLE_ID = "org.eclipse.emf.cdo.common"; //$NON-NLS-1$
-
- public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
-
- public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
-
- public static final OMTracer DEBUG_PROTOCOL = DEBUG.tracer("protocol"); //$NON-NLS-1$
-
- public static final OMTracer DEBUG_ID = DEBUG.tracer("id"); //$NON-NLS-1$
-
- public static final OMTracer DEBUG_REVISION = DEBUG.tracer("revision"); //$NON-NLS-1$
-
- public static final OMTracer PERF = BUNDLE.tracer("perf"); //$NON-NLS-1$
-
- public static final OMTracer PERF_REVISION = PERF.tracer("revision"); //$NON-NLS-1$
-
- public static final OMTracer PERF_REVISION_READING = PERF_REVISION.tracer("reading"); //$NON-NLS-1$
-
- public static final OMTracer PERF_REVISION_WRITING = PERF_REVISION.tracer("writing"); //$NON-NLS-1$
-
- public static final OMLogger LOG = BUNDLE.logger();
-
- /**
- * @author Eike Stepper
- */
- public static final class Activator extends OSGiActivator
- {
- public Activator()
- {
- super(BUNDLE);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.bundle;
+
+import org.eclipse.net4j.util.om.OMBundle;
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.OSGiActivator;
+import org.eclipse.net4j.util.om.log.OMLogger;
+import org.eclipse.net4j.util.om.trace.OMTracer;
+
+/**
+ * The <em>Operations & Maintenance</em> class of this bundle.
+ *
+ * @author Eike Stepper
+ */
+public abstract class OM
+{
+ public static final String BUNDLE_ID = "org.eclipse.emf.cdo.common"; //$NON-NLS-1$
+
+ public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
+
+ public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
+
+ public static final OMTracer DEBUG_PROTOCOL = DEBUG.tracer("protocol"); //$NON-NLS-1$
+
+ public static final OMTracer DEBUG_ID = DEBUG.tracer("id"); //$NON-NLS-1$
+
+ public static final OMTracer DEBUG_REVISION = DEBUG.tracer("revision"); //$NON-NLS-1$
+
+ public static final OMTracer PERF = BUNDLE.tracer("perf"); //$NON-NLS-1$
+
+ public static final OMTracer PERF_REVISION = PERF.tracer("revision"); //$NON-NLS-1$
+
+ public static final OMTracer PERF_REVISION_READING = PERF_REVISION.tracer("reading"); //$NON-NLS-1$
+
+ public static final OMTracer PERF_REVISION_WRITING = PERF_REVISION.tracer("writing"); //$NON-NLS-1$
+
+ public static final OMLogger LOG = BUNDLE.logger();
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class Activator extends OSGiActivator
+ {
+ public Activator()
+ {
+ super(BUNDLE);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetDataImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetDataImpl.java
index 5bf0c33f6a..b327991a41 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetDataImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetDataImpl.java
@@ -1,225 +1,225 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.commit;
-
-import org.eclipse.emf.cdo.common.commit.CDOChangeKind;
-import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-import org.eclipse.emf.cdo.spi.common.commit.CDOChangeKindCache;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class CDOChangeSetDataImpl implements CDOChangeSetData
-{
- private List<CDOIDAndVersion> newObjects;
-
- private List<CDORevisionKey> changedObjects;
-
- private List<CDOIDAndVersion> detachedObjects;
-
- private CDOChangeKindCache changeKindCache;
-
- public CDOChangeSetDataImpl(List<CDOIDAndVersion> newObjects, List<CDORevisionKey> changedObjects,
- List<CDOIDAndVersion> detachedObjects)
- {
- this.newObjects = newObjects;
- this.changedObjects = changedObjects;
- this.detachedObjects = detachedObjects;
- }
-
- public CDOChangeSetDataImpl()
- {
- this(new ArrayList<CDOIDAndVersion>(), new ArrayList<CDORevisionKey>(), new ArrayList<CDOIDAndVersion>());
- }
-
- public boolean isEmpty()
- {
- if (newObjects != null && !newObjects.isEmpty())
- {
- return false;
- }
-
- if (changedObjects != null && !changedObjects.isEmpty())
- {
- return false;
- }
-
- if (detachedObjects != null && !detachedObjects.isEmpty())
- {
- return false;
- }
-
- return true;
- }
-
- public CDOChangeSetData copy()
- {
- List<CDOIDAndVersion> newObjectsCopy = new ArrayList<CDOIDAndVersion>(newObjects.size());
- for (CDOIDAndVersion key : newObjects)
- {
- if (key instanceof CDORevision)
- {
- CDORevision revision = (CDORevision)key;
- newObjectsCopy.add(revision.copy());
- }
- else
- {
- newObjectsCopy.add(key);
- }
- }
-
- List<CDORevisionKey> changedObjectsCopy = new ArrayList<CDORevisionKey>(changedObjects.size());
- for (CDORevisionKey key : changedObjects)
- {
- if (key instanceof CDORevisionDelta)
- {
- CDORevisionDelta delta = (CDORevisionDelta)key;
- changedObjectsCopy.add(delta.copy());
- }
- else
- {
- changedObjectsCopy.add(key);
- }
- }
-
- List<CDOIDAndVersion> detachedObjectsCopy = new ArrayList<CDOIDAndVersion>(detachedObjects.size());
- for (CDOIDAndVersion key : detachedObjects)
- {
- detachedObjectsCopy.add(key);
- }
-
- return new CDOChangeSetDataImpl(newObjectsCopy, changedObjectsCopy, detachedObjectsCopy);
- }
-
- public void merge(CDOChangeSetData changeSetData)
- {
- Map<CDOID, CDOIDAndVersion> newMap = new HashMap<CDOID, CDOIDAndVersion>();
- fillMap(newMap, newObjects);
- fillMap(newMap, changeSetData.getNewObjects());
-
- Map<CDOID, CDORevisionKey> changedMap = new HashMap<CDOID, CDORevisionKey>();
- fillMap(changedMap, changedObjects);
- for (CDORevisionKey key : changeSetData.getChangedObjects())
- {
- mergeChangedObject(key, newMap, changedMap);
- }
-
- Map<CDOID, CDOIDAndVersion> detachedMap = new HashMap<CDOID, CDOIDAndVersion>();
- fillMap(detachedMap, detachedObjects);
- for (CDOIDAndVersion key : changeSetData.getDetachedObjects())
- {
- CDOID id = key.getID();
- if (newMap.remove(id) == null)
- {
- detachedMap.put(id, key);
- }
- }
-
- newObjects = new ArrayList<CDOIDAndVersion>(newMap.values());
- changedObjects = new ArrayList<CDORevisionKey>(changedMap.values());
- detachedObjects = new ArrayList<CDOIDAndVersion>(detachedMap.values());
- }
-
- private void mergeChangedObject(CDORevisionKey key, Map<CDOID, CDOIDAndVersion> newMap,
- Map<CDOID, CDORevisionKey> changedMap)
- {
- CDOID id = key.getID();
- if (key instanceof CDORevisionDelta)
- {
- CDORevisionDelta delta = (CDORevisionDelta)key;
-
- // Try to add the delta to existing new revision
- CDOIDAndVersion oldRevision = newMap.get(id);
- if (oldRevision instanceof CDORevision)
- {
- CDORevision newRevision = (CDORevision)oldRevision;
- delta.apply(newRevision);
- return;
- }
-
- // Try to add the delta to existing delta
- CDORevisionKey oldDelta = changedMap.get(id);
- if (oldDelta instanceof CDORevisionDelta)
- {
- InternalCDORevisionDelta newDelta = (InternalCDORevisionDelta)oldDelta;
- for (CDOFeatureDelta featureDelta : delta.getFeatureDeltas())
- {
- newDelta.addFeatureDelta(featureDelta);
- }
-
- return;
- }
- }
-
- // Fall back
- changedMap.put(id, key);
- }
-
- public List<CDOIDAndVersion> getNewObjects()
- {
- return newObjects;
- }
-
- public List<CDORevisionKey> getChangedObjects()
- {
- return changedObjects;
- }
-
- public List<CDOIDAndVersion> getDetachedObjects()
- {
- return detachedObjects;
- }
-
- public synchronized Map<CDOID, CDOChangeKind> getChangeKinds()
- {
- if (changeKindCache == null)
- {
- changeKindCache = new CDOChangeKindCache(this);
- }
-
- return changeKindCache;
- }
-
- public CDOChangeKind getChangeKind(CDOID id)
- {
- return getChangeKinds().get(id);
- }
-
- @Override
- public String toString()
- {
- return MessageFormat
- .format(
- "ChangeSetData[newObjects={0}, changedObjects={1}, detachedObjects={2}]", newObjects.size(), changedObjects.size(), detachedObjects.size()); //$NON-NLS-1$
- }
-
- private static <T extends CDOIDAndVersion> void fillMap(Map<CDOID, T> map, Collection<T> c)
- {
- for (T key : c)
- {
- map.put(key.getID(), key);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.commit;
+
+import org.eclipse.emf.cdo.common.commit.CDOChangeKind;
+import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.spi.common.commit.CDOChangeKindCache;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOChangeSetDataImpl implements CDOChangeSetData
+{
+ private List<CDOIDAndVersion> newObjects;
+
+ private List<CDORevisionKey> changedObjects;
+
+ private List<CDOIDAndVersion> detachedObjects;
+
+ private CDOChangeKindCache changeKindCache;
+
+ public CDOChangeSetDataImpl(List<CDOIDAndVersion> newObjects, List<CDORevisionKey> changedObjects,
+ List<CDOIDAndVersion> detachedObjects)
+ {
+ this.newObjects = newObjects;
+ this.changedObjects = changedObjects;
+ this.detachedObjects = detachedObjects;
+ }
+
+ public CDOChangeSetDataImpl()
+ {
+ this(new ArrayList<CDOIDAndVersion>(), new ArrayList<CDORevisionKey>(), new ArrayList<CDOIDAndVersion>());
+ }
+
+ public boolean isEmpty()
+ {
+ if (newObjects != null && !newObjects.isEmpty())
+ {
+ return false;
+ }
+
+ if (changedObjects != null && !changedObjects.isEmpty())
+ {
+ return false;
+ }
+
+ if (detachedObjects != null && !detachedObjects.isEmpty())
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public CDOChangeSetData copy()
+ {
+ List<CDOIDAndVersion> newObjectsCopy = new ArrayList<CDOIDAndVersion>(newObjects.size());
+ for (CDOIDAndVersion key : newObjects)
+ {
+ if (key instanceof CDORevision)
+ {
+ CDORevision revision = (CDORevision)key;
+ newObjectsCopy.add(revision.copy());
+ }
+ else
+ {
+ newObjectsCopy.add(key);
+ }
+ }
+
+ List<CDORevisionKey> changedObjectsCopy = new ArrayList<CDORevisionKey>(changedObjects.size());
+ for (CDORevisionKey key : changedObjects)
+ {
+ if (key instanceof CDORevisionDelta)
+ {
+ CDORevisionDelta delta = (CDORevisionDelta)key;
+ changedObjectsCopy.add(delta.copy());
+ }
+ else
+ {
+ changedObjectsCopy.add(key);
+ }
+ }
+
+ List<CDOIDAndVersion> detachedObjectsCopy = new ArrayList<CDOIDAndVersion>(detachedObjects.size());
+ for (CDOIDAndVersion key : detachedObjects)
+ {
+ detachedObjectsCopy.add(key);
+ }
+
+ return new CDOChangeSetDataImpl(newObjectsCopy, changedObjectsCopy, detachedObjectsCopy);
+ }
+
+ public void merge(CDOChangeSetData changeSetData)
+ {
+ Map<CDOID, CDOIDAndVersion> newMap = new HashMap<CDOID, CDOIDAndVersion>();
+ fillMap(newMap, newObjects);
+ fillMap(newMap, changeSetData.getNewObjects());
+
+ Map<CDOID, CDORevisionKey> changedMap = new HashMap<CDOID, CDORevisionKey>();
+ fillMap(changedMap, changedObjects);
+ for (CDORevisionKey key : changeSetData.getChangedObjects())
+ {
+ mergeChangedObject(key, newMap, changedMap);
+ }
+
+ Map<CDOID, CDOIDAndVersion> detachedMap = new HashMap<CDOID, CDOIDAndVersion>();
+ fillMap(detachedMap, detachedObjects);
+ for (CDOIDAndVersion key : changeSetData.getDetachedObjects())
+ {
+ CDOID id = key.getID();
+ if (newMap.remove(id) == null)
+ {
+ detachedMap.put(id, key);
+ }
+ }
+
+ newObjects = new ArrayList<CDOIDAndVersion>(newMap.values());
+ changedObjects = new ArrayList<CDORevisionKey>(changedMap.values());
+ detachedObjects = new ArrayList<CDOIDAndVersion>(detachedMap.values());
+ }
+
+ private void mergeChangedObject(CDORevisionKey key, Map<CDOID, CDOIDAndVersion> newMap,
+ Map<CDOID, CDORevisionKey> changedMap)
+ {
+ CDOID id = key.getID();
+ if (key instanceof CDORevisionDelta)
+ {
+ CDORevisionDelta delta = (CDORevisionDelta)key;
+
+ // Try to add the delta to existing new revision
+ CDOIDAndVersion oldRevision = newMap.get(id);
+ if (oldRevision instanceof CDORevision)
+ {
+ CDORevision newRevision = (CDORevision)oldRevision;
+ delta.apply(newRevision);
+ return;
+ }
+
+ // Try to add the delta to existing delta
+ CDORevisionKey oldDelta = changedMap.get(id);
+ if (oldDelta instanceof CDORevisionDelta)
+ {
+ InternalCDORevisionDelta newDelta = (InternalCDORevisionDelta)oldDelta;
+ for (CDOFeatureDelta featureDelta : delta.getFeatureDeltas())
+ {
+ newDelta.addFeatureDelta(featureDelta);
+ }
+
+ return;
+ }
+ }
+
+ // Fall back
+ changedMap.put(id, key);
+ }
+
+ public List<CDOIDAndVersion> getNewObjects()
+ {
+ return newObjects;
+ }
+
+ public List<CDORevisionKey> getChangedObjects()
+ {
+ return changedObjects;
+ }
+
+ public List<CDOIDAndVersion> getDetachedObjects()
+ {
+ return detachedObjects;
+ }
+
+ public synchronized Map<CDOID, CDOChangeKind> getChangeKinds()
+ {
+ if (changeKindCache == null)
+ {
+ changeKindCache = new CDOChangeKindCache(this);
+ }
+
+ return changeKindCache;
+ }
+
+ public CDOChangeKind getChangeKind(CDOID id)
+ {
+ return getChangeKinds().get(id);
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat
+ .format(
+ "ChangeSetData[newObjects={0}, changedObjects={1}, detachedObjects={2}]", newObjects.size(), changedObjects.size(), detachedObjects.size()); //$NON-NLS-1$
+ }
+
+ private static <T extends CDOIDAndVersion> void fillMap(Map<CDOID, T> map, Collection<T> c)
+ {
+ for (T key : c)
+ {
+ map.put(key.getID(), key);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetImpl.java
index ab04acaf47..f637f6ee24 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetImpl.java
@@ -1,48 +1,48 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.commit;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.commit.CDOChangeSet;
-import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
-
-/**
- * @author Eike Stepper
- */
-public class CDOChangeSetImpl extends CDOChangeSetDataImpl implements CDOChangeSet
-{
- private CDOBranchPoint startPoint;
-
- private CDOBranchPoint endPoint;
-
- public CDOChangeSetImpl(CDOBranchPoint startPoint, CDOBranchPoint endPoint, CDOChangeSetData data)
- {
- super(data.getNewObjects(), data.getChangedObjects(), data.getDetachedObjects());
- this.startPoint = startPoint;
- this.endPoint = endPoint;
- }
-
- public CDOBranchPoint getStartPoint()
- {
- return startPoint;
- }
-
- public CDOBranchPoint getEndPoint()
- {
- return endPoint;
- }
-
- public CDOBranchPoint getAncestorPoint()
- {
- return CDOBranchUtil.getAncestor(startPoint, endPoint);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.commit;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.commit.CDOChangeSet;
+import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
+import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOChangeSetImpl extends CDOChangeSetDataImpl implements CDOChangeSet
+{
+ private CDOBranchPoint startPoint;
+
+ private CDOBranchPoint endPoint;
+
+ public CDOChangeSetImpl(CDOBranchPoint startPoint, CDOBranchPoint endPoint, CDOChangeSetData data)
+ {
+ super(data.getNewObjects(), data.getChangedObjects(), data.getDetachedObjects());
+ this.startPoint = startPoint;
+ this.endPoint = endPoint;
+ }
+
+ public CDOBranchPoint getStartPoint()
+ {
+ return startPoint;
+ }
+
+ public CDOBranchPoint getEndPoint()
+ {
+ return endPoint;
+ }
+
+ public CDOBranchPoint getAncestorPoint()
+ {
+ return CDOBranchUtil.getAncestor(startPoint, endPoint);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitDataImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitDataImpl.java
index 9d47b8a77a..3ae3d24957 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitDataImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitDataImpl.java
@@ -1,47 +1,47 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.commit;
-
-import org.eclipse.emf.cdo.common.commit.CDOCommitData;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-
-import java.text.MessageFormat;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class CDOCommitDataImpl extends CDOChangeSetDataImpl implements CDOCommitData
-{
- private List<CDOPackageUnit> newPackageUnits;
-
- public CDOCommitDataImpl(List<CDOPackageUnit> newPackageUnits, List<CDOIDAndVersion> newObjects,
- List<CDORevisionKey> changedObjects, List<CDOIDAndVersion> detachedObjects)
- {
- super(newObjects, changedObjects, detachedObjects);
- this.newPackageUnits = newPackageUnits;
- }
-
- public List<CDOPackageUnit> getNewPackageUnits()
- {
- return newPackageUnits;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format(
- "CommitData[newPackageUnits={0}, newObjects={1}, changedObjects={2}, detachedObjects={3}]", //$NON-NLS-1$
- newPackageUnits.size(), getNewObjects().size(), getChangedObjects().size(), getDetachedObjects().size());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.commit;
+
+import org.eclipse.emf.cdo.common.commit.CDOCommitData;
+import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
+import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
+
+import java.text.MessageFormat;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOCommitDataImpl extends CDOChangeSetDataImpl implements CDOCommitData
+{
+ private List<CDOPackageUnit> newPackageUnits;
+
+ public CDOCommitDataImpl(List<CDOPackageUnit> newPackageUnits, List<CDOIDAndVersion> newObjects,
+ List<CDORevisionKey> changedObjects, List<CDOIDAndVersion> detachedObjects)
+ {
+ super(newObjects, changedObjects, detachedObjects);
+ this.newPackageUnits = newPackageUnits;
+ }
+
+ public List<CDOPackageUnit> getNewPackageUnits()
+ {
+ return newPackageUnits;
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format(
+ "CommitData[newPackageUnits={0}, newObjects={1}, changedObjects={2}, detachedObjects={3}]", //$NON-NLS-1$
+ newPackageUnits.size(), getNewObjects().size(), getChangedObjects().size(), getDetachedObjects().size());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoImpl.java
index b4267abc82..b556e5072a 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoImpl.java
@@ -1,153 +1,153 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.commit;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.commit.CDOChangeKind;
-import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-import org.eclipse.emf.cdo.common.commit.CDOCommitData;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
-import org.eclipse.emf.cdo.internal.common.branch.CDOBranchPointImpl;
-import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
-
-import org.eclipse.net4j.util.CheckUtil;
-
-import java.text.MessageFormat;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class CDOCommitInfoImpl extends CDOBranchPointImpl implements CDOCommitInfo
-{
- private InternalCDOCommitInfoManager commitInfoManager;
-
- private long previousTimeStamp;
-
- private String userID;
-
- private String comment;
-
- private CDOCommitData commitData;
-
- public CDOCommitInfoImpl(InternalCDOCommitInfoManager commitInfoManager, CDOBranch branch, long timeStamp,
- long previousTimeStamp, String userID, String comment, CDOCommitData commitData)
- {
- super(branch, timeStamp);
- CheckUtil.checkArg(commitInfoManager, "commitInfoManager"); //$NON-NLS-1$
- this.commitInfoManager = commitInfoManager;
- this.previousTimeStamp = previousTimeStamp;
- this.userID = userID;
- this.comment = comment;
- this.commitData = commitData;
- }
-
- public InternalCDOCommitInfoManager getCommitInfoManager()
- {
- return commitInfoManager;
- }
-
- public long getPreviousTimeStamp()
- {
- return previousTimeStamp;
- }
-
- public String getUserID()
- {
- return userID;
- }
-
- public String getComment()
- {
- return comment;
- }
-
- public boolean isEmpty()
- {
- return false;
- }
-
- public CDOChangeSetData copy()
- {
- return commitData == null ? null : commitData.copy();
- }
-
- public void merge(CDOChangeSetData changeSetData)
- {
- loadCommitDataIfNeeded();
- commitData.merge(changeSetData);
- }
-
- public synchronized List<CDOPackageUnit> getNewPackageUnits()
- {
- loadCommitDataIfNeeded();
- return commitData.getNewPackageUnits();
- }
-
- public synchronized List<CDOIDAndVersion> getNewObjects()
- {
- loadCommitDataIfNeeded();
- return commitData.getNewObjects();
- }
-
- public synchronized List<CDORevisionKey> getChangedObjects()
- {
- loadCommitDataIfNeeded();
- return commitData.getChangedObjects();
- }
-
- public synchronized List<CDOIDAndVersion> getDetachedObjects()
- {
- loadCommitDataIfNeeded();
- return commitData.getDetachedObjects();
- }
-
- public Map<CDOID, CDOChangeKind> getChangeKinds()
- {
- loadCommitDataIfNeeded();
- return commitData.getChangeKinds();
- }
-
- public CDOChangeKind getChangeKind(CDOID id)
- {
- loadCommitDataIfNeeded();
- return commitData.getChangeKind(id);
- }
-
- @Override
- public String toString()
- {
- String data = null;
- if (commitData != null)
- {
- data = commitData.toString();
- }
-
- String timeStamp = CDOCommonUtil.formatTimeStamp(getTimeStamp());
- return MessageFormat
- .format(
- "CommitInfo[{0}, {1}, {2}, {3}, {4}, {5}]", getPreviousTimeStamp(), getBranch(), timeStamp, getUserID(), getComment(), data); //$NON-NLS-1$
- }
-
- private void loadCommitDataIfNeeded()
- {
- if (commitData == null)
- {
- commitData = commitInfoManager.getCommitInfoLoader().loadCommitData(getTimeStamp());
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.commit;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.commit.CDOChangeKind;
+import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
+import org.eclipse.emf.cdo.common.commit.CDOCommitData;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
+import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
+import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
+import org.eclipse.emf.cdo.internal.common.branch.CDOBranchPointImpl;
+import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
+
+import org.eclipse.net4j.util.CheckUtil;
+
+import java.text.MessageFormat;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOCommitInfoImpl extends CDOBranchPointImpl implements CDOCommitInfo
+{
+ private InternalCDOCommitInfoManager commitInfoManager;
+
+ private long previousTimeStamp;
+
+ private String userID;
+
+ private String comment;
+
+ private CDOCommitData commitData;
+
+ public CDOCommitInfoImpl(InternalCDOCommitInfoManager commitInfoManager, CDOBranch branch, long timeStamp,
+ long previousTimeStamp, String userID, String comment, CDOCommitData commitData)
+ {
+ super(branch, timeStamp);
+ CheckUtil.checkArg(commitInfoManager, "commitInfoManager"); //$NON-NLS-1$
+ this.commitInfoManager = commitInfoManager;
+ this.previousTimeStamp = previousTimeStamp;
+ this.userID = userID;
+ this.comment = comment;
+ this.commitData = commitData;
+ }
+
+ public InternalCDOCommitInfoManager getCommitInfoManager()
+ {
+ return commitInfoManager;
+ }
+
+ public long getPreviousTimeStamp()
+ {
+ return previousTimeStamp;
+ }
+
+ public String getUserID()
+ {
+ return userID;
+ }
+
+ public String getComment()
+ {
+ return comment;
+ }
+
+ public boolean isEmpty()
+ {
+ return false;
+ }
+
+ public CDOChangeSetData copy()
+ {
+ return commitData == null ? null : commitData.copy();
+ }
+
+ public void merge(CDOChangeSetData changeSetData)
+ {
+ loadCommitDataIfNeeded();
+ commitData.merge(changeSetData);
+ }
+
+ public synchronized List<CDOPackageUnit> getNewPackageUnits()
+ {
+ loadCommitDataIfNeeded();
+ return commitData.getNewPackageUnits();
+ }
+
+ public synchronized List<CDOIDAndVersion> getNewObjects()
+ {
+ loadCommitDataIfNeeded();
+ return commitData.getNewObjects();
+ }
+
+ public synchronized List<CDORevisionKey> getChangedObjects()
+ {
+ loadCommitDataIfNeeded();
+ return commitData.getChangedObjects();
+ }
+
+ public synchronized List<CDOIDAndVersion> getDetachedObjects()
+ {
+ loadCommitDataIfNeeded();
+ return commitData.getDetachedObjects();
+ }
+
+ public Map<CDOID, CDOChangeKind> getChangeKinds()
+ {
+ loadCommitDataIfNeeded();
+ return commitData.getChangeKinds();
+ }
+
+ public CDOChangeKind getChangeKind(CDOID id)
+ {
+ loadCommitDataIfNeeded();
+ return commitData.getChangeKind(id);
+ }
+
+ @Override
+ public String toString()
+ {
+ String data = null;
+ if (commitData != null)
+ {
+ data = commitData.toString();
+ }
+
+ String timeStamp = CDOCommonUtil.formatTimeStamp(getTimeStamp());
+ return MessageFormat
+ .format(
+ "CommitInfo[{0}, {1}, {2}, {3}, {4}, {5}]", getPreviousTimeStamp(), getBranch(), timeStamp, getUserID(), getComment(), data); //$NON-NLS-1$
+ }
+
+ private void loadCommitDataIfNeeded()
+ {
+ if (commitData == null)
+ {
+ commitData = commitInfoManager.getCommitInfoLoader().loadCommitData(getTimeStamp());
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoManagerImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoManagerImpl.java
index 78f1339385..271f294d24 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoManagerImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoManagerImpl.java
@@ -1,87 +1,87 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Andre Dietisheim - bug 256649
- */
-package org.eclipse.emf.cdo.internal.common.commit;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.commit.CDOCommitData;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
-import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
-
-import org.eclipse.net4j.util.lifecycle.Lifecycle;
-
-/**
- * @author Andre Dietisheim
- */
-public class CDOCommitInfoManagerImpl extends Lifecycle implements InternalCDOCommitInfoManager
-{
- private CommitInfoLoader commitInfoLoader;
-
- public CDOCommitInfoManagerImpl()
- {
- }
-
- public CommitInfoLoader getCommitInfoLoader()
- {
- return commitInfoLoader;
- }
-
- public void setCommitInfoLoader(CommitInfoLoader commitInfoLoader)
- {
- checkInactive();
- this.commitInfoLoader = commitInfoLoader;
- }
-
- public CDOCommitInfo createCommitInfo(CDOBranch branch, long timeStamp, long previousTimeStamp, String userID,
- String comment, CDOCommitData commitData)
- {
- checkActive();
- return new CDOCommitInfoImpl(this, branch, timeStamp, previousTimeStamp, userID, comment, commitData);
- }
-
- public CDOCommitInfo getCommitInfo(long timeStamp)
- {
- checkActive();
- final CDOCommitInfo[] result = { null };
- getCommitInfos(null, timeStamp, timeStamp, new CDOCommitInfoHandler()
- {
- public void handleCommitInfo(CDOCommitInfo commitInfo)
- {
- result[0] = commitInfo;
- }
- });
-
- return result[0];
- }
-
- public void getCommitInfos(CDOBranch branch, long startTime, long endTime, CDOCommitInfoHandler handler)
- {
- checkActive();
- commitInfoLoader.loadCommitInfos(branch, startTime, endTime, handler);
- }
-
- public void getCommitInfos(CDOBranch branch, long startTime, String userID, String comment, int count,
- CDOCommitInfoHandler handler)
- {
- checkActive();
-
- // TODO: implement CDOCommitInfoManagerImpl.getCommitInfos(branch, startTime, userID, comment, count, handler)
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected void doBeforeActivate() throws Exception
- {
- super.doBeforeActivate();
- checkState(commitInfoLoader, "commitInfoLoader"); //$NON-NLS-1$
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Andre Dietisheim - bug 256649
+ */
+package org.eclipse.emf.cdo.internal.common.commit;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.commit.CDOCommitData;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
+import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
+
+import org.eclipse.net4j.util.lifecycle.Lifecycle;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class CDOCommitInfoManagerImpl extends Lifecycle implements InternalCDOCommitInfoManager
+{
+ private CommitInfoLoader commitInfoLoader;
+
+ public CDOCommitInfoManagerImpl()
+ {
+ }
+
+ public CommitInfoLoader getCommitInfoLoader()
+ {
+ return commitInfoLoader;
+ }
+
+ public void setCommitInfoLoader(CommitInfoLoader commitInfoLoader)
+ {
+ checkInactive();
+ this.commitInfoLoader = commitInfoLoader;
+ }
+
+ public CDOCommitInfo createCommitInfo(CDOBranch branch, long timeStamp, long previousTimeStamp, String userID,
+ String comment, CDOCommitData commitData)
+ {
+ checkActive();
+ return new CDOCommitInfoImpl(this, branch, timeStamp, previousTimeStamp, userID, comment, commitData);
+ }
+
+ public CDOCommitInfo getCommitInfo(long timeStamp)
+ {
+ checkActive();
+ final CDOCommitInfo[] result = { null };
+ getCommitInfos(null, timeStamp, timeStamp, new CDOCommitInfoHandler()
+ {
+ public void handleCommitInfo(CDOCommitInfo commitInfo)
+ {
+ result[0] = commitInfo;
+ }
+ });
+
+ return result[0];
+ }
+
+ public void getCommitInfos(CDOBranch branch, long startTime, long endTime, CDOCommitInfoHandler handler)
+ {
+ checkActive();
+ commitInfoLoader.loadCommitInfos(branch, startTime, endTime, handler);
+ }
+
+ public void getCommitInfos(CDOBranch branch, long startTime, String userID, String comment, int count,
+ CDOCommitInfoHandler handler)
+ {
+ checkActive();
+
+ // TODO: implement CDOCommitInfoManagerImpl.getCommitInfos(branch, startTime, userID, comment, count, handler)
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected void doBeforeActivate() throws Exception
+ {
+ super.doBeforeActivate();
+ checkState(commitInfoLoader, "commitInfoLoader"); //$NON-NLS-1$
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/DelegatingCommitInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/DelegatingCommitInfo.java
index 517e590bba..6f464afefe 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/DelegatingCommitInfo.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/DelegatingCommitInfo.java
@@ -1,111 +1,111 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.commit;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.commit.CDOChangeKind;
-import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public abstract class DelegatingCommitInfo implements CDOCommitInfo
-{
- public DelegatingCommitInfo()
- {
- }
-
- protected abstract CDOCommitInfo getDelegate();
-
- public CDOBranch getBranch()
- {
- return getDelegate().getBranch();
- }
-
- public CDOCommitInfoManager getCommitInfoManager()
- {
- return getDelegate().getCommitInfoManager();
- }
-
- public long getPreviousTimeStamp()
- {
- return getDelegate().getPreviousTimeStamp();
- }
-
- public long getTimeStamp()
- {
- return getDelegate().getTimeStamp();
- }
-
- public String getUserID()
- {
- return getDelegate().getUserID();
- }
-
- public String getComment()
- {
- return getDelegate().getComment();
- }
-
- public boolean isEmpty()
- {
- return getDelegate().isEmpty();
- }
-
- public List<CDOPackageUnit> getNewPackageUnits()
- {
- return getDelegate().getNewPackageUnits();
- }
-
- public List<CDOIDAndVersion> getNewObjects()
- {
- return getDelegate().getNewObjects();
- }
-
- public List<CDORevisionKey> getChangedObjects()
- {
- return getDelegate().getChangedObjects();
- }
-
- public List<CDOIDAndVersion> getDetachedObjects()
- {
- return getDelegate().getDetachedObjects();
- }
-
- public Map<CDOID, CDOChangeKind> getChangeKinds()
- {
- return getDelegate().getChangeKinds();
- }
-
- public CDOChangeKind getChangeKind(CDOID id)
- {
- return getDelegate().getChangeKind(id);
- }
-
- public CDOChangeSetData copy()
- {
- return getDelegate().copy();
- }
-
- public void merge(CDOChangeSetData changeSetData)
- {
- getDelegate().merge(changeSetData);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.commit;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.commit.CDOChangeKind;
+import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
+import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class DelegatingCommitInfo implements CDOCommitInfo
+{
+ public DelegatingCommitInfo()
+ {
+ }
+
+ protected abstract CDOCommitInfo getDelegate();
+
+ public CDOBranch getBranch()
+ {
+ return getDelegate().getBranch();
+ }
+
+ public CDOCommitInfoManager getCommitInfoManager()
+ {
+ return getDelegate().getCommitInfoManager();
+ }
+
+ public long getPreviousTimeStamp()
+ {
+ return getDelegate().getPreviousTimeStamp();
+ }
+
+ public long getTimeStamp()
+ {
+ return getDelegate().getTimeStamp();
+ }
+
+ public String getUserID()
+ {
+ return getDelegate().getUserID();
+ }
+
+ public String getComment()
+ {
+ return getDelegate().getComment();
+ }
+
+ public boolean isEmpty()
+ {
+ return getDelegate().isEmpty();
+ }
+
+ public List<CDOPackageUnit> getNewPackageUnits()
+ {
+ return getDelegate().getNewPackageUnits();
+ }
+
+ public List<CDOIDAndVersion> getNewObjects()
+ {
+ return getDelegate().getNewObjects();
+ }
+
+ public List<CDORevisionKey> getChangedObjects()
+ {
+ return getDelegate().getChangedObjects();
+ }
+
+ public List<CDOIDAndVersion> getDetachedObjects()
+ {
+ return getDelegate().getDetachedObjects();
+ }
+
+ public Map<CDOID, CDOChangeKind> getChangeKinds()
+ {
+ return getDelegate().getChangeKinds();
+ }
+
+ public CDOChangeKind getChangeKind(CDOID id)
+ {
+ return getDelegate().getChangeKind(id);
+ }
+
+ public CDOChangeSetData copy()
+ {
+ return getDelegate().copy();
+ }
+
+ public void merge(CDOChangeSetData changeSetData)
+ {
+ getDelegate().merge(changeSetData);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/FailureCommitInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/FailureCommitInfo.java
index c4f54e6cc9..11bc8b007a 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/FailureCommitInfo.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/FailureCommitInfo.java
@@ -1,116 +1,116 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.commit;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.commit.CDOChangeKind;
-import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class FailureCommitInfo implements CDOCommitInfo
-{
- private long timeStamp;
-
- private long previousTimeStamp;
-
- public FailureCommitInfo(long timeStamp, long previousTimeStamp)
- {
- this.timeStamp = timeStamp;
- this.previousTimeStamp = previousTimeStamp;
- }
-
- public long getTimeStamp()
- {
- return timeStamp;
- }
-
- public long getPreviousTimeStamp()
- {
- return previousTimeStamp;
- }
-
- public CDOBranch getBranch()
- {
- return null;
- }
-
- public String getUserID()
- {
- return null;
- }
-
- public String getComment()
- {
- return null;
- }
-
- public CDOCommitInfoManager getCommitInfoManager()
- {
- return null;
- }
-
- public boolean isEmpty()
- {
- return true;
- }
-
- public List<CDOPackageUnit> getNewPackageUnits()
- {
- return Collections.emptyList();
- }
-
- public List<CDOIDAndVersion> getNewObjects()
- {
- return Collections.emptyList();
- }
-
- public List<CDORevisionKey> getChangedObjects()
- {
- return Collections.emptyList();
- }
-
- public List<CDOIDAndVersion> getDetachedObjects()
- {
- return Collections.emptyList();
- }
-
- public Map<CDOID, CDOChangeKind> getChangeKinds()
- {
- return Collections.emptyMap();
- }
-
- public CDOChangeKind getChangeKind(CDOID id)
- {
- return null;
- }
-
- public CDOChangeSetData copy()
- {
- return this;
- }
-
- public void merge(CDOChangeSetData changeSetData)
- {
- throw new UnsupportedOperationException();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.commit;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.commit.CDOChangeKind;
+import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
+import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class FailureCommitInfo implements CDOCommitInfo
+{
+ private long timeStamp;
+
+ private long previousTimeStamp;
+
+ public FailureCommitInfo(long timeStamp, long previousTimeStamp)
+ {
+ this.timeStamp = timeStamp;
+ this.previousTimeStamp = previousTimeStamp;
+ }
+
+ public long getTimeStamp()
+ {
+ return timeStamp;
+ }
+
+ public long getPreviousTimeStamp()
+ {
+ return previousTimeStamp;
+ }
+
+ public CDOBranch getBranch()
+ {
+ return null;
+ }
+
+ public String getUserID()
+ {
+ return null;
+ }
+
+ public String getComment()
+ {
+ return null;
+ }
+
+ public CDOCommitInfoManager getCommitInfoManager()
+ {
+ return null;
+ }
+
+ public boolean isEmpty()
+ {
+ return true;
+ }
+
+ public List<CDOPackageUnit> getNewPackageUnits()
+ {
+ return Collections.emptyList();
+ }
+
+ public List<CDOIDAndVersion> getNewObjects()
+ {
+ return Collections.emptyList();
+ }
+
+ public List<CDORevisionKey> getChangedObjects()
+ {
+ return Collections.emptyList();
+ }
+
+ public List<CDOIDAndVersion> getDetachedObjects()
+ {
+ return Collections.emptyList();
+ }
+
+ public Map<CDOID, CDOChangeKind> getChangeKinds()
+ {
+ return Collections.emptyMap();
+ }
+
+ public CDOChangeKind getChangeKind(CDOID id)
+ {
+ return null;
+ }
+
+ public CDOChangeSetData copy()
+ {
+ return this;
+ }
+
+ public void merge(CDOChangeSetData changeSetData)
+ {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDExternalImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDExternalImpl.java
index c90cc9af5d..887ac19adf 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDExternalImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDExternalImpl.java
@@ -1,131 +1,131 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.id;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDExternal;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOID;
-
-import org.eclipse.net4j.util.ObjectUtil;
-import org.eclipse.net4j.util.io.ExtendedDataInput;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
-
-import java.io.IOException;
-
-/**
- * @author Simon McDuff
- */
-public class CDOIDExternalImpl extends AbstractCDOID implements CDOIDExternal
-{
- private static final long serialVersionUID = 1L;
-
- private String uri;
-
- public CDOIDExternalImpl(String uri)
- {
- this.uri = uri;
- }
-
- public Type getType()
- {
- return Type.EXTERNAL_OBJECT;
- }
-
- public boolean isDangling()
- {
- return false;
- }
-
- public boolean isExternal()
- {
- return true;
- }
-
- public boolean isNull()
- {
- return false;
- }
-
- public boolean isObject()
- {
- return true;
- }
-
- public boolean isTemporary()
- {
- return false;
- }
-
- public String getURI()
- {
- return uri;
- }
-
- @Override
- public String toString()
- {
- return "oid:" + toURIFragment(); //$NON-NLS-1$
- }
-
- @Override
- public void read(String fragmentPart)
- {
- uri = fragmentPart;
- }
-
- @Override
- public void read(ExtendedDataInput in) throws IOException
- {
- uri = in.readString();
- }
-
- @Override
- public void write(ExtendedDataOutput out) throws IOException
- {
- out.writeString(uri);
- }
-
- public String toURIFragment()
- {
- return uri;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- // Could CDOIDTempObjectExternalImpl and CDOIDExternalImpl have the same uri. We don't want to mixed them.
- if (obj != null && obj.getClass() == getClass())
- {
- CDOIDExternal that = (CDOIDExternal)obj;
- return ObjectUtil.equals(getURI(), that.getURI());
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- return getClass().hashCode() ^ uri.hashCode();
- }
-
- @Override
- protected int doCompareTo(CDOID o) throws ClassCastException
- {
- return getURI().compareTo(((CDOIDExternalImpl)o).getURI());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.common.id;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDExternal;
+import org.eclipse.emf.cdo.spi.common.id.AbstractCDOID;
+
+import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.io.ExtendedDataInput;
+import org.eclipse.net4j.util.io.ExtendedDataOutput;
+
+import java.io.IOException;
+
+/**
+ * @author Simon McDuff
+ */
+public class CDOIDExternalImpl extends AbstractCDOID implements CDOIDExternal
+{
+ private static final long serialVersionUID = 1L;
+
+ private String uri;
+
+ public CDOIDExternalImpl(String uri)
+ {
+ this.uri = uri;
+ }
+
+ public Type getType()
+ {
+ return Type.EXTERNAL_OBJECT;
+ }
+
+ public boolean isDangling()
+ {
+ return false;
+ }
+
+ public boolean isExternal()
+ {
+ return true;
+ }
+
+ public boolean isNull()
+ {
+ return false;
+ }
+
+ public boolean isObject()
+ {
+ return true;
+ }
+
+ public boolean isTemporary()
+ {
+ return false;
+ }
+
+ public String getURI()
+ {
+ return uri;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "oid:" + toURIFragment(); //$NON-NLS-1$
+ }
+
+ @Override
+ public void read(String fragmentPart)
+ {
+ uri = fragmentPart;
+ }
+
+ @Override
+ public void read(ExtendedDataInput in) throws IOException
+ {
+ uri = in.readString();
+ }
+
+ @Override
+ public void write(ExtendedDataOutput out) throws IOException
+ {
+ out.writeString(uri);
+ }
+
+ public String toURIFragment()
+ {
+ return uri;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+
+ // Could CDOIDTempObjectExternalImpl and CDOIDExternalImpl have the same uri. We don't want to mixed them.
+ if (obj != null && obj.getClass() == getClass())
+ {
+ CDOIDExternal that = (CDOIDExternal)obj;
+ return ObjectUtil.equals(getURI(), that.getURI());
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return getClass().hashCode() ^ uri.hashCode();
+ }
+
+ @Override
+ protected int doCompareTo(CDOID o) throws ClassCastException
+ {
+ return getURI().compareTo(((CDOIDExternalImpl)o).getURI());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDNullImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDNullImpl.java
index 4fd07ea586..4162b4d7b9 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDNullImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDNullImpl.java
@@ -1,125 +1,125 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - bug 226778
- *
- */
-package org.eclipse.emf.cdo.internal.common.id;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDObject;
-import org.eclipse.emf.cdo.common.id.CDOIDTemp;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOID;
-
-import org.eclipse.net4j.util.io.ExtendedDataInput;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public final class CDOIDNullImpl extends AbstractCDOID implements CDOIDTemp, CDOIDObject
-{
- public static final CDOIDNullImpl INSTANCE = new CDOIDNullImpl();
-
- private static final long serialVersionUID = 1L;
-
- private CDOIDNullImpl()
- {
- }
-
- public Type getType()
- {
- return Type.NULL;
- }
-
- public boolean isDangling()
- {
- return false;
- }
-
- public boolean isExternal()
- {
- return false;
- }
-
- public boolean isNull()
- {
- return true;
- }
-
- public boolean isObject()
- {
- return false;
- }
-
- public boolean isTemporary()
- {
- return false;
- }
-
- public int getIntValue()
- {
- return 0;
- }
-
- public long getLongValue()
- {
- return 0L;
- }
-
- public String toURIFragment()
- {
- return "NULL"; //$NON-NLS-1$
- }
-
- @Override
- public void read(String fragmentPart)
- {
- // Do nothing
- }
-
- @Override
- public void read(ExtendedDataInput in) throws IOException
- {
- // Do nothing
- }
-
- @Override
- public void write(ExtendedDataOutput out) throws IOException
- {
- // Do nothing
- }
-
- @Override
- public boolean equals(Object obj)
- {
- return obj == INSTANCE;
- }
-
- @Override
- public int hashCode()
- {
- return 0;
- }
-
- @Override
- public String toString()
- {
- return "NULL"; //$NON-NLS-1$
- }
-
- @Override
- protected int doCompareTo(CDOID o) throws ClassCastException
- {
- ((CDOIDNullImpl)o).getIntValue(); // Possibly throw ClassCastException
- return 0; // NULL == NULL
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Simon McDuff - bug 226778
+ *
+ */
+package org.eclipse.emf.cdo.internal.common.id;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDObject;
+import org.eclipse.emf.cdo.common.id.CDOIDTemp;
+import org.eclipse.emf.cdo.spi.common.id.AbstractCDOID;
+
+import org.eclipse.net4j.util.io.ExtendedDataInput;
+import org.eclipse.net4j.util.io.ExtendedDataOutput;
+
+import java.io.IOException;
+
+/**
+ * @author Eike Stepper
+ */
+public final class CDOIDNullImpl extends AbstractCDOID implements CDOIDTemp, CDOIDObject
+{
+ public static final CDOIDNullImpl INSTANCE = new CDOIDNullImpl();
+
+ private static final long serialVersionUID = 1L;
+
+ private CDOIDNullImpl()
+ {
+ }
+
+ public Type getType()
+ {
+ return Type.NULL;
+ }
+
+ public boolean isDangling()
+ {
+ return false;
+ }
+
+ public boolean isExternal()
+ {
+ return false;
+ }
+
+ public boolean isNull()
+ {
+ return true;
+ }
+
+ public boolean isObject()
+ {
+ return false;
+ }
+
+ public boolean isTemporary()
+ {
+ return false;
+ }
+
+ public int getIntValue()
+ {
+ return 0;
+ }
+
+ public long getLongValue()
+ {
+ return 0L;
+ }
+
+ public String toURIFragment()
+ {
+ return "NULL"; //$NON-NLS-1$
+ }
+
+ @Override
+ public void read(String fragmentPart)
+ {
+ // Do nothing
+ }
+
+ @Override
+ public void read(ExtendedDataInput in) throws IOException
+ {
+ // Do nothing
+ }
+
+ @Override
+ public void write(ExtendedDataOutput out) throws IOException
+ {
+ // Do nothing
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ return obj == INSTANCE;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return 0;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "NULL"; //$NON-NLS-1$
+ }
+
+ @Override
+ protected int doCompareTo(CDOID o) throws ClassCastException
+ {
+ ((CDOIDNullImpl)o).getIntValue(); // Possibly throw ClassCastException
+ return 0; // NULL == NULL
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectLongImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectLongImpl.java
index 49d3eb23b5..9e95fc337c 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectLongImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectLongImpl.java
@@ -1,83 +1,83 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.id;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong;
-import org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject;
-
-/**
- * @author Eike Stepper
- * @since 2.0
- */
-public class CDOIDObjectLongImpl extends AbstractCDOIDLong implements InternalCDOIDObject
-{
- private static final long serialVersionUID = 1L;
-
- public CDOIDObjectLongImpl()
- {
- }
-
- public CDOIDObjectLongImpl(long value)
- {
- super(value);
- }
-
- public Type getType()
- {
- return Type.OBJECT;
- }
-
- public boolean isDangling()
- {
- return false;
- }
-
- public boolean isExternal()
- {
- return false;
- }
-
- public boolean isNull()
- {
- return false;
- }
-
- public boolean isObject()
- {
- return true;
- }
-
- public boolean isTemporary()
- {
- return false;
- }
-
- /**
- * @since 3.0
- */
- public CDOID.ObjectType getSubType()
- {
- return CDOID.ObjectType.LONG;
- }
-
- @Override
- public String toString()
- {
- return "OID" + getLongValue(); //$NON-NLS-1$
- }
-
- @Override
- protected int doCompareTo(CDOID o) throws ClassCastException
- {
- return new Long(getLongValue()).compareTo(((CDOIDObjectLongImpl)o).getLongValue());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.id;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong;
+import org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public class CDOIDObjectLongImpl extends AbstractCDOIDLong implements InternalCDOIDObject
+{
+ private static final long serialVersionUID = 1L;
+
+ public CDOIDObjectLongImpl()
+ {
+ }
+
+ public CDOIDObjectLongImpl(long value)
+ {
+ super(value);
+ }
+
+ public Type getType()
+ {
+ return Type.OBJECT;
+ }
+
+ public boolean isDangling()
+ {
+ return false;
+ }
+
+ public boolean isExternal()
+ {
+ return false;
+ }
+
+ public boolean isNull()
+ {
+ return false;
+ }
+
+ public boolean isObject()
+ {
+ return true;
+ }
+
+ public boolean isTemporary()
+ {
+ return false;
+ }
+
+ /**
+ * @since 3.0
+ */
+ public CDOID.ObjectType getSubType()
+ {
+ return CDOID.ObjectType.LONG;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "OID" + getLongValue(); //$NON-NLS-1$
+ }
+
+ @Override
+ protected int doCompareTo(CDOID o) throws ClassCastException
+ {
+ return new Long(getLongValue()).compareTo(((CDOIDObjectLongImpl)o).getLongValue());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectLongWithClassifierImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectLongWithClassifierImpl.java
index 7bbc109e38..6e3a5c7ae1 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectLongWithClassifierImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectLongWithClassifierImpl.java
@@ -1,145 +1,145 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Taal - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.id;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.model.CDOClassifierRef;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-
-import org.eclipse.net4j.util.ObjectUtil;
-import org.eclipse.net4j.util.io.ExtendedDataInput;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
-
-import java.io.IOException;
-
-/**
- * @author Martin Taal
- * @since 3.0
- */
-public class CDOIDObjectLongWithClassifierImpl extends CDOIDObjectLongImpl implements CDOClassifierRef.Provider
-{
- private static final long serialVersionUID = 1L;
-
- private CDOClassifierRef classifierRef;
-
- public CDOIDObjectLongWithClassifierImpl()
- {
- }
-
- public CDOIDObjectLongWithClassifierImpl(CDOClassifierRef classifierRef, long value)
- {
- super(value);
- this.classifierRef = classifierRef;
- }
-
- public CDOClassifierRef getClassifierRef()
- {
- return classifierRef;
- }
-
- @Override
- public Type getType()
- {
- return Type.OBJECT;
- }
-
- @Override
- public CDOID.ObjectType getSubType()
- {
- return CDOID.ObjectType.LONG_WITH_CLASSIFIER;
- }
-
- @Override
- public String toURIFragment()
- {
- return getClassifierRef().getPackageURI() + CDOClassifierRef.URI_SEPARATOR + getClassifierRef().getClassifierName()
- + CDOClassifierRef.URI_SEPARATOR + super.toURIFragment();
- }
-
- @Override
- public void read(String fragmentPart)
- {
- // get the CDOClassifierRef part
- int index1 = fragmentPart.indexOf(CDOClassifierRef.URI_SEPARATOR);
- int index2 = fragmentPart.indexOf(CDOClassifierRef.URI_SEPARATOR, index1 + 1);
- if (index1 == -1 || index2 == -1)
- {
- throw new IllegalArgumentException("The fragment " + fragmentPart + " is not a valid fragment");
- }
-
- classifierRef = new CDOClassifierRef(fragmentPart.substring(0, index1), fragmentPart.substring(index1 + 1, index2));
-
- // let the super take care of the rest
- super.read(fragmentPart.substring(index2 + 1));
- }
-
- @Override
- public void read(ExtendedDataInput in) throws IOException
- {
- // TODO: change the parameter to prevent casting to CDODataInput
- CDODataInput cdoDataInput = (CDODataInput)in;
- classifierRef = cdoDataInput.readCDOClassifierRef();
-
- // and let the super take care of the rest
- super.read(in);
- }
-
- @Override
- public void write(ExtendedDataOutput out) throws IOException
- {
- // TODO: change the parameter to prevent casting to CDODataInput
- CDODataOutput cdoDataOutput = (CDODataOutput)out;
- cdoDataOutput.writeCDOClassifierRef(classifierRef);
-
- // and let the super write the rest
- super.write(out);
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj != null && obj.getClass() == getClass())
- {
- CDOIDObjectLongWithClassifierImpl that = (CDOIDObjectLongWithClassifierImpl)obj;
- return ObjectUtil.equals(classifierRef, that.classifierRef) && getLongValue() == that.getLongValue();
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- int hashCode = classifierRef.hashCode() ^ ObjectUtil.hashCode(getLongValue());
- return getClass().hashCode() ^ hashCode;
- }
-
- @Override
- public String toString()
- {
- return "OID:" + toURIFragment(); //$NON-NLS-1$
- }
-
- @Override
- protected int doCompareTo(CDOID o) throws ClassCastException
- {
- // conversion to uri fragment is pretty heavy but afaics the compareTo
- // is not used in a critical place.
- return toURIFragment().compareTo(o.toURIFragment());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Taal - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.common.id;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.model.CDOClassifierRef;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+
+import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.io.ExtendedDataInput;
+import org.eclipse.net4j.util.io.ExtendedDataOutput;
+
+import java.io.IOException;
+
+/**
+ * @author Martin Taal
+ * @since 3.0
+ */
+public class CDOIDObjectLongWithClassifierImpl extends CDOIDObjectLongImpl implements CDOClassifierRef.Provider
+{
+ private static final long serialVersionUID = 1L;
+
+ private CDOClassifierRef classifierRef;
+
+ public CDOIDObjectLongWithClassifierImpl()
+ {
+ }
+
+ public CDOIDObjectLongWithClassifierImpl(CDOClassifierRef classifierRef, long value)
+ {
+ super(value);
+ this.classifierRef = classifierRef;
+ }
+
+ public CDOClassifierRef getClassifierRef()
+ {
+ return classifierRef;
+ }
+
+ @Override
+ public Type getType()
+ {
+ return Type.OBJECT;
+ }
+
+ @Override
+ public CDOID.ObjectType getSubType()
+ {
+ return CDOID.ObjectType.LONG_WITH_CLASSIFIER;
+ }
+
+ @Override
+ public String toURIFragment()
+ {
+ return getClassifierRef().getPackageURI() + CDOClassifierRef.URI_SEPARATOR + getClassifierRef().getClassifierName()
+ + CDOClassifierRef.URI_SEPARATOR + super.toURIFragment();
+ }
+
+ @Override
+ public void read(String fragmentPart)
+ {
+ // get the CDOClassifierRef part
+ int index1 = fragmentPart.indexOf(CDOClassifierRef.URI_SEPARATOR);
+ int index2 = fragmentPart.indexOf(CDOClassifierRef.URI_SEPARATOR, index1 + 1);
+ if (index1 == -1 || index2 == -1)
+ {
+ throw new IllegalArgumentException("The fragment " + fragmentPart + " is not a valid fragment");
+ }
+
+ classifierRef = new CDOClassifierRef(fragmentPart.substring(0, index1), fragmentPart.substring(index1 + 1, index2));
+
+ // let the super take care of the rest
+ super.read(fragmentPart.substring(index2 + 1));
+ }
+
+ @Override
+ public void read(ExtendedDataInput in) throws IOException
+ {
+ // TODO: change the parameter to prevent casting to CDODataInput
+ CDODataInput cdoDataInput = (CDODataInput)in;
+ classifierRef = cdoDataInput.readCDOClassifierRef();
+
+ // and let the super take care of the rest
+ super.read(in);
+ }
+
+ @Override
+ public void write(ExtendedDataOutput out) throws IOException
+ {
+ // TODO: change the parameter to prevent casting to CDODataInput
+ CDODataOutput cdoDataOutput = (CDODataOutput)out;
+ cdoDataOutput.writeCDOClassifierRef(classifierRef);
+
+ // and let the super write the rest
+ super.write(out);
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+
+ if (obj != null && obj.getClass() == getClass())
+ {
+ CDOIDObjectLongWithClassifierImpl that = (CDOIDObjectLongWithClassifierImpl)obj;
+ return ObjectUtil.equals(classifierRef, that.classifierRef) && getLongValue() == that.getLongValue();
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int hashCode = classifierRef.hashCode() ^ ObjectUtil.hashCode(getLongValue());
+ return getClass().hashCode() ^ hashCode;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "OID:" + toURIFragment(); //$NON-NLS-1$
+ }
+
+ @Override
+ protected int doCompareTo(CDOID o) throws ClassCastException
+ {
+ // conversion to uri fragment is pretty heavy but afaics the compareTo
+ // is not used in a critical place.
+ return toURIFragment().compareTo(o.toURIFragment());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectStringImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectStringImpl.java
index 9e8d7c4496..42ceebddd6 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectStringImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectStringImpl.java
@@ -1,81 +1,81 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Taal - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.id;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDString;
-import org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject;
-
-/**
- * @author Martin Taal
- * @since 3.0
- */
-public class CDOIDObjectStringImpl extends AbstractCDOIDString implements InternalCDOIDObject
-{
- private static final long serialVersionUID = 1L;
-
- public CDOIDObjectStringImpl()
- {
- }
-
- public CDOIDObjectStringImpl(String value)
- {
- super(value);
- }
-
- public Type getType()
- {
- return Type.OBJECT;
- }
-
- public boolean isDangling()
- {
- return false;
- }
-
- public boolean isExternal()
- {
- return false;
- }
-
- public boolean isNull()
- {
- return false;
- }
-
- public boolean isObject()
- {
- return true;
- }
-
- public boolean isTemporary()
- {
- return false;
- }
-
- public CDOID.ObjectType getSubType()
- {
- return CDOID.ObjectType.STRING;
- }
-
- @Override
- public String toString()
- {
- return "OID" + getStringValue(); //$NON-NLS-1$
- }
-
- @Override
- protected int doCompareTo(CDOID o) throws ClassCastException
- {
- return getStringValue().compareTo(((CDOIDObjectStringImpl)o).getStringValue());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Taal - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.common.id;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDString;
+import org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject;
+
+/**
+ * @author Martin Taal
+ * @since 3.0
+ */
+public class CDOIDObjectStringImpl extends AbstractCDOIDString implements InternalCDOIDObject
+{
+ private static final long serialVersionUID = 1L;
+
+ public CDOIDObjectStringImpl()
+ {
+ }
+
+ public CDOIDObjectStringImpl(String value)
+ {
+ super(value);
+ }
+
+ public Type getType()
+ {
+ return Type.OBJECT;
+ }
+
+ public boolean isDangling()
+ {
+ return false;
+ }
+
+ public boolean isExternal()
+ {
+ return false;
+ }
+
+ public boolean isNull()
+ {
+ return false;
+ }
+
+ public boolean isObject()
+ {
+ return true;
+ }
+
+ public boolean isTemporary()
+ {
+ return false;
+ }
+
+ public CDOID.ObjectType getSubType()
+ {
+ return CDOID.ObjectType.STRING;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "OID" + getStringValue(); //$NON-NLS-1$
+ }
+
+ @Override
+ protected int doCompareTo(CDOID o) throws ClassCastException
+ {
+ return getStringValue().compareTo(((CDOIDObjectStringImpl)o).getStringValue());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectStringWithClassifierImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectStringWithClassifierImpl.java
index 48e592e500..4d24ee6380 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectStringWithClassifierImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectStringWithClassifierImpl.java
@@ -1,138 +1,138 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Taal - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.id;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.model.CDOClassifierRef;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-
-import org.eclipse.net4j.util.ObjectUtil;
-import org.eclipse.net4j.util.io.ExtendedDataInput;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
-
-import java.io.IOException;
-
-/**
- * @author Martin Taal
- * @since 3.0
- */
-public class CDOIDObjectStringWithClassifierImpl extends CDOIDObjectStringImpl implements CDOClassifierRef.Provider
-{
- private static final long serialVersionUID = 1L;
-
- private CDOClassifierRef classifierRef;
-
- public CDOIDObjectStringWithClassifierImpl()
- {
- }
-
- public CDOIDObjectStringWithClassifierImpl(CDOClassifierRef classifierRef, String value)
- {
- super(value);
- this.classifierRef = classifierRef;
- }
-
- public CDOClassifierRef getClassifierRef()
- {
- return classifierRef;
- }
-
- @Override
- public CDOID.ObjectType getSubType()
- {
- return CDOID.ObjectType.STRING_WITH_CLASSIFIER;
- }
-
- @Override
- public String toURIFragment()
- {
- return getClassifierRef().getPackageURI() + CDOClassifierRef.URI_SEPARATOR + getClassifierRef().getClassifierName()
- + CDOClassifierRef.URI_SEPARATOR + super.toURIFragment();
- }
-
- @Override
- public void read(String fragmentPart)
- {
- // get the EClass part
- int index1 = fragmentPart.indexOf(CDOClassifierRef.URI_SEPARATOR);
- int index2 = fragmentPart.indexOf(CDOClassifierRef.URI_SEPARATOR, index1 + 1);
- if (index1 == -1 || index2 == -1)
- {
- throw new IllegalArgumentException("The fragment " + fragmentPart + " is invalid");
- }
-
- classifierRef = new CDOClassifierRef(fragmentPart.substring(0, index1), fragmentPart.substring(index1 + 1, index2));
-
- // let the super take care of the rest
- super.read(fragmentPart.substring(index2 + 1));
- }
-
- @Override
- public void read(ExtendedDataInput in) throws IOException
- {
- CDODataInput cdoDataInput = (CDODataInput)in;
- classifierRef = cdoDataInput.readCDOClassifierRef();
-
- // and let the super take care of the rest
- super.read(in);
- }
-
- @Override
- public void write(ExtendedDataOutput out) throws IOException
- {
- // TODO: change the parameter to prevent casting to CDODataInput
- CDODataOutput cdoDataOutput = (CDODataOutput)out;
- cdoDataOutput.writeCDOClassifierRef(classifierRef);
-
- // and let the super write the rest
- super.write(out);
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj != null && obj.getClass() == getClass())
- {
- CDOIDObjectStringWithClassifierImpl that = (CDOIDObjectStringWithClassifierImpl)obj;
- return ObjectUtil.equals(classifierRef, that.classifierRef) && getStringValue().equals(that.getStringValue());
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- int hashCode = classifierRef.hashCode() ^ ObjectUtil.hashCode(getStringValue());
- return getClass().hashCode() ^ hashCode;
- }
-
- @Override
- public String toString()
- {
- return "OID:" + toURIFragment(); //$NON-NLS-1$
- }
-
- @Override
- protected int doCompareTo(CDOID o) throws ClassCastException
- {
- // conversion to uri fragment is pretty heavy but afaics the compareTo
- // is not used in a critical place.
- return toURIFragment().compareTo(o.toURIFragment());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Taal - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.common.id;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.model.CDOClassifierRef;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+
+import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.io.ExtendedDataInput;
+import org.eclipse.net4j.util.io.ExtendedDataOutput;
+
+import java.io.IOException;
+
+/**
+ * @author Martin Taal
+ * @since 3.0
+ */
+public class CDOIDObjectStringWithClassifierImpl extends CDOIDObjectStringImpl implements CDOClassifierRef.Provider
+{
+ private static final long serialVersionUID = 1L;
+
+ private CDOClassifierRef classifierRef;
+
+ public CDOIDObjectStringWithClassifierImpl()
+ {
+ }
+
+ public CDOIDObjectStringWithClassifierImpl(CDOClassifierRef classifierRef, String value)
+ {
+ super(value);
+ this.classifierRef = classifierRef;
+ }
+
+ public CDOClassifierRef getClassifierRef()
+ {
+ return classifierRef;
+ }
+
+ @Override
+ public CDOID.ObjectType getSubType()
+ {
+ return CDOID.ObjectType.STRING_WITH_CLASSIFIER;
+ }
+
+ @Override
+ public String toURIFragment()
+ {
+ return getClassifierRef().getPackageURI() + CDOClassifierRef.URI_SEPARATOR + getClassifierRef().getClassifierName()
+ + CDOClassifierRef.URI_SEPARATOR + super.toURIFragment();
+ }
+
+ @Override
+ public void read(String fragmentPart)
+ {
+ // get the EClass part
+ int index1 = fragmentPart.indexOf(CDOClassifierRef.URI_SEPARATOR);
+ int index2 = fragmentPart.indexOf(CDOClassifierRef.URI_SEPARATOR, index1 + 1);
+ if (index1 == -1 || index2 == -1)
+ {
+ throw new IllegalArgumentException("The fragment " + fragmentPart + " is invalid");
+ }
+
+ classifierRef = new CDOClassifierRef(fragmentPart.substring(0, index1), fragmentPart.substring(index1 + 1, index2));
+
+ // let the super take care of the rest
+ super.read(fragmentPart.substring(index2 + 1));
+ }
+
+ @Override
+ public void read(ExtendedDataInput in) throws IOException
+ {
+ CDODataInput cdoDataInput = (CDODataInput)in;
+ classifierRef = cdoDataInput.readCDOClassifierRef();
+
+ // and let the super take care of the rest
+ super.read(in);
+ }
+
+ @Override
+ public void write(ExtendedDataOutput out) throws IOException
+ {
+ // TODO: change the parameter to prevent casting to CDODataInput
+ CDODataOutput cdoDataOutput = (CDODataOutput)out;
+ cdoDataOutput.writeCDOClassifierRef(classifierRef);
+
+ // and let the super write the rest
+ super.write(out);
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+
+ if (obj != null && obj.getClass() == getClass())
+ {
+ CDOIDObjectStringWithClassifierImpl that = (CDOIDObjectStringWithClassifierImpl)obj;
+ return ObjectUtil.equals(classifierRef, that.classifierRef) && getStringValue().equals(that.getStringValue());
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int hashCode = classifierRef.hashCode() ^ ObjectUtil.hashCode(getStringValue());
+ return getClass().hashCode() ^ hashCode;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "OID:" + toURIFragment(); //$NON-NLS-1$
+ }
+
+ @Override
+ protected int doCompareTo(CDOID o) throws ClassCastException
+ {
+ // conversion to uri fragment is pretty heavy but afaics the compareTo
+ // is not used in a critical place.
+ return toURIFragment().compareTo(o.toURIFragment());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectUUIDImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectUUIDImpl.java
index 1337fac0db..5b5e04f3fc 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectUUIDImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectUUIDImpl.java
@@ -1,104 +1,104 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Taal - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.id;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDByteArray;
-import org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject;
-
-/**
- * @author Martin Taal
- * @since 3.0
- */
-public class CDOIDObjectUUIDImpl extends AbstractCDOIDByteArray implements InternalCDOIDObject
-{
- private static final long serialVersionUID = 1L;
-
- public CDOIDObjectUUIDImpl()
- {
- }
-
- public CDOIDObjectUUIDImpl(byte[] value)
- {
- super(value);
- }
-
- public Type getType()
- {
- return Type.OBJECT;
- }
-
- public boolean isDangling()
- {
- return false;
- }
-
- public boolean isExternal()
- {
- return false;
- }
-
- public boolean isNull()
- {
- return false;
- }
-
- public boolean isObject()
- {
- return true;
- }
-
- public boolean isTemporary()
- {
- return false;
- }
-
- public CDOID.ObjectType getSubType()
- {
- return CDOID.ObjectType.UUID;
- }
-
- @Override
- protected int doCompareTo(CDOID o) throws ClassCastException
- {
- byte[] thisValue = getByteArrayValue();
- byte[] thatValue = ((CDOIDObjectUUIDImpl)o).getByteArrayValue();
- int minLength = Math.min(thisValue.length, thatValue.length);
-
- for (int i = 0; i < minLength; i++)
- {
- byte thisByte = thisValue[i];
- byte thatByte = thatValue[i];
- if (thisByte < thatByte)
- {
- return -1;
- }
-
- if (thisByte > thatByte)
- {
- return 1;
- }
- }
-
- if (thisValue.length < thatValue.length)
- {
- return -1;
- }
-
- if (thisValue.length > thatValue.length)
- {
- return 1;
- }
-
- return 0;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Martin Taal - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.common.id;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDByteArray;
+import org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject;
+
+/**
+ * @author Martin Taal
+ * @since 3.0
+ */
+public class CDOIDObjectUUIDImpl extends AbstractCDOIDByteArray implements InternalCDOIDObject
+{
+ private static final long serialVersionUID = 1L;
+
+ public CDOIDObjectUUIDImpl()
+ {
+ }
+
+ public CDOIDObjectUUIDImpl(byte[] value)
+ {
+ super(value);
+ }
+
+ public Type getType()
+ {
+ return Type.OBJECT;
+ }
+
+ public boolean isDangling()
+ {
+ return false;
+ }
+
+ public boolean isExternal()
+ {
+ return false;
+ }
+
+ public boolean isNull()
+ {
+ return false;
+ }
+
+ public boolean isObject()
+ {
+ return true;
+ }
+
+ public boolean isTemporary()
+ {
+ return false;
+ }
+
+ public CDOID.ObjectType getSubType()
+ {
+ return CDOID.ObjectType.UUID;
+ }
+
+ @Override
+ protected int doCompareTo(CDOID o) throws ClassCastException
+ {
+ byte[] thisValue = getByteArrayValue();
+ byte[] thatValue = ((CDOIDObjectUUIDImpl)o).getByteArrayValue();
+ int minLength = Math.min(thisValue.length, thatValue.length);
+
+ for (int i = 0; i < minLength; i++)
+ {
+ byte thisByte = thisValue[i];
+ byte thatByte = thatValue[i];
+ if (thisByte < thatByte)
+ {
+ return -1;
+ }
+
+ if (thisByte > thatByte)
+ {
+ return 1;
+ }
+ }
+
+ if (thisValue.length < thatValue.length)
+ {
+ return -1;
+ }
+
+ if (thisValue.length > thatValue.length)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectExternalImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectExternalImpl.java
index a0c534dacf..1a637113b6 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectExternalImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectExternalImpl.java
@@ -1,33 +1,33 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.id;
-
-import org.eclipse.emf.cdo.common.id.CDOIDTemp;
-
-/**
- * @author Simon McDuff
- */
-public class CDOIDTempObjectExternalImpl extends CDOIDExternalImpl implements CDOIDTemp
-{
- private static final long serialVersionUID = 1L;
-
- public CDOIDTempObjectExternalImpl(String uri)
- {
- super(uri);
- }
-
- @Override
- public Type getType()
- {
- return Type.EXTERNAL_TEMP_OBJECT;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.common.id;
+
+import org.eclipse.emf.cdo.common.id.CDOIDTemp;
+
+/**
+ * @author Simon McDuff
+ */
+public class CDOIDTempObjectExternalImpl extends CDOIDExternalImpl implements CDOIDTemp
+{
+ private static final long serialVersionUID = 1L;
+
+ public CDOIDTempObjectExternalImpl(String uri)
+ {
+ super(uri);
+ }
+
+ @Override
+ public Type getType()
+ {
+ return Type.EXTERNAL_TEMP_OBJECT;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectImpl.java
index 28601c5ad9..625d9660b4 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectImpl.java
@@ -1,70 +1,70 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.id;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDTemp;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDInteger;
-
-/**
- * @author Eike Stepper
- */
-public class CDOIDTempObjectImpl extends AbstractCDOIDInteger implements CDOIDTemp
-{
- private static final long serialVersionUID = 1L;
-
- public CDOIDTempObjectImpl(int value)
- {
- super(value);
- }
-
- public Type getType()
- {
- return Type.TEMP_OBJECT;
- }
-
- public boolean isDangling()
- {
- return false;
- }
-
- public boolean isExternal()
- {
- return false;
- }
-
- public boolean isNull()
- {
- return false;
- }
-
- public boolean isObject()
- {
- return true;
- }
-
- public boolean isTemporary()
- {
- return true;
- }
-
- @Override
- public String toString()
- {
- return "oid" + getIntValue(); //$NON-NLS-1$
- }
-
- @Override
- protected int doCompareTo(CDOID o) throws ClassCastException
- {
- return new Integer(getIntValue()).compareTo(((CDOIDTempObjectImpl)o).getIntValue());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.id;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDTemp;
+import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDInteger;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOIDTempObjectImpl extends AbstractCDOIDInteger implements CDOIDTemp
+{
+ private static final long serialVersionUID = 1L;
+
+ public CDOIDTempObjectImpl(int value)
+ {
+ super(value);
+ }
+
+ public Type getType()
+ {
+ return Type.TEMP_OBJECT;
+ }
+
+ public boolean isDangling()
+ {
+ return false;
+ }
+
+ public boolean isExternal()
+ {
+ return false;
+ }
+
+ public boolean isNull()
+ {
+ return false;
+ }
+
+ public boolean isObject()
+ {
+ return true;
+ }
+
+ public boolean isTemporary()
+ {
+ return true;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "oid" + getIntValue(); //$NON-NLS-1$
+ }
+
+ @Override
+ protected int doCompareTo(CDOID o) throws ClassCastException
+ {
+ return new Integer(getIntValue()).compareTo(((CDOIDTempObjectImpl)o).getIntValue());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockAreaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockAreaImpl.java
index 79fb5e4154..923dd38f8f 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockAreaImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockAreaImpl.java
@@ -1,106 +1,106 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Caspar De Groot - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.lock;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea;
-import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockGrade;
-
-import java.text.MessageFormat;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- * @since 4.1
- * @noextend This interface is not intended to be extended by clients.
- */
-public class CDOLockAreaImpl implements LockArea
-{
- public static final int DEFAULT_DURABLE_LOCKING_ID_BYTES = 32;
-
- private final String durableLockingID;
-
- private final String userID;
-
- private final CDOBranchPoint branchPoint;
-
- private final boolean readOnly;
-
- private final Map<CDOID, LockGrade> locks;
-
- private final boolean missing;
-
- public CDOLockAreaImpl(String durableLockingID, String userID, CDOBranchPoint branchPoint, boolean readOnly,
- Map<CDOID, LockGrade> locks)
- {
- this.durableLockingID = durableLockingID;
- this.userID = userID;
- this.branchPoint = branchPoint;
- this.readOnly = readOnly;
- this.locks = locks;
- missing = false;
- }
-
- public CDOLockAreaImpl(String durableLockingID)
- {
- this.durableLockingID = durableLockingID;
- userID = null;
- branchPoint = null;
- readOnly = false;
- locks = null;
- missing = true;
- }
-
- public String getDurableLockingID()
- {
- return durableLockingID;
- }
-
- public String getUserID()
- {
- return userID;
- }
-
- public CDOBranch getBranch()
- {
- return branchPoint.getBranch();
- }
-
- public long getTimeStamp()
- {
- return branchPoint.getTimeStamp();
- }
-
- public boolean isReadOnly()
- {
- return readOnly;
- }
-
- public Map<CDOID, LockGrade> getLocks()
- {
- return locks;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("DurableLockArea\nid={0}\nuser={1}\nbranchPoint={2}\nreadOnly={3}\nlocks={4}",
- durableLockingID, userID, branchPoint, readOnly, locks);
- }
-
- public boolean isMissing()
- {
- return missing;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Caspar De Groot - maintenance
+ */
+package org.eclipse.emf.cdo.internal.common.lock;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea;
+import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockGrade;
+
+import java.text.MessageFormat;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ * @since 4.1
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public class CDOLockAreaImpl implements LockArea
+{
+ public static final int DEFAULT_DURABLE_LOCKING_ID_BYTES = 32;
+
+ private final String durableLockingID;
+
+ private final String userID;
+
+ private final CDOBranchPoint branchPoint;
+
+ private final boolean readOnly;
+
+ private final Map<CDOID, LockGrade> locks;
+
+ private final boolean missing;
+
+ public CDOLockAreaImpl(String durableLockingID, String userID, CDOBranchPoint branchPoint, boolean readOnly,
+ Map<CDOID, LockGrade> locks)
+ {
+ this.durableLockingID = durableLockingID;
+ this.userID = userID;
+ this.branchPoint = branchPoint;
+ this.readOnly = readOnly;
+ this.locks = locks;
+ missing = false;
+ }
+
+ public CDOLockAreaImpl(String durableLockingID)
+ {
+ this.durableLockingID = durableLockingID;
+ userID = null;
+ branchPoint = null;
+ readOnly = false;
+ locks = null;
+ missing = true;
+ }
+
+ public String getDurableLockingID()
+ {
+ return durableLockingID;
+ }
+
+ public String getUserID()
+ {
+ return userID;
+ }
+
+ public CDOBranch getBranch()
+ {
+ return branchPoint.getBranch();
+ }
+
+ public long getTimeStamp()
+ {
+ return branchPoint.getTimeStamp();
+ }
+
+ public boolean isReadOnly()
+ {
+ return readOnly;
+ }
+
+ public Map<CDOID, LockGrade> getLocks()
+ {
+ return locks;
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("DurableLockArea\nid={0}\nuser={1}\nbranchPoint={2}\nreadOnly={3}\nlocks={4}",
+ durableLockingID, userID, branchPoint, readOnly, locks);
+ }
+
+ public boolean isMissing()
+ {
+ return missing;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockChangeInfoImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockChangeInfoImpl.java
index 47379ccd6f..49747d85f1 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockChangeInfoImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockChangeInfoImpl.java
@@ -1,93 +1,93 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.lock;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo;
-import org.eclipse.emf.cdo.common.lock.CDOLockOwner;
-import org.eclipse.emf.cdo.common.lock.CDOLockState;
-
-import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
-
-/**
- * @author Caspar De Groot
- */
-public class CDOLockChangeInfoImpl implements CDOLockChangeInfo
-{
- private final CDOBranchPoint branchPoint;
-
- private final CDOLockOwner lockOwner;
-
- private final CDOLockState[] lockStates;
-
- private final Operation operation;
-
- private final LockType lockType;
-
- private final boolean isInvalidateAll;
-
- public CDOLockChangeInfoImpl(CDOBranchPoint branchPoint, CDOLockOwner lockOwner, CDOLockState[] lockStates,
- Operation operation, LockType lockType)
- {
- this.branchPoint = branchPoint;
- this.lockOwner = lockOwner;
- this.lockStates = lockStates;
- this.operation = operation;
- this.lockType = lockType;
- isInvalidateAll = false;
- }
-
- public CDOLockChangeInfoImpl()
- {
- branchPoint = null;
- lockOwner = null;
- lockStates = null;
- operation = null;
- lockType = null;
- isInvalidateAll = true;
- }
-
- public CDOBranch getBranch()
- {
- return branchPoint == null ? null : branchPoint.getBranch();
- }
-
- public long getTimeStamp()
- {
- return branchPoint == null ? CDOBranchPoint.UNSPECIFIED_DATE : branchPoint.getTimeStamp();
- }
-
- public CDOLockOwner getLockOwner()
- {
- return lockOwner;
- }
-
- public CDOLockState[] getLockStates()
- {
- return lockStates;
- }
-
- public Operation getOperation()
- {
- return operation;
- }
-
- public LockType getLockType()
- {
- return lockType;
- }
-
- public boolean isInvalidateAll()
- {
- return isInvalidateAll;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.lock;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo;
+import org.eclipse.emf.cdo.common.lock.CDOLockOwner;
+import org.eclipse.emf.cdo.common.lock.CDOLockState;
+
+import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
+
+/**
+ * @author Caspar De Groot
+ */
+public class CDOLockChangeInfoImpl implements CDOLockChangeInfo
+{
+ private final CDOBranchPoint branchPoint;
+
+ private final CDOLockOwner lockOwner;
+
+ private final CDOLockState[] lockStates;
+
+ private final Operation operation;
+
+ private final LockType lockType;
+
+ private final boolean isInvalidateAll;
+
+ public CDOLockChangeInfoImpl(CDOBranchPoint branchPoint, CDOLockOwner lockOwner, CDOLockState[] lockStates,
+ Operation operation, LockType lockType)
+ {
+ this.branchPoint = branchPoint;
+ this.lockOwner = lockOwner;
+ this.lockStates = lockStates;
+ this.operation = operation;
+ this.lockType = lockType;
+ isInvalidateAll = false;
+ }
+
+ public CDOLockChangeInfoImpl()
+ {
+ branchPoint = null;
+ lockOwner = null;
+ lockStates = null;
+ operation = null;
+ lockType = null;
+ isInvalidateAll = true;
+ }
+
+ public CDOBranch getBranch()
+ {
+ return branchPoint == null ? null : branchPoint.getBranch();
+ }
+
+ public long getTimeStamp()
+ {
+ return branchPoint == null ? CDOBranchPoint.UNSPECIFIED_DATE : branchPoint.getTimeStamp();
+ }
+
+ public CDOLockOwner getLockOwner()
+ {
+ return lockOwner;
+ }
+
+ public CDOLockState[] getLockStates()
+ {
+ return lockStates;
+ }
+
+ public Operation getOperation()
+ {
+ return operation;
+ }
+
+ public LockType getLockType()
+ {
+ return lockType;
+ }
+
+ public boolean isInvalidateAll()
+ {
+ return isInvalidateAll;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockOwnerImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockOwnerImpl.java
index e110e63839..7d4c1c7925 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockOwnerImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockOwnerImpl.java
@@ -1,91 +1,91 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.lock;
-
-import org.eclipse.emf.cdo.common.lock.CDOLockOwner;
-
-import org.eclipse.net4j.util.ObjectUtil;
-
-/**
- * @author Caspar De Groot
- */
-public class CDOLockOwnerImpl implements CDOLockOwner
-{
- private final int sessionID;
-
- private final int viewID;
-
- private final String durableLockingID;
-
- private final boolean isDurableView;
-
- public CDOLockOwnerImpl(int sessionID, int viewID, String durableLockingID, boolean isDurableView)
- {
- this.sessionID = sessionID;
- this.viewID = viewID;
- this.durableLockingID = durableLockingID;
- this.isDurableView = isDurableView;
- }
-
- public int getSessionID()
- {
- return sessionID;
- }
-
- public int getViewID()
- {
- return viewID;
- }
-
- public String getDurableLockingID()
- {
- return durableLockingID;
- }
-
- public boolean isDurableView()
- {
- return isDurableView;
- }
-
- @Override
- public int hashCode()
- {
- return ObjectUtil.hashCode(sessionID, viewID);
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj instanceof CDOLockOwner)
- {
- CDOLockOwner that = (CDOLockOwner)obj;
- return sessionID == that.getSessionID() && viewID == that.getViewID();
- }
-
- return false;
- }
-
- @Override
- public String toString()
- {
- StringBuilder builder = new StringBuilder("CDOLockOwner[");
- builder.append(sessionID);
- builder.append(':');
- builder.append(viewID);
- builder.append(']');
- return builder.toString();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.lock;
+
+import org.eclipse.emf.cdo.common.lock.CDOLockOwner;
+
+import org.eclipse.net4j.util.ObjectUtil;
+
+/**
+ * @author Caspar De Groot
+ */
+public class CDOLockOwnerImpl implements CDOLockOwner
+{
+ private final int sessionID;
+
+ private final int viewID;
+
+ private final String durableLockingID;
+
+ private final boolean isDurableView;
+
+ public CDOLockOwnerImpl(int sessionID, int viewID, String durableLockingID, boolean isDurableView)
+ {
+ this.sessionID = sessionID;
+ this.viewID = viewID;
+ this.durableLockingID = durableLockingID;
+ this.isDurableView = isDurableView;
+ }
+
+ public int getSessionID()
+ {
+ return sessionID;
+ }
+
+ public int getViewID()
+ {
+ return viewID;
+ }
+
+ public String getDurableLockingID()
+ {
+ return durableLockingID;
+ }
+
+ public boolean isDurableView()
+ {
+ return isDurableView;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return ObjectUtil.hashCode(sessionID, viewID);
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+
+ if (obj instanceof CDOLockOwner)
+ {
+ CDOLockOwner that = (CDOLockOwner)obj;
+ return sessionID == that.getSessionID() && viewID == that.getViewID();
+ }
+
+ return false;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("CDOLockOwner[");
+ builder.append(sessionID);
+ builder.append(':');
+ builder.append(viewID);
+ builder.append(']');
+ return builder.toString();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockStateImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockStateImpl.java
index 5f85e905a3..f5f88aff7d 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockStateImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockStateImpl.java
@@ -1,191 +1,191 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.lock;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.lock.CDOLockOwner;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch;
-import org.eclipse.emf.cdo.spi.common.lock.InternalCDOLockState;
-
-import org.eclipse.net4j.util.CheckUtil;
-import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author Caspar De Groot
- */
-public class CDOLockStateImpl implements InternalCDOLockState
-{
- private final Object lockedObject;
-
- private final Set<CDOLockOwner> readLockOwners = new HashSet<CDOLockOwner>();
-
- private CDOLockOwner writeLockOwner;
-
- private CDOLockOwner writeOptionOwner;
-
- public CDOLockStateImpl(Object lockedObject)
- {
- CheckUtil.checkArg(lockedObject, "lockedObject");
- CheckUtil.checkState(lockedObject instanceof CDOID || lockedObject instanceof CDOIDAndBranch,
- "lockedObject is of wrong type");
- this.lockedObject = lockedObject;
- }
-
- public CDOLockStateImpl copy()
- {
- CDOLockStateImpl newLockState = new CDOLockStateImpl(lockedObject);
- for (CDOLockOwner owner : readLockOwners)
- {
- newLockState.readLockOwners.add(owner);
- }
-
- newLockState.writeLockOwner = writeLockOwner;
- newLockState.writeOptionOwner = writeOptionOwner;
- return newLockState;
- }
-
- public boolean isLocked(LockType lockType, CDOLockOwner lockOwner, boolean others)
- {
- switch (lockType)
- {
- case READ:
- return isReadLocked(lockOwner, others);
-
- case WRITE:
- return isWriteLocked(lockOwner, others);
-
- case OPTION:
- return isOptionLocked(lockOwner, others);
- }
-
- return false;
- }
-
- private boolean isReadLocked(CDOLockOwner by, boolean others)
- {
- int n = readLockOwners.size();
- if (n == 0)
- {
- return false;
- }
-
- if (!others)
- {
- return readLockOwners.contains(by);
- }
-
- return true;
- }
-
- private boolean isWriteLocked(CDOLockOwner by, boolean others)
- {
- if (writeLockOwner == null)
- {
- return false;
- }
-
- return writeLockOwner.equals(by) ^ others;
- }
-
- private boolean isOptionLocked(CDOLockOwner by, boolean others)
- {
- if (writeOptionOwner == null)
- {
- return false;
- }
-
- return writeOptionOwner.equals(by) ^ others;
- }
-
- public Set<CDOLockOwner> getReadLockOwners()
- {
- return Collections.unmodifiableSet(readLockOwners);
- }
-
- public void addReadLockOwner(CDOLockOwner lockOwner)
- {
- readLockOwners.add(lockOwner);
- }
-
- public boolean removeReadLockOwner(CDOLockOwner lockOwner)
- {
- return readLockOwners.remove(lockOwner);
- }
-
- public CDOLockOwner getWriteLockOwner()
- {
- return writeLockOwner;
- }
-
- public void setWriteLockOwner(CDOLockOwner lockOwner)
- {
- writeLockOwner = lockOwner;
- }
-
- public CDOLockOwner getWriteOptionOwner()
- {
- return writeOptionOwner;
- }
-
- public void setWriteOptionOwner(CDOLockOwner lockOwner)
- {
- writeOptionOwner = lockOwner;
- }
-
- public Object getLockedObject()
- {
- return lockedObject;
- }
-
- @Override
- public String toString()
- {
- StringBuilder builder = new StringBuilder("CDOLockState\nlockedObject=");
- builder.append(lockedObject);
-
- builder.append("\nreadLockOwners=");
- if (readLockOwners.size() > 0)
- {
- boolean first = true;
- for (CDOLockOwner lockOwner : readLockOwners)
- {
- if (first)
- {
- first = false;
- }
- else
- {
- builder.append(", ");
- }
-
- builder.append(lockOwner);
- }
-
- builder.deleteCharAt(builder.length() - 1);
- }
- else
- {
- builder.append("NONE");
- }
-
- builder.append("\nwriteLockOwner=");
- builder.append(writeLockOwner != null ? writeLockOwner : "NONE");
-
- builder.append("\nwriteOptionOwner=");
- builder.append(writeOptionOwner != null ? writeOptionOwner : "NONE");
-
- return builder.toString();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.lock;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.lock.CDOLockOwner;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch;
+import org.eclipse.emf.cdo.spi.common.lock.InternalCDOLockState;
+
+import org.eclipse.net4j.util.CheckUtil;
+import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Caspar De Groot
+ */
+public class CDOLockStateImpl implements InternalCDOLockState
+{
+ private final Object lockedObject;
+
+ private final Set<CDOLockOwner> readLockOwners = new HashSet<CDOLockOwner>();
+
+ private CDOLockOwner writeLockOwner;
+
+ private CDOLockOwner writeOptionOwner;
+
+ public CDOLockStateImpl(Object lockedObject)
+ {
+ CheckUtil.checkArg(lockedObject, "lockedObject");
+ CheckUtil.checkState(lockedObject instanceof CDOID || lockedObject instanceof CDOIDAndBranch,
+ "lockedObject is of wrong type");
+ this.lockedObject = lockedObject;
+ }
+
+ public CDOLockStateImpl copy()
+ {
+ CDOLockStateImpl newLockState = new CDOLockStateImpl(lockedObject);
+ for (CDOLockOwner owner : readLockOwners)
+ {
+ newLockState.readLockOwners.add(owner);
+ }
+
+ newLockState.writeLockOwner = writeLockOwner;
+ newLockState.writeOptionOwner = writeOptionOwner;
+ return newLockState;
+ }
+
+ public boolean isLocked(LockType lockType, CDOLockOwner lockOwner, boolean others)
+ {
+ switch (lockType)
+ {
+ case READ:
+ return isReadLocked(lockOwner, others);
+
+ case WRITE:
+ return isWriteLocked(lockOwner, others);
+
+ case OPTION:
+ return isOptionLocked(lockOwner, others);
+ }
+
+ return false;
+ }
+
+ private boolean isReadLocked(CDOLockOwner by, boolean others)
+ {
+ int n = readLockOwners.size();
+ if (n == 0)
+ {
+ return false;
+ }
+
+ if (!others)
+ {
+ return readLockOwners.contains(by);
+ }
+
+ return true;
+ }
+
+ private boolean isWriteLocked(CDOLockOwner by, boolean others)
+ {
+ if (writeLockOwner == null)
+ {
+ return false;
+ }
+
+ return writeLockOwner.equals(by) ^ others;
+ }
+
+ private boolean isOptionLocked(CDOLockOwner by, boolean others)
+ {
+ if (writeOptionOwner == null)
+ {
+ return false;
+ }
+
+ return writeOptionOwner.equals(by) ^ others;
+ }
+
+ public Set<CDOLockOwner> getReadLockOwners()
+ {
+ return Collections.unmodifiableSet(readLockOwners);
+ }
+
+ public void addReadLockOwner(CDOLockOwner lockOwner)
+ {
+ readLockOwners.add(lockOwner);
+ }
+
+ public boolean removeReadLockOwner(CDOLockOwner lockOwner)
+ {
+ return readLockOwners.remove(lockOwner);
+ }
+
+ public CDOLockOwner getWriteLockOwner()
+ {
+ return writeLockOwner;
+ }
+
+ public void setWriteLockOwner(CDOLockOwner lockOwner)
+ {
+ writeLockOwner = lockOwner;
+ }
+
+ public CDOLockOwner getWriteOptionOwner()
+ {
+ return writeOptionOwner;
+ }
+
+ public void setWriteOptionOwner(CDOLockOwner lockOwner)
+ {
+ writeOptionOwner = lockOwner;
+ }
+
+ public Object getLockedObject()
+ {
+ return lockedObject;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("CDOLockState\nlockedObject=");
+ builder.append(lockedObject);
+
+ builder.append("\nreadLockOwners=");
+ if (readLockOwners.size() > 0)
+ {
+ boolean first = true;
+ for (CDOLockOwner lockOwner : readLockOwners)
+ {
+ if (first)
+ {
+ first = false;
+ }
+ else
+ {
+ builder.append(", ");
+ }
+
+ builder.append(lockOwner);
+ }
+
+ builder.deleteCharAt(builder.length() - 1);
+ }
+ else
+ {
+ builder.append("NONE");
+ }
+
+ builder.append("\nwriteLockOwner=");
+ builder.append(writeLockOwner != null ? writeLockOwner : "NONE");
+
+ builder.append("\nwriteOptionOwner=");
+ builder.append(writeOptionOwner != null ? writeOptionOwner : "NONE");
+
+ return builder.toString();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/messages/Messages.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/messages/Messages.java
index 25c110b98c..6e854db79c 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/messages/Messages.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/messages/Messages.java
@@ -1,41 +1,41 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.messages;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * @author Victor Roldan Betancort
- */
-public class Messages
-{
- private static final String BUNDLE_NAME = "org.eclipse.emf.cdo.internal.common.messages.messages"; //$NON-NLS-1$
-
- private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
-
- private Messages()
- {
- }
-
- public static String getString(String key)
- {
- try
- {
- return RESOURCE_BUNDLE.getString(key);
- }
- catch (MissingResourceException e)
- {
- return '!' + key + '!';
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Victor Roldan Betancort - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.common.messages;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * @author Victor Roldan Betancort
+ */
+public class Messages
+{
+ private static final String BUNDLE_NAME = "org.eclipse.emf.cdo.internal.common.messages.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages()
+ {
+ }
+
+ public static String getString(String key)
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/messages/messages.properties b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/messages/messages.properties
index b6a593995b..cf74bb5f59 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/messages/messages.properties
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/messages/messages.properties
@@ -1,39 +1,39 @@
-# Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Victor Roldan Betancort - initial API and implementation
-# Eike Stepper - maintenance
-
-AbstractCDORevision.0=EClass is abstract: {0}
-AbstractCDORevision.1=CDOID is null
-AbstractCDORevision.2=Missing ID mapping for {0}
-AbstractCDORevision.20=Could not find feature {0} in class {1}
-CDOClassifierRef.0=Package not found: {0}
-CDOClassifierRef.1=Invalid classifier URI:
-CDODataInputImpl.5=Invalid CDOFeatureDelta type
-CDODataOutputImpl.5=Temporary ID not supported: {0}
-CDODataOutputImpl.6=No type for object of class {0}
-CDOIDLibraryProviderImpl.0=Unknown library: {0}
-CDOIDLibraryProviderImpl.2=Not a JAR: {0}
-CDOIDUtil.0=Unknown CDOIDObject implementation: {0}
-CDOIDUtil.1=ID is temporary
-CDOIDUtil.2=Can not get id value from external ID types
-CDOIDUtil.3=Invalid CDOID type: {0}
-CDOIDUtil.5=Invalid ID type: {0}
-CDOModelUtil.6=No type for id {0}
-CDOModelUtil.7=Not a primitive type nor String nor Date: {0}
-CDOPackageRegistryImpl.0=No package unit available for: {0}
-CDOPackageUnit.0=Package unit type is unknown
-CDOPackageUnitImpl.0=UNINITIALIZED
-CDOPackageUnitImpl.1=Package unit not initialized
-CDORevisionUtil.0=UNINITIALIZED
-CDOTypeImpl.23=Cannot find the enum literal {0}
-DLRevisionList.0=Cannot assign to a different list while linked to a list
-DLRevisionList.3=Holder {0} is still linked in different list
-DLRevisionList.5=Holder {0} does not belong to this list
-LRURevisionHolder.0=Not a {0}: {1}
-MEMRevisionCache.1=Invalid referenceType: {0}
+# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Victor Roldan Betancort - initial API and implementation
+# Eike Stepper - maintenance
+
+AbstractCDORevision.0=EClass is abstract: {0}
+AbstractCDORevision.1=CDOID is null
+AbstractCDORevision.2=Missing ID mapping for {0}
+AbstractCDORevision.20=Could not find feature {0} in class {1}
+CDOClassifierRef.0=Package not found: {0}
+CDOClassifierRef.1=Invalid classifier URI:
+CDODataInputImpl.5=Invalid CDOFeatureDelta type
+CDODataOutputImpl.5=Temporary ID not supported: {0}
+CDODataOutputImpl.6=No type for object of class {0}
+CDOIDLibraryProviderImpl.0=Unknown library: {0}
+CDOIDLibraryProviderImpl.2=Not a JAR: {0}
+CDOIDUtil.0=Unknown CDOIDObject implementation: {0}
+CDOIDUtil.1=ID is temporary
+CDOIDUtil.2=Can not get id value from external ID types
+CDOIDUtil.3=Invalid CDOID type: {0}
+CDOIDUtil.5=Invalid ID type: {0}
+CDOModelUtil.6=No type for id {0}
+CDOModelUtil.7=Not a primitive type nor String nor Date: {0}
+CDOPackageRegistryImpl.0=No package unit available for: {0}
+CDOPackageUnit.0=Package unit type is unknown
+CDOPackageUnitImpl.0=UNINITIALIZED
+CDOPackageUnitImpl.1=Package unit not initialized
+CDORevisionUtil.0=UNINITIALIZED
+CDOTypeImpl.23=Cannot find the enum literal {0}
+DLRevisionList.0=Cannot assign to a different list while linked to a list
+DLRevisionList.3=Holder {0} is still linked in different list
+DLRevisionList.5=Holder {0} does not belong to this list
+LRURevisionHolder.0=Not a {0}: {1}
+MEMRevisionCache.1=Invalid referenceType: {0}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java
index 1c8b7e8ed8..49ed16a907 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java
@@ -1,126 +1,126 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.model;
-
-import org.eclipse.emf.cdo.common.model.CDOClassInfo;
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class CDOClassInfoImpl extends AdapterImpl implements CDOClassInfo
-{
- private static final int NOT_MAPPED = -1;
-
- private EStructuralFeature[] allPersistentFeatures;
-
- private int[] featureIDMappings;
-
- public CDOClassInfoImpl()
- {
- }
-
- @Override
- public boolean isAdapterForType(Object type)
- {
- return type == CDOClassInfo.class;
- }
-
- @Override
- public void setTarget(Notifier newTarget)
- {
- init((EClass)newTarget);
- super.setTarget(newTarget);
- }
-
- public EClass getEClass()
- {
- return (EClass)getTarget();
- }
-
- public boolean isResource()
- {
- return CDOModelUtil.isResource(getEClass());
- }
-
- public boolean isResourceFolder()
- {
- return CDOModelUtil.isResourceFolder(getEClass());
- }
-
- public boolean isResourceNode()
- {
- return CDOModelUtil.isResourceNode(getEClass());
- }
-
- public EStructuralFeature[] getAllPersistentFeatures()
- {
- return allPersistentFeatures;
- }
-
- public int getFeatureIndex(EStructuralFeature feature)
- {
- int featureID = getEClass().getFeatureID(feature);
- return getFeatureIndex(featureID);
- }
-
- public int getFeatureIndex(int featureID)
- {
- int index = featureIDMappings[featureID];
- if (index == NOT_MAPPED)
- {
- throw new IllegalArgumentException("Feature not mapped: " + getEClass().getEStructuralFeature(featureID)); //$NON-NLS-1$
- }
-
- return index;
- }
-
- private void init(EClass eClass)
- {
- List<EStructuralFeature> persistentFeatures = new ArrayList<EStructuralFeature>();
- EList<EStructuralFeature> allFeatures = eClass.getEAllStructuralFeatures();
- for (EStructuralFeature feature : allFeatures)
- {
- if (EMFUtil.isPersistent(feature))
- {
- persistentFeatures.add(feature);
- }
- }
-
- allPersistentFeatures = persistentFeatures.toArray(new EStructuralFeature[persistentFeatures.size()]);
- featureIDMappings = new int[allFeatures.size()];
- Arrays.fill(featureIDMappings, NOT_MAPPED);
-
- for (int i = 0; i < allPersistentFeatures.length; i++)
- {
- EStructuralFeature feature = allPersistentFeatures[i];
- int featureID = eClass.getFeatureID(feature);
- featureIDMappings[featureID] = i;
- }
- }
-
- @Override
- public String toString()
- {
- return getEClass().toString();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.model;
+
+import org.eclipse.emf.cdo.common.model.CDOClassInfo;
+import org.eclipse.emf.cdo.common.model.CDOModelUtil;
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOClassInfoImpl extends AdapterImpl implements CDOClassInfo
+{
+ private static final int NOT_MAPPED = -1;
+
+ private EStructuralFeature[] allPersistentFeatures;
+
+ private int[] featureIDMappings;
+
+ public CDOClassInfoImpl()
+ {
+ }
+
+ @Override
+ public boolean isAdapterForType(Object type)
+ {
+ return type == CDOClassInfo.class;
+ }
+
+ @Override
+ public void setTarget(Notifier newTarget)
+ {
+ init((EClass)newTarget);
+ super.setTarget(newTarget);
+ }
+
+ public EClass getEClass()
+ {
+ return (EClass)getTarget();
+ }
+
+ public boolean isResource()
+ {
+ return CDOModelUtil.isResource(getEClass());
+ }
+
+ public boolean isResourceFolder()
+ {
+ return CDOModelUtil.isResourceFolder(getEClass());
+ }
+
+ public boolean isResourceNode()
+ {
+ return CDOModelUtil.isResourceNode(getEClass());
+ }
+
+ public EStructuralFeature[] getAllPersistentFeatures()
+ {
+ return allPersistentFeatures;
+ }
+
+ public int getFeatureIndex(EStructuralFeature feature)
+ {
+ int featureID = getEClass().getFeatureID(feature);
+ return getFeatureIndex(featureID);
+ }
+
+ public int getFeatureIndex(int featureID)
+ {
+ int index = featureIDMappings[featureID];
+ if (index == NOT_MAPPED)
+ {
+ throw new IllegalArgumentException("Feature not mapped: " + getEClass().getEStructuralFeature(featureID)); //$NON-NLS-1$
+ }
+
+ return index;
+ }
+
+ private void init(EClass eClass)
+ {
+ List<EStructuralFeature> persistentFeatures = new ArrayList<EStructuralFeature>();
+ EList<EStructuralFeature> allFeatures = eClass.getEAllStructuralFeatures();
+ for (EStructuralFeature feature : allFeatures)
+ {
+ if (EMFUtil.isPersistent(feature))
+ {
+ persistentFeatures.add(feature);
+ }
+ }
+
+ allPersistentFeatures = persistentFeatures.toArray(new EStructuralFeature[persistentFeatures.size()]);
+ featureIDMappings = new int[allFeatures.size()];
+ Arrays.fill(featureIDMappings, NOT_MAPPED);
+
+ for (int i = 0; i < allPersistentFeatures.length; i++)
+ {
+ EStructuralFeature feature = allPersistentFeatures[i];
+ int featureID = eClass.getFeatureID(feature);
+ featureIDMappings[featureID] = i;
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return getEClass().toString();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageInfoImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageInfoImpl.java
index b3fa82be4c..2b182cc038 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageInfoImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageInfoImpl.java
@@ -1,160 +1,160 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.model;
-
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.internal.common.bundle.OM;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.emf.ecore.EPackage;
-
-import java.io.IOException;
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public class CDOPackageInfoImpl extends AdapterImpl implements InternalCDOPackageInfo
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDOPackageInfoImpl.class);
-
- private InternalCDOPackageUnit packageUnit;
-
- private String packageURI;
-
- private String parentURI;
-
- public CDOPackageInfoImpl()
- {
- }
-
- public InternalCDOPackageUnit getPackageUnit()
- {
- return packageUnit;
- }
-
- public void setPackageUnit(InternalCDOPackageUnit packageUnit)
- {
- this.packageUnit = packageUnit;
- }
-
- public String getPackageURI()
- {
- return packageURI;
- }
-
- public void setPackageURI(String packageURI)
- {
- this.packageURI = packageURI;
- }
-
- public String getParentURI()
- {
- return parentURI;
- }
-
- public void setParentURI(String parentURI)
- {
- this.parentURI = parentURI;
- }
-
- public void write(CDODataOutput out) throws IOException
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing {0}", this); //$NON-NLS-1$
- }
-
- out.writeCDOPackageURI(packageURI);
- out.writeCDOPackageURI(parentURI);
- }
-
- public void read(CDODataInput in) throws IOException
- {
- packageURI = in.readCDOPackageURI();
- parentURI = in.readCDOPackageURI();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read {0}", this); //$NON-NLS-1$
- }
- }
-
- public EFactory getEFactory()
- {
- return getEPackage().getEFactoryInstance();
- }
-
- public EPackage getEPackage()
- {
- return getEPackage(true);
- }
-
- public EPackage getEPackage(boolean loadOnDemand)
- {
- return doGetEPackage(loadOnDemand);
- }
-
- public EPackage doGetEPackage(boolean loadOnDemand)
- {
- EPackage ePackage = (EPackage)getTarget();
- if (ePackage != null)
- {
- return ePackage;
- }
-
- if (loadOnDemand)
- {
- packageUnit.load(true); // TODO (CD) Dubious: is resolution-on-load really a good idea?
- return (EPackage)getTarget();
- }
-
- return null;
- }
-
- public boolean isCorePackage()
- {
- return CDOModelUtil.isCorePackage(getEPackage());
- }
-
- public boolean isResourcePackage()
- {
- return CDOModelUtil.isResourcePackage(getEPackage());
- }
-
- public boolean isTypePackage()
- {
- return CDOModelUtil.isTypesPackage(getEPackage());
- }
-
- public boolean isSystemPackage()
- {
- return CDOModelUtil.isSystemPackage(getEPackage());
- }
-
- public int compareTo(CDOPackageInfo o)
- {
- return getPackageURI().compareTo(o.getPackageURI());
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("CDOPackageInfo[packageURI={0}, parentURI={1}]", packageURI, parentURI); //$NON-NLS-1$
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.model;
+
+import org.eclipse.emf.cdo.common.model.CDOModelUtil;
+import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.internal.common.bundle.OM;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EFactory;
+import org.eclipse.emf.ecore.EPackage;
+
+import java.io.IOException;
+import java.text.MessageFormat;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOPackageInfoImpl extends AdapterImpl implements InternalCDOPackageInfo
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDOPackageInfoImpl.class);
+
+ private InternalCDOPackageUnit packageUnit;
+
+ private String packageURI;
+
+ private String parentURI;
+
+ public CDOPackageInfoImpl()
+ {
+ }
+
+ public InternalCDOPackageUnit getPackageUnit()
+ {
+ return packageUnit;
+ }
+
+ public void setPackageUnit(InternalCDOPackageUnit packageUnit)
+ {
+ this.packageUnit = packageUnit;
+ }
+
+ public String getPackageURI()
+ {
+ return packageURI;
+ }
+
+ public void setPackageURI(String packageURI)
+ {
+ this.packageURI = packageURI;
+ }
+
+ public String getParentURI()
+ {
+ return parentURI;
+ }
+
+ public void setParentURI(String parentURI)
+ {
+ this.parentURI = parentURI;
+ }
+
+ public void write(CDODataOutput out) throws IOException
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Writing {0}", this); //$NON-NLS-1$
+ }
+
+ out.writeCDOPackageURI(packageURI);
+ out.writeCDOPackageURI(parentURI);
+ }
+
+ public void read(CDODataInput in) throws IOException
+ {
+ packageURI = in.readCDOPackageURI();
+ parentURI = in.readCDOPackageURI();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read {0}", this); //$NON-NLS-1$
+ }
+ }
+
+ public EFactory getEFactory()
+ {
+ return getEPackage().getEFactoryInstance();
+ }
+
+ public EPackage getEPackage()
+ {
+ return getEPackage(true);
+ }
+
+ public EPackage getEPackage(boolean loadOnDemand)
+ {
+ return doGetEPackage(loadOnDemand);
+ }
+
+ public EPackage doGetEPackage(boolean loadOnDemand)
+ {
+ EPackage ePackage = (EPackage)getTarget();
+ if (ePackage != null)
+ {
+ return ePackage;
+ }
+
+ if (loadOnDemand)
+ {
+ packageUnit.load(true); // TODO (CD) Dubious: is resolution-on-load really a good idea?
+ return (EPackage)getTarget();
+ }
+
+ return null;
+ }
+
+ public boolean isCorePackage()
+ {
+ return CDOModelUtil.isCorePackage(getEPackage());
+ }
+
+ public boolean isResourcePackage()
+ {
+ return CDOModelUtil.isResourcePackage(getEPackage());
+ }
+
+ public boolean isTypePackage()
+ {
+ return CDOModelUtil.isTypesPackage(getEPackage());
+ }
+
+ public boolean isSystemPackage()
+ {
+ return CDOModelUtil.isSystemPackage(getEPackage());
+ }
+
+ public int compareTo(CDOPackageInfo o)
+ {
+ return getPackageURI().compareTo(o.getPackageURI());
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("CDOPackageInfo[packageURI={0}, parentURI={1}]", packageURI, parentURI); //$NON-NLS-1$
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageRegistryImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageRegistryImpl.java
index 4e774d13d5..8c07d0c508 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageRegistryImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageRegistryImpl.java
@@ -1,663 +1,663 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Stefan Winkler - Bug 332912 - Caching subtype-relationships in the CDOPackageRegistry
- */
-package org.eclipse.emf.cdo.internal.common.model;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit.State;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.internal.common.bundle.OM;
-import org.eclipse.emf.cdo.internal.common.messages.Messages;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
-
-import org.eclipse.net4j.util.CheckUtil;
-import org.eclipse.net4j.util.ImplementationError;
-import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
-import org.eclipse.net4j.util.event.EventUtil;
-import org.eclipse.net4j.util.event.IListener;
-import org.eclipse.net4j.util.lifecycle.LifecycleException;
-import org.eclipse.net4j.util.lifecycle.LifecycleState;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.Enumerator;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EEnum;
-import org.eclipse.emf.ecore.EEnumLiteral;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.impl.EPackageRegistryImpl;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements InternalCDOPackageRegistry
-{
- private static final long serialVersionUID = 1L;
-
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDOPackageRegistryImpl.class);
-
- private static final boolean eagerInternalCaches = false;
-
- private boolean replacingDescriptors;
-
- private PackageProcessor packageProcessor;
-
- private PackageLoader packageLoader;
-
- private transient boolean active;
-
- @ExcludeFromDump
- private transient InternalCDOPackageInfo[] packageInfos;
-
- @ExcludeFromDump
- private transient InternalCDOPackageUnit[] packageUnits;
-
- @ExcludeFromDump
- private transient Map<EClass, List<EClass>> subTypes;
-
- private Map<Enumerator, EEnumLiteral> enumLiterals = new HashMap<Enumerator, EEnumLiteral>();
-
- private Set<CDOPackageInfo> visitedPackages = new HashSet<CDOPackageInfo>();
-
- public CDOPackageRegistryImpl()
- {
- }
-
- public boolean isReplacingDescriptors()
- {
- return replacingDescriptors;
- }
-
- public void setReplacingDescriptors(boolean replacingDescriptors)
- {
- this.replacingDescriptors = replacingDescriptors;
- }
-
- public PackageProcessor getPackageProcessor()
- {
- return packageProcessor;
- }
-
- public void setPackageProcessor(PackageProcessor packageProcessor)
- {
- this.packageProcessor = packageProcessor;
- }
-
- public PackageLoader getPackageLoader()
- {
- return packageLoader;
- }
-
- public void setPackageLoader(PackageLoader packageLoader)
- {
- LifecycleUtil.checkInactive(this);
- this.packageLoader = packageLoader;
- }
-
- static int lockCount;
-
- @Override
- public Object get(Object key)
- {
- LifecycleUtil.checkActive(this);
- return super.get(key);
- }
-
- public synchronized Set<String> getAllKeys()
- {
- LifecycleUtil.checkActive(this);
- Set<String> result = new HashSet<String>();
- result.addAll(keySet());
- if (delegateRegistry != null)
- {
- if (delegateRegistry instanceof InternalCDOPackageRegistry)
- {
- result.addAll(((InternalCDOPackageRegistry)delegateRegistry).getAllKeys());
- }
- else
- {
- result.addAll(delegateRegistry.keySet());
- }
- }
-
- return result;
- }
-
- public synchronized Object getWithDelegation(String nsURI, boolean resolve)
- {
- LifecycleUtil.checkActive(this);
- Object result = getFrom(this, nsURI, resolve);
- if (result == null && delegateRegistry != null)
- {
- result = getFrom(delegateRegistry, nsURI, resolve);
- }
-
- return result;
- }
-
- private static Object getFrom(EPackage.Registry registry, String nsURI, boolean resolve)
- {
- if (resolve)
- {
- return registry.getEPackage(nsURI);
- }
-
- return registry.get(nsURI);
- }
-
- public synchronized Object basicPut(String nsURI, Object value)
- {
- LifecycleUtil.checkActive(this);
- if (TRACER.isEnabled())
- {
- TRACER.format("Registering {0} --> {1}", nsURI, value); //$NON-NLS-1$
- }
-
- if (packageProcessor != null)
- {
- value = packageProcessor.processPackage(value);
- }
-
- Object oldValue = get(nsURI);
- if (oldValue instanceof InternalCDOPackageInfo && value instanceof EPackage)
- {
- InternalCDOPackageInfo oldPackageInfo = (InternalCDOPackageInfo)oldValue;
- EPackage newValue = (EPackage)value;
- if (oldPackageInfo.getEPackage(false) == null)
- {
- EMFUtil.addAdapter(newValue, oldPackageInfo);
- oldPackageInfo.getPackageUnit().setState(CDOPackageUnit.State.LOADED);
- }
- }
- else if (oldValue instanceof EPackage && value instanceof InternalCDOPackageInfo)
- {
- EPackage oldPackage = (EPackage)oldValue;
- InternalCDOPackageInfo oldPackageInfo = getPackageInfo(oldPackage);
- InternalCDOPackageInfo newPackageInfo = (InternalCDOPackageInfo)value;
-
- InternalCDOPackageUnit oldPackageUnit = oldPackageInfo.getPackageUnit();
- InternalCDOPackageUnit newPackageUnit = newPackageInfo.getPackageUnit();
- if (oldPackageUnit.getState() == CDOPackageUnit.State.NEW
- && newPackageUnit.getState() != CDOPackageUnit.State.NEW)
- {
- oldPackageUnit.setState(CDOPackageUnit.State.LOADED);
- }
-
- // Keep old value!
- return null;
- }
-
- return super.put(nsURI, value);
- }
-
- @Override
- public synchronized Object put(String nsURI, Object value)
- {
- LifecycleUtil.checkActive(this);
- if (replacingDescriptors && value instanceof EPackage.Descriptor)
- {
- EPackage.Descriptor descriptor = (EPackage.Descriptor)value;
- value = descriptor.getEPackage();
- }
-
- if (value instanceof EPackage)
- {
- EPackage ePackage = (EPackage)value;
- InternalCDOPackageInfo packageInfo = getPackageInfo(ePackage);
- if (packageInfo == null)
- {
- initPackageUnit(ePackage);
- return null;
- }
- }
-
- return basicPut(nsURI, value);
- }
-
- public synchronized Object putEPackage(EPackage ePackage)
- {
- LifecycleUtil.checkActive(this);
- return put(ePackage.getNsURI(), ePackage);
- }
-
- public synchronized void putPackageUnit(InternalCDOPackageUnit packageUnit)
- {
- LifecycleUtil.checkActive(this);
- packageUnit.setPackageRegistry(this);
- for (InternalCDOPackageInfo packageInfo : packageUnit.getPackageInfos())
- {
- EPackage ePackage = packageInfo.getEPackage(false);
- if (ePackage != null)
- {
- EMFUtil.addAdapter(ePackage, packageInfo);
- basicPut(ePackage.getNsURI(), ePackage);
- }
- else
- {
- basicPut(packageInfo.getPackageURI(), packageInfo);
- }
- }
-
- resetInternalCaches();
- }
-
- public synchronized void putPackageUnits(InternalCDOPackageUnit[] packageUnits, State state)
- {
- LifecycleUtil.checkActive(this);
- for (InternalCDOPackageUnit packageUnit : packageUnits)
- {
- if (state != null)
- {
- packageUnit.setState(state);
- }
-
- putPackageUnit(packageUnit);
- }
- }
-
- public synchronized InternalCDOPackageInfo getPackageInfo(EPackage ePackage)
- {
- LifecycleUtil.checkActive(this);
-
- // Looks in the registry
- Object object = get(ePackage.getNsURI());
- if (object instanceof InternalCDOPackageInfo)
- {
- InternalCDOPackageInfo packageInfo = (InternalCDOPackageInfo)object;
- if (packageInfo.getPackageUnit().getPackageRegistry() == this)
- {
- return packageInfo;
- }
- }
-
- // Looks in the adapters
- synchronized (ePackage)
- {
- EList<Adapter> adapters = ePackage.eAdapters();
- for (int i = 0, size = adapters.size(); i < size; ++i)
- {
- Adapter adapter = adapters.get(i);
- if (adapter instanceof InternalCDOPackageInfo)
- {
- InternalCDOPackageInfo packageInfo = (InternalCDOPackageInfo)adapter;
- if (packageInfo.getPackageUnit().getPackageRegistry() == this)
- {
- return packageInfo;
- }
- }
- }
- }
-
- return null;
- }
-
- public synchronized InternalCDOPackageInfo[] getPackageInfos()
- {
- LifecycleUtil.checkActive(this);
- if (packageInfos == null)
- {
- List<InternalCDOPackageInfo> result = new ArrayList<InternalCDOPackageInfo>();
- for (Object value : values())
- {
- if (value instanceof InternalCDOPackageInfo)
- {
- result.add((InternalCDOPackageInfo)value);
- }
- else if (value instanceof EPackage)
- {
- InternalCDOPackageInfo packageInfo = getPackageInfo((EPackage)value);
- if (packageInfo != null)
- {
- result.add(packageInfo);
- }
- }
- }
-
- packageInfos = result.toArray(new InternalCDOPackageInfo[result.size()]);
- Arrays.sort(packageInfos);
- }
-
- return packageInfos;
- }
-
- public synchronized InternalCDOPackageUnit getPackageUnit(EPackage ePackage)
- {
- LifecycleUtil.checkActive(this);
- CDOPackageInfo packageInfo = getPackageInfo(ePackage);
- if (packageInfo == null)
- {
- putEPackage(ePackage);
- packageInfo = getPackageInfo(ePackage);
- if (packageInfo == null)
- {
- throw new ImplementationError(MessageFormat.format(Messages.getString("CDOPackageRegistryImpl.0"), ePackage)); //$NON-NLS-1$
- }
- }
-
- return (InternalCDOPackageUnit)packageInfo.getPackageUnit();
- }
-
- public synchronized InternalCDOPackageUnit getPackageUnit(String id)
- {
- LifecycleUtil.checkActive(this);
- for (Object value : values())
- {
- InternalCDOPackageUnit packageUnit = null;
- if (value instanceof InternalCDOPackageInfo)
- {
- packageUnit = ((InternalCDOPackageInfo)value).getPackageUnit();
- }
- else if (value instanceof EPackage)
- {
- InternalCDOPackageInfo packageInfo = getPackageInfo((EPackage)value);
- if (packageInfo != null)
- {
- packageUnit = packageInfo.getPackageUnit();
- }
- }
-
- if (packageUnit != null && id.equals(packageUnit.getID()))
- {
- return packageUnit;
- }
- }
-
- return null;
- }
-
- public synchronized InternalCDOPackageUnit[] getPackageUnits(long startTime, long endTime)
- {
- LifecycleUtil.checkActive(this);
- if (endTime == CDOBranchPoint.UNSPECIFIED_DATE)
- {
- endTime = Long.MAX_VALUE;
- }
-
- Set<InternalCDOPackageUnit> result = new HashSet<InternalCDOPackageUnit>();
- for (Object value : values())
- {
- InternalCDOPackageUnit packageUnit = null;
- if (value instanceof InternalCDOPackageInfo)
- {
- packageUnit = ((InternalCDOPackageInfo)value).getPackageUnit();
- }
- else if (value instanceof EPackage)
- {
- InternalCDOPackageInfo packageInfo = getPackageInfo((EPackage)value);
- if (packageInfo != null)
- {
- packageUnit = packageInfo.getPackageUnit();
- }
- }
-
- if (packageUnit != null)
- {
- long timeStamp = packageUnit.getTimeStamp();
- if (startTime <= timeStamp && timeStamp <= endTime)
- {
- result.add(packageUnit);
- }
- }
- }
-
- return result.toArray(new InternalCDOPackageUnit[result.size()]);
- }
-
- public synchronized InternalCDOPackageUnit[] getPackageUnits(boolean withSystemPackages)
- {
- LifecycleUtil.checkActive(this);
- return collectPackageUnits(withSystemPackages);
- }
-
- public synchronized InternalCDOPackageUnit[] getPackageUnits()
- {
- LifecycleUtil.checkActive(this);
- if (packageUnits == null)
- {
- packageUnits = collectPackageUnits(true);
- Arrays.sort(packageUnits);
- }
-
- return packageUnits;
- }
-
- private InternalCDOPackageUnit[] collectPackageUnits(boolean withSystemPackages)
- {
- Set<InternalCDOPackageUnit> result = new HashSet<InternalCDOPackageUnit>();
- for (Object value : values())
- {
- InternalCDOPackageUnit packageUnit = collectPackageUnit(value);
- if (packageUnit != null && (withSystemPackages || !packageUnit.isSystem()))
- {
- result.add(packageUnit);
- }
- }
-
- return result.toArray(new InternalCDOPackageUnit[result.size()]);
- }
-
- private InternalCDOPackageUnit collectPackageUnit(Object value)
- {
- if (value instanceof InternalCDOPackageInfo)
- {
- return ((InternalCDOPackageInfo)value).getPackageUnit();
- }
-
- if (value instanceof EPackage)
- {
- InternalCDOPackageInfo packageInfo = getPackageInfo((EPackage)value);
- if (packageInfo != null)
- {
- InternalCDOPackageUnit packageUnit = packageInfo.getPackageUnit();
- return packageUnit;
- }
- }
-
- return null;
- }
-
- public synchronized EPackage[] getEPackages()
- {
- LifecycleUtil.checkActive(this);
- List<EPackage> result = new ArrayList<EPackage>();
- for (String packageURI : keySet())
- {
- EPackage ePackage = getEPackage(packageURI);
- if (ePackage != null)
- {
- result.add(ePackage);
- }
- }
-
- return result.toArray(new EPackage[result.size()]);
- }
-
- public synchronized EEnumLiteral getEnumLiteralFor(Enumerator value)
- {
- LifecycleUtil.checkActive(this);
- EEnumLiteral result = enumLiterals.get(value);
- if (result != null)
- {
- return result;
- }
-
- for (CDOPackageUnit packageUnit : getPackageUnits())
- {
- for (CDOPackageInfo packageInfo : packageUnit.getPackageInfos())
- {
- if (visitedPackages.add(packageInfo))
- {
- result = visitPackage(packageInfo, value);
- if (result != null)
- {
- return result;
- }
- }
- }
- }
-
- return null;
- }
-
- private EEnumLiteral visitPackage(CDOPackageInfo packageInfo, Enumerator value)
- {
- EEnumLiteral result = null;
- for (EClassifier classifier : packageInfo.getEPackage().getEClassifiers())
- {
- if (classifier instanceof EEnum)
- {
- EEnum eenum = (EEnum)classifier;
- for (EEnumLiteral eEnumLiteral : eenum.getELiterals())
- {
- Enumerator instance = eEnumLiteral.getInstance();
- enumLiterals.put(instance, eEnumLiteral);
- if (instance == value)
- {
- result = eEnumLiteral;
- }
- }
- }
- }
-
- return result;
- }
-
- public synchronized Map<EClass, List<EClass>> getSubTypes()
- {
- LifecycleUtil.checkActive(this);
- if (subTypes == null)
- {
- subTypes = CDOModelUtil.getSubTypes(this);
- }
-
- return subTypes;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("{0}[packageLoader={1}]", getClass().getSimpleName(), getPackageLoader()); //$NON-NLS-1$
- }
-
- public void addListener(IListener listener)
- {
- // Do nothing
- }
-
- public void removeListener(IListener listener)
- {
- // Do nothing
- }
-
- public IListener[] getListeners()
- {
- return EventUtil.NO_LISTENERS;
- }
-
- public boolean hasListeners()
- {
- return false;
- }
-
- public synchronized boolean isActive()
- {
- return active;
- }
-
- public synchronized LifecycleState getLifecycleState()
- {
- return active ? LifecycleState.ACTIVE : LifecycleState.INACTIVE;
- }
-
- public synchronized void activate() throws LifecycleException
- {
- if (!active)
- {
- CheckUtil.checkState(packageLoader, "packageLoader"); //$NON-NLS-1$
- active = true;
- }
- }
-
- public synchronized Exception deactivate()
- {
- if (active)
- {
- try
- {
- disposePackageUnits();
- clear();
- active = false;
- }
- catch (RuntimeException ex)
- {
- return ex;
- }
- }
-
- return null;
- }
-
- protected void disposePackageUnits()
- {
- for (InternalCDOPackageUnit packageUnit : getPackageUnits())
- {
- packageUnit.dispose();
- }
-
- packageInfos = null;
- packageUnits = null;
- subTypes = null;
- }
-
- protected void initPackageUnit(EPackage ePackage)
- {
- InternalCDOPackageUnit packageUnit = createPackageUnit();
- packageUnit.init(ePackage);
- resetInternalCaches();
- }
-
- protected void resetInternalCaches()
- {
- packageInfos = null;
- packageUnits = null;
- subTypes = null;
- if (eagerInternalCaches)
- {
- getPackageInfos();
- getPackageUnits();
- getSubTypes();
- }
- }
-
- public InternalCDOPackageUnit createPackageUnit()
- {
- InternalCDOPackageUnit packageUnit = (InternalCDOPackageUnit)CDOModelUtil.createPackageUnit();
- packageUnit.setPackageRegistry(this);
- return packageUnit;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Stefan Winkler - Bug 332912 - Caching subtype-relationships in the CDOPackageRegistry
+ */
+package org.eclipse.emf.cdo.internal.common.model;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.model.CDOModelUtil;
+import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
+import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
+import org.eclipse.emf.cdo.common.model.CDOPackageUnit.State;
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.internal.common.bundle.OM;
+import org.eclipse.emf.cdo.internal.common.messages.Messages;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
+
+import org.eclipse.net4j.util.CheckUtil;
+import org.eclipse.net4j.util.ImplementationError;
+import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
+import org.eclipse.net4j.util.event.EventUtil;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.lifecycle.LifecycleException;
+import org.eclipse.net4j.util.lifecycle.LifecycleState;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.Enumerator;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EEnumLiteral;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.impl.EPackageRegistryImpl;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements InternalCDOPackageRegistry
+{
+ private static final long serialVersionUID = 1L;
+
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDOPackageRegistryImpl.class);
+
+ private static final boolean eagerInternalCaches = false;
+
+ private boolean replacingDescriptors;
+
+ private PackageProcessor packageProcessor;
+
+ private PackageLoader packageLoader;
+
+ private transient boolean active;
+
+ @ExcludeFromDump
+ private transient InternalCDOPackageInfo[] packageInfos;
+
+ @ExcludeFromDump
+ private transient InternalCDOPackageUnit[] packageUnits;
+
+ @ExcludeFromDump
+ private transient Map<EClass, List<EClass>> subTypes;
+
+ private Map<Enumerator, EEnumLiteral> enumLiterals = new HashMap<Enumerator, EEnumLiteral>();
+
+ private Set<CDOPackageInfo> visitedPackages = new HashSet<CDOPackageInfo>();
+
+ public CDOPackageRegistryImpl()
+ {
+ }
+
+ public boolean isReplacingDescriptors()
+ {
+ return replacingDescriptors;
+ }
+
+ public void setReplacingDescriptors(boolean replacingDescriptors)
+ {
+ this.replacingDescriptors = replacingDescriptors;
+ }
+
+ public PackageProcessor getPackageProcessor()
+ {
+ return packageProcessor;
+ }
+
+ public void setPackageProcessor(PackageProcessor packageProcessor)
+ {
+ this.packageProcessor = packageProcessor;
+ }
+
+ public PackageLoader getPackageLoader()
+ {
+ return packageLoader;
+ }
+
+ public void setPackageLoader(PackageLoader packageLoader)
+ {
+ LifecycleUtil.checkInactive(this);
+ this.packageLoader = packageLoader;
+ }
+
+ static int lockCount;
+
+ @Override
+ public Object get(Object key)
+ {
+ LifecycleUtil.checkActive(this);
+ return super.get(key);
+ }
+
+ public synchronized Set<String> getAllKeys()
+ {
+ LifecycleUtil.checkActive(this);
+ Set<String> result = new HashSet<String>();
+ result.addAll(keySet());
+ if (delegateRegistry != null)
+ {
+ if (delegateRegistry instanceof InternalCDOPackageRegistry)
+ {
+ result.addAll(((InternalCDOPackageRegistry)delegateRegistry).getAllKeys());
+ }
+ else
+ {
+ result.addAll(delegateRegistry.keySet());
+ }
+ }
+
+ return result;
+ }
+
+ public synchronized Object getWithDelegation(String nsURI, boolean resolve)
+ {
+ LifecycleUtil.checkActive(this);
+ Object result = getFrom(this, nsURI, resolve);
+ if (result == null && delegateRegistry != null)
+ {
+ result = getFrom(delegateRegistry, nsURI, resolve);
+ }
+
+ return result;
+ }
+
+ private static Object getFrom(EPackage.Registry registry, String nsURI, boolean resolve)
+ {
+ if (resolve)
+ {
+ return registry.getEPackage(nsURI);
+ }
+
+ return registry.get(nsURI);
+ }
+
+ public synchronized Object basicPut(String nsURI, Object value)
+ {
+ LifecycleUtil.checkActive(this);
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Registering {0} --> {1}", nsURI, value); //$NON-NLS-1$
+ }
+
+ if (packageProcessor != null)
+ {
+ value = packageProcessor.processPackage(value);
+ }
+
+ Object oldValue = get(nsURI);
+ if (oldValue instanceof InternalCDOPackageInfo && value instanceof EPackage)
+ {
+ InternalCDOPackageInfo oldPackageInfo = (InternalCDOPackageInfo)oldValue;
+ EPackage newValue = (EPackage)value;
+ if (oldPackageInfo.getEPackage(false) == null)
+ {
+ EMFUtil.addAdapter(newValue, oldPackageInfo);
+ oldPackageInfo.getPackageUnit().setState(CDOPackageUnit.State.LOADED);
+ }
+ }
+ else if (oldValue instanceof EPackage && value instanceof InternalCDOPackageInfo)
+ {
+ EPackage oldPackage = (EPackage)oldValue;
+ InternalCDOPackageInfo oldPackageInfo = getPackageInfo(oldPackage);
+ InternalCDOPackageInfo newPackageInfo = (InternalCDOPackageInfo)value;
+
+ InternalCDOPackageUnit oldPackageUnit = oldPackageInfo.getPackageUnit();
+ InternalCDOPackageUnit newPackageUnit = newPackageInfo.getPackageUnit();
+ if (oldPackageUnit.getState() == CDOPackageUnit.State.NEW
+ && newPackageUnit.getState() != CDOPackageUnit.State.NEW)
+ {
+ oldPackageUnit.setState(CDOPackageUnit.State.LOADED);
+ }
+
+ // Keep old value!
+ return null;
+ }
+
+ return super.put(nsURI, value);
+ }
+
+ @Override
+ public synchronized Object put(String nsURI, Object value)
+ {
+ LifecycleUtil.checkActive(this);
+ if (replacingDescriptors && value instanceof EPackage.Descriptor)
+ {
+ EPackage.Descriptor descriptor = (EPackage.Descriptor)value;
+ value = descriptor.getEPackage();
+ }
+
+ if (value instanceof EPackage)
+ {
+ EPackage ePackage = (EPackage)value;
+ InternalCDOPackageInfo packageInfo = getPackageInfo(ePackage);
+ if (packageInfo == null)
+ {
+ initPackageUnit(ePackage);
+ return null;
+ }
+ }
+
+ return basicPut(nsURI, value);
+ }
+
+ public synchronized Object putEPackage(EPackage ePackage)
+ {
+ LifecycleUtil.checkActive(this);
+ return put(ePackage.getNsURI(), ePackage);
+ }
+
+ public synchronized void putPackageUnit(InternalCDOPackageUnit packageUnit)
+ {
+ LifecycleUtil.checkActive(this);
+ packageUnit.setPackageRegistry(this);
+ for (InternalCDOPackageInfo packageInfo : packageUnit.getPackageInfos())
+ {
+ EPackage ePackage = packageInfo.getEPackage(false);
+ if (ePackage != null)
+ {
+ EMFUtil.addAdapter(ePackage, packageInfo);
+ basicPut(ePackage.getNsURI(), ePackage);
+ }
+ else
+ {
+ basicPut(packageInfo.getPackageURI(), packageInfo);
+ }
+ }
+
+ resetInternalCaches();
+ }
+
+ public synchronized void putPackageUnits(InternalCDOPackageUnit[] packageUnits, State state)
+ {
+ LifecycleUtil.checkActive(this);
+ for (InternalCDOPackageUnit packageUnit : packageUnits)
+ {
+ if (state != null)
+ {
+ packageUnit.setState(state);
+ }
+
+ putPackageUnit(packageUnit);
+ }
+ }
+
+ public synchronized InternalCDOPackageInfo getPackageInfo(EPackage ePackage)
+ {
+ LifecycleUtil.checkActive(this);
+
+ // Looks in the registry
+ Object object = get(ePackage.getNsURI());
+ if (object instanceof InternalCDOPackageInfo)
+ {
+ InternalCDOPackageInfo packageInfo = (InternalCDOPackageInfo)object;
+ if (packageInfo.getPackageUnit().getPackageRegistry() == this)
+ {
+ return packageInfo;
+ }
+ }
+
+ // Looks in the adapters
+ synchronized (ePackage)
+ {
+ EList<Adapter> adapters = ePackage.eAdapters();
+ for (int i = 0, size = adapters.size(); i < size; ++i)
+ {
+ Adapter adapter = adapters.get(i);
+ if (adapter instanceof InternalCDOPackageInfo)
+ {
+ InternalCDOPackageInfo packageInfo = (InternalCDOPackageInfo)adapter;
+ if (packageInfo.getPackageUnit().getPackageRegistry() == this)
+ {
+ return packageInfo;
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public synchronized InternalCDOPackageInfo[] getPackageInfos()
+ {
+ LifecycleUtil.checkActive(this);
+ if (packageInfos == null)
+ {
+ List<InternalCDOPackageInfo> result = new ArrayList<InternalCDOPackageInfo>();
+ for (Object value : values())
+ {
+ if (value instanceof InternalCDOPackageInfo)
+ {
+ result.add((InternalCDOPackageInfo)value);
+ }
+ else if (value instanceof EPackage)
+ {
+ InternalCDOPackageInfo packageInfo = getPackageInfo((EPackage)value);
+ if (packageInfo != null)
+ {
+ result.add(packageInfo);
+ }
+ }
+ }
+
+ packageInfos = result.toArray(new InternalCDOPackageInfo[result.size()]);
+ Arrays.sort(packageInfos);
+ }
+
+ return packageInfos;
+ }
+
+ public synchronized InternalCDOPackageUnit getPackageUnit(EPackage ePackage)
+ {
+ LifecycleUtil.checkActive(this);
+ CDOPackageInfo packageInfo = getPackageInfo(ePackage);
+ if (packageInfo == null)
+ {
+ putEPackage(ePackage);
+ packageInfo = getPackageInfo(ePackage);
+ if (packageInfo == null)
+ {
+ throw new ImplementationError(MessageFormat.format(Messages.getString("CDOPackageRegistryImpl.0"), ePackage)); //$NON-NLS-1$
+ }
+ }
+
+ return (InternalCDOPackageUnit)packageInfo.getPackageUnit();
+ }
+
+ public synchronized InternalCDOPackageUnit getPackageUnit(String id)
+ {
+ LifecycleUtil.checkActive(this);
+ for (Object value : values())
+ {
+ InternalCDOPackageUnit packageUnit = null;
+ if (value instanceof InternalCDOPackageInfo)
+ {
+ packageUnit = ((InternalCDOPackageInfo)value).getPackageUnit();
+ }
+ else if (value instanceof EPackage)
+ {
+ InternalCDOPackageInfo packageInfo = getPackageInfo((EPackage)value);
+ if (packageInfo != null)
+ {
+ packageUnit = packageInfo.getPackageUnit();
+ }
+ }
+
+ if (packageUnit != null && id.equals(packageUnit.getID()))
+ {
+ return packageUnit;
+ }
+ }
+
+ return null;
+ }
+
+ public synchronized InternalCDOPackageUnit[] getPackageUnits(long startTime, long endTime)
+ {
+ LifecycleUtil.checkActive(this);
+ if (endTime == CDOBranchPoint.UNSPECIFIED_DATE)
+ {
+ endTime = Long.MAX_VALUE;
+ }
+
+ Set<InternalCDOPackageUnit> result = new HashSet<InternalCDOPackageUnit>();
+ for (Object value : values())
+ {
+ InternalCDOPackageUnit packageUnit = null;
+ if (value instanceof InternalCDOPackageInfo)
+ {
+ packageUnit = ((InternalCDOPackageInfo)value).getPackageUnit();
+ }
+ else if (value instanceof EPackage)
+ {
+ InternalCDOPackageInfo packageInfo = getPackageInfo((EPackage)value);
+ if (packageInfo != null)
+ {
+ packageUnit = packageInfo.getPackageUnit();
+ }
+ }
+
+ if (packageUnit != null)
+ {
+ long timeStamp = packageUnit.getTimeStamp();
+ if (startTime <= timeStamp && timeStamp <= endTime)
+ {
+ result.add(packageUnit);
+ }
+ }
+ }
+
+ return result.toArray(new InternalCDOPackageUnit[result.size()]);
+ }
+
+ public synchronized InternalCDOPackageUnit[] getPackageUnits(boolean withSystemPackages)
+ {
+ LifecycleUtil.checkActive(this);
+ return collectPackageUnits(withSystemPackages);
+ }
+
+ public synchronized InternalCDOPackageUnit[] getPackageUnits()
+ {
+ LifecycleUtil.checkActive(this);
+ if (packageUnits == null)
+ {
+ packageUnits = collectPackageUnits(true);
+ Arrays.sort(packageUnits);
+ }
+
+ return packageUnits;
+ }
+
+ private InternalCDOPackageUnit[] collectPackageUnits(boolean withSystemPackages)
+ {
+ Set<InternalCDOPackageUnit> result = new HashSet<InternalCDOPackageUnit>();
+ for (Object value : values())
+ {
+ InternalCDOPackageUnit packageUnit = collectPackageUnit(value);
+ if (packageUnit != null && (withSystemPackages || !packageUnit.isSystem()))
+ {
+ result.add(packageUnit);
+ }
+ }
+
+ return result.toArray(new InternalCDOPackageUnit[result.size()]);
+ }
+
+ private InternalCDOPackageUnit collectPackageUnit(Object value)
+ {
+ if (value instanceof InternalCDOPackageInfo)
+ {
+ return ((InternalCDOPackageInfo)value).getPackageUnit();
+ }
+
+ if (value instanceof EPackage)
+ {
+ InternalCDOPackageInfo packageInfo = getPackageInfo((EPackage)value);
+ if (packageInfo != null)
+ {
+ InternalCDOPackageUnit packageUnit = packageInfo.getPackageUnit();
+ return packageUnit;
+ }
+ }
+
+ return null;
+ }
+
+ public synchronized EPackage[] getEPackages()
+ {
+ LifecycleUtil.checkActive(this);
+ List<EPackage> result = new ArrayList<EPackage>();
+ for (String packageURI : keySet())
+ {
+ EPackage ePackage = getEPackage(packageURI);
+ if (ePackage != null)
+ {
+ result.add(ePackage);
+ }
+ }
+
+ return result.toArray(new EPackage[result.size()]);
+ }
+
+ public synchronized EEnumLiteral getEnumLiteralFor(Enumerator value)
+ {
+ LifecycleUtil.checkActive(this);
+ EEnumLiteral result = enumLiterals.get(value);
+ if (result != null)
+ {
+ return result;
+ }
+
+ for (CDOPackageUnit packageUnit : getPackageUnits())
+ {
+ for (CDOPackageInfo packageInfo : packageUnit.getPackageInfos())
+ {
+ if (visitedPackages.add(packageInfo))
+ {
+ result = visitPackage(packageInfo, value);
+ if (result != null)
+ {
+ return result;
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private EEnumLiteral visitPackage(CDOPackageInfo packageInfo, Enumerator value)
+ {
+ EEnumLiteral result = null;
+ for (EClassifier classifier : packageInfo.getEPackage().getEClassifiers())
+ {
+ if (classifier instanceof EEnum)
+ {
+ EEnum eenum = (EEnum)classifier;
+ for (EEnumLiteral eEnumLiteral : eenum.getELiterals())
+ {
+ Enumerator instance = eEnumLiteral.getInstance();
+ enumLiterals.put(instance, eEnumLiteral);
+ if (instance == value)
+ {
+ result = eEnumLiteral;
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public synchronized Map<EClass, List<EClass>> getSubTypes()
+ {
+ LifecycleUtil.checkActive(this);
+ if (subTypes == null)
+ {
+ subTypes = CDOModelUtil.getSubTypes(this);
+ }
+
+ return subTypes;
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("{0}[packageLoader={1}]", getClass().getSimpleName(), getPackageLoader()); //$NON-NLS-1$
+ }
+
+ public void addListener(IListener listener)
+ {
+ // Do nothing
+ }
+
+ public void removeListener(IListener listener)
+ {
+ // Do nothing
+ }
+
+ public IListener[] getListeners()
+ {
+ return EventUtil.NO_LISTENERS;
+ }
+
+ public boolean hasListeners()
+ {
+ return false;
+ }
+
+ public synchronized boolean isActive()
+ {
+ return active;
+ }
+
+ public synchronized LifecycleState getLifecycleState()
+ {
+ return active ? LifecycleState.ACTIVE : LifecycleState.INACTIVE;
+ }
+
+ public synchronized void activate() throws LifecycleException
+ {
+ if (!active)
+ {
+ CheckUtil.checkState(packageLoader, "packageLoader"); //$NON-NLS-1$
+ active = true;
+ }
+ }
+
+ public synchronized Exception deactivate()
+ {
+ if (active)
+ {
+ try
+ {
+ disposePackageUnits();
+ clear();
+ active = false;
+ }
+ catch (RuntimeException ex)
+ {
+ return ex;
+ }
+ }
+
+ return null;
+ }
+
+ protected void disposePackageUnits()
+ {
+ for (InternalCDOPackageUnit packageUnit : getPackageUnits())
+ {
+ packageUnit.dispose();
+ }
+
+ packageInfos = null;
+ packageUnits = null;
+ subTypes = null;
+ }
+
+ protected void initPackageUnit(EPackage ePackage)
+ {
+ InternalCDOPackageUnit packageUnit = createPackageUnit();
+ packageUnit.init(ePackage);
+ resetInternalCaches();
+ }
+
+ protected void resetInternalCaches()
+ {
+ packageInfos = null;
+ packageUnits = null;
+ subTypes = null;
+ if (eagerInternalCaches)
+ {
+ getPackageInfos();
+ getPackageUnits();
+ getSubTypes();
+ }
+ }
+
+ public InternalCDOPackageUnit createPackageUnit()
+ {
+ InternalCDOPackageUnit packageUnit = (InternalCDOPackageUnit)CDOModelUtil.createPackageUnit();
+ packageUnit.setPackageRegistry(this);
+ return packageUnit;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageUnitImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageUnitImpl.java
index 8282ed13c0..bd0106bea3 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageUnitImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageUnitImpl.java
@@ -1,393 +1,393 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.model;
-
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.model.CDOPackageTypeRegistry;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
-import org.eclipse.emf.cdo.internal.common.bundle.OM;
-import org.eclipse.emf.cdo.internal.common.messages.Messages;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry.PackageLoader;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
-
-import org.eclipse.net4j.util.CheckUtil;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-import java.io.IOException;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class CDOPackageUnitImpl implements InternalCDOPackageUnit
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDOPackageUnitImpl.class);
-
- private InternalCDOPackageRegistry packageRegistry;
-
- private State state = State.PROXY;
-
- private Type type;
-
- private Type originalType;
-
- private long timeStamp;
-
- private InternalCDOPackageInfo[] packageInfos;
-
- public CDOPackageUnitImpl()
- {
- }
-
- public InternalCDOPackageRegistry getPackageRegistry()
- {
- return packageRegistry;
- }
-
- public void setPackageRegistry(InternalCDOPackageRegistry packageRegistry)
- {
- this.packageRegistry = packageRegistry;
- }
-
- public String getID()
- {
- try
- {
- return getTopLevelPackageInfo().getPackageURI();
- }
- catch (RuntimeException ex)
- {
- return Messages.getString("CDOPackageUnitImpl.0"); //$NON-NLS-1$
- }
- }
-
- public State getState()
- {
- return state;
- }
-
- public void setState(State state)
- {
- this.state = state;
- if (state == State.LOADED)
- {
- type = null;
- }
- }
-
- public Type getType()
- {
- if (getOriginalType() == Type.DYNAMIC)
- {
- type = Type.DYNAMIC;
- }
- else if (type == null || type == Type.UNKNOWN)
- {
- if (state == State.PROXY)
- {
- type = CDOPackageTypeRegistry.INSTANCE.lookup(getID());
- }
- else
- {
- InternalCDOPackageInfo packageInfo = getTopLevelPackageInfo();
- EPackage ePackage = packageInfo.getEPackage();
- type = CDOPackageTypeRegistry.INSTANCE.lookup(ePackage);
- }
-
- if (type == null)
- {
- type = Type.UNKNOWN;
- }
- }
-
- return type;
- }
-
- public Type getOriginalType()
- {
- return originalType;
- }
-
- public void setOriginalType(Type originalType)
- {
- this.originalType = originalType;
- }
-
- public long getTimeStamp()
- {
- return timeStamp;
- }
-
- public void setTimeStamp(long timeStamp)
- {
- this.timeStamp = timeStamp;
- }
-
- public InternalCDOPackageInfo getTopLevelPackageInfo()
- {
- if (packageInfos == null || packageInfos.length == 0)
- {
- throw new IllegalStateException(Messages.getString("CDOPackageUnitImpl.1")); //$NON-NLS-1$
- }
-
- return packageInfos[0];
- }
-
- public InternalCDOPackageInfo getPackageInfo(String packageURI)
- {
- for (InternalCDOPackageInfo packageInfo : packageInfos)
- {
- if (packageInfo.getPackageURI().equals(packageURI))
- {
- return packageInfo;
- }
- }
-
- return null;
- }
-
- public InternalCDOPackageInfo[] getPackageInfos()
- {
- return packageInfos;
- }
-
- public void setPackageInfos(InternalCDOPackageInfo[] packageInfos)
- {
- this.packageInfos = packageInfos;
- for (InternalCDOPackageInfo packageInfo : packageInfos)
- {
- packageInfo.setPackageUnit(this);
- }
- }
-
- public EPackage[] getEPackages(boolean loadOnDemand)
- {
- List<EPackage> result = new ArrayList<EPackage>();
- for (InternalCDOPackageInfo packageInfo : packageInfos)
- {
- EPackage ePackage = packageInfo.getEPackage(loadOnDemand);
- if (ePackage != null)
- {
- result.add(ePackage);
- }
- }
-
- return result.toArray(new EPackage[result.size()]);
- }
-
- public boolean isSystem()
- {
- return getTopLevelPackageInfo().isSystemPackage();
- }
-
- public boolean isResource()
- {
- return getTopLevelPackageInfo().isResourcePackage();
- }
-
- public void init(EPackage ePackage)
- {
- EPackage topLevelPackage = EMFUtil.getTopLevelPackage(ePackage);
- List<InternalCDOPackageInfo> result = new ArrayList<InternalCDOPackageInfo>();
- initPackageInfos(topLevelPackage, result);
- packageInfos = result.toArray(new InternalCDOPackageInfo[result.size()]);
-
- setState(State.NEW);
- setOriginalType(getType());
- }
-
- public void dispose()
- {
- for (InternalCDOPackageInfo packageInfo : packageInfos)
- {
- EPackage ePackage = packageInfo.getEPackage(false);
- if (ePackage != null)
- {
- synchronized (ePackage)
- {
- ePackage.eAdapters().remove(packageInfo);
- }
- }
- }
-
- packageInfos = null;
- setState(State.DISPOSED);
- }
-
- public synchronized void load(boolean resolve)
- {
- load(packageRegistry.getPackageLoader(), resolve);
- }
-
- public synchronized void load(PackageLoader packageLoader, boolean resolve)
- {
- if (state == State.PROXY)
- {
- EPackage[] ePackages = null;
- ePackages = loadPackagesFromGlobalRegistry();
- if (ePackages == null)
- {
- ePackages = packageLoader.loadPackages(this);
- }
-
- for (EPackage ePackage : ePackages)
- {
- String packageURI = ePackage.getNsURI();
- InternalCDOPackageInfo packageInfo = getPackageInfo(packageURI);
- synchronized (ePackage)
- {
- EMFUtil.addAdapter(ePackage, packageInfo);
- if (resolve)
- {
- EcoreUtil.resolveAll(ePackage);
- }
- }
- }
-
- setState(State.LOADED);
- }
- }
-
- public void write(CDODataOutput out, boolean withPackages) throws IOException
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing {0}", this); //$NON-NLS-1$
- }
-
- out.writeBoolean(withPackages);
- if (withPackages)
- {
- CDOModelUtil.writePackage(out, packageInfos[0].getEPackage(), true, packageRegistry);
- }
-
- out.writeCDOPackageUnitType(originalType);
- out.writeLong(timeStamp);
- out.writeInt(packageInfos.length);
- for (InternalCDOPackageInfo packageInfo : packageInfos)
- {
- out.writeCDOPackageInfo(packageInfo);
- }
- }
-
- public void read(CDODataInput in, ResourceSet resourceSet) throws IOException
- {
- EPackage ePackage = null;
- boolean withPackages = in.readBoolean();
- if (withPackages)
- {
- CheckUtil.checkArg(resourceSet, "resourceSet"); //$NON-NLS-1$
- CheckUtil.checkNull(resourceSet.getPackageRegistry(), "ResourceSet's packageRegistry == null");
- ePackage = CDOModelUtil.readPackage(in, resourceSet, true);
- EPackage globalPackage = loadPackageFromGlobalRegistry(ePackage.getNsURI());
- if (globalPackage != null)
- {
- ePackage = globalPackage;
- }
-
- setState(State.LOADED);
- }
-
- originalType = in.readCDOPackageUnitType();
- timeStamp = in.readLong();
- packageInfos = new InternalCDOPackageInfo[in.readInt()];
- for (int i = 0; i < packageInfos.length; i++)
- {
- packageInfos[i] = (InternalCDOPackageInfo)in.readCDOPackageInfo();
- packageInfos[i].setPackageUnit(this);
- }
-
- if (ePackage != null)
- {
- attachPackageInfos(ePackage);
- }
-
- if (TRACER.isEnabled())
- {
- TRACER.format("Read {0}", this); //$NON-NLS-1$
- }
- }
-
- public int compareTo(CDOPackageUnit o)
- {
- return getID().compareTo(o.getID());
- }
-
- @Override
- public String toString()
- {
- String fmt = "CDOPackageUnit[id={0}, state={1}, type={2}, originalType={3}, timeStamp={4}]"; //$NON-NLS-1$
- return MessageFormat.format(fmt, getID(), getState(), getType(), getOriginalType(),
- CDOCommonUtil.formatTimeStamp(getTimeStamp()));
- }
-
- private void initPackageInfos(EPackage ePackage, List<InternalCDOPackageInfo> result)
- {
- InternalCDOPackageInfo packageInfo = (InternalCDOPackageInfo)CDOModelUtil.createPackageInfo();
- packageInfo.setPackageUnit(this);
- packageInfo.setPackageURI(ePackage.getNsURI());
- packageInfo.setParentURI(ePackage.getESuperPackage() == null ? null : ePackage.getESuperPackage().getNsURI());
- EMFUtil.addAdapter(ePackage, packageInfo);
-
- packageRegistry.basicPut(ePackage.getNsURI(), ePackage);
- result.add(packageInfo);
- for (EPackage subPackage : ePackage.getESubpackages())
- {
- initPackageInfos(subPackage, result);
- }
- }
-
- private void attachPackageInfos(EPackage ePackage)
- {
- InternalCDOPackageInfo packageInfo = getPackageInfo(ePackage.getNsURI());
- if (packageInfo != null)
- {
- EMFUtil.addAdapter(ePackage, packageInfo);
- }
-
- for (EPackage subPackage : ePackage.getESubpackages())
- {
- attachPackageInfos(subPackage);
- }
- }
-
- private EPackage[] loadPackagesFromGlobalRegistry()
- {
- EPackage[] ePackages = new EPackage[packageInfos.length];
- for (int i = 0; i < ePackages.length; i++)
- {
- ePackages[i] = loadPackageFromGlobalRegistry(packageInfos[i].getPackageURI());
- if (ePackages[i] == null)
- {
- return null;
- }
- }
-
- return ePackages;
- }
-
- private EPackage loadPackageFromGlobalRegistry(String packageURI)
- {
- return EPackage.Registry.INSTANCE.getEPackage(packageURI);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.model;
+
+import org.eclipse.emf.cdo.common.model.CDOModelUtil;
+import org.eclipse.emf.cdo.common.model.CDOPackageTypeRegistry;
+import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
+import org.eclipse.emf.cdo.internal.common.bundle.OM;
+import org.eclipse.emf.cdo.internal.common.messages.Messages;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry.PackageLoader;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
+
+import org.eclipse.net4j.util.CheckUtil;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import java.io.IOException;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOPackageUnitImpl implements InternalCDOPackageUnit
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDOPackageUnitImpl.class);
+
+ private InternalCDOPackageRegistry packageRegistry;
+
+ private State state = State.PROXY;
+
+ private Type type;
+
+ private Type originalType;
+
+ private long timeStamp;
+
+ private InternalCDOPackageInfo[] packageInfos;
+
+ public CDOPackageUnitImpl()
+ {
+ }
+
+ public InternalCDOPackageRegistry getPackageRegistry()
+ {
+ return packageRegistry;
+ }
+
+ public void setPackageRegistry(InternalCDOPackageRegistry packageRegistry)
+ {
+ this.packageRegistry = packageRegistry;
+ }
+
+ public String getID()
+ {
+ try
+ {
+ return getTopLevelPackageInfo().getPackageURI();
+ }
+ catch (RuntimeException ex)
+ {
+ return Messages.getString("CDOPackageUnitImpl.0"); //$NON-NLS-1$
+ }
+ }
+
+ public State getState()
+ {
+ return state;
+ }
+
+ public void setState(State state)
+ {
+ this.state = state;
+ if (state == State.LOADED)
+ {
+ type = null;
+ }
+ }
+
+ public Type getType()
+ {
+ if (getOriginalType() == Type.DYNAMIC)
+ {
+ type = Type.DYNAMIC;
+ }
+ else if (type == null || type == Type.UNKNOWN)
+ {
+ if (state == State.PROXY)
+ {
+ type = CDOPackageTypeRegistry.INSTANCE.lookup(getID());
+ }
+ else
+ {
+ InternalCDOPackageInfo packageInfo = getTopLevelPackageInfo();
+ EPackage ePackage = packageInfo.getEPackage();
+ type = CDOPackageTypeRegistry.INSTANCE.lookup(ePackage);
+ }
+
+ if (type == null)
+ {
+ type = Type.UNKNOWN;
+ }
+ }
+
+ return type;
+ }
+
+ public Type getOriginalType()
+ {
+ return originalType;
+ }
+
+ public void setOriginalType(Type originalType)
+ {
+ this.originalType = originalType;
+ }
+
+ public long getTimeStamp()
+ {
+ return timeStamp;
+ }
+
+ public void setTimeStamp(long timeStamp)
+ {
+ this.timeStamp = timeStamp;
+ }
+
+ public InternalCDOPackageInfo getTopLevelPackageInfo()
+ {
+ if (packageInfos == null || packageInfos.length == 0)
+ {
+ throw new IllegalStateException(Messages.getString("CDOPackageUnitImpl.1")); //$NON-NLS-1$
+ }
+
+ return packageInfos[0];
+ }
+
+ public InternalCDOPackageInfo getPackageInfo(String packageURI)
+ {
+ for (InternalCDOPackageInfo packageInfo : packageInfos)
+ {
+ if (packageInfo.getPackageURI().equals(packageURI))
+ {
+ return packageInfo;
+ }
+ }
+
+ return null;
+ }
+
+ public InternalCDOPackageInfo[] getPackageInfos()
+ {
+ return packageInfos;
+ }
+
+ public void setPackageInfos(InternalCDOPackageInfo[] packageInfos)
+ {
+ this.packageInfos = packageInfos;
+ for (InternalCDOPackageInfo packageInfo : packageInfos)
+ {
+ packageInfo.setPackageUnit(this);
+ }
+ }
+
+ public EPackage[] getEPackages(boolean loadOnDemand)
+ {
+ List<EPackage> result = new ArrayList<EPackage>();
+ for (InternalCDOPackageInfo packageInfo : packageInfos)
+ {
+ EPackage ePackage = packageInfo.getEPackage(loadOnDemand);
+ if (ePackage != null)
+ {
+ result.add(ePackage);
+ }
+ }
+
+ return result.toArray(new EPackage[result.size()]);
+ }
+
+ public boolean isSystem()
+ {
+ return getTopLevelPackageInfo().isSystemPackage();
+ }
+
+ public boolean isResource()
+ {
+ return getTopLevelPackageInfo().isResourcePackage();
+ }
+
+ public void init(EPackage ePackage)
+ {
+ EPackage topLevelPackage = EMFUtil.getTopLevelPackage(ePackage);
+ List<InternalCDOPackageInfo> result = new ArrayList<InternalCDOPackageInfo>();
+ initPackageInfos(topLevelPackage, result);
+ packageInfos = result.toArray(new InternalCDOPackageInfo[result.size()]);
+
+ setState(State.NEW);
+ setOriginalType(getType());
+ }
+
+ public void dispose()
+ {
+ for (InternalCDOPackageInfo packageInfo : packageInfos)
+ {
+ EPackage ePackage = packageInfo.getEPackage(false);
+ if (ePackage != null)
+ {
+ synchronized (ePackage)
+ {
+ ePackage.eAdapters().remove(packageInfo);
+ }
+ }
+ }
+
+ packageInfos = null;
+ setState(State.DISPOSED);
+ }
+
+ public synchronized void load(boolean resolve)
+ {
+ load(packageRegistry.getPackageLoader(), resolve);
+ }
+
+ public synchronized void load(PackageLoader packageLoader, boolean resolve)
+ {
+ if (state == State.PROXY)
+ {
+ EPackage[] ePackages = null;
+ ePackages = loadPackagesFromGlobalRegistry();
+ if (ePackages == null)
+ {
+ ePackages = packageLoader.loadPackages(this);
+ }
+
+ for (EPackage ePackage : ePackages)
+ {
+ String packageURI = ePackage.getNsURI();
+ InternalCDOPackageInfo packageInfo = getPackageInfo(packageURI);
+ synchronized (ePackage)
+ {
+ EMFUtil.addAdapter(ePackage, packageInfo);
+ if (resolve)
+ {
+ EcoreUtil.resolveAll(ePackage);
+ }
+ }
+ }
+
+ setState(State.LOADED);
+ }
+ }
+
+ public void write(CDODataOutput out, boolean withPackages) throws IOException
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Writing {0}", this); //$NON-NLS-1$
+ }
+
+ out.writeBoolean(withPackages);
+ if (withPackages)
+ {
+ CDOModelUtil.writePackage(out, packageInfos[0].getEPackage(), true, packageRegistry);
+ }
+
+ out.writeCDOPackageUnitType(originalType);
+ out.writeLong(timeStamp);
+ out.writeInt(packageInfos.length);
+ for (InternalCDOPackageInfo packageInfo : packageInfos)
+ {
+ out.writeCDOPackageInfo(packageInfo);
+ }
+ }
+
+ public void read(CDODataInput in, ResourceSet resourceSet) throws IOException
+ {
+ EPackage ePackage = null;
+ boolean withPackages = in.readBoolean();
+ if (withPackages)
+ {
+ CheckUtil.checkArg(resourceSet, "resourceSet"); //$NON-NLS-1$
+ CheckUtil.checkNull(resourceSet.getPackageRegistry(), "ResourceSet's packageRegistry == null");
+ ePackage = CDOModelUtil.readPackage(in, resourceSet, true);
+ EPackage globalPackage = loadPackageFromGlobalRegistry(ePackage.getNsURI());
+ if (globalPackage != null)
+ {
+ ePackage = globalPackage;
+ }
+
+ setState(State.LOADED);
+ }
+
+ originalType = in.readCDOPackageUnitType();
+ timeStamp = in.readLong();
+ packageInfos = new InternalCDOPackageInfo[in.readInt()];
+ for (int i = 0; i < packageInfos.length; i++)
+ {
+ packageInfos[i] = (InternalCDOPackageInfo)in.readCDOPackageInfo();
+ packageInfos[i].setPackageUnit(this);
+ }
+
+ if (ePackage != null)
+ {
+ attachPackageInfos(ePackage);
+ }
+
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read {0}", this); //$NON-NLS-1$
+ }
+ }
+
+ public int compareTo(CDOPackageUnit o)
+ {
+ return getID().compareTo(o.getID());
+ }
+
+ @Override
+ public String toString()
+ {
+ String fmt = "CDOPackageUnit[id={0}, state={1}, type={2}, originalType={3}, timeStamp={4}]"; //$NON-NLS-1$
+ return MessageFormat.format(fmt, getID(), getState(), getType(), getOriginalType(),
+ CDOCommonUtil.formatTimeStamp(getTimeStamp()));
+ }
+
+ private void initPackageInfos(EPackage ePackage, List<InternalCDOPackageInfo> result)
+ {
+ InternalCDOPackageInfo packageInfo = (InternalCDOPackageInfo)CDOModelUtil.createPackageInfo();
+ packageInfo.setPackageUnit(this);
+ packageInfo.setPackageURI(ePackage.getNsURI());
+ packageInfo.setParentURI(ePackage.getESuperPackage() == null ? null : ePackage.getESuperPackage().getNsURI());
+ EMFUtil.addAdapter(ePackage, packageInfo);
+
+ packageRegistry.basicPut(ePackage.getNsURI(), ePackage);
+ result.add(packageInfo);
+ for (EPackage subPackage : ePackage.getESubpackages())
+ {
+ initPackageInfos(subPackage, result);
+ }
+ }
+
+ private void attachPackageInfos(EPackage ePackage)
+ {
+ InternalCDOPackageInfo packageInfo = getPackageInfo(ePackage.getNsURI());
+ if (packageInfo != null)
+ {
+ EMFUtil.addAdapter(ePackage, packageInfo);
+ }
+
+ for (EPackage subPackage : ePackage.getESubpackages())
+ {
+ attachPackageInfos(subPackage);
+ }
+ }
+
+ private EPackage[] loadPackagesFromGlobalRegistry()
+ {
+ EPackage[] ePackages = new EPackage[packageInfos.length];
+ for (int i = 0; i < ePackages.length; i++)
+ {
+ ePackages[i] = loadPackageFromGlobalRegistry(packageInfos[i].getPackageURI());
+ if (ePackages[i] == null)
+ {
+ return null;
+ }
+ }
+
+ return ePackages;
+ }
+
+ private EPackage loadPackageFromGlobalRegistry(String packageURI)
+ {
+ return EPackage.Registry.INSTANCE.getEPackage(packageURI);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOTypeImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOTypeImpl.java
index 909e9c9f77..48ba6aaf38 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOTypeImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOTypeImpl.java
@@ -1,943 +1,943 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Stefan Winkler - Bug 299194: unsettable features inconsistent between revisions
- * Erdal Karaca - added support for HASHMAP CDO Type
- */
-package org.eclipse.emf.cdo.internal.common.model;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.lob.CDOBlob;
-import org.eclipse.emf.cdo.common.lob.CDOClob;
-import org.eclipse.emf.cdo.common.lob.CDOLobUtil;
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.model.CDOType;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionData;
-import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
-import org.eclipse.emf.cdo.internal.common.messages.Messages;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
-import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
-
-import org.eclipse.emf.common.util.Enumerator;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EEnum;
-import org.eclipse.emf.ecore.EEnumLiteral;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.util.FeatureMap;
-
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.text.MessageFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public abstract class CDOTypeImpl implements CDOType
-{
- private static CDOTypeImpl[] ids = new CDOTypeImpl[Byte.MAX_VALUE - Byte.MIN_VALUE + 1];
-
- private static final byte BOOLEAN_DEFAULT_PRIMITIVE = 0;
-
- private static final char CHARACTER_DEFAULT_PRIMITIVE = 0;
-
- private static final short SHORT_DEFAULT_PRIMITIVE = 0;
-
- public static final Boolean BOOLEAN_DEFAULT = new Boolean(false);
-
- public static final Byte BYTE_DEFAULT = new Byte(BOOLEAN_DEFAULT_PRIMITIVE);
-
- public static final Character CHARACTER_DEFAULT = new Character(CHARACTER_DEFAULT_PRIMITIVE);
-
- public static final Double DOUBLE_DEFAULT = new Double(0.0);
-
- public static final Float FLOAT_DEFAULT = new Float(0.0);
-
- public static final Integer INTEGER_DEFAULT = new Integer(0);
-
- public static final Long LONG_DEFAULT = new Long(0L);
-
- public static final Short SHORT_DEFAULT = new Short(SHORT_DEFAULT_PRIMITIVE);
-
- public static final CDOType BOOLEAN = new CDOTypeImpl("BOOLEAN", EcorePackage.EBOOLEAN, false, BOOLEAN_DEFAULT) //$NON-NLS-1$
- {
- public void writeValue(CDODataOutput out, Object value) throws IOException
- {
- boolean v = (Boolean)(value == null ? getDefaultValue() : value);
- out.writeBoolean(v);
- }
-
- public Boolean readValue(CDODataInput in) throws IOException
- {
- return in.readBoolean();
- }
- };
-
- public static final CDOType BYTE = new CDOTypeImpl("BYTE", EcorePackage.EBYTE, false, BYTE_DEFAULT) //$NON-NLS-1$
- {
- public void writeValue(CDODataOutput out, Object value) throws IOException
- {
- out.writeByte((Byte)(value == null ? getDefaultValue() : value));
- }
-
- public Byte readValue(CDODataInput in) throws IOException
- {
- return in.readByte();
- }
- };
-
- public static final CDOType CHAR = new CDOTypeImpl("CHAR", EcorePackage.ECHAR, false, CHARACTER_DEFAULT) //$NON-NLS-1$
- {
- public void writeValue(CDODataOutput out, Object value) throws IOException
- {
- out.writeChar(((Character)(value == null ? getDefaultValue() : value)).charValue());
- }
-
- public Character readValue(CDODataInput in) throws IOException
- {
- return in.readChar();
- }
- };
-
- public static final CDOType DOUBLE = new CDOTypeImpl("DOUBLE", EcorePackage.EDOUBLE, false, DOUBLE_DEFAULT) //$NON-NLS-1$
- {
- public void writeValue(CDODataOutput out, Object value) throws IOException
- {
- out.writeDouble((Double)(value == null ? getDefaultValue() : value));
- }
-
- public Double readValue(CDODataInput in) throws IOException
- {
- return in.readDouble();
- }
- };
-
- public static final CDOType FLOAT = new CDOTypeImpl("FLOAT", EcorePackage.EFLOAT, false, FLOAT_DEFAULT) //$NON-NLS-1$
- {
- public void writeValue(CDODataOutput out, Object value) throws IOException
- {
- out.writeFloat((Float)(value == null ? getDefaultValue() : value));
- }
-
- public Float readValue(CDODataInput in) throws IOException
- {
- return in.readFloat();
- }
- };
-
- public static final CDOType INT = new CDOTypeImpl("INT", EcorePackage.EINT, false, INTEGER_DEFAULT) //$NON-NLS-1$
- {
- public void writeValue(CDODataOutput out, Object value) throws IOException
- {
- out.writeInt((Integer)(value == null ? getDefaultValue() : value));
- }
-
- public Integer readValue(CDODataInput in) throws IOException
- {
- return in.readInt();
- }
- };
-
- public static final CDOType LONG = new CDOTypeImpl("LONG", EcorePackage.ELONG, false, LONG_DEFAULT) //$NON-NLS-1$
- {
- public void writeValue(CDODataOutput out, Object value) throws IOException
- {
- out.writeLong((Long)(value == null ? getDefaultValue() : value));
- }
-
- public Long readValue(CDODataInput in) throws IOException
- {
- return in.readLong();
- }
- };
-
- public static final CDOType SHORT = new CDOTypeImpl("SHORT", EcorePackage.ESHORT, false, SHORT_DEFAULT) //$NON-NLS-1$
- {
- public void writeValue(CDODataOutput out, Object value) throws IOException
- {
- out.writeShort((Short)(value == null ? getDefaultValue() : value));
- }
-
- public Short readValue(CDODataInput in) throws IOException
- {
- return in.readShort();
- }
- };
-
- public static final CDOType BIG_DECIMAL = new CDOTypeImpl("BIG_DECIMAL", EcorePackage.EBIG_DECIMAL, true) //$NON-NLS-1$
- {
- public void writeValue(CDODataOutput out, Object value) throws IOException
- {
- if (value == null)
- {
- out.writeByteArray(null);
- }
- else
- {
- BigDecimal bigDecimal = (BigDecimal)value;
- out.writeByteArray(bigDecimal.unscaledValue().toByteArray());
- out.writeInt(bigDecimal.scale());
- }
- }
-
- public BigDecimal readValue(CDODataInput in) throws IOException
- {
- byte[] array = in.readByteArray();
- if (array == null)
- {
- return null;
- }
-
- BigInteger unscaled = new BigInteger(array);
- int scale = in.readInt();
- return new BigDecimal(unscaled, scale);
- }
- };
-
- public static final CDOType BIG_INTEGER = new CDOTypeImpl("BIG_INTEGER", EcorePackage.EBIG_INTEGER, true) //$NON-NLS-1$
- {
- public void writeValue(CDODataOutput out, Object value) throws IOException
- {
- if (value == null)
- {
- out.writeByteArray(null);
- }
- else
- {
- out.writeByteArray(((BigInteger)value).toByteArray());
- }
- }
-
- public BigInteger readValue(CDODataInput in) throws IOException
- {
- byte[] array = in.readByteArray();
- if (array == null)
- {
- return null;
- }
-
- return new BigInteger(array);
- }
- };
-
- public static final CDOType OBJECT = new CDOTypeImpl("OBJECT", EcorePackage.EOBJECT, true, CDOID.NULL) //$NON-NLS-1$
- {
- public void writeValue(CDODataOutput out, Object value) throws IOException
- {
- if (value instanceof CDORevision)
- {
- out.writeCDOID(((CDORevision)value).getID());
- }
- else
- {
- out.writeCDOID((CDOID)value);
- }
- }
-
- public CDOID readValue(CDODataInput in) throws IOException
- {
- return in.readCDOID();
- }
-
- @Override
- public Object doAdjustReferences(CDOReferenceAdjuster adjuster, Object value, EStructuralFeature feature, int index)
- {
- return adjuster.adjustReference(value, feature, index);
- }
- };
-
- public static final CDOType BOOLEAN_OBJECT = new ObjectType("BOOLEAN_OBJECT", EcorePackage.EBOOLEAN_OBJECT) //$NON-NLS-1$
- {
- @Override
- protected void doWriteValue(CDODataOutput out, Object value) throws IOException
- {
- out.writeBoolean((Boolean)value);
- }
-
- @Override
- protected Boolean doReadValue(CDODataInput in) throws IOException
- {
- return in.readBoolean();
- }
- };
-
- public static final CDOType BYTE_OBJECT = new ObjectType("BYTE_OBJECT", EcorePackage.EBYTE_OBJECT) //$NON-NLS-1$
- {
- @Override
- protected void doWriteValue(CDODataOutput out, Object value) throws IOException
- {
- out.writeByte((Byte)value);
- }
-
- @Override
- protected Byte doReadValue(CDODataInput in) throws IOException
- {
- return in.readByte();
- }
- };
-
- public static final CDOType CHARACTER_OBJECT = new ObjectType("CHARACTER_OBJECT", EcorePackage.ECHARACTER_OBJECT) //$NON-NLS-1$
- {
- @Override
- protected void doWriteValue(CDODataOutput out, Object value) throws IOException
- {
- out.writeChar((Character)value);
- }
-
- @Override
- protected Character doReadValue(CDODataInput in) throws IOException
- {
- return in.readChar();
- }
- };
-
- public static final CDOType DATE = new ObjectType("DATE", EcorePackage.EDATE) //$NON-NLS-1$
- {
- @Override
- protected void doWriteValue(CDODataOutput out, Object value) throws IOException
- {
- out.writeLong(((Date)value).getTime());
- }
-
- @Override
- protected Date doReadValue(CDODataInput in) throws IOException
- {
- return new Date(in.readLong());
- }
- };
-
- public static final CDOType DOUBLE_OBJECT = new ObjectType("DOUBLE_OBJECT", EcorePackage.EDOUBLE_OBJECT) //$NON-NLS-1$
- {
- @Override
- protected void doWriteValue(CDODataOutput out, Object value) throws IOException
- {
- out.writeDouble((Double)value);
- }
-
- @Override
- protected Double doReadValue(CDODataInput in) throws IOException
- {
- return in.readDouble();
- }
- };
-
- public static final CDOType FLOAT_OBJECT = new ObjectType("FLOAT_OBJECT", EcorePackage.EFLOAT_OBJECT) //$NON-NLS-1$
- {
- @Override
- protected void doWriteValue(CDODataOutput out, Object value) throws IOException
- {
- out.writeFloat((Float)value);
- }
-
- @Override
- protected Float doReadValue(CDODataInput in) throws IOException
- {
- return in.readFloat();
- }
- };
-
- public static final CDOType INTEGER_OBJECT = new ObjectType("INTEGER_OBJECT", EcorePackage.EINTEGER_OBJECT) //$NON-NLS-1$
- {
- @Override
- protected void doWriteValue(CDODataOutput out, Object value) throws IOException
- {
- out.writeInt((Integer)value);
- }
-
- @Override
- protected Integer doReadValue(CDODataInput in) throws IOException
- {
- return in.readInt();
- }
- };
-
- public static final CDOType LONG_OBJECT = new ObjectType("LONG_OBJECT", EcorePackage.ELONG_OBJECT) //$NON-NLS-1$
- {
- @Override
- protected void doWriteValue(CDODataOutput out, Object value) throws IOException
- {
- out.writeLong((Long)value);
- }
-
- @Override
- protected Long doReadValue(CDODataInput in) throws IOException
- {
- return in.readLong();
- }
- };
-
- public static final CDOType SHORT_OBJECT = new ObjectType("SHORT_OBJECT", EcorePackage.ESHORT_OBJECT) //$NON-NLS-1$
- {
- @Override
- protected void doWriteValue(CDODataOutput out, Object value) throws IOException
- {
- out.writeShort((Short)value);
- }
-
- @Override
- protected Short doReadValue(CDODataInput in) throws IOException
- {
- return in.readShort();
- }
- };
-
- public static final CDOType STRING = new CDOTypeImpl("STRING", EcorePackage.ESTRING, true) //$NON-NLS-1$
- {
- @Override
- protected String doCopyValue(Object value)
- {
- return (String)value;
- }
-
- public void writeValue(CDODataOutput out, Object value) throws IOException
- {
- out.writeString((String)value);
- }
-
- public String readValue(CDODataInput in) throws IOException
- {
- return in.readString();
- }
- };
-
- public static final CDOType BYTE_ARRAY = new CDOTypeImpl("BYTE_ARRAY", EcorePackage.EBYTE_ARRAY, true) //$NON-NLS-1$
- {
- @Override
- protected byte[] doCopyValue(Object value)
- {
- byte[] array = (byte[])value;
- byte[] result = new byte[array.length];
- System.arraycopy(value, 0, result, 0, array.length);
- return result;
- }
-
- public void writeValue(CDODataOutput out, Object value) throws IOException
- {
- out.writeByteArray((byte[])value);
- }
-
- public byte[] readValue(CDODataInput in) throws IOException
- {
- return in.readByteArray();
- }
- };
-
- public static final CDOType FEATURE_MAP_ENTRY = new CDOTypeImpl("FEATURE_MAP_ENTRY", EcorePackage.EFEATURE_MAP_ENTRY, //$NON-NLS-1$
- false)
- {
- @Override
- protected FeatureMap.Entry doCopyValue(Object value)
- {
- FeatureMap.Entry entry = (FeatureMap.Entry)value;
- EStructuralFeature innerFeature = entry.getEStructuralFeature();
- Object innerValue = entry.getValue();
- CDOType innerType = CDOModelUtil.getType(innerFeature.getEType());
-
- Object innerCopy = innerType.copyValue(innerValue);
- return CDORevisionUtil.createFeatureMapEntry(innerFeature, innerCopy);
- }
-
- public void writeValue(CDODataOutput out, Object value) throws IOException
- {
- throw new UnsupportedOperationException();
- }
-
- public FeatureMap.Entry readValue(CDODataInput in) throws IOException
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Object doAdjustReferences(CDOReferenceAdjuster adjuster, Object value, EStructuralFeature feature, int index)
- {
- FeatureMap.Entry entry = (FeatureMap.Entry)value;
- EStructuralFeature innerFeature = entry.getEStructuralFeature();
- Object innerValue = entry.getValue();
- CDOType innerType = CDOModelUtil.getType(innerFeature.getEType());
-
- Object innerCopy = innerType.adjustReferences(adjuster, innerValue, feature, index);
- if (innerCopy != innerValue) // Just an optimization for NOOP adjusters
- {
- value = CDORevisionUtil.createFeatureMapEntry(innerFeature, innerCopy);
- }
-
- return value;
- }
- };
-
- public static final CDOType CUSTOM = new CDOTypeImpl("CUSTOM", 0, true) //$NON-NLS-1$
- {
- @Override
- protected String doCopyValue(Object value)
- {
- return (String)value;
- }
-
- public void writeValue(CDODataOutput out, Object value) throws IOException
- {
- out.writeString((String)value);
- }
-
- public String readValue(CDODataInput in) throws IOException
- {
- return in.readString();
- }
-
- @Override
- public Object convertToEMF(EClassifier eType, Object value)
- {
- return EcoreUtil.createFromString((EDataType)eType, (String)value);
- }
-
- @Override
- public Object convertToCDO(EClassifier eType, Object value)
- {
- return EcoreUtil.convertToString((EDataType)eType, value);
- }
- };
-
- /**
- * TODO Transfer integers!
- */
- public static final CDOType ENUM_ORDINAL = new ObjectType("ENUM_ORDINAL", -1) //$NON-NLS-1$
- {
- @Override
- protected Integer doCopyValue(Object value)
- {
- return (Integer)value;
- }
-
- @Override
- public void doWriteValue(CDODataOutput out, Object value) throws IOException
- {
- out.writeInt((Integer)value);
- }
-
- @Override
- public Integer doReadValue(CDODataInput in) throws IOException
- {
- return in.readInt();
- }
-
- @Override
- public Object convertToCDO(EClassifier type, Object value)
- {
- for (EEnumLiteral literal : ((EEnum)type).getELiterals())
- {
- if (literal == value || literal.getInstance() == value)
- {
- return literal.getValue();
- }
- }
-
- throw new IllegalStateException(MessageFormat.format(Messages.getString("CDOTypeImpl.23"), value)); //$NON-NLS-1$
- }
-
- @Override
- public Object convertToEMF(EClassifier type, Object value)
- {
- return ((EEnum)type).getEEnumLiteral((Integer)value).getInstance();
- }
- };
-
- public static final CDOType ENUM_LITERAL = new ObjectType("ENUM_LITERAL", -2) //$NON-NLS-1$
- {
- @Override
- protected void doWriteValue(CDODataOutput out, Object value) throws IOException
- {
- EEnum eEnum;
- if (value instanceof EEnumLiteral)
- {
- eEnum = ((EEnumLiteral)value).getEEnum();
- }
- else
- {
- eEnum = findEnum((InternalCDOPackageRegistry)out.getPackageRegistry(), value);
- }
-
- out.writeCDOClassifierRef(eEnum);
- out.writeInt(((Enumerator)value).getValue());
- }
-
- @Override
- protected Object doReadValue(CDODataInput in) throws IOException
- {
- EEnum eEnum = (EEnum)in.readCDOClassifierRefAndResolve();
- int ordinal = in.readInt();
-
- EEnumLiteral literal = eEnum.getEEnumLiteral(ordinal);
- if (literal == null)
- {
- throw new IllegalArgumentException("Enum literal " + ordinal + " not found in " + eEnum);
- }
-
- return literal.getInstance();
- }
-
- private EEnum findEnum(InternalCDOPackageRegistry registry, Object value)
- {
- Set<String> keys = registry.getAllKeys();
-
- // First try all the packages that are already resolved
- for (String nsURI : keys)
- {
- Object possiblePackage = registry.getWithDelegation(nsURI, false);
- if (possiblePackage instanceof EPackage)
- {
- EPackage ePackage = (EPackage)possiblePackage;
- EEnum eEnum = findEnum(ePackage, value);
- if (eEnum != null)
- {
- return eEnum;
- }
- }
- }
-
- // Then try all the package descriptors
- for (String nsURI : keys)
- {
- Object possiblePackage = registry.getWithDelegation(nsURI, false);
- if (possiblePackage instanceof EPackage.Descriptor)
- {
- EPackage ePackage = registry.getEPackage(nsURI);
- EEnum eEnum = findEnum(ePackage, value);
- if (eEnum != null)
- {
- return eEnum;
- }
- }
- }
-
- throw new IllegalArgumentException("EENum instance " + value.getClass().getName() + " not supported");
- }
-
- private EEnum findEnum(EPackage ePackage, Object value)
- {
- for (EClassifier eClassifier : ePackage.getEClassifiers())
- {
- if (eClassifier instanceof EEnum)
- {
- EEnum eEnum = (EEnum)eClassifier;
- if (eEnum.getInstanceClass() != null && eEnum.getInstanceClass() == value.getClass())
- {
- return eEnum;
- }
- }
- }
-
- return null;
- }
- };
-
- public static final CDOType BLOB = new CDOTypeImpl("BLOB", -3, true) //$NON-NLS-1$
- {
- public CDOBlob readValue(CDODataInput in) throws IOException
- {
- if (in.readBoolean())
- {
- return CDOLobUtil.readBlob(in);
- }
-
- return null;
- }
-
- public void writeValue(CDODataOutput out, Object value) throws IOException
- {
- if (value != null)
- {
- out.writeBoolean(true);
- CDOLobUtil.write(out, (CDOBlob)value);
- }
- else
- {
- out.writeBoolean(false);
- }
- }
- };
-
- public static final CDOType CLOB = new CDOTypeImpl("CLOB", -4, true) //$NON-NLS-1$
- {
- public CDOClob readValue(CDODataInput in) throws IOException
- {
- if (in.readBoolean())
- {
- return CDOLobUtil.readClob(in);
- }
-
- return null;
- }
-
- public void writeValue(CDODataOutput out, Object value) throws IOException
- {
- if (value != null)
- {
- out.writeBoolean(true);
- CDOLobUtil.write(out, (CDOClob)value);
- }
- else
- {
- out.writeBoolean(false);
- }
- }
- };
-
- public static final CDOType OBJECT_ARRAY = new ObjectType("OBJECT_ARRAY", -5) //$NON-NLS-1$
- {
- @Override
- protected void doWriteValue(CDODataOutput out, Object value) throws IOException
- {
- Object[] objects = (Object[])value;
- out.writeInt(objects.length);
- for (Object object : objects)
- {
- writeTypeAndValue(out, object);
- }
- }
-
- @Override
- protected Object[] doReadValue(CDODataInput in) throws IOException
- {
- int size = in.readInt();
- Object[] objects = new Object[size];
- for (int i = 0; i < size; i++)
- {
- objects[i] = readTypeAndValue(in);
- }
-
- return objects;
- }
-
- @Override
- public Object doAdjustReferences(CDOReferenceAdjuster adjuster, Object value, EStructuralFeature feature, int index)
- {
- Object[] objects = (Object[])value;
- int i = 0;
- for (Object object : objects)
- {
- if (object instanceof CDOID)
- {
- objects[i] = adjuster.adjustReference(object, feature, i);
- }
- else
- {
- objects[i] = object;
- }
-
- ++i;
- }
-
- return objects;
- }
- };
-
- public static final CDOType MAP = new ObjectType("MAP", -6) //$NON-NLS-1$
- {
- @SuppressWarnings("unchecked")
- @Override
- protected void doWriteValue(CDODataOutput out, Object value) throws IOException
- {
- Map<Object, Object> map = (Map<Object, Object>)value;
- out.writeInt(map.size());
-
- for (Entry<Object, Object> entry : map.entrySet())
- {
- writeTypeAndValue(out, entry.getKey());
- writeTypeAndValue(out, entry.getValue());
- }
- }
-
- @Override
- protected Map<Object, Object> doReadValue(CDODataInput in) throws IOException
- {
- Map<Object, Object> result = new HashMap<Object, Object>();
- int size = in.readInt();
- for (int i = 0; i < size; i++)
- {
- Object key = readTypeAndValue(in);
- Object value = readTypeAndValue(in);
- result.put(key, value == CDOID.NULL ? null : value);
- }
-
- return result;
- }
- };
-
- private String name;
-
- private byte typeID;
-
- private boolean canBeNull;
-
- private Object defaultValue;
-
- private CDOTypeImpl(String name, int typeID, boolean canBeNull, Object defaultValue)
- {
- ids[typeID - Byte.MIN_VALUE] = this;
-
- this.name = name;
- this.typeID = (byte)typeID;
- this.canBeNull = canBeNull;
- this.defaultValue = defaultValue;
- }
-
- private CDOTypeImpl(String name, int typeID, boolean canBeNull)
- {
- this(name, typeID, canBeNull, null);
- }
-
- public String getName()
- {
- return name;
- }
-
- public byte getTypeID()
- {
- return typeID;
- }
-
- public boolean canBeNull()
- {
- return canBeNull;
- }
-
- public Object getDefaultValue()
- {
- return defaultValue;
- }
-
- @Override
- public String toString()
- {
- return name;
- }
-
- public final Object copyValue(Object value)
- {
- if (value == null || value == CDORevisionData.NIL)
- {
- return value;
- }
-
- return doCopyValue(value);
- }
-
- protected Object doCopyValue(Object value)
- {
- return value;
- }
-
- public void write(CDODataOutput out) throws IOException
- {
- out.writeByte(typeID);
- }
-
- final public Object adjustReferences(CDOReferenceAdjuster adjuster, Object value, EStructuralFeature feature,
- int index)
- {
- return value == null ? null : doAdjustReferences(adjuster, value, feature, index);
- }
-
- protected Object doAdjustReferences(CDOReferenceAdjuster adjuster, Object value, EStructuralFeature feature,
- int indexs)
- {
- return value;
- }
-
- /**
- * @since 2.0
- */
- public Object convertToEMF(EClassifier feature, Object value)
- {
- return value;
- }
-
- /**
- * @since 2.0
- */
- public Object convertToCDO(EClassifier feature, Object value)
- {
- return value;
- }
-
- protected void writeTypeAndValue(CDODataOutput out, Object object) throws IOException
- {
- CDOType cdoType = CDOModelUtil.getTypeOfObject(object);
- out.writeByte(cdoType.getTypeID());
- cdoType.writeValue(out, object);
- }
-
- protected Object readTypeAndValue(CDODataInput in) throws IOException
- {
- byte typeID = in.readByte();
- CDOType cdoType = CDOModelUtil.getType(typeID);
- return cdoType.readValue(in);
- }
-
- public static CDOType getType(byte typeID)
- {
- CDOTypeImpl type = ids[typeID - Byte.MIN_VALUE];
- if (type == null)
- {
- throw new IllegalStateException(MessageFormat.format(Messages.getString("CDOModelUtil.6"), typeID));
- }
-
- return type;
- }
-
- /**
- * @author Eike Stepper
- */
- private static abstract class ObjectType extends CDOTypeImpl
- {
- public ObjectType(String name, int typeID)
- {
- super(name, typeID, true);
- }
-
- public final void writeValue(CDODataOutput out, Object value) throws IOException
- {
- if (value == null)
- {
- out.writeBoolean(false);
- }
- else
- {
- out.writeBoolean(true);
- doWriteValue(out, value);
- }
- }
-
- protected abstract void doWriteValue(CDODataOutput out, Object value) throws IOException;
-
- public final Object readValue(CDODataInput in) throws IOException
- {
- boolean notNull = in.readBoolean();
- if (notNull)
- {
- return doReadValue(in);
- }
-
- return null;
- }
-
- protected abstract Object doReadValue(CDODataInput in) throws IOException;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Stefan Winkler - Bug 299194: unsettable features inconsistent between revisions
+ * Erdal Karaca - added support for HASHMAP CDO Type
+ */
+package org.eclipse.emf.cdo.internal.common.model;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.lob.CDOBlob;
+import org.eclipse.emf.cdo.common.lob.CDOClob;
+import org.eclipse.emf.cdo.common.lob.CDOLobUtil;
+import org.eclipse.emf.cdo.common.model.CDOModelUtil;
+import org.eclipse.emf.cdo.common.model.CDOType;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionData;
+import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
+import org.eclipse.emf.cdo.internal.common.messages.Messages;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
+import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
+
+import org.eclipse.emf.common.util.Enumerator;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EEnumLiteral;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.util.FeatureMap;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.text.MessageFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class CDOTypeImpl implements CDOType
+{
+ private static CDOTypeImpl[] ids = new CDOTypeImpl[Byte.MAX_VALUE - Byte.MIN_VALUE + 1];
+
+ private static final byte BOOLEAN_DEFAULT_PRIMITIVE = 0;
+
+ private static final char CHARACTER_DEFAULT_PRIMITIVE = 0;
+
+ private static final short SHORT_DEFAULT_PRIMITIVE = 0;
+
+ public static final Boolean BOOLEAN_DEFAULT = new Boolean(false);
+
+ public static final Byte BYTE_DEFAULT = new Byte(BOOLEAN_DEFAULT_PRIMITIVE);
+
+ public static final Character CHARACTER_DEFAULT = new Character(CHARACTER_DEFAULT_PRIMITIVE);
+
+ public static final Double DOUBLE_DEFAULT = new Double(0.0);
+
+ public static final Float FLOAT_DEFAULT = new Float(0.0);
+
+ public static final Integer INTEGER_DEFAULT = new Integer(0);
+
+ public static final Long LONG_DEFAULT = new Long(0L);
+
+ public static final Short SHORT_DEFAULT = new Short(SHORT_DEFAULT_PRIMITIVE);
+
+ public static final CDOType BOOLEAN = new CDOTypeImpl("BOOLEAN", EcorePackage.EBOOLEAN, false, BOOLEAN_DEFAULT) //$NON-NLS-1$
+ {
+ public void writeValue(CDODataOutput out, Object value) throws IOException
+ {
+ boolean v = (Boolean)(value == null ? getDefaultValue() : value);
+ out.writeBoolean(v);
+ }
+
+ public Boolean readValue(CDODataInput in) throws IOException
+ {
+ return in.readBoolean();
+ }
+ };
+
+ public static final CDOType BYTE = new CDOTypeImpl("BYTE", EcorePackage.EBYTE, false, BYTE_DEFAULT) //$NON-NLS-1$
+ {
+ public void writeValue(CDODataOutput out, Object value) throws IOException
+ {
+ out.writeByte((Byte)(value == null ? getDefaultValue() : value));
+ }
+
+ public Byte readValue(CDODataInput in) throws IOException
+ {
+ return in.readByte();
+ }
+ };
+
+ public static final CDOType CHAR = new CDOTypeImpl("CHAR", EcorePackage.ECHAR, false, CHARACTER_DEFAULT) //$NON-NLS-1$
+ {
+ public void writeValue(CDODataOutput out, Object value) throws IOException
+ {
+ out.writeChar(((Character)(value == null ? getDefaultValue() : value)).charValue());
+ }
+
+ public Character readValue(CDODataInput in) throws IOException
+ {
+ return in.readChar();
+ }
+ };
+
+ public static final CDOType DOUBLE = new CDOTypeImpl("DOUBLE", EcorePackage.EDOUBLE, false, DOUBLE_DEFAULT) //$NON-NLS-1$
+ {
+ public void writeValue(CDODataOutput out, Object value) throws IOException
+ {
+ out.writeDouble((Double)(value == null ? getDefaultValue() : value));
+ }
+
+ public Double readValue(CDODataInput in) throws IOException
+ {
+ return in.readDouble();
+ }
+ };
+
+ public static final CDOType FLOAT = new CDOTypeImpl("FLOAT", EcorePackage.EFLOAT, false, FLOAT_DEFAULT) //$NON-NLS-1$
+ {
+ public void writeValue(CDODataOutput out, Object value) throws IOException
+ {
+ out.writeFloat((Float)(value == null ? getDefaultValue() : value));
+ }
+
+ public Float readValue(CDODataInput in) throws IOException
+ {
+ return in.readFloat();
+ }
+ };
+
+ public static final CDOType INT = new CDOTypeImpl("INT", EcorePackage.EINT, false, INTEGER_DEFAULT) //$NON-NLS-1$
+ {
+ public void writeValue(CDODataOutput out, Object value) throws IOException
+ {
+ out.writeInt((Integer)(value == null ? getDefaultValue() : value));
+ }
+
+ public Integer readValue(CDODataInput in) throws IOException
+ {
+ return in.readInt();
+ }
+ };
+
+ public static final CDOType LONG = new CDOTypeImpl("LONG", EcorePackage.ELONG, false, LONG_DEFAULT) //$NON-NLS-1$
+ {
+ public void writeValue(CDODataOutput out, Object value) throws IOException
+ {
+ out.writeLong((Long)(value == null ? getDefaultValue() : value));
+ }
+
+ public Long readValue(CDODataInput in) throws IOException
+ {
+ return in.readLong();
+ }
+ };
+
+ public static final CDOType SHORT = new CDOTypeImpl("SHORT", EcorePackage.ESHORT, false, SHORT_DEFAULT) //$NON-NLS-1$
+ {
+ public void writeValue(CDODataOutput out, Object value) throws IOException
+ {
+ out.writeShort((Short)(value == null ? getDefaultValue() : value));
+ }
+
+ public Short readValue(CDODataInput in) throws IOException
+ {
+ return in.readShort();
+ }
+ };
+
+ public static final CDOType BIG_DECIMAL = new CDOTypeImpl("BIG_DECIMAL", EcorePackage.EBIG_DECIMAL, true) //$NON-NLS-1$
+ {
+ public void writeValue(CDODataOutput out, Object value) throws IOException
+ {
+ if (value == null)
+ {
+ out.writeByteArray(null);
+ }
+ else
+ {
+ BigDecimal bigDecimal = (BigDecimal)value;
+ out.writeByteArray(bigDecimal.unscaledValue().toByteArray());
+ out.writeInt(bigDecimal.scale());
+ }
+ }
+
+ public BigDecimal readValue(CDODataInput in) throws IOException
+ {
+ byte[] array = in.readByteArray();
+ if (array == null)
+ {
+ return null;
+ }
+
+ BigInteger unscaled = new BigInteger(array);
+ int scale = in.readInt();
+ return new BigDecimal(unscaled, scale);
+ }
+ };
+
+ public static final CDOType BIG_INTEGER = new CDOTypeImpl("BIG_INTEGER", EcorePackage.EBIG_INTEGER, true) //$NON-NLS-1$
+ {
+ public void writeValue(CDODataOutput out, Object value) throws IOException
+ {
+ if (value == null)
+ {
+ out.writeByteArray(null);
+ }
+ else
+ {
+ out.writeByteArray(((BigInteger)value).toByteArray());
+ }
+ }
+
+ public BigInteger readValue(CDODataInput in) throws IOException
+ {
+ byte[] array = in.readByteArray();
+ if (array == null)
+ {
+ return null;
+ }
+
+ return new BigInteger(array);
+ }
+ };
+
+ public static final CDOType OBJECT = new CDOTypeImpl("OBJECT", EcorePackage.EOBJECT, true, CDOID.NULL) //$NON-NLS-1$
+ {
+ public void writeValue(CDODataOutput out, Object value) throws IOException
+ {
+ if (value instanceof CDORevision)
+ {
+ out.writeCDOID(((CDORevision)value).getID());
+ }
+ else
+ {
+ out.writeCDOID((CDOID)value);
+ }
+ }
+
+ public CDOID readValue(CDODataInput in) throws IOException
+ {
+ return in.readCDOID();
+ }
+
+ @Override
+ public Object doAdjustReferences(CDOReferenceAdjuster adjuster, Object value, EStructuralFeature feature, int index)
+ {
+ return adjuster.adjustReference(value, feature, index);
+ }
+ };
+
+ public static final CDOType BOOLEAN_OBJECT = new ObjectType("BOOLEAN_OBJECT", EcorePackage.EBOOLEAN_OBJECT) //$NON-NLS-1$
+ {
+ @Override
+ protected void doWriteValue(CDODataOutput out, Object value) throws IOException
+ {
+ out.writeBoolean((Boolean)value);
+ }
+
+ @Override
+ protected Boolean doReadValue(CDODataInput in) throws IOException
+ {
+ return in.readBoolean();
+ }
+ };
+
+ public static final CDOType BYTE_OBJECT = new ObjectType("BYTE_OBJECT", EcorePackage.EBYTE_OBJECT) //$NON-NLS-1$
+ {
+ @Override
+ protected void doWriteValue(CDODataOutput out, Object value) throws IOException
+ {
+ out.writeByte((Byte)value);
+ }
+
+ @Override
+ protected Byte doReadValue(CDODataInput in) throws IOException
+ {
+ return in.readByte();
+ }
+ };
+
+ public static final CDOType CHARACTER_OBJECT = new ObjectType("CHARACTER_OBJECT", EcorePackage.ECHARACTER_OBJECT) //$NON-NLS-1$
+ {
+ @Override
+ protected void doWriteValue(CDODataOutput out, Object value) throws IOException
+ {
+ out.writeChar((Character)value);
+ }
+
+ @Override
+ protected Character doReadValue(CDODataInput in) throws IOException
+ {
+ return in.readChar();
+ }
+ };
+
+ public static final CDOType DATE = new ObjectType("DATE", EcorePackage.EDATE) //$NON-NLS-1$
+ {
+ @Override
+ protected void doWriteValue(CDODataOutput out, Object value) throws IOException
+ {
+ out.writeLong(((Date)value).getTime());
+ }
+
+ @Override
+ protected Date doReadValue(CDODataInput in) throws IOException
+ {
+ return new Date(in.readLong());
+ }
+ };
+
+ public static final CDOType DOUBLE_OBJECT = new ObjectType("DOUBLE_OBJECT", EcorePackage.EDOUBLE_OBJECT) //$NON-NLS-1$
+ {
+ @Override
+ protected void doWriteValue(CDODataOutput out, Object value) throws IOException
+ {
+ out.writeDouble((Double)value);
+ }
+
+ @Override
+ protected Double doReadValue(CDODataInput in) throws IOException
+ {
+ return in.readDouble();
+ }
+ };
+
+ public static final CDOType FLOAT_OBJECT = new ObjectType("FLOAT_OBJECT", EcorePackage.EFLOAT_OBJECT) //$NON-NLS-1$
+ {
+ @Override
+ protected void doWriteValue(CDODataOutput out, Object value) throws IOException
+ {
+ out.writeFloat((Float)value);
+ }
+
+ @Override
+ protected Float doReadValue(CDODataInput in) throws IOException
+ {
+ return in.readFloat();
+ }
+ };
+
+ public static final CDOType INTEGER_OBJECT = new ObjectType("INTEGER_OBJECT", EcorePackage.EINTEGER_OBJECT) //$NON-NLS-1$
+ {
+ @Override
+ protected void doWriteValue(CDODataOutput out, Object value) throws IOException
+ {
+ out.writeInt((Integer)value);
+ }
+
+ @Override
+ protected Integer doReadValue(CDODataInput in) throws IOException
+ {
+ return in.readInt();
+ }
+ };
+
+ public static final CDOType LONG_OBJECT = new ObjectType("LONG_OBJECT", EcorePackage.ELONG_OBJECT) //$NON-NLS-1$
+ {
+ @Override
+ protected void doWriteValue(CDODataOutput out, Object value) throws IOException
+ {
+ out.writeLong((Long)value);
+ }
+
+ @Override
+ protected Long doReadValue(CDODataInput in) throws IOException
+ {
+ return in.readLong();
+ }
+ };
+
+ public static final CDOType SHORT_OBJECT = new ObjectType("SHORT_OBJECT", EcorePackage.ESHORT_OBJECT) //$NON-NLS-1$
+ {
+ @Override
+ protected void doWriteValue(CDODataOutput out, Object value) throws IOException
+ {
+ out.writeShort((Short)value);
+ }
+
+ @Override
+ protected Short doReadValue(CDODataInput in) throws IOException
+ {
+ return in.readShort();
+ }
+ };
+
+ public static final CDOType STRING = new CDOTypeImpl("STRING", EcorePackage.ESTRING, true) //$NON-NLS-1$
+ {
+ @Override
+ protected String doCopyValue(Object value)
+ {
+ return (String)value;
+ }
+
+ public void writeValue(CDODataOutput out, Object value) throws IOException
+ {
+ out.writeString((String)value);
+ }
+
+ public String readValue(CDODataInput in) throws IOException
+ {
+ return in.readString();
+ }
+ };
+
+ public static final CDOType BYTE_ARRAY = new CDOTypeImpl("BYTE_ARRAY", EcorePackage.EBYTE_ARRAY, true) //$NON-NLS-1$
+ {
+ @Override
+ protected byte[] doCopyValue(Object value)
+ {
+ byte[] array = (byte[])value;
+ byte[] result = new byte[array.length];
+ System.arraycopy(value, 0, result, 0, array.length);
+ return result;
+ }
+
+ public void writeValue(CDODataOutput out, Object value) throws IOException
+ {
+ out.writeByteArray((byte[])value);
+ }
+
+ public byte[] readValue(CDODataInput in) throws IOException
+ {
+ return in.readByteArray();
+ }
+ };
+
+ public static final CDOType FEATURE_MAP_ENTRY = new CDOTypeImpl("FEATURE_MAP_ENTRY", EcorePackage.EFEATURE_MAP_ENTRY, //$NON-NLS-1$
+ false)
+ {
+ @Override
+ protected FeatureMap.Entry doCopyValue(Object value)
+ {
+ FeatureMap.Entry entry = (FeatureMap.Entry)value;
+ EStructuralFeature innerFeature = entry.getEStructuralFeature();
+ Object innerValue = entry.getValue();
+ CDOType innerType = CDOModelUtil.getType(innerFeature.getEType());
+
+ Object innerCopy = innerType.copyValue(innerValue);
+ return CDORevisionUtil.createFeatureMapEntry(innerFeature, innerCopy);
+ }
+
+ public void writeValue(CDODataOutput out, Object value) throws IOException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public FeatureMap.Entry readValue(CDODataInput in) throws IOException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Object doAdjustReferences(CDOReferenceAdjuster adjuster, Object value, EStructuralFeature feature, int index)
+ {
+ FeatureMap.Entry entry = (FeatureMap.Entry)value;
+ EStructuralFeature innerFeature = entry.getEStructuralFeature();
+ Object innerValue = entry.getValue();
+ CDOType innerType = CDOModelUtil.getType(innerFeature.getEType());
+
+ Object innerCopy = innerType.adjustReferences(adjuster, innerValue, feature, index);
+ if (innerCopy != innerValue) // Just an optimization for NOOP adjusters
+ {
+ value = CDORevisionUtil.createFeatureMapEntry(innerFeature, innerCopy);
+ }
+
+ return value;
+ }
+ };
+
+ public static final CDOType CUSTOM = new CDOTypeImpl("CUSTOM", 0, true) //$NON-NLS-1$
+ {
+ @Override
+ protected String doCopyValue(Object value)
+ {
+ return (String)value;
+ }
+
+ public void writeValue(CDODataOutput out, Object value) throws IOException
+ {
+ out.writeString((String)value);
+ }
+
+ public String readValue(CDODataInput in) throws IOException
+ {
+ return in.readString();
+ }
+
+ @Override
+ public Object convertToEMF(EClassifier eType, Object value)
+ {
+ return EcoreUtil.createFromString((EDataType)eType, (String)value);
+ }
+
+ @Override
+ public Object convertToCDO(EClassifier eType, Object value)
+ {
+ return EcoreUtil.convertToString((EDataType)eType, value);
+ }
+ };
+
+ /**
+ * TODO Transfer integers!
+ */
+ public static final CDOType ENUM_ORDINAL = new ObjectType("ENUM_ORDINAL", -1) //$NON-NLS-1$
+ {
+ @Override
+ protected Integer doCopyValue(Object value)
+ {
+ return (Integer)value;
+ }
+
+ @Override
+ public void doWriteValue(CDODataOutput out, Object value) throws IOException
+ {
+ out.writeInt((Integer)value);
+ }
+
+ @Override
+ public Integer doReadValue(CDODataInput in) throws IOException
+ {
+ return in.readInt();
+ }
+
+ @Override
+ public Object convertToCDO(EClassifier type, Object value)
+ {
+ for (EEnumLiteral literal : ((EEnum)type).getELiterals())
+ {
+ if (literal == value || literal.getInstance() == value)
+ {
+ return literal.getValue();
+ }
+ }
+
+ throw new IllegalStateException(MessageFormat.format(Messages.getString("CDOTypeImpl.23"), value)); //$NON-NLS-1$
+ }
+
+ @Override
+ public Object convertToEMF(EClassifier type, Object value)
+ {
+ return ((EEnum)type).getEEnumLiteral((Integer)value).getInstance();
+ }
+ };
+
+ public static final CDOType ENUM_LITERAL = new ObjectType("ENUM_LITERAL", -2) //$NON-NLS-1$
+ {
+ @Override
+ protected void doWriteValue(CDODataOutput out, Object value) throws IOException
+ {
+ EEnum eEnum;
+ if (value instanceof EEnumLiteral)
+ {
+ eEnum = ((EEnumLiteral)value).getEEnum();
+ }
+ else
+ {
+ eEnum = findEnum((InternalCDOPackageRegistry)out.getPackageRegistry(), value);
+ }
+
+ out.writeCDOClassifierRef(eEnum);
+ out.writeInt(((Enumerator)value).getValue());
+ }
+
+ @Override
+ protected Object doReadValue(CDODataInput in) throws IOException
+ {
+ EEnum eEnum = (EEnum)in.readCDOClassifierRefAndResolve();
+ int ordinal = in.readInt();
+
+ EEnumLiteral literal = eEnum.getEEnumLiteral(ordinal);
+ if (literal == null)
+ {
+ throw new IllegalArgumentException("Enum literal " + ordinal + " not found in " + eEnum);
+ }
+
+ return literal.getInstance();
+ }
+
+ private EEnum findEnum(InternalCDOPackageRegistry registry, Object value)
+ {
+ Set<String> keys = registry.getAllKeys();
+
+ // First try all the packages that are already resolved
+ for (String nsURI : keys)
+ {
+ Object possiblePackage = registry.getWithDelegation(nsURI, false);
+ if (possiblePackage instanceof EPackage)
+ {
+ EPackage ePackage = (EPackage)possiblePackage;
+ EEnum eEnum = findEnum(ePackage, value);
+ if (eEnum != null)
+ {
+ return eEnum;
+ }
+ }
+ }
+
+ // Then try all the package descriptors
+ for (String nsURI : keys)
+ {
+ Object possiblePackage = registry.getWithDelegation(nsURI, false);
+ if (possiblePackage instanceof EPackage.Descriptor)
+ {
+ EPackage ePackage = registry.getEPackage(nsURI);
+ EEnum eEnum = findEnum(ePackage, value);
+ if (eEnum != null)
+ {
+ return eEnum;
+ }
+ }
+ }
+
+ throw new IllegalArgumentException("EENum instance " + value.getClass().getName() + " not supported");
+ }
+
+ private EEnum findEnum(EPackage ePackage, Object value)
+ {
+ for (EClassifier eClassifier : ePackage.getEClassifiers())
+ {
+ if (eClassifier instanceof EEnum)
+ {
+ EEnum eEnum = (EEnum)eClassifier;
+ if (eEnum.getInstanceClass() != null && eEnum.getInstanceClass() == value.getClass())
+ {
+ return eEnum;
+ }
+ }
+ }
+
+ return null;
+ }
+ };
+
+ public static final CDOType BLOB = new CDOTypeImpl("BLOB", -3, true) //$NON-NLS-1$
+ {
+ public CDOBlob readValue(CDODataInput in) throws IOException
+ {
+ if (in.readBoolean())
+ {
+ return CDOLobUtil.readBlob(in);
+ }
+
+ return null;
+ }
+
+ public void writeValue(CDODataOutput out, Object value) throws IOException
+ {
+ if (value != null)
+ {
+ out.writeBoolean(true);
+ CDOLobUtil.write(out, (CDOBlob)value);
+ }
+ else
+ {
+ out.writeBoolean(false);
+ }
+ }
+ };
+
+ public static final CDOType CLOB = new CDOTypeImpl("CLOB", -4, true) //$NON-NLS-1$
+ {
+ public CDOClob readValue(CDODataInput in) throws IOException
+ {
+ if (in.readBoolean())
+ {
+ return CDOLobUtil.readClob(in);
+ }
+
+ return null;
+ }
+
+ public void writeValue(CDODataOutput out, Object value) throws IOException
+ {
+ if (value != null)
+ {
+ out.writeBoolean(true);
+ CDOLobUtil.write(out, (CDOClob)value);
+ }
+ else
+ {
+ out.writeBoolean(false);
+ }
+ }
+ };
+
+ public static final CDOType OBJECT_ARRAY = new ObjectType("OBJECT_ARRAY", -5) //$NON-NLS-1$
+ {
+ @Override
+ protected void doWriteValue(CDODataOutput out, Object value) throws IOException
+ {
+ Object[] objects = (Object[])value;
+ out.writeInt(objects.length);
+ for (Object object : objects)
+ {
+ writeTypeAndValue(out, object);
+ }
+ }
+
+ @Override
+ protected Object[] doReadValue(CDODataInput in) throws IOException
+ {
+ int size = in.readInt();
+ Object[] objects = new Object[size];
+ for (int i = 0; i < size; i++)
+ {
+ objects[i] = readTypeAndValue(in);
+ }
+
+ return objects;
+ }
+
+ @Override
+ public Object doAdjustReferences(CDOReferenceAdjuster adjuster, Object value, EStructuralFeature feature, int index)
+ {
+ Object[] objects = (Object[])value;
+ int i = 0;
+ for (Object object : objects)
+ {
+ if (object instanceof CDOID)
+ {
+ objects[i] = adjuster.adjustReference(object, feature, i);
+ }
+ else
+ {
+ objects[i] = object;
+ }
+
+ ++i;
+ }
+
+ return objects;
+ }
+ };
+
+ public static final CDOType MAP = new ObjectType("MAP", -6) //$NON-NLS-1$
+ {
+ @SuppressWarnings("unchecked")
+ @Override
+ protected void doWriteValue(CDODataOutput out, Object value) throws IOException
+ {
+ Map<Object, Object> map = (Map<Object, Object>)value;
+ out.writeInt(map.size());
+
+ for (Entry<Object, Object> entry : map.entrySet())
+ {
+ writeTypeAndValue(out, entry.getKey());
+ writeTypeAndValue(out, entry.getValue());
+ }
+ }
+
+ @Override
+ protected Map<Object, Object> doReadValue(CDODataInput in) throws IOException
+ {
+ Map<Object, Object> result = new HashMap<Object, Object>();
+ int size = in.readInt();
+ for (int i = 0; i < size; i++)
+ {
+ Object key = readTypeAndValue(in);
+ Object value = readTypeAndValue(in);
+ result.put(key, value == CDOID.NULL ? null : value);
+ }
+
+ return result;
+ }
+ };
+
+ private String name;
+
+ private byte typeID;
+
+ private boolean canBeNull;
+
+ private Object defaultValue;
+
+ private CDOTypeImpl(String name, int typeID, boolean canBeNull, Object defaultValue)
+ {
+ ids[typeID - Byte.MIN_VALUE] = this;
+
+ this.name = name;
+ this.typeID = (byte)typeID;
+ this.canBeNull = canBeNull;
+ this.defaultValue = defaultValue;
+ }
+
+ private CDOTypeImpl(String name, int typeID, boolean canBeNull)
+ {
+ this(name, typeID, canBeNull, null);
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public byte getTypeID()
+ {
+ return typeID;
+ }
+
+ public boolean canBeNull()
+ {
+ return canBeNull;
+ }
+
+ public Object getDefaultValue()
+ {
+ return defaultValue;
+ }
+
+ @Override
+ public String toString()
+ {
+ return name;
+ }
+
+ public final Object copyValue(Object value)
+ {
+ if (value == null || value == CDORevisionData.NIL)
+ {
+ return value;
+ }
+
+ return doCopyValue(value);
+ }
+
+ protected Object doCopyValue(Object value)
+ {
+ return value;
+ }
+
+ public void write(CDODataOutput out) throws IOException
+ {
+ out.writeByte(typeID);
+ }
+
+ final public Object adjustReferences(CDOReferenceAdjuster adjuster, Object value, EStructuralFeature feature,
+ int index)
+ {
+ return value == null ? null : doAdjustReferences(adjuster, value, feature, index);
+ }
+
+ protected Object doAdjustReferences(CDOReferenceAdjuster adjuster, Object value, EStructuralFeature feature,
+ int indexs)
+ {
+ return value;
+ }
+
+ /**
+ * @since 2.0
+ */
+ public Object convertToEMF(EClassifier feature, Object value)
+ {
+ return value;
+ }
+
+ /**
+ * @since 2.0
+ */
+ public Object convertToCDO(EClassifier feature, Object value)
+ {
+ return value;
+ }
+
+ protected void writeTypeAndValue(CDODataOutput out, Object object) throws IOException
+ {
+ CDOType cdoType = CDOModelUtil.getTypeOfObject(object);
+ out.writeByte(cdoType.getTypeID());
+ cdoType.writeValue(out, object);
+ }
+
+ protected Object readTypeAndValue(CDODataInput in) throws IOException
+ {
+ byte typeID = in.readByte();
+ CDOType cdoType = CDOModelUtil.getType(typeID);
+ return cdoType.readValue(in);
+ }
+
+ public static CDOType getType(byte typeID)
+ {
+ CDOTypeImpl type = ids[typeID - Byte.MIN_VALUE];
+ if (type == null)
+ {
+ throw new IllegalStateException(MessageFormat.format(Messages.getString("CDOModelUtil.6"), typeID));
+ }
+
+ return type;
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static abstract class ObjectType extends CDOTypeImpl
+ {
+ public ObjectType(String name, int typeID)
+ {
+ super(name, typeID, true);
+ }
+
+ public final void writeValue(CDODataOutput out, Object value) throws IOException
+ {
+ if (value == null)
+ {
+ out.writeBoolean(false);
+ }
+ else
+ {
+ out.writeBoolean(true);
+ doWriteValue(out, value);
+ }
+ }
+
+ protected abstract void doWriteValue(CDODataOutput out, Object value) throws IOException;
+
+ public final Object readValue(CDODataInput in) throws IOException
+ {
+ boolean notNull = in.readBoolean();
+ if (notNull)
+ {
+ return doReadValue(in);
+ }
+
+ return null;
+ }
+
+ protected abstract Object doReadValue(CDODataInput in) throws IOException;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/GenUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/GenUtil.java
index b407d25fec..14794fe6b5 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/GenUtil.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/GenUtil.java
@@ -1,213 +1,213 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.model;
-
-import org.eclipse.net4j.util.StringUtil;
-
-import org.eclipse.emf.ecore.EClassifier;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public final class GenUtil
-{
- private GenUtil()
- {
- }
-
- /**
- * See GenGenBaseImpl.isPrimitiveType
- */
- public static boolean isPrimitiveType(EClassifier eType)
- {
- try
- {
- // J9 2.2 has problems assigning null to a Class variable.
- Object result = eType.getInstanceClass();
- if (result == null)
- {
- return false;
- }
-
- Class<?> instanceClass = (Class<?>)result;
- return instanceClass.isPrimitive();
- }
- catch (Exception e)
- {
- return false;
- }
- }
-
- /**
- * See GenFeatureImpl.getUpperName
- */
- public static String getFeatureUpperName(String featureName)
- {
- return format(featureName, '_', null, false, true).toUpperCase();
- }
-
- /**
- * See GenFeatureImpl.getGetAccessor
- */
- public static String getFeatureGetterName(String featureName, boolean isBooleanType)
- {
- String capName = StringUtil.cap(featureName);
- // if (isMapEntryFeature())
- // return "getTyped" + capName;
- String result = isBooleanType ? "is" + capName : "get" + ("Class".equals(capName) ? "Class_" : capName); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- // if (isListType() && !isFeatureMapType() && !isMapType() &&
- // getGenModel().isArrayAccessors())
- // {
- // result += "List";
- // }
-
- // GenClass rootImplementsInterface =
- // getGenModel().getRootImplementsInterfaceGenClass();
- // GenClass context = getContext();
- // if (rootImplementsInterface != null &&
- // !rootImplementsInterface.isEObject())
- // {
- // for (GenOperation genOperation :
- // rootImplementsInterface.getAllGenOperations())
- // {
- // if (genOperation.getName().equals(result) &&
- // genOperation.getGenParameters().isEmpty() &&
- // !genOperation.getType(context).equals(getType(context)))
- // {
- // result = result + "_";
- // break;
- // }
- // }
- // }
-
- return result;
- }
-
- /**
- * Formats a name by parsing it into words separated by underscores and/or mixed-casing and then recombining them
- * using the specified separator. A prefix can also be given to be recognized as a separate word or to be trimmed.
- * Leading underscores can be ignored or can cause a leading separator to be prepended.
- */
- public static String format(String name, char separator, String prefix, boolean includePrefix,
- boolean includeLeadingSeparator)
- {
- String leadingSeparators = includeLeadingSeparator ? getLeadingSeparators(name, '_') : null;
- if (leadingSeparators != null)
- {
- name = name.substring(leadingSeparators.length());
- }
-
- List<String> parsedName = new ArrayList<String>();
- if (prefix != null && name.startsWith(prefix) && name.length() > prefix.length()
- && Character.isUpperCase(name.charAt(prefix.length())))
- {
- name = name.substring(prefix.length());
- if (includePrefix)
- {
- parsedName = parseName(prefix, '_');
- }
- }
-
- if (name.length() != 0)
- {
- parsedName.addAll(parseName(name, '_'));
- }
-
- StringBuilder result = new StringBuilder();
-
- for (Iterator<String> nameIter = parsedName.iterator(); nameIter.hasNext();)
- {
- String nameComponent = nameIter.next();
- result.append(nameComponent);
-
- if (nameIter.hasNext() && nameComponent.length() > 1)
- {
- result.append(separator);
- }
- }
-
- if (result.length() == 0 && prefix != null)
- {
- result.append(prefix);
- }
-
- return leadingSeparators != null ? "_" + result.toString() : result.toString(); //$NON-NLS-1$
- }
-
- /**
- * This method breaks sourceName into words delimited by separator and/or mixed-case naming.
- */
- public static List<String> parseName(String sourceName, char separator)
- {
- List<String> result = new ArrayList<String>();
- if (sourceName != null)
- {
- StringBuilder currentWord = new StringBuilder();
- boolean lastIsLower = false;
- for (int index = 0, length = sourceName.length(); index < length; ++index)
- {
- char curChar = sourceName.charAt(index);
- if (Character.isUpperCase(curChar) || !lastIsLower && Character.isDigit(curChar) || curChar == separator)
- {
- if (lastIsLower && currentWord.length() > 1 || curChar == separator && currentWord.length() > 0)
- {
- result.add(currentWord.toString());
- currentWord = new StringBuilder();
- }
-
- lastIsLower = false;
- }
- else
- {
- if (!lastIsLower)
- {
- int currentWordLength = currentWord.length();
- if (currentWordLength > 1)
- {
- char lastChar = currentWord.charAt(--currentWordLength);
- currentWord.setLength(currentWordLength);
- result.add(currentWord.toString());
- currentWord = new StringBuilder();
- currentWord.append(lastChar);
- }
- }
-
- lastIsLower = true;
- }
-
- if (curChar != separator)
- {
- currentWord.append(curChar);
- }
- }
-
- result.add(currentWord.toString());
- }
-
- return result;
- }
-
- private static String getLeadingSeparators(String name, char separator)
- {
- int i = 0;
- for (int len = name.length(); i < len && name.charAt(i) == separator; i++)
- {
- // the for loop's condition finds the separator
- }
-
- return i != 0 ? name.substring(0, i) : null;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.model;
+
+import org.eclipse.net4j.util.StringUtil;
+
+import org.eclipse.emf.ecore.EClassifier;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public final class GenUtil
+{
+ private GenUtil()
+ {
+ }
+
+ /**
+ * See GenGenBaseImpl.isPrimitiveType
+ */
+ public static boolean isPrimitiveType(EClassifier eType)
+ {
+ try
+ {
+ // J9 2.2 has problems assigning null to a Class variable.
+ Object result = eType.getInstanceClass();
+ if (result == null)
+ {
+ return false;
+ }
+
+ Class<?> instanceClass = (Class<?>)result;
+ return instanceClass.isPrimitive();
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+ }
+
+ /**
+ * See GenFeatureImpl.getUpperName
+ */
+ public static String getFeatureUpperName(String featureName)
+ {
+ return format(featureName, '_', null, false, true).toUpperCase();
+ }
+
+ /**
+ * See GenFeatureImpl.getGetAccessor
+ */
+ public static String getFeatureGetterName(String featureName, boolean isBooleanType)
+ {
+ String capName = StringUtil.cap(featureName);
+ // if (isMapEntryFeature())
+ // return "getTyped" + capName;
+ String result = isBooleanType ? "is" + capName : "get" + ("Class".equals(capName) ? "Class_" : capName); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ // if (isListType() && !isFeatureMapType() && !isMapType() &&
+ // getGenModel().isArrayAccessors())
+ // {
+ // result += "List";
+ // }
+
+ // GenClass rootImplementsInterface =
+ // getGenModel().getRootImplementsInterfaceGenClass();
+ // GenClass context = getContext();
+ // if (rootImplementsInterface != null &&
+ // !rootImplementsInterface.isEObject())
+ // {
+ // for (GenOperation genOperation :
+ // rootImplementsInterface.getAllGenOperations())
+ // {
+ // if (genOperation.getName().equals(result) &&
+ // genOperation.getGenParameters().isEmpty() &&
+ // !genOperation.getType(context).equals(getType(context)))
+ // {
+ // result = result + "_";
+ // break;
+ // }
+ // }
+ // }
+
+ return result;
+ }
+
+ /**
+ * Formats a name by parsing it into words separated by underscores and/or mixed-casing and then recombining them
+ * using the specified separator. A prefix can also be given to be recognized as a separate word or to be trimmed.
+ * Leading underscores can be ignored or can cause a leading separator to be prepended.
+ */
+ public static String format(String name, char separator, String prefix, boolean includePrefix,
+ boolean includeLeadingSeparator)
+ {
+ String leadingSeparators = includeLeadingSeparator ? getLeadingSeparators(name, '_') : null;
+ if (leadingSeparators != null)
+ {
+ name = name.substring(leadingSeparators.length());
+ }
+
+ List<String> parsedName = new ArrayList<String>();
+ if (prefix != null && name.startsWith(prefix) && name.length() > prefix.length()
+ && Character.isUpperCase(name.charAt(prefix.length())))
+ {
+ name = name.substring(prefix.length());
+ if (includePrefix)
+ {
+ parsedName = parseName(prefix, '_');
+ }
+ }
+
+ if (name.length() != 0)
+ {
+ parsedName.addAll(parseName(name, '_'));
+ }
+
+ StringBuilder result = new StringBuilder();
+
+ for (Iterator<String> nameIter = parsedName.iterator(); nameIter.hasNext();)
+ {
+ String nameComponent = nameIter.next();
+ result.append(nameComponent);
+
+ if (nameIter.hasNext() && nameComponent.length() > 1)
+ {
+ result.append(separator);
+ }
+ }
+
+ if (result.length() == 0 && prefix != null)
+ {
+ result.append(prefix);
+ }
+
+ return leadingSeparators != null ? "_" + result.toString() : result.toString(); //$NON-NLS-1$
+ }
+
+ /**
+ * This method breaks sourceName into words delimited by separator and/or mixed-case naming.
+ */
+ public static List<String> parseName(String sourceName, char separator)
+ {
+ List<String> result = new ArrayList<String>();
+ if (sourceName != null)
+ {
+ StringBuilder currentWord = new StringBuilder();
+ boolean lastIsLower = false;
+ for (int index = 0, length = sourceName.length(); index < length; ++index)
+ {
+ char curChar = sourceName.charAt(index);
+ if (Character.isUpperCase(curChar) || !lastIsLower && Character.isDigit(curChar) || curChar == separator)
+ {
+ if (lastIsLower && currentWord.length() > 1 || curChar == separator && currentWord.length() > 0)
+ {
+ result.add(currentWord.toString());
+ currentWord = new StringBuilder();
+ }
+
+ lastIsLower = false;
+ }
+ else
+ {
+ if (!lastIsLower)
+ {
+ int currentWordLength = currentWord.length();
+ if (currentWordLength > 1)
+ {
+ char lastChar = currentWord.charAt(--currentWordLength);
+ currentWord.setLength(currentWordLength);
+ result.add(currentWord.toString());
+ currentWord = new StringBuilder();
+ currentWord.append(lastChar);
+ }
+ }
+
+ lastIsLower = true;
+ }
+
+ if (curChar != separator)
+ {
+ currentWord.append(curChar);
+ }
+ }
+
+ result.add(currentWord.toString());
+ }
+
+ return result;
+ }
+
+ private static String getLeadingSeparators(String name, char separator)
+ {
+ int i = 0;
+ for (int len = name.length(); i < len && name.charAt(i) == separator; i++)
+ {
+ // the for loop's condition finds the separator
+ }
+
+ return i != 0 ? name.substring(0, i) : null;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/protocol/CDODataInputImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/protocol/CDODataInputImpl.java
index c37dd98f69..9013a9485b 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/protocol/CDODataInputImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/protocol/CDODataInputImpl.java
@@ -1,651 +1,651 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - bug 213402
- */
-package org.eclipse.emf.cdo.internal.common.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
-import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-import org.eclipse.emf.cdo.common.commit.CDOCommitData;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOID.Type;
-import org.eclipse.emf.cdo.common.id.CDOIDReference;
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-import org.eclipse.emf.cdo.common.lob.CDOLob;
-import org.eclipse.emf.cdo.common.lob.CDOLobStore;
-import org.eclipse.emf.cdo.common.lob.CDOLobUtil;
-import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo;
-import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo.Operation;
-import org.eclipse.emf.cdo.common.lock.CDOLockOwner;
-import org.eclipse.emf.cdo.common.lock.CDOLockState;
-import org.eclipse.emf.cdo.common.lock.CDOLockUtil;
-import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea;
-import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockGrade;
-import org.eclipse.emf.cdo.common.model.CDOClassifierRef;
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
-import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.model.CDOType;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
-import org.eclipse.emf.cdo.common.revision.CDOList;
-import org.eclipse.emf.cdo.common.revision.CDOListFactory;
-import org.eclipse.emf.cdo.common.revision.CDORevisable;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-import org.eclipse.emf.cdo.internal.common.bundle.OM;
-import org.eclipse.emf.cdo.internal.common.commit.CDOChangeSetDataImpl;
-import org.eclipse.emf.cdo.internal.common.commit.CDOCommitDataImpl;
-import org.eclipse.emf.cdo.internal.common.commit.FailureCommitInfo;
-import org.eclipse.emf.cdo.internal.common.id.CDOIDExternalImpl;
-import org.eclipse.emf.cdo.internal.common.id.CDOIDObjectLongImpl;
-import org.eclipse.emf.cdo.internal.common.id.CDOIDTempObjectExternalImpl;
-import org.eclipse.emf.cdo.internal.common.id.CDOIDTempObjectImpl;
-import org.eclipse.emf.cdo.internal.common.lock.CDOLockAreaImpl;
-import org.eclipse.emf.cdo.internal.common.lock.CDOLockChangeInfoImpl;
-import org.eclipse.emf.cdo.internal.common.lock.CDOLockOwnerImpl;
-import org.eclipse.emf.cdo.internal.common.lock.CDOLockStateImpl;
-import org.eclipse.emf.cdo.internal.common.messages.Messages;
-import org.eclipse.emf.cdo.internal.common.revision.CDOIDAndBranchImpl;
-import org.eclipse.emf.cdo.internal.common.revision.CDOIDAndVersionImpl;
-import org.eclipse.emf.cdo.internal.common.revision.delta.CDOAddFeatureDeltaImpl;
-import org.eclipse.emf.cdo.internal.common.revision.delta.CDOClearFeatureDeltaImpl;
-import org.eclipse.emf.cdo.internal.common.revision.delta.CDOContainerFeatureDeltaImpl;
-import org.eclipse.emf.cdo.internal.common.revision.delta.CDOListFeatureDeltaImpl;
-import org.eclipse.emf.cdo.internal.common.revision.delta.CDOMoveFeatureDeltaImpl;
-import org.eclipse.emf.cdo.internal.common.revision.delta.CDORemoveFeatureDeltaImpl;
-import org.eclipse.emf.cdo.internal.common.revision.delta.CDORevisionDeltaImpl;
-import org.eclipse.emf.cdo.internal.common.revision.delta.CDOSetFeatureDeltaImpl;
-import org.eclipse.emf.cdo.internal.common.revision.delta.CDOUnsetFeatureDeltaImpl;
-import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOID;
-import org.eclipse.emf.cdo.spi.common.lock.InternalCDOLockState;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOList;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
-import org.eclipse.net4j.util.io.ExtendedDataInput;
-import org.eclipse.net4j.util.io.StringIO;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.util.FeatureMapUtil;
-
-import java.io.IOException;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public abstract class CDODataInputImpl extends ExtendedDataInput.Delegating implements CDODataInput
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, CDODataInputImpl.class);
-
- public CDODataInputImpl(ExtendedDataInput delegate)
- {
- super(delegate);
- }
-
- public CDOPackageUnit readCDOPackageUnit(ResourceSet resourceSet) throws IOException
- {
- InternalCDOPackageUnit packageUnit = (InternalCDOPackageUnit)CDOModelUtil.createPackageUnit();
- packageUnit.read(this, resourceSet);
- return packageUnit;
- }
-
- public CDOPackageUnit[] readCDOPackageUnits(ResourceSet resourceSet) throws IOException
- {
- int size = readInt();
- if (TRACER.isEnabled())
- {
- TRACER.format("Reading {0} package units", size); //$NON-NLS-1$
- }
-
- CDOPackageUnit[] packageUnits = new CDOPackageUnit[size];
- for (int i = 0; i < size; i++)
- {
- packageUnits[i] = readCDOPackageUnit(resourceSet);
- }
-
- return packageUnits;
- }
-
- public CDOPackageUnit.Type readCDOPackageUnitType() throws IOException
- {
- return CDOPackageUnit.Type.values()[readByte()];
- }
-
- public CDOPackageInfo readCDOPackageInfo() throws IOException
- {
- InternalCDOPackageInfo packageInfo = (InternalCDOPackageInfo)CDOModelUtil.createPackageInfo();
- packageInfo.read(this);
- return packageInfo;
- }
-
- public String readCDOPackageURI() throws IOException
- {
- return getPackageURICompressor().read(this);
- }
-
- public CDOClassifierRef readCDOClassifierRef() throws IOException
- {
- return new CDOClassifierRef(this);
- }
-
- public EClassifier readCDOClassifierRefAndResolve() throws IOException
- {
- CDOClassifierRef classifierRef = readCDOClassifierRef();
- EClassifier classifier = classifierRef.resolve(getPackageRegistry());
- if (classifier == null)
- {
- throw new IOException("Unable to resolve " + classifierRef);
- }
-
- return classifier;
- }
-
- public CDOType readCDOType() throws IOException
- {
- byte typeID = readByte();
- return CDOModelUtil.getType(typeID);
- }
-
- public CDOBranch readCDOBranch() throws IOException
- {
- int branchID = readInt();
- return getBranchManager().getBranch(branchID);
- }
-
- public CDOBranchPoint readCDOBranchPoint() throws IOException
- {
- CDOBranch branch = readCDOBranch();
- long timeStamp = readLong();
- return branch.getPoint(timeStamp);
- }
-
- public CDOBranchVersion readCDOBranchVersion() throws IOException
- {
- CDOBranch branch = readCDOBranch();
- int version = readInt();
- return branch.getVersion(version);
- }
-
- public CDOChangeSetData readCDOChangeSetData() throws IOException
- {
- int size1 = readInt();
- List<CDOIDAndVersion> newObjects = new ArrayList<CDOIDAndVersion>(size1);
- for (int i = 0; i < size1; i++)
- {
- boolean revision = readBoolean();
- CDOIDAndVersion data = revision ? readCDORevision() : readCDOIDAndVersion();
- newObjects.add(data);
- }
-
- int size2 = readInt();
- List<CDORevisionKey> changedObjects = new ArrayList<CDORevisionKey>(size2);
- for (int i = 0; i < size2; i++)
- {
- boolean delta = readBoolean();
- CDORevisionKey data = delta ? readCDORevisionDelta() : readCDORevisionKey();
- changedObjects.add(data);
- }
-
- int size3 = readInt();
- List<CDOIDAndVersion> detachedObjects = new ArrayList<CDOIDAndVersion>(size3);
- for (int i = 0; i < size3; i++)
- {
- CDOIDAndVersion data = readCDOIDAndVersion();
- detachedObjects.add(data);
- }
-
- return new CDOChangeSetDataImpl(newObjects, changedObjects, detachedObjects);
- }
-
- public CDOCommitData readCDOCommitData() throws IOException
- {
- InternalCDOPackageRegistry packageRegistry = (InternalCDOPackageRegistry)getPackageRegistry();
- ResourceSet resourceSet = new ResourceSetImpl();
- resourceSet.setPackageRegistry(packageRegistry);
-
- int size = readInt();
- List<CDOPackageUnit> newPackageUnits = new ArrayList<CDOPackageUnit>(size);
- for (int i = 0; i < size; i++)
- {
- CDOPackageUnit data = readCDOPackageUnit(resourceSet);
- newPackageUnits.add(data);
- packageRegistry.putPackageUnit((InternalCDOPackageUnit)data);
- }
-
- CDOChangeSetData data = readCDOChangeSetData();
- return new CDOCommitDataImpl(newPackageUnits, data.getNewObjects(), data.getChangedObjects(),
- data.getDetachedObjects());
- }
-
- public CDOCommitInfo readCDOCommitInfo() throws IOException
- {
- long timeStamp = readLong();
- long previousTimeStamp = readLong();
-
- if (readBoolean())
- {
- CDOBranch branch = readCDOBranch();
- String userID = readString();
- String comment = readString();
- CDOCommitData commitData = readCDOCommitData();
-
- InternalCDOCommitInfoManager commitInfoManager = (InternalCDOCommitInfoManager)getCommitInfoManager();
- return commitInfoManager.createCommitInfo(branch, timeStamp, previousTimeStamp, userID, comment, commitData);
- }
-
- return new FailureCommitInfo(timeStamp, previousTimeStamp);
- }
-
- public CDOLockChangeInfo readCDOLockChangeInfo() throws IOException
- {
- boolean isInvalidateAll = readBoolean();
- if (isInvalidateAll)
- {
- return CDOLockUtil.createLockChangeInfo();
- }
-
- CDOBranchPoint branchPoint = readCDOBranchPoint();
- CDOLockOwner lockOwner = readCDOLockOwner();
- Operation operation = readEnum(Operation.class);
- LockType lockType = readCDOLockType();
-
- int n = readInt();
- CDOLockState[] lockStates = new CDOLockState[n];
- for (int i = 0; i < n; i++)
- {
- lockStates[i] = readCDOLockState();
- }
-
- return new CDOLockChangeInfoImpl(branchPoint, lockOwner, lockStates, operation, lockType);
- }
-
- public LockArea readCDOLockArea() throws IOException
- {
- String durableLockingID = readString();
- CDOBranch branch = readCDOBranch();
- long timestamp = readLong();
- String userID = readString();
- boolean readOnly = readBoolean();
-
- int nLockStates = readInt();
- Map<CDOID, LockGrade> locks = new HashMap<CDOID, LockGrade>();
- for (int i = 0; i < nLockStates; i++)
- {
- CDOID key = readCDOID();
- LockGrade value = readEnum(LockGrade.class);
- locks.put(key, value);
- }
-
- return new CDOLockAreaImpl(durableLockingID, userID, branch.getPoint(timestamp), readOnly, locks);
- }
-
- public CDOLockOwner readCDOLockOwner() throws IOException
- {
- int session = readInt();
- int view = readInt();
- String lockAreaID = readString();
- boolean isDurableView = readBoolean();
- return new CDOLockOwnerImpl(session, view, lockAreaID, isDurableView);
- }
-
- public CDOLockState readCDOLockState() throws IOException
- {
- Object target;
- boolean sendingBranchWithID = readBoolean();
- if (!sendingBranchWithID)
- {
- target = readCDOID();
- }
- else
- {
- target = readCDOIDAndBranch();
- }
-
- InternalCDOLockState lockState = new CDOLockStateImpl(target);
-
- int nReadLockOwners = readInt();
- for (int i = 0; i < nReadLockOwners; i++)
- {
- CDOLockOwner lockOwner = readCDOLockOwner();
- lockState.addReadLockOwner(lockOwner);
- }
-
- boolean hasWriteLock = readBoolean();
- if (hasWriteLock)
- {
- CDOLockOwner lockOwner = readCDOLockOwner();
- lockState.setWriteLockOwner(lockOwner);
- }
-
- boolean hasWriteOption = readBoolean();
- if (hasWriteOption)
- {
- CDOLockOwner lockOwner = readCDOLockOwner();
- lockState.setWriteOptionOwner(lockOwner);
- }
-
- return lockState;
- }
-
- public LockType readCDOLockType() throws IOException
- {
- return readEnum(LockType.class);
- }
-
- public CDOID readCDOID() throws IOException
- {
- byte ordinal = readByte();
-
- // A subtype of OBJECT
- if (ordinal < 0)
- {
- // The ordinal value is negated in the stream to distinguish from the main type.
- // Note: Added 1 because ordinal start at 0, so correct by minus 1.
- return readCDOIDObject(-ordinal - 1);
- }
-
- if (TRACER.isEnabled())
- {
- String type;
- try
- {
- type = Type.values()[ordinal].toString();
- }
- catch (RuntimeException ex)
- {
- type = ex.getMessage();
- }
-
- TRACER.format("Reading CDOID of type {0} ({1})", ordinal, type); //$NON-NLS-1$
- }
-
- Type type = Type.values()[ordinal];
- switch (type)
- {
- case NULL:
- return CDOID.NULL;
-
- case TEMP_OBJECT:
- return new CDOIDTempObjectImpl(readInt());
-
- case EXTERNAL_OBJECT:
- return new CDOIDExternalImpl(readString());
-
- case EXTERNAL_TEMP_OBJECT:
- return new CDOIDTempObjectExternalImpl(readString());
-
- case OBJECT:
- {
- // should normally not occur is handled by
- // readCDOIDObject, code remains here
- // for backward compatibility
- AbstractCDOID id = new CDOIDObjectLongImpl();
- id.read(this);
- return id;
- }
-
- default:
- throw new IOException("Illegal type: " + type);
- }
- }
-
- private CDOID readCDOIDObject(int subTypeOrdinal) throws IOException
- {
- if (TRACER.isEnabled())
- {
- String subType;
-
- try
- {
- subType = CDOID.ObjectType.values()[subTypeOrdinal].toString();
- }
- catch (RuntimeException ex)
- {
- subType = ex.getMessage();
- }
-
- TRACER.format("Reading CDOIDObject of sub type {0} ({1})", subTypeOrdinal, subType); //$NON-NLS-1$
- }
-
- CDOID.ObjectType subType = CDOID.ObjectType.values()[subTypeOrdinal];
- AbstractCDOID id = CDOIDUtil.createCDOIDObject(subType);
- id.read(this);
- return id;
- }
-
- public CDOIDReference readCDOIDReference() throws IOException
- {
- return new CDOIDReference(this);
- }
-
- public CDOIDAndVersion readCDOIDAndVersion() throws IOException
- {
- CDOID id = readCDOID();
- int version = readInt();
- return new CDOIDAndVersionImpl(id, version);
- }
-
- public CDOIDAndBranch readCDOIDAndBranch() throws IOException
- {
- CDOID id = readCDOID();
- CDOBranch branch = readCDOBranch();
- return new CDOIDAndBranchImpl(id, branch);
- }
-
- public CDORevisionKey readCDORevisionKey() throws IOException
- {
- CDOID id = readCDOID();
- CDOBranch branch = readCDOBranch();
- int version = readInt();
- return CDORevisionUtil.createRevisionKey(id, branch, version);
- }
-
- public CDORevision readCDORevision() throws IOException
- {
- return readCDORevision(true);
- }
-
- public CDORevision readCDORevision(boolean freeze) throws IOException
- {
- boolean notNull = readBoolean();
- if (notNull)
- {
- InternalCDORevision revision = (InternalCDORevision)getRevisionFactory().createRevision(null);
- revision.read(this);
-
- if (freeze)
- {
- revision.freeze();
- }
-
- return revision;
- }
-
- return null;
- }
-
- public CDORevisable readCDORevisable() throws IOException
- {
- CDOBranch branch = readCDOBranch();
- int version = readInt();
- long timeStamp = readLong();
- long revised = readLong();
- return CDORevisionUtil.createRevisable(branch, version, timeStamp, revised);
- }
-
- public CDOList readCDOList(EClass owner, EStructuralFeature feature) throws IOException
- {
- int referenceChunk;
- int size = readInt();
- if (size < 0)
- {
- size = -size;
- referenceChunk = readInt();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read feature {0}: size={1}, referenceChunk={2}", feature.getName(), size, referenceChunk); //$NON-NLS-1$
- }
- }
- else
- {
- referenceChunk = size;
- if (TRACER.isEnabled())
- {
- TRACER.format("Read feature {0}: size={1}", feature.getName(), size); //$NON-NLS-1$
- }
- }
-
- Object value = null;
- CDOType type = null;
- boolean isFeatureMap = FeatureMapUtil.isFeatureMap(feature);
- if (!isFeatureMap)
- {
- type = CDOModelUtil.getType(feature.getEType());
- }
-
- InternalCDOList list = (InternalCDOList)getListFactory().createList(size, size, referenceChunk);
- for (int j = 0; j < referenceChunk; j++)
- {
- if (isFeatureMap)
- {
- int featureID = readInt();
- EStructuralFeature innerFeature = owner.getEStructuralFeature(featureID);
- type = CDOModelUtil.getType(innerFeature.getEType());
- value = type.readValue(this);
- value = CDORevisionUtil.createFeatureMapEntry(innerFeature, value);
- }
- else
- {
- value = type.readValue(this);
- }
-
- list.set(j, value);
- if (TRACER.isEnabled())
- {
- TRACER.trace(" " + value); //$NON-NLS-1$
- }
- }
-
- return list;
- }
-
- public Object readCDOFeatureValue(EStructuralFeature feature) throws IOException
- {
- CDOType type = CDOModelUtil.getType(feature);
- Object value = type.readValue(this);
- if (value instanceof CDOLob<?>)
- {
- CDOLob<?> lob = (CDOLob<?>)value;
- CDOLobUtil.setStore(getLobStore(), lob);
- }
-
- return value;
- }
-
- public CDORevisionDelta readCDORevisionDelta() throws IOException
- {
- return new CDORevisionDeltaImpl(this);
- }
-
- public CDOFeatureDelta readCDOFeatureDelta(EClass owner) throws IOException
- {
- int typeOrdinal = readInt();
- CDOFeatureDelta.Type type = CDOFeatureDelta.Type.values()[typeOrdinal];
- switch (type)
- {
- case ADD:
- return new CDOAddFeatureDeltaImpl(this, owner);
-
- case SET:
- return new CDOSetFeatureDeltaImpl(this, owner);
-
- case LIST:
- return new CDOListFeatureDeltaImpl(this, owner);
-
- case MOVE:
- return new CDOMoveFeatureDeltaImpl(this, owner);
-
- case CLEAR:
- return new CDOClearFeatureDeltaImpl(this, owner);
-
- case REMOVE:
- return new CDORemoveFeatureDeltaImpl(this, owner);
-
- case CONTAINER:
- return new CDOContainerFeatureDeltaImpl(this, owner);
-
- case UNSET:
- return new CDOUnsetFeatureDeltaImpl(this, owner);
-
- default:
- throw new IOException(MessageFormat.format(Messages.getString("CDODataInputImpl.5"), typeOrdinal)); //$NON-NLS-1$
- }
- }
-
- public Object readCDORevisionOrPrimitive() throws IOException
- {
- CDOType type = readCDOType();
- return type.readValue(this);
- }
-
- public Object readCDORevisionOrPrimitiveOrClassifier() throws IOException
- {
- boolean isClassifier = readBoolean();
- if (isClassifier)
- {
- return readCDOClassifierRefAndResolve();
- }
-
- return readCDORevisionOrPrimitive();
- }
-
- protected StringIO getPackageURICompressor()
- {
- return StringIO.DIRECT;
- }
-
- protected abstract CDOPackageRegistry getPackageRegistry();
-
- protected abstract CDOBranchManager getBranchManager();
-
- protected abstract CDOCommitInfoManager getCommitInfoManager();
-
- protected abstract CDORevisionFactory getRevisionFactory();
-
- protected abstract CDOListFactory getListFactory();
-
- protected abstract CDOLobStore getLobStore();
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Simon McDuff - bug 213402
+ */
+package org.eclipse.emf.cdo.internal.common.protocol;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
+import org.eclipse.emf.cdo.common.commit.CDOCommitData;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOID.Type;
+import org.eclipse.emf.cdo.common.id.CDOIDReference;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
+import org.eclipse.emf.cdo.common.lob.CDOLob;
+import org.eclipse.emf.cdo.common.lob.CDOLobStore;
+import org.eclipse.emf.cdo.common.lob.CDOLobUtil;
+import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo;
+import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo.Operation;
+import org.eclipse.emf.cdo.common.lock.CDOLockOwner;
+import org.eclipse.emf.cdo.common.lock.CDOLockState;
+import org.eclipse.emf.cdo.common.lock.CDOLockUtil;
+import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea;
+import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockGrade;
+import org.eclipse.emf.cdo.common.model.CDOClassifierRef;
+import org.eclipse.emf.cdo.common.model.CDOModelUtil;
+import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
+import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
+import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
+import org.eclipse.emf.cdo.common.model.CDOType;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
+import org.eclipse.emf.cdo.common.revision.CDOList;
+import org.eclipse.emf.cdo.common.revision.CDOListFactory;
+import org.eclipse.emf.cdo.common.revision.CDORevisable;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
+import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
+import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.internal.common.bundle.OM;
+import org.eclipse.emf.cdo.internal.common.commit.CDOChangeSetDataImpl;
+import org.eclipse.emf.cdo.internal.common.commit.CDOCommitDataImpl;
+import org.eclipse.emf.cdo.internal.common.commit.FailureCommitInfo;
+import org.eclipse.emf.cdo.internal.common.id.CDOIDExternalImpl;
+import org.eclipse.emf.cdo.internal.common.id.CDOIDObjectLongImpl;
+import org.eclipse.emf.cdo.internal.common.id.CDOIDTempObjectExternalImpl;
+import org.eclipse.emf.cdo.internal.common.id.CDOIDTempObjectImpl;
+import org.eclipse.emf.cdo.internal.common.lock.CDOLockAreaImpl;
+import org.eclipse.emf.cdo.internal.common.lock.CDOLockChangeInfoImpl;
+import org.eclipse.emf.cdo.internal.common.lock.CDOLockOwnerImpl;
+import org.eclipse.emf.cdo.internal.common.lock.CDOLockStateImpl;
+import org.eclipse.emf.cdo.internal.common.messages.Messages;
+import org.eclipse.emf.cdo.internal.common.revision.CDOIDAndBranchImpl;
+import org.eclipse.emf.cdo.internal.common.revision.CDOIDAndVersionImpl;
+import org.eclipse.emf.cdo.internal.common.revision.delta.CDOAddFeatureDeltaImpl;
+import org.eclipse.emf.cdo.internal.common.revision.delta.CDOClearFeatureDeltaImpl;
+import org.eclipse.emf.cdo.internal.common.revision.delta.CDOContainerFeatureDeltaImpl;
+import org.eclipse.emf.cdo.internal.common.revision.delta.CDOListFeatureDeltaImpl;
+import org.eclipse.emf.cdo.internal.common.revision.delta.CDOMoveFeatureDeltaImpl;
+import org.eclipse.emf.cdo.internal.common.revision.delta.CDORemoveFeatureDeltaImpl;
+import org.eclipse.emf.cdo.internal.common.revision.delta.CDORevisionDeltaImpl;
+import org.eclipse.emf.cdo.internal.common.revision.delta.CDOSetFeatureDeltaImpl;
+import org.eclipse.emf.cdo.internal.common.revision.delta.CDOUnsetFeatureDeltaImpl;
+import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
+import org.eclipse.emf.cdo.spi.common.id.AbstractCDOID;
+import org.eclipse.emf.cdo.spi.common.lock.InternalCDOLockState;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDOList;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+
+import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
+import org.eclipse.net4j.util.io.ExtendedDataInput;
+import org.eclipse.net4j.util.io.StringIO;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.FeatureMapUtil;
+
+import java.io.IOException;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class CDODataInputImpl extends ExtendedDataInput.Delegating implements CDODataInput
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, CDODataInputImpl.class);
+
+ public CDODataInputImpl(ExtendedDataInput delegate)
+ {
+ super(delegate);
+ }
+
+ public CDOPackageUnit readCDOPackageUnit(ResourceSet resourceSet) throws IOException
+ {
+ InternalCDOPackageUnit packageUnit = (InternalCDOPackageUnit)CDOModelUtil.createPackageUnit();
+ packageUnit.read(this, resourceSet);
+ return packageUnit;
+ }
+
+ public CDOPackageUnit[] readCDOPackageUnits(ResourceSet resourceSet) throws IOException
+ {
+ int size = readInt();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Reading {0} package units", size); //$NON-NLS-1$
+ }
+
+ CDOPackageUnit[] packageUnits = new CDOPackageUnit[size];
+ for (int i = 0; i < size; i++)
+ {
+ packageUnits[i] = readCDOPackageUnit(resourceSet);
+ }
+
+ return packageUnits;
+ }
+
+ public CDOPackageUnit.Type readCDOPackageUnitType() throws IOException
+ {
+ return CDOPackageUnit.Type.values()[readByte()];
+ }
+
+ public CDOPackageInfo readCDOPackageInfo() throws IOException
+ {
+ InternalCDOPackageInfo packageInfo = (InternalCDOPackageInfo)CDOModelUtil.createPackageInfo();
+ packageInfo.read(this);
+ return packageInfo;
+ }
+
+ public String readCDOPackageURI() throws IOException
+ {
+ return getPackageURICompressor().read(this);
+ }
+
+ public CDOClassifierRef readCDOClassifierRef() throws IOException
+ {
+ return new CDOClassifierRef(this);
+ }
+
+ public EClassifier readCDOClassifierRefAndResolve() throws IOException
+ {
+ CDOClassifierRef classifierRef = readCDOClassifierRef();
+ EClassifier classifier = classifierRef.resolve(getPackageRegistry());
+ if (classifier == null)
+ {
+ throw new IOException("Unable to resolve " + classifierRef);
+ }
+
+ return classifier;
+ }
+
+ public CDOType readCDOType() throws IOException
+ {
+ byte typeID = readByte();
+ return CDOModelUtil.getType(typeID);
+ }
+
+ public CDOBranch readCDOBranch() throws IOException
+ {
+ int branchID = readInt();
+ return getBranchManager().getBranch(branchID);
+ }
+
+ public CDOBranchPoint readCDOBranchPoint() throws IOException
+ {
+ CDOBranch branch = readCDOBranch();
+ long timeStamp = readLong();
+ return branch.getPoint(timeStamp);
+ }
+
+ public CDOBranchVersion readCDOBranchVersion() throws IOException
+ {
+ CDOBranch branch = readCDOBranch();
+ int version = readInt();
+ return branch.getVersion(version);
+ }
+
+ public CDOChangeSetData readCDOChangeSetData() throws IOException
+ {
+ int size1 = readInt();
+ List<CDOIDAndVersion> newObjects = new ArrayList<CDOIDAndVersion>(size1);
+ for (int i = 0; i < size1; i++)
+ {
+ boolean revision = readBoolean();
+ CDOIDAndVersion data = revision ? readCDORevision() : readCDOIDAndVersion();
+ newObjects.add(data);
+ }
+
+ int size2 = readInt();
+ List<CDORevisionKey> changedObjects = new ArrayList<CDORevisionKey>(size2);
+ for (int i = 0; i < size2; i++)
+ {
+ boolean delta = readBoolean();
+ CDORevisionKey data = delta ? readCDORevisionDelta() : readCDORevisionKey();
+ changedObjects.add(data);
+ }
+
+ int size3 = readInt();
+ List<CDOIDAndVersion> detachedObjects = new ArrayList<CDOIDAndVersion>(size3);
+ for (int i = 0; i < size3; i++)
+ {
+ CDOIDAndVersion data = readCDOIDAndVersion();
+ detachedObjects.add(data);
+ }
+
+ return new CDOChangeSetDataImpl(newObjects, changedObjects, detachedObjects);
+ }
+
+ public CDOCommitData readCDOCommitData() throws IOException
+ {
+ InternalCDOPackageRegistry packageRegistry = (InternalCDOPackageRegistry)getPackageRegistry();
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.setPackageRegistry(packageRegistry);
+
+ int size = readInt();
+ List<CDOPackageUnit> newPackageUnits = new ArrayList<CDOPackageUnit>(size);
+ for (int i = 0; i < size; i++)
+ {
+ CDOPackageUnit data = readCDOPackageUnit(resourceSet);
+ newPackageUnits.add(data);
+ packageRegistry.putPackageUnit((InternalCDOPackageUnit)data);
+ }
+
+ CDOChangeSetData data = readCDOChangeSetData();
+ return new CDOCommitDataImpl(newPackageUnits, data.getNewObjects(), data.getChangedObjects(),
+ data.getDetachedObjects());
+ }
+
+ public CDOCommitInfo readCDOCommitInfo() throws IOException
+ {
+ long timeStamp = readLong();
+ long previousTimeStamp = readLong();
+
+ if (readBoolean())
+ {
+ CDOBranch branch = readCDOBranch();
+ String userID = readString();
+ String comment = readString();
+ CDOCommitData commitData = readCDOCommitData();
+
+ InternalCDOCommitInfoManager commitInfoManager = (InternalCDOCommitInfoManager)getCommitInfoManager();
+ return commitInfoManager.createCommitInfo(branch, timeStamp, previousTimeStamp, userID, comment, commitData);
+ }
+
+ return new FailureCommitInfo(timeStamp, previousTimeStamp);
+ }
+
+ public CDOLockChangeInfo readCDOLockChangeInfo() throws IOException
+ {
+ boolean isInvalidateAll = readBoolean();
+ if (isInvalidateAll)
+ {
+ return CDOLockUtil.createLockChangeInfo();
+ }
+
+ CDOBranchPoint branchPoint = readCDOBranchPoint();
+ CDOLockOwner lockOwner = readCDOLockOwner();
+ Operation operation = readEnum(Operation.class);
+ LockType lockType = readCDOLockType();
+
+ int n = readInt();
+ CDOLockState[] lockStates = new CDOLockState[n];
+ for (int i = 0; i < n; i++)
+ {
+ lockStates[i] = readCDOLockState();
+ }
+
+ return new CDOLockChangeInfoImpl(branchPoint, lockOwner, lockStates, operation, lockType);
+ }
+
+ public LockArea readCDOLockArea() throws IOException
+ {
+ String durableLockingID = readString();
+ CDOBranch branch = readCDOBranch();
+ long timestamp = readLong();
+ String userID = readString();
+ boolean readOnly = readBoolean();
+
+ int nLockStates = readInt();
+ Map<CDOID, LockGrade> locks = new HashMap<CDOID, LockGrade>();
+ for (int i = 0; i < nLockStates; i++)
+ {
+ CDOID key = readCDOID();
+ LockGrade value = readEnum(LockGrade.class);
+ locks.put(key, value);
+ }
+
+ return new CDOLockAreaImpl(durableLockingID, userID, branch.getPoint(timestamp), readOnly, locks);
+ }
+
+ public CDOLockOwner readCDOLockOwner() throws IOException
+ {
+ int session = readInt();
+ int view = readInt();
+ String lockAreaID = readString();
+ boolean isDurableView = readBoolean();
+ return new CDOLockOwnerImpl(session, view, lockAreaID, isDurableView);
+ }
+
+ public CDOLockState readCDOLockState() throws IOException
+ {
+ Object target;
+ boolean sendingBranchWithID = readBoolean();
+ if (!sendingBranchWithID)
+ {
+ target = readCDOID();
+ }
+ else
+ {
+ target = readCDOIDAndBranch();
+ }
+
+ InternalCDOLockState lockState = new CDOLockStateImpl(target);
+
+ int nReadLockOwners = readInt();
+ for (int i = 0; i < nReadLockOwners; i++)
+ {
+ CDOLockOwner lockOwner = readCDOLockOwner();
+ lockState.addReadLockOwner(lockOwner);
+ }
+
+ boolean hasWriteLock = readBoolean();
+ if (hasWriteLock)
+ {
+ CDOLockOwner lockOwner = readCDOLockOwner();
+ lockState.setWriteLockOwner(lockOwner);
+ }
+
+ boolean hasWriteOption = readBoolean();
+ if (hasWriteOption)
+ {
+ CDOLockOwner lockOwner = readCDOLockOwner();
+ lockState.setWriteOptionOwner(lockOwner);
+ }
+
+ return lockState;
+ }
+
+ public LockType readCDOLockType() throws IOException
+ {
+ return readEnum(LockType.class);
+ }
+
+ public CDOID readCDOID() throws IOException
+ {
+ byte ordinal = readByte();
+
+ // A subtype of OBJECT
+ if (ordinal < 0)
+ {
+ // The ordinal value is negated in the stream to distinguish from the main type.
+ // Note: Added 1 because ordinal start at 0, so correct by minus 1.
+ return readCDOIDObject(-ordinal - 1);
+ }
+
+ if (TRACER.isEnabled())
+ {
+ String type;
+ try
+ {
+ type = Type.values()[ordinal].toString();
+ }
+ catch (RuntimeException ex)
+ {
+ type = ex.getMessage();
+ }
+
+ TRACER.format("Reading CDOID of type {0} ({1})", ordinal, type); //$NON-NLS-1$
+ }
+
+ Type type = Type.values()[ordinal];
+ switch (type)
+ {
+ case NULL:
+ return CDOID.NULL;
+
+ case TEMP_OBJECT:
+ return new CDOIDTempObjectImpl(readInt());
+
+ case EXTERNAL_OBJECT:
+ return new CDOIDExternalImpl(readString());
+
+ case EXTERNAL_TEMP_OBJECT:
+ return new CDOIDTempObjectExternalImpl(readString());
+
+ case OBJECT:
+ {
+ // should normally not occur is handled by
+ // readCDOIDObject, code remains here
+ // for backward compatibility
+ AbstractCDOID id = new CDOIDObjectLongImpl();
+ id.read(this);
+ return id;
+ }
+
+ default:
+ throw new IOException("Illegal type: " + type);
+ }
+ }
+
+ private CDOID readCDOIDObject(int subTypeOrdinal) throws IOException
+ {
+ if (TRACER.isEnabled())
+ {
+ String subType;
+
+ try
+ {
+ subType = CDOID.ObjectType.values()[subTypeOrdinal].toString();
+ }
+ catch (RuntimeException ex)
+ {
+ subType = ex.getMessage();
+ }
+
+ TRACER.format("Reading CDOIDObject of sub type {0} ({1})", subTypeOrdinal, subType); //$NON-NLS-1$
+ }
+
+ CDOID.ObjectType subType = CDOID.ObjectType.values()[subTypeOrdinal];
+ AbstractCDOID id = CDOIDUtil.createCDOIDObject(subType);
+ id.read(this);
+ return id;
+ }
+
+ public CDOIDReference readCDOIDReference() throws IOException
+ {
+ return new CDOIDReference(this);
+ }
+
+ public CDOIDAndVersion readCDOIDAndVersion() throws IOException
+ {
+ CDOID id = readCDOID();
+ int version = readInt();
+ return new CDOIDAndVersionImpl(id, version);
+ }
+
+ public CDOIDAndBranch readCDOIDAndBranch() throws IOException
+ {
+ CDOID id = readCDOID();
+ CDOBranch branch = readCDOBranch();
+ return new CDOIDAndBranchImpl(id, branch);
+ }
+
+ public CDORevisionKey readCDORevisionKey() throws IOException
+ {
+ CDOID id = readCDOID();
+ CDOBranch branch = readCDOBranch();
+ int version = readInt();
+ return CDORevisionUtil.createRevisionKey(id, branch, version);
+ }
+
+ public CDORevision readCDORevision() throws IOException
+ {
+ return readCDORevision(true);
+ }
+
+ public CDORevision readCDORevision(boolean freeze) throws IOException
+ {
+ boolean notNull = readBoolean();
+ if (notNull)
+ {
+ InternalCDORevision revision = (InternalCDORevision)getRevisionFactory().createRevision(null);
+ revision.read(this);
+
+ if (freeze)
+ {
+ revision.freeze();
+ }
+
+ return revision;
+ }
+
+ return null;
+ }
+
+ public CDORevisable readCDORevisable() throws IOException
+ {
+ CDOBranch branch = readCDOBranch();
+ int version = readInt();
+ long timeStamp = readLong();
+ long revised = readLong();
+ return CDORevisionUtil.createRevisable(branch, version, timeStamp, revised);
+ }
+
+ public CDOList readCDOList(EClass owner, EStructuralFeature feature) throws IOException
+ {
+ int referenceChunk;
+ int size = readInt();
+ if (size < 0)
+ {
+ size = -size;
+ referenceChunk = readInt();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read feature {0}: size={1}, referenceChunk={2}", feature.getName(), size, referenceChunk); //$NON-NLS-1$
+ }
+ }
+ else
+ {
+ referenceChunk = size;
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read feature {0}: size={1}", feature.getName(), size); //$NON-NLS-1$
+ }
+ }
+
+ Object value = null;
+ CDOType type = null;
+ boolean isFeatureMap = FeatureMapUtil.isFeatureMap(feature);
+ if (!isFeatureMap)
+ {
+ type = CDOModelUtil.getType(feature.getEType());
+ }
+
+ InternalCDOList list = (InternalCDOList)getListFactory().createList(size, size, referenceChunk);
+ for (int j = 0; j < referenceChunk; j++)
+ {
+ if (isFeatureMap)
+ {
+ int featureID = readInt();
+ EStructuralFeature innerFeature = owner.getEStructuralFeature(featureID);
+ type = CDOModelUtil.getType(innerFeature.getEType());
+ value = type.readValue(this);
+ value = CDORevisionUtil.createFeatureMapEntry(innerFeature, value);
+ }
+ else
+ {
+ value = type.readValue(this);
+ }
+
+ list.set(j, value);
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(" " + value); //$NON-NLS-1$
+ }
+ }
+
+ return list;
+ }
+
+ public Object readCDOFeatureValue(EStructuralFeature feature) throws IOException
+ {
+ CDOType type = CDOModelUtil.getType(feature);
+ Object value = type.readValue(this);
+ if (value instanceof CDOLob<?>)
+ {
+ CDOLob<?> lob = (CDOLob<?>)value;
+ CDOLobUtil.setStore(getLobStore(), lob);
+ }
+
+ return value;
+ }
+
+ public CDORevisionDelta readCDORevisionDelta() throws IOException
+ {
+ return new CDORevisionDeltaImpl(this);
+ }
+
+ public CDOFeatureDelta readCDOFeatureDelta(EClass owner) throws IOException
+ {
+ int typeOrdinal = readInt();
+ CDOFeatureDelta.Type type = CDOFeatureDelta.Type.values()[typeOrdinal];
+ switch (type)
+ {
+ case ADD:
+ return new CDOAddFeatureDeltaImpl(this, owner);
+
+ case SET:
+ return new CDOSetFeatureDeltaImpl(this, owner);
+
+ case LIST:
+ return new CDOListFeatureDeltaImpl(this, owner);
+
+ case MOVE:
+ return new CDOMoveFeatureDeltaImpl(this, owner);
+
+ case CLEAR:
+ return new CDOClearFeatureDeltaImpl(this, owner);
+
+ case REMOVE:
+ return new CDORemoveFeatureDeltaImpl(this, owner);
+
+ case CONTAINER:
+ return new CDOContainerFeatureDeltaImpl(this, owner);
+
+ case UNSET:
+ return new CDOUnsetFeatureDeltaImpl(this, owner);
+
+ default:
+ throw new IOException(MessageFormat.format(Messages.getString("CDODataInputImpl.5"), typeOrdinal)); //$NON-NLS-1$
+ }
+ }
+
+ public Object readCDORevisionOrPrimitive() throws IOException
+ {
+ CDOType type = readCDOType();
+ return type.readValue(this);
+ }
+
+ public Object readCDORevisionOrPrimitiveOrClassifier() throws IOException
+ {
+ boolean isClassifier = readBoolean();
+ if (isClassifier)
+ {
+ return readCDOClassifierRefAndResolve();
+ }
+
+ return readCDORevisionOrPrimitive();
+ }
+
+ protected StringIO getPackageURICompressor()
+ {
+ return StringIO.DIRECT;
+ }
+
+ protected abstract CDOPackageRegistry getPackageRegistry();
+
+ protected abstract CDOBranchManager getBranchManager();
+
+ protected abstract CDOCommitInfoManager getCommitInfoManager();
+
+ protected abstract CDORevisionFactory getRevisionFactory();
+
+ protected abstract CDOListFactory getListFactory();
+
+ protected abstract CDOLobStore getLobStore();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/protocol/CDODataOutputImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/protocol/CDODataOutputImpl.java
index df2a2a7a8b..3853a9f162 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/protocol/CDODataOutputImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/protocol/CDODataOutputImpl.java
@@ -1,560 +1,560 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
-import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-import org.eclipse.emf.cdo.common.commit.CDOCommitData;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDProvider;
-import org.eclipse.emf.cdo.common.id.CDOIDReference;
-import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo;
-import org.eclipse.emf.cdo.common.lock.CDOLockOwner;
-import org.eclipse.emf.cdo.common.lock.CDOLockState;
-import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea;
-import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockGrade;
-import org.eclipse.emf.cdo.common.model.CDOClassifierRef;
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
-import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.model.CDOType;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
-import org.eclipse.emf.cdo.common.revision.CDOList;
-import org.eclipse.emf.cdo.common.revision.CDORevisable;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-import org.eclipse.emf.cdo.internal.common.bundle.OM;
-import org.eclipse.emf.cdo.internal.common.messages.Messages;
-import org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl;
-import org.eclipse.emf.cdo.internal.common.revision.delta.CDOFeatureDeltaImpl;
-import org.eclipse.emf.cdo.internal.common.revision.delta.CDORevisionDeltaImpl;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOID;
-import org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
-import org.eclipse.net4j.util.io.StringIO;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.util.FeatureMap;
-import org.eclipse.emf.ecore.util.FeatureMap.Entry;
-import org.eclipse.emf.ecore.util.FeatureMapUtil;
-
-import java.io.IOException;
-import java.text.MessageFormat;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public abstract class CDODataOutputImpl extends ExtendedDataOutput.Delegating implements CDODataOutput
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, CDODataOutputImpl.class);
-
- public CDODataOutputImpl(ExtendedDataOutput delegate)
- {
- super(delegate);
- }
-
- public void writeCDOPackageUnit(CDOPackageUnit packageUnit, boolean withPackages) throws IOException
- {
- ((InternalCDOPackageUnit)packageUnit).write(this, withPackages);
- }
-
- public void writeCDOPackageUnits(CDOPackageUnit... packageUnits) throws IOException
- {
- int size = packageUnits.length;
- writeInt(size);
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing {0} package units", size); //$NON-NLS-1$
- }
-
- for (CDOPackageUnit packageUnit : packageUnits)
- {
- writeCDOPackageUnit(packageUnit, false);
- }
- }
-
- public void writeCDOPackageUnitType(CDOPackageUnit.Type type) throws IOException
- {
- writeByte(type.ordinal());
- }
-
- public void writeCDOPackageInfo(CDOPackageInfo packageInfo) throws IOException
- {
- ((InternalCDOPackageInfo)packageInfo).write(this);
- }
-
- public void writeCDOClassifierRef(CDOClassifierRef eClassifierRef) throws IOException
- {
- eClassifierRef.write(this);
- }
-
- public void writeCDOClassifierRef(EClassifier eClassifier) throws IOException
- {
- writeCDOClassifierRef(new CDOClassifierRef(eClassifier));
- }
-
- public void writeCDOPackageURI(String uri) throws IOException
- {
- getPackageURICompressor().write(this, uri);
- }
-
- public void writeCDOType(CDOType cdoType) throws IOException
- {
- ((CDOTypeImpl)cdoType).write(this);
- }
-
- public void writeCDOBranch(CDOBranch branch) throws IOException
- {
- writeInt(branch.getID());
- }
-
- public void writeCDOBranchPoint(CDOBranchPoint branchPoint) throws IOException
- {
- writeCDOBranch(branchPoint.getBranch());
- writeLong(branchPoint.getTimeStamp());
- }
-
- public void writeCDOBranchVersion(CDOBranchVersion branchVersion) throws IOException
- {
- writeCDOBranch(branchVersion.getBranch());
- writeInt(branchVersion.getVersion());
- }
-
- public void writeCDOChangeSetData(CDOChangeSetData changeSetData) throws IOException
- {
- Collection<CDOIDAndVersion> newObjects = changeSetData.getNewObjects();
- writeInt(newObjects.size());
- for (CDOIDAndVersion data : newObjects)
- {
- if (data instanceof CDORevision)
- {
- writeBoolean(true);
- writeCDORevision((CDORevision)data, CDORevision.UNCHUNKED);
- }
- else
- {
- writeBoolean(false);
- writeCDOIDAndVersion(data);
- }
- }
-
- Collection<CDORevisionKey> changedObjects = changeSetData.getChangedObjects();
- writeInt(changedObjects.size());
- for (CDORevisionKey data : changedObjects)
- {
- if (data instanceof CDORevisionDelta)
- {
- writeBoolean(true);
- writeCDORevisionDelta((CDORevisionDelta)data);
- }
- else
- {
- writeBoolean(false);
- writeCDORevisionKey(data);
- }
- }
-
- Collection<CDOIDAndVersion> detachedObjects = changeSetData.getDetachedObjects();
- writeInt(detachedObjects.size());
- for (CDOIDAndVersion data : detachedObjects)
- {
- writeCDOIDAndVersion(data);
- }
- }
-
- public void writeCDOCommitData(CDOCommitData commitData) throws IOException
- {
- Collection<CDOPackageUnit> newPackageUnits = commitData.getNewPackageUnits();
- writeInt(newPackageUnits.size());
- for (CDOPackageUnit data : newPackageUnits)
- {
- writeCDOPackageUnit(data, false);
- }
-
- writeCDOChangeSetData(commitData);
- }
-
- public void writeCDOCommitInfo(CDOCommitInfo commitInfo) throws IOException
- {
- writeLong(commitInfo.getTimeStamp());
- writeLong(commitInfo.getPreviousTimeStamp());
-
- CDOBranch branch = commitInfo.getBranch();
- if (branch != null)
- {
- writeBoolean(true);
- writeCDOBranch(branch);
- writeString(commitInfo.getUserID());
- writeString(commitInfo.getComment());
- writeCDOCommitData(commitInfo);
- }
- else
- {
- // FailureCommitInfo
- writeBoolean(false);
- }
- }
-
- public void writeCDOLockChangeInfo(CDOLockChangeInfo lockChangeInfo) throws IOException
- {
- if (lockChangeInfo.isInvalidateAll())
- {
- writeBoolean(true);
- }
- else
- {
- writeBoolean(false);
- writeCDOBranchPoint(lockChangeInfo);
- writeCDOLockOwner(lockChangeInfo.getLockOwner());
- writeEnum(lockChangeInfo.getOperation());
- writeCDOLockType(lockChangeInfo.getLockType());
-
- CDOLockState[] lockStates = lockChangeInfo.getLockStates();
- writeInt(lockStates.length);
- for (CDOLockState lockState : lockStates)
- {
- writeCDOLockState(lockState);
- }
- }
- }
-
- public void writeCDOLockArea(LockArea lockArea) throws IOException
- {
- writeString(lockArea.getDurableLockingID());
- writeCDOBranch(lockArea.getBranch());
- writeLong(lockArea.getTimeStamp());
- writeString(lockArea.getUserID());
- writeBoolean(lockArea.isReadOnly());
-
- writeInt(lockArea.getLocks().size());
- for (Map.Entry<CDOID, LockGrade> entry : lockArea.getLocks().entrySet())
- {
- writeCDOID(entry.getKey());
- writeEnum(entry.getValue());
- }
- }
-
- public void writeCDOLockOwner(CDOLockOwner lockOwner) throws IOException
- {
- writeInt(lockOwner.getSessionID());
- writeInt(lockOwner.getViewID());
- writeString(lockOwner.getDurableLockingID());
- writeBoolean(lockOwner.isDurableView());
- }
-
- public void writeCDOLockState(CDOLockState lockState) throws IOException
- {
- Object o = lockState.getLockedObject();
- if (o instanceof CDOID)
- {
- writeBoolean(false);
- writeCDOID((CDOID)o);
- }
- else if (o instanceof CDOIDAndBranch)
- {
- writeBoolean(true);
- writeCDOIDAndBranch((CDOIDAndBranch)o);
- }
- else
- {
- throw new AssertionError("Unexpected type: " + o.getClass().getSimpleName());
- }
-
- Set<CDOLockOwner> readLockOwners = lockState.getReadLockOwners();
- writeInt(readLockOwners.size());
- for (CDOLockOwner readLockOwner : readLockOwners)
- {
- writeCDOLockOwner(readLockOwner);
- }
-
- CDOLockOwner writeLockOwner = lockState.getWriteLockOwner();
- if (writeLockOwner != null)
- {
- writeBoolean(true);
- writeCDOLockOwner(writeLockOwner);
- }
- else
- {
- writeBoolean(false);
- }
-
- CDOLockOwner writeOptionOwner = lockState.getWriteOptionOwner();
- if (writeOptionOwner != null)
- {
- writeBoolean(true);
- writeCDOLockOwner(writeOptionOwner);
- }
- else
- {
- writeBoolean(false);
- }
- }
-
- public void writeCDOLockType(LockType lockType) throws IOException
- {
- writeEnum(lockType);
- }
-
- public void writeCDOID(CDOID id) throws IOException
- {
- if (id == null)
- {
- id = CDOID.NULL;
- }
-
- if (id instanceof InternalCDOIDObject)
- {
- CDOID.ObjectType subType = ((InternalCDOIDObject)id).getSubType();
- int ordinal = subType.ordinal();
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing CDOIDObject of subtype {0} ({1})", ordinal, subType); //$NON-NLS-1$
- }
-
- // Negated to distinguish between the subtypes and the maintypes.
- // Note: Added 1 because ordinal start at 0
- writeByte(-ordinal - 1);
- }
- else
- {
- CDOID.Type type = id.getType();
- int ordinal = type.ordinal();
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing CDOID of type {0} ({1})", ordinal, type); //$NON-NLS-1$
- }
-
- writeByte(ordinal);
- }
-
- ((AbstractCDOID)id).write(this);
- }
-
- public void writeCDOIDReference(CDOIDReference idReference) throws IOException
- {
- idReference.write(this);
- }
-
- public void writeCDOIDAndVersion(CDOIDAndVersion idAndVersion) throws IOException
- {
- writeCDOID(idAndVersion.getID());
- writeInt(idAndVersion.getVersion());
- }
-
- public void writeCDOIDAndBranch(CDOIDAndBranch idAndBranch) throws IOException
- {
- writeCDOID(idAndBranch.getID());
- writeCDOBranch(idAndBranch.getBranch());
- }
-
- public void writeCDORevisionKey(CDORevisionKey revisionKey) throws IOException
- {
- writeCDOID(revisionKey.getID());
- writeCDOBranch(revisionKey.getBranch());
- writeInt(revisionKey.getVersion());
- }
-
- public void writeCDORevision(CDORevision revision, int referenceChunk) throws IOException
- {
- if (revision != null)
- {
- writeBoolean(true);
- ((InternalCDORevision)revision).write(this, referenceChunk);
- }
- else
- {
- writeBoolean(false);
- }
- }
-
- public void writeCDORevisable(CDORevisable revisable) throws IOException
- {
- writeCDOBranch(revisable.getBranch());
- writeInt(revisable.getVersion());
- writeLong(revisable.getTimeStamp());
- writeLong(revisable.getRevised());
- }
-
- public void writeCDOList(EClass owner, EStructuralFeature feature, CDOList list, int referenceChunk)
- throws IOException
- {
- // TODO Simon: Could most of this stuff be moved into the list?
- // (only if protected methods of this class don't need to become public)
- int size = list == null ? 0 : list.size();
- if (size > 0)
- {
- // Need to adjust the referenceChunk in case where we do not have enough value in the list.
- // Even if the referenceChunk is specified, a provider of data could have override that value.
- int sizeToLook = referenceChunk == CDORevision.UNCHUNKED ? size : Math.min(referenceChunk, size);
- for (int i = 0; i < sizeToLook; i++)
- {
- Object element = list.get(i, false);
- if (element == CDORevisionUtil.UNINITIALIZED)
- {
- referenceChunk = i;
- break;
- }
- }
- }
-
- if (referenceChunk != CDORevision.UNCHUNKED && referenceChunk < size)
- {
- // This happens only on server-side
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing feature {0}: size={1}, referenceChunk={2}", feature.getName(), size, referenceChunk); //$NON-NLS-1$
- }
-
- writeInt(-size);
- writeInt(referenceChunk);
- size = referenceChunk;
- }
- else
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing feature {0}: size={1}", feature.getName(), size); //$NON-NLS-1$
- }
-
- writeInt(size);
- }
-
- CDOIDProvider idProvider = getIDProvider();
- boolean isFeatureMap = FeatureMapUtil.isFeatureMap(feature);
- for (int j = 0; j < size; j++)
- {
- Object value = list.get(j, false);
- EStructuralFeature innerFeature = feature; // Prepare for possible feature map
- if (isFeatureMap)
- {
- Entry entry = (FeatureMap.Entry)value;
- innerFeature = entry.getEStructuralFeature();
- value = entry.getValue();
-
- int featureID = owner.getFeatureID(innerFeature);
- writeInt(featureID);
- }
-
- if (value != null && innerFeature instanceof EReference)
- {
- value = idProvider.provideCDOID(value);
- }
-
- if (TRACER.isEnabled())
- {
- TRACER.trace(" " + value); //$NON-NLS-1$
- }
-
- writeCDOFeatureValue(innerFeature, value);
- }
- }
-
- public void writeCDOFeatureValue(EStructuralFeature feature, Object value) throws IOException
- {
- CDOType type = CDOModelUtil.getType(feature);
- type.writeValue(this, value);
- }
-
- public void writeCDORevisionDelta(CDORevisionDelta revisionDelta) throws IOException
- {
- ((CDORevisionDeltaImpl)revisionDelta).write(this);
- }
-
- public void writeCDOFeatureDelta(EClass owner, CDOFeatureDelta featureDelta) throws IOException
- {
- ((CDOFeatureDeltaImpl)featureDelta).write(this, owner);
- }
-
- public void writeCDORevisionOrPrimitive(Object value) throws IOException
- {
- if (value == null)
- {
- value = CDOID.NULL;
- }
- else if (value instanceof EObject)
- {
- value = getIDProvider().provideCDOID(value);
- }
- else if (value instanceof CDORevision)
- {
- value = ((CDORevision)value).getID();
- }
-
- CDOType type = null;
- if (value instanceof CDOID)
- {
- type = CDOType.OBJECT;
- }
- else
- {
- type = CDOModelUtil.getPrimitiveType(value.getClass());
- if (type == null)
- {
- throw new IllegalArgumentException(MessageFormat.format(
- Messages.getString("CDODataOutputImpl.6"), value.getClass())); //$NON-NLS-1$
- }
- }
-
- writeCDOType(type);
- type.writeValue(this, value);
- }
-
- public void writeCDORevisionOrPrimitiveOrClassifier(Object value) throws IOException
- {
- if (value instanceof EClassifier)
- {
- writeBoolean(true);
- writeCDOClassifierRef((EClass)value);
- }
- else
- {
- writeBoolean(false);
- writeCDORevisionOrPrimitive(value);
- }
- }
-
- public CDOPackageRegistry getPackageRegistry()
- {
- return null;
- }
-
- public CDOIDProvider getIDProvider()
- {
- return null;
- }
-
- protected StringIO getPackageURICompressor()
- {
- return StringIO.DIRECT;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.protocol;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
+import org.eclipse.emf.cdo.common.commit.CDOCommitData;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDProvider;
+import org.eclipse.emf.cdo.common.id.CDOIDReference;
+import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo;
+import org.eclipse.emf.cdo.common.lock.CDOLockOwner;
+import org.eclipse.emf.cdo.common.lock.CDOLockState;
+import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea;
+import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockGrade;
+import org.eclipse.emf.cdo.common.model.CDOClassifierRef;
+import org.eclipse.emf.cdo.common.model.CDOModelUtil;
+import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
+import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
+import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
+import org.eclipse.emf.cdo.common.model.CDOType;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
+import org.eclipse.emf.cdo.common.revision.CDOList;
+import org.eclipse.emf.cdo.common.revision.CDORevisable;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
+import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.internal.common.bundle.OM;
+import org.eclipse.emf.cdo.internal.common.messages.Messages;
+import org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl;
+import org.eclipse.emf.cdo.internal.common.revision.delta.CDOFeatureDeltaImpl;
+import org.eclipse.emf.cdo.internal.common.revision.delta.CDORevisionDeltaImpl;
+import org.eclipse.emf.cdo.spi.common.id.AbstractCDOID;
+import org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+
+import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
+import org.eclipse.net4j.util.io.ExtendedDataOutput;
+import org.eclipse.net4j.util.io.StringIO;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.FeatureMap;
+import org.eclipse.emf.ecore.util.FeatureMap.Entry;
+import org.eclipse.emf.ecore.util.FeatureMapUtil;
+
+import java.io.IOException;
+import java.text.MessageFormat;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class CDODataOutputImpl extends ExtendedDataOutput.Delegating implements CDODataOutput
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, CDODataOutputImpl.class);
+
+ public CDODataOutputImpl(ExtendedDataOutput delegate)
+ {
+ super(delegate);
+ }
+
+ public void writeCDOPackageUnit(CDOPackageUnit packageUnit, boolean withPackages) throws IOException
+ {
+ ((InternalCDOPackageUnit)packageUnit).write(this, withPackages);
+ }
+
+ public void writeCDOPackageUnits(CDOPackageUnit... packageUnits) throws IOException
+ {
+ int size = packageUnits.length;
+ writeInt(size);
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Writing {0} package units", size); //$NON-NLS-1$
+ }
+
+ for (CDOPackageUnit packageUnit : packageUnits)
+ {
+ writeCDOPackageUnit(packageUnit, false);
+ }
+ }
+
+ public void writeCDOPackageUnitType(CDOPackageUnit.Type type) throws IOException
+ {
+ writeByte(type.ordinal());
+ }
+
+ public void writeCDOPackageInfo(CDOPackageInfo packageInfo) throws IOException
+ {
+ ((InternalCDOPackageInfo)packageInfo).write(this);
+ }
+
+ public void writeCDOClassifierRef(CDOClassifierRef eClassifierRef) throws IOException
+ {
+ eClassifierRef.write(this);
+ }
+
+ public void writeCDOClassifierRef(EClassifier eClassifier) throws IOException
+ {
+ writeCDOClassifierRef(new CDOClassifierRef(eClassifier));
+ }
+
+ public void writeCDOPackageURI(String uri) throws IOException
+ {
+ getPackageURICompressor().write(this, uri);
+ }
+
+ public void writeCDOType(CDOType cdoType) throws IOException
+ {
+ ((CDOTypeImpl)cdoType).write(this);
+ }
+
+ public void writeCDOBranch(CDOBranch branch) throws IOException
+ {
+ writeInt(branch.getID());
+ }
+
+ public void writeCDOBranchPoint(CDOBranchPoint branchPoint) throws IOException
+ {
+ writeCDOBranch(branchPoint.getBranch());
+ writeLong(branchPoint.getTimeStamp());
+ }
+
+ public void writeCDOBranchVersion(CDOBranchVersion branchVersion) throws IOException
+ {
+ writeCDOBranch(branchVersion.getBranch());
+ writeInt(branchVersion.getVersion());
+ }
+
+ public void writeCDOChangeSetData(CDOChangeSetData changeSetData) throws IOException
+ {
+ Collection<CDOIDAndVersion> newObjects = changeSetData.getNewObjects();
+ writeInt(newObjects.size());
+ for (CDOIDAndVersion data : newObjects)
+ {
+ if (data instanceof CDORevision)
+ {
+ writeBoolean(true);
+ writeCDORevision((CDORevision)data, CDORevision.UNCHUNKED);
+ }
+ else
+ {
+ writeBoolean(false);
+ writeCDOIDAndVersion(data);
+ }
+ }
+
+ Collection<CDORevisionKey> changedObjects = changeSetData.getChangedObjects();
+ writeInt(changedObjects.size());
+ for (CDORevisionKey data : changedObjects)
+ {
+ if (data instanceof CDORevisionDelta)
+ {
+ writeBoolean(true);
+ writeCDORevisionDelta((CDORevisionDelta)data);
+ }
+ else
+ {
+ writeBoolean(false);
+ writeCDORevisionKey(data);
+ }
+ }
+
+ Collection<CDOIDAndVersion> detachedObjects = changeSetData.getDetachedObjects();
+ writeInt(detachedObjects.size());
+ for (CDOIDAndVersion data : detachedObjects)
+ {
+ writeCDOIDAndVersion(data);
+ }
+ }
+
+ public void writeCDOCommitData(CDOCommitData commitData) throws IOException
+ {
+ Collection<CDOPackageUnit> newPackageUnits = commitData.getNewPackageUnits();
+ writeInt(newPackageUnits.size());
+ for (CDOPackageUnit data : newPackageUnits)
+ {
+ writeCDOPackageUnit(data, false);
+ }
+
+ writeCDOChangeSetData(commitData);
+ }
+
+ public void writeCDOCommitInfo(CDOCommitInfo commitInfo) throws IOException
+ {
+ writeLong(commitInfo.getTimeStamp());
+ writeLong(commitInfo.getPreviousTimeStamp());
+
+ CDOBranch branch = commitInfo.getBranch();
+ if (branch != null)
+ {
+ writeBoolean(true);
+ writeCDOBranch(branch);
+ writeString(commitInfo.getUserID());
+ writeString(commitInfo.getComment());
+ writeCDOCommitData(commitInfo);
+ }
+ else
+ {
+ // FailureCommitInfo
+ writeBoolean(false);
+ }
+ }
+
+ public void writeCDOLockChangeInfo(CDOLockChangeInfo lockChangeInfo) throws IOException
+ {
+ if (lockChangeInfo.isInvalidateAll())
+ {
+ writeBoolean(true);
+ }
+ else
+ {
+ writeBoolean(false);
+ writeCDOBranchPoint(lockChangeInfo);
+ writeCDOLockOwner(lockChangeInfo.getLockOwner());
+ writeEnum(lockChangeInfo.getOperation());
+ writeCDOLockType(lockChangeInfo.getLockType());
+
+ CDOLockState[] lockStates = lockChangeInfo.getLockStates();
+ writeInt(lockStates.length);
+ for (CDOLockState lockState : lockStates)
+ {
+ writeCDOLockState(lockState);
+ }
+ }
+ }
+
+ public void writeCDOLockArea(LockArea lockArea) throws IOException
+ {
+ writeString(lockArea.getDurableLockingID());
+ writeCDOBranch(lockArea.getBranch());
+ writeLong(lockArea.getTimeStamp());
+ writeString(lockArea.getUserID());
+ writeBoolean(lockArea.isReadOnly());
+
+ writeInt(lockArea.getLocks().size());
+ for (Map.Entry<CDOID, LockGrade> entry : lockArea.getLocks().entrySet())
+ {
+ writeCDOID(entry.getKey());
+ writeEnum(entry.getValue());
+ }
+ }
+
+ public void writeCDOLockOwner(CDOLockOwner lockOwner) throws IOException
+ {
+ writeInt(lockOwner.getSessionID());
+ writeInt(lockOwner.getViewID());
+ writeString(lockOwner.getDurableLockingID());
+ writeBoolean(lockOwner.isDurableView());
+ }
+
+ public void writeCDOLockState(CDOLockState lockState) throws IOException
+ {
+ Object o = lockState.getLockedObject();
+ if (o instanceof CDOID)
+ {
+ writeBoolean(false);
+ writeCDOID((CDOID)o);
+ }
+ else if (o instanceof CDOIDAndBranch)
+ {
+ writeBoolean(true);
+ writeCDOIDAndBranch((CDOIDAndBranch)o);
+ }
+ else
+ {
+ throw new AssertionError("Unexpected type: " + o.getClass().getSimpleName());
+ }
+
+ Set<CDOLockOwner> readLockOwners = lockState.getReadLockOwners();
+ writeInt(readLockOwners.size());
+ for (CDOLockOwner readLockOwner : readLockOwners)
+ {
+ writeCDOLockOwner(readLockOwner);
+ }
+
+ CDOLockOwner writeLockOwner = lockState.getWriteLockOwner();
+ if (writeLockOwner != null)
+ {
+ writeBoolean(true);
+ writeCDOLockOwner(writeLockOwner);
+ }
+ else
+ {
+ writeBoolean(false);
+ }
+
+ CDOLockOwner writeOptionOwner = lockState.getWriteOptionOwner();
+ if (writeOptionOwner != null)
+ {
+ writeBoolean(true);
+ writeCDOLockOwner(writeOptionOwner);
+ }
+ else
+ {
+ writeBoolean(false);
+ }
+ }
+
+ public void writeCDOLockType(LockType lockType) throws IOException
+ {
+ writeEnum(lockType);
+ }
+
+ public void writeCDOID(CDOID id) throws IOException
+ {
+ if (id == null)
+ {
+ id = CDOID.NULL;
+ }
+
+ if (id instanceof InternalCDOIDObject)
+ {
+ CDOID.ObjectType subType = ((InternalCDOIDObject)id).getSubType();
+ int ordinal = subType.ordinal();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Writing CDOIDObject of subtype {0} ({1})", ordinal, subType); //$NON-NLS-1$
+ }
+
+ // Negated to distinguish between the subtypes and the maintypes.
+ // Note: Added 1 because ordinal start at 0
+ writeByte(-ordinal - 1);
+ }
+ else
+ {
+ CDOID.Type type = id.getType();
+ int ordinal = type.ordinal();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Writing CDOID of type {0} ({1})", ordinal, type); //$NON-NLS-1$
+ }
+
+ writeByte(ordinal);
+ }
+
+ ((AbstractCDOID)id).write(this);
+ }
+
+ public void writeCDOIDReference(CDOIDReference idReference) throws IOException
+ {
+ idReference.write(this);
+ }
+
+ public void writeCDOIDAndVersion(CDOIDAndVersion idAndVersion) throws IOException
+ {
+ writeCDOID(idAndVersion.getID());
+ writeInt(idAndVersion.getVersion());
+ }
+
+ public void writeCDOIDAndBranch(CDOIDAndBranch idAndBranch) throws IOException
+ {
+ writeCDOID(idAndBranch.getID());
+ writeCDOBranch(idAndBranch.getBranch());
+ }
+
+ public void writeCDORevisionKey(CDORevisionKey revisionKey) throws IOException
+ {
+ writeCDOID(revisionKey.getID());
+ writeCDOBranch(revisionKey.getBranch());
+ writeInt(revisionKey.getVersion());
+ }
+
+ public void writeCDORevision(CDORevision revision, int referenceChunk) throws IOException
+ {
+ if (revision != null)
+ {
+ writeBoolean(true);
+ ((InternalCDORevision)revision).write(this, referenceChunk);
+ }
+ else
+ {
+ writeBoolean(false);
+ }
+ }
+
+ public void writeCDORevisable(CDORevisable revisable) throws IOException
+ {
+ writeCDOBranch(revisable.getBranch());
+ writeInt(revisable.getVersion());
+ writeLong(revisable.getTimeStamp());
+ writeLong(revisable.getRevised());
+ }
+
+ public void writeCDOList(EClass owner, EStructuralFeature feature, CDOList list, int referenceChunk)
+ throws IOException
+ {
+ // TODO Simon: Could most of this stuff be moved into the list?
+ // (only if protected methods of this class don't need to become public)
+ int size = list == null ? 0 : list.size();
+ if (size > 0)
+ {
+ // Need to adjust the referenceChunk in case where we do not have enough value in the list.
+ // Even if the referenceChunk is specified, a provider of data could have override that value.
+ int sizeToLook = referenceChunk == CDORevision.UNCHUNKED ? size : Math.min(referenceChunk, size);
+ for (int i = 0; i < sizeToLook; i++)
+ {
+ Object element = list.get(i, false);
+ if (element == CDORevisionUtil.UNINITIALIZED)
+ {
+ referenceChunk = i;
+ break;
+ }
+ }
+ }
+
+ if (referenceChunk != CDORevision.UNCHUNKED && referenceChunk < size)
+ {
+ // This happens only on server-side
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Writing feature {0}: size={1}, referenceChunk={2}", feature.getName(), size, referenceChunk); //$NON-NLS-1$
+ }
+
+ writeInt(-size);
+ writeInt(referenceChunk);
+ size = referenceChunk;
+ }
+ else
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Writing feature {0}: size={1}", feature.getName(), size); //$NON-NLS-1$
+ }
+
+ writeInt(size);
+ }
+
+ CDOIDProvider idProvider = getIDProvider();
+ boolean isFeatureMap = FeatureMapUtil.isFeatureMap(feature);
+ for (int j = 0; j < size; j++)
+ {
+ Object value = list.get(j, false);
+ EStructuralFeature innerFeature = feature; // Prepare for possible feature map
+ if (isFeatureMap)
+ {
+ Entry entry = (FeatureMap.Entry)value;
+ innerFeature = entry.getEStructuralFeature();
+ value = entry.getValue();
+
+ int featureID = owner.getFeatureID(innerFeature);
+ writeInt(featureID);
+ }
+
+ if (value != null && innerFeature instanceof EReference)
+ {
+ value = idProvider.provideCDOID(value);
+ }
+
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(" " + value); //$NON-NLS-1$
+ }
+
+ writeCDOFeatureValue(innerFeature, value);
+ }
+ }
+
+ public void writeCDOFeatureValue(EStructuralFeature feature, Object value) throws IOException
+ {
+ CDOType type = CDOModelUtil.getType(feature);
+ type.writeValue(this, value);
+ }
+
+ public void writeCDORevisionDelta(CDORevisionDelta revisionDelta) throws IOException
+ {
+ ((CDORevisionDeltaImpl)revisionDelta).write(this);
+ }
+
+ public void writeCDOFeatureDelta(EClass owner, CDOFeatureDelta featureDelta) throws IOException
+ {
+ ((CDOFeatureDeltaImpl)featureDelta).write(this, owner);
+ }
+
+ public void writeCDORevisionOrPrimitive(Object value) throws IOException
+ {
+ if (value == null)
+ {
+ value = CDOID.NULL;
+ }
+ else if (value instanceof EObject)
+ {
+ value = getIDProvider().provideCDOID(value);
+ }
+ else if (value instanceof CDORevision)
+ {
+ value = ((CDORevision)value).getID();
+ }
+
+ CDOType type = null;
+ if (value instanceof CDOID)
+ {
+ type = CDOType.OBJECT;
+ }
+ else
+ {
+ type = CDOModelUtil.getPrimitiveType(value.getClass());
+ if (type == null)
+ {
+ throw new IllegalArgumentException(MessageFormat.format(
+ Messages.getString("CDODataOutputImpl.6"), value.getClass())); //$NON-NLS-1$
+ }
+ }
+
+ writeCDOType(type);
+ type.writeValue(this, value);
+ }
+
+ public void writeCDORevisionOrPrimitiveOrClassifier(Object value) throws IOException
+ {
+ if (value instanceof EClassifier)
+ {
+ writeBoolean(true);
+ writeCDOClassifierRef((EClass)value);
+ }
+ else
+ {
+ writeBoolean(false);
+ writeCDORevisionOrPrimitive(value);
+ }
+ }
+
+ public CDOPackageRegistry getPackageRegistry()
+ {
+ return null;
+ }
+
+ public CDOIDProvider getIDProvider()
+ {
+ return null;
+ }
+
+ protected StringIO getPackageURICompressor()
+ {
+ return StringIO.DIRECT;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/AbstractCDORevisionCache.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/AbstractCDORevisionCache.java
index 58eb68b4f3..43f0cf2f8c 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/AbstractCDORevisionCache.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/AbstractCDORevisionCache.java
@@ -1,156 +1,156 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - bug 201266
- * Simon McDuff - bug 230832
- */
-package org.eclipse.emf.cdo.internal.common.revision;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
-
-import org.eclipse.net4j.util.event.IListener;
-import org.eclipse.net4j.util.ref.ReferenceQueueWorker;
-
-import java.lang.ref.Reference;
-import java.lang.ref.ReferenceQueue;
-import java.lang.ref.SoftReference;
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public abstract class AbstractCDORevisionCache extends ReferenceQueueWorker<InternalCDORevision> implements
- InternalCDORevisionCache
-{
- private static boolean disableGC;
-
- public AbstractCDORevisionCache()
- {
- }
-
- @Override
- protected void work(Reference<? extends InternalCDORevision> reference)
- {
- CDORevisionKey key = (CDORevisionKey)reference;
-
- CDOID id = key.getID();
- CDOBranch branch = key.getBranch();
- int version = key.getVersion();
-
- InternalCDORevision revision = (InternalCDORevision)removeRevision(id, branch.getVersion(version));
- if (revision == null)
- {
- // Use revision in eviction event
- key = revision;
- }
-
- IListener[] listeners = getListeners();
- if (listeners != null)
- {
- fireEvent(new EvictionEventImpl(this, key), listeners);
- }
- }
-
- protected Reference<InternalCDORevision> createReference(CDORevision revision)
- {
- if (disableGC)
- {
- return new CacheStrongReference((InternalCDORevision)revision);
- }
-
- return new CacheSoftReference((InternalCDORevision)revision, getQueue());
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class CacheSoftReference extends SoftReference<InternalCDORevision> implements CDORevisionKey
- {
- private CDOID id;
-
- private CDOBranch branch;
-
- private int version;
-
- public CacheSoftReference(InternalCDORevision revision, ReferenceQueue<InternalCDORevision> queue)
- {
- super(revision, queue);
- id = revision.getID();
- branch = revision.getBranch();
- version = revision.getVersion();
- }
-
- public CDOID getID()
- {
- return id;
- }
-
- public CDOBranch getBranch()
- {
- return branch;
- }
-
- public int getVersion()
- {
- return version;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("{0}:{1}v{2}", getID(), getBranch().getID(), getVersion());
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class CacheStrongReference extends SoftReference<InternalCDORevision> implements CDORevisionKey
- {
- private CDOID id;
-
- private CDOBranch branch;
-
- private int version;
-
- public CacheStrongReference(InternalCDORevision revision)
- {
- super(revision);
- id = revision.getID();
- branch = revision.getBranch();
- version = revision.getVersion();
- }
-
- public CDOID getID()
- {
- return id;
- }
-
- public CDOBranch getBranch()
- {
- return branch;
- }
-
- public int getVersion()
- {
- return version;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("{0}:{1}v{2}", getID(), getBranch().getID(), getVersion());
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Simon McDuff - bug 201266
+ * Simon McDuff - bug 230832
+ */
+package org.eclipse.emf.cdo.internal.common.revision;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
+
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.ref.ReferenceQueueWorker;
+
+import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.SoftReference;
+import java.text.MessageFormat;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class AbstractCDORevisionCache extends ReferenceQueueWorker<InternalCDORevision> implements
+ InternalCDORevisionCache
+{
+ private static boolean disableGC;
+
+ public AbstractCDORevisionCache()
+ {
+ }
+
+ @Override
+ protected void work(Reference<? extends InternalCDORevision> reference)
+ {
+ CDORevisionKey key = (CDORevisionKey)reference;
+
+ CDOID id = key.getID();
+ CDOBranch branch = key.getBranch();
+ int version = key.getVersion();
+
+ InternalCDORevision revision = (InternalCDORevision)removeRevision(id, branch.getVersion(version));
+ if (revision == null)
+ {
+ // Use revision in eviction event
+ key = revision;
+ }
+
+ IListener[] listeners = getListeners();
+ if (listeners != null)
+ {
+ fireEvent(new EvictionEventImpl(this, key), listeners);
+ }
+ }
+
+ protected Reference<InternalCDORevision> createReference(CDORevision revision)
+ {
+ if (disableGC)
+ {
+ return new CacheStrongReference((InternalCDORevision)revision);
+ }
+
+ return new CacheSoftReference((InternalCDORevision)revision, getQueue());
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class CacheSoftReference extends SoftReference<InternalCDORevision> implements CDORevisionKey
+ {
+ private CDOID id;
+
+ private CDOBranch branch;
+
+ private int version;
+
+ public CacheSoftReference(InternalCDORevision revision, ReferenceQueue<InternalCDORevision> queue)
+ {
+ super(revision, queue);
+ id = revision.getID();
+ branch = revision.getBranch();
+ version = revision.getVersion();
+ }
+
+ public CDOID getID()
+ {
+ return id;
+ }
+
+ public CDOBranch getBranch()
+ {
+ return branch;
+ }
+
+ public int getVersion()
+ {
+ return version;
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("{0}:{1}v{2}", getID(), getBranch().getID(), getVersion());
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class CacheStrongReference extends SoftReference<InternalCDORevision> implements CDORevisionKey
+ {
+ private CDOID id;
+
+ private CDOBranch branch;
+
+ private int version;
+
+ public CacheStrongReference(InternalCDORevision revision)
+ {
+ super(revision);
+ id = revision.getID();
+ branch = revision.getBranch();
+ version = revision.getVersion();
+ }
+
+ public CDOID getID()
+ {
+ return id;
+ }
+
+ public CDOBranch getBranch()
+ {
+ return branch;
+ }
+
+ public int getVersion()
+ {
+ return version;
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("{0}:{1}v{2}", getID(), getBranch().getID(), getVersion());
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOElementProxyImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOElementProxyImpl.java
index 8c5536fae8..cda9a09a9e 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOElementProxyImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOElementProxyImpl.java
@@ -1,45 +1,45 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.revision;
-
-import org.eclipse.emf.cdo.common.revision.CDOElementProxy;
-
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public final class CDOElementProxyImpl implements CDOElementProxy
-{
- private int index;
-
- public CDOElementProxyImpl(int index)
- {
- this.index = index;
- }
-
- public int getIndex()
- {
- return index;
- }
-
- public void setIndex(int index)
- {
- this.index = index;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("CDOElementProxy[{0}]", index); //$NON-NLS-1$
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Simon McDuff - maintenance
+ */
+package org.eclipse.emf.cdo.internal.common.revision;
+
+import org.eclipse.emf.cdo.common.revision.CDOElementProxy;
+
+import java.text.MessageFormat;
+
+/**
+ * @author Eike Stepper
+ */
+public final class CDOElementProxyImpl implements CDOElementProxy
+{
+ private int index;
+
+ public CDOElementProxyImpl(int index)
+ {
+ this.index = index;
+ }
+
+ public int getIndex()
+ {
+ return index;
+ }
+
+ public void setIndex(int index)
+ {
+ this.index = index;
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("CDOElementProxy[{0}]", index); //$NON-NLS-1$
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOFeatureMapEntryImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOFeatureMapEntryImpl.java
index 7e317f626d..f852ffafd8 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOFeatureMapEntryImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOFeatureMapEntryImpl.java
@@ -1,63 +1,63 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.revision;
-
-import org.eclipse.emf.cdo.spi.common.revision.CDOFeatureMapEntry;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public class CDOFeatureMapEntryImpl implements CDOFeatureMapEntry
-{
- private EStructuralFeature feature;
-
- private Object value;
-
- public CDOFeatureMapEntryImpl()
- {
- }
-
- public CDOFeatureMapEntryImpl(EStructuralFeature feature, Object value)
- {
- this.feature = feature;
- this.value = value;
- }
-
- public EStructuralFeature getEStructuralFeature()
- {
- return feature;
- }
-
- public void setEStructuralFeature(EStructuralFeature feature)
- {
- this.feature = feature;
- }
-
- public Object getValue()
- {
- return value;
- }
-
- public void setValue(Object value)
- {
- this.value = value;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("CDOFeatureMapEntry({0}, {1})", feature.getName(), value); //$NON-NLS-1$
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.revision;
+
+import org.eclipse.emf.cdo.spi.common.revision.CDOFeatureMapEntry;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import java.text.MessageFormat;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOFeatureMapEntryImpl implements CDOFeatureMapEntry
+{
+ private EStructuralFeature feature;
+
+ private Object value;
+
+ public CDOFeatureMapEntryImpl()
+ {
+ }
+
+ public CDOFeatureMapEntryImpl(EStructuralFeature feature, Object value)
+ {
+ this.feature = feature;
+ this.value = value;
+ }
+
+ public EStructuralFeature getEStructuralFeature()
+ {
+ return feature;
+ }
+
+ public void setEStructuralFeature(EStructuralFeature feature)
+ {
+ this.feature = feature;
+ }
+
+ public Object getValue()
+ {
+ return value;
+ }
+
+ public void setValue(Object value)
+ {
+ this.value = value;
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("CDOFeatureMapEntry({0}, {1})", feature.getName(), value); //$NON-NLS-1$
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndBranchImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndBranchImpl.java
index a9d8d05cbf..22abddb88f 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndBranchImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndBranchImpl.java
@@ -1,78 +1,78 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.revision;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch;
-
-import org.eclipse.net4j.util.CheckUtil;
-import org.eclipse.net4j.util.ObjectUtil;
-
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public class CDOIDAndBranchImpl implements CDOIDAndBranch
-{
- private CDOID id;
-
- private CDOBranch branch;
-
- public CDOIDAndBranchImpl(CDOID id, CDOBranch branch)
- {
- CheckUtil.checkArg(id, "id");
- CheckUtil.checkArg(branch, "branch");
-
- this.id = id;
- this.branch = branch;
- }
-
- public CDOID getID()
- {
- return id;
- }
-
- public CDOBranch getBranch()
- {
- return branch;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj instanceof CDOIDAndBranch)
- {
- CDOIDAndBranch that = (CDOIDAndBranch)obj;
- return ObjectUtil.equals(branch, that.getBranch()) && ObjectUtil.equals(id, that.getID());
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- return id.hashCode() ^ branch.hashCode();
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("{0}:{1}", id, branch.getID()); //$NON-NLS-1$
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.revision;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch;
+
+import org.eclipse.net4j.util.CheckUtil;
+import org.eclipse.net4j.util.ObjectUtil;
+
+import java.text.MessageFormat;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOIDAndBranchImpl implements CDOIDAndBranch
+{
+ private CDOID id;
+
+ private CDOBranch branch;
+
+ public CDOIDAndBranchImpl(CDOID id, CDOBranch branch)
+ {
+ CheckUtil.checkArg(id, "id");
+ CheckUtil.checkArg(branch, "branch");
+
+ this.id = id;
+ this.branch = branch;
+ }
+
+ public CDOID getID()
+ {
+ return id;
+ }
+
+ public CDOBranch getBranch()
+ {
+ return branch;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+
+ if (obj instanceof CDOIDAndBranch)
+ {
+ CDOIDAndBranch that = (CDOIDAndBranch)obj;
+ return ObjectUtil.equals(branch, that.getBranch()) && ObjectUtil.equals(id, that.getID());
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return id.hashCode() ^ branch.hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("{0}:{1}", id, branch.getID()); //$NON-NLS-1$
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndVersionImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndVersionImpl.java
index 3ffd488c67..27ead89940 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndVersionImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndVersionImpl.java
@@ -1,75 +1,75 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.revision;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
-
-import org.eclipse.net4j.util.CheckUtil;
-
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public class CDOIDAndVersionImpl implements CDOIDAndVersion
-{
- private CDOID id;
-
- private int version;
-
- public CDOIDAndVersionImpl(CDOID id, int version)
- {
- CheckUtil.checkArg(id, "id");
-
- this.id = id;
- this.version = version;
- }
-
- public CDOID getID()
- {
- return id;
- }
-
- public int getVersion()
- {
- return version;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj instanceof CDOIDAndVersion)
- {
- CDOIDAndVersion that = (CDOIDAndVersion)obj;
- return id.equals(that.getID()) && version == that.getVersion();
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- return id.hashCode() ^ version;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("{0}v{1}", id, version); //$NON-NLS-1$
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.revision;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
+
+import org.eclipse.net4j.util.CheckUtil;
+
+import java.text.MessageFormat;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOIDAndVersionImpl implements CDOIDAndVersion
+{
+ private CDOID id;
+
+ private int version;
+
+ public CDOIDAndVersionImpl(CDOID id, int version)
+ {
+ CheckUtil.checkArg(id, "id");
+
+ this.id = id;
+ this.version = version;
+ }
+
+ public CDOID getID()
+ {
+ return id;
+ }
+
+ public int getVersion()
+ {
+ return version;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+
+ if (obj instanceof CDOIDAndVersion)
+ {
+ CDOIDAndVersion that = (CDOIDAndVersion)obj;
+ return id.equals(that.getID()) && version == that.getVersion();
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return id.hashCode() ^ version;
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("{0}v{1}", id, version); //$NON-NLS-1$
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListImpl.java
index fb4ccfe944..62b5cbc176 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListImpl.java
@@ -1,187 +1,187 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.revision;
-
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.model.CDOType;
-import org.eclipse.emf.cdo.common.revision.CDOList;
-import org.eclipse.emf.cdo.common.revision.CDOListFactory;
-import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOList;
-
-import org.eclipse.net4j.util.collection.MoveableArrayList;
-
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.util.Collection;
-
-/**
- * @author Simon McDuff
- */
-public class CDOListImpl extends MoveableArrayList<Object> implements InternalCDOList
-{
- public static final CDOListFactory FACTORY = new CDOListFactory()
- {
- public CDOList createList(int initialCapacity, int size, int initialChunk)
- {
- return new CDOListImpl(initialCapacity, size);
- }
- };
-
- private static final long serialVersionUID = 1L;
-
- private transient boolean frozen;
-
- public CDOListImpl(int initialCapacity, int size)
- {
- super(initialCapacity);
- for (int j = 0; j < size; j++)
- {
- this.add(UNINITIALIZED);
- }
- }
-
- public InternalCDOList clone(EClassifier classifier)
- {
- CDOType type = CDOModelUtil.getType(classifier);
- int size = size();
- InternalCDOList list = new CDOListImpl(size, 0);
- for (int j = 0; j < size; j++)
- {
- Object value = this.get(j);
- list.add(j, type.copyValue(value));
- }
-
- return list;
- }
-
- public Object get(int index, boolean resolve)
- {
- return super.get(index);
- }
-
- /**
- * There's a duplicate of this method in WrappedHibernateList!!!
- */
- public boolean adjustReferences(CDOReferenceAdjuster revisionAdjuster, EStructuralFeature feature)
- {
- boolean changed = false;
- CDOType type = CDOModelUtil.getType(feature);
- int size = size();
- for (int i = 0; i < size; i++)
- {
- Object element = super.get(i);
- handleAdjustReference(i, element);
- Object newID = type.adjustReferences(revisionAdjuster, element, feature, i);
- if (newID != element) // Just an optimization for NOOP adjusters
- {
- super.set(i, newID);
- changed = true;
- }
- }
-
- return changed;
- }
-
- protected void handleAdjustReference(int index, Object element)
- {
- }
-
- public void freeze()
- {
- frozen = true;
- }
-
- private void checkFrozen()
- {
- if (frozen)
- {
- throw new IllegalStateException("Cannot modify a frozen list");
- }
- }
-
- @Override
- public boolean add(Object o)
- {
- checkFrozen();
- return super.add(o);
- }
-
- @Override
- public boolean remove(Object o)
- {
- checkFrozen();
- return super.remove(o);
- }
-
- @Override
- public boolean addAll(Collection<? extends Object> c)
- {
- checkFrozen();
- return super.addAll(c);
- }
-
- @Override
- public boolean addAll(int index, Collection<? extends Object> c)
- {
- checkFrozen();
- return super.addAll(index, c);
- }
-
- @Override
- public boolean removeAll(Collection<?> c)
- {
- checkFrozen();
- return super.removeAll(c);
- }
-
- @Override
- public boolean retainAll(Collection<?> c)
- {
- checkFrozen();
- return super.retainAll(c);
- }
-
- @Override
- public void clear()
- {
- checkFrozen();
- super.clear();
- }
-
- @Override
- public Object set(int index, Object element)
- {
- checkFrozen();
- return super.set(index, element);
- }
-
- @Override
- public void add(int index, Object element)
- {
- checkFrozen();
- super.add(index, element);
- }
-
- @Override
- public Object remove(int index)
- {
- checkFrozen();
- return super.remove(index);
- }
-
- public void setWithoutFrozenCheck(int index, Object element)
- {
- super.set(index, element);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.common.revision;
+
+import org.eclipse.emf.cdo.common.model.CDOModelUtil;
+import org.eclipse.emf.cdo.common.model.CDOType;
+import org.eclipse.emf.cdo.common.revision.CDOList;
+import org.eclipse.emf.cdo.common.revision.CDOListFactory;
+import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDOList;
+
+import org.eclipse.net4j.util.collection.MoveableArrayList;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import java.util.Collection;
+
+/**
+ * @author Simon McDuff
+ */
+public class CDOListImpl extends MoveableArrayList<Object> implements InternalCDOList
+{
+ public static final CDOListFactory FACTORY = new CDOListFactory()
+ {
+ public CDOList createList(int initialCapacity, int size, int initialChunk)
+ {
+ return new CDOListImpl(initialCapacity, size);
+ }
+ };
+
+ private static final long serialVersionUID = 1L;
+
+ private transient boolean frozen;
+
+ public CDOListImpl(int initialCapacity, int size)
+ {
+ super(initialCapacity);
+ for (int j = 0; j < size; j++)
+ {
+ this.add(UNINITIALIZED);
+ }
+ }
+
+ public InternalCDOList clone(EClassifier classifier)
+ {
+ CDOType type = CDOModelUtil.getType(classifier);
+ int size = size();
+ InternalCDOList list = new CDOListImpl(size, 0);
+ for (int j = 0; j < size; j++)
+ {
+ Object value = this.get(j);
+ list.add(j, type.copyValue(value));
+ }
+
+ return list;
+ }
+
+ public Object get(int index, boolean resolve)
+ {
+ return super.get(index);
+ }
+
+ /**
+ * There's a duplicate of this method in WrappedHibernateList!!!
+ */
+ public boolean adjustReferences(CDOReferenceAdjuster revisionAdjuster, EStructuralFeature feature)
+ {
+ boolean changed = false;
+ CDOType type = CDOModelUtil.getType(feature);
+ int size = size();
+ for (int i = 0; i < size; i++)
+ {
+ Object element = super.get(i);
+ handleAdjustReference(i, element);
+ Object newID = type.adjustReferences(revisionAdjuster, element, feature, i);
+ if (newID != element) // Just an optimization for NOOP adjusters
+ {
+ super.set(i, newID);
+ changed = true;
+ }
+ }
+
+ return changed;
+ }
+
+ protected void handleAdjustReference(int index, Object element)
+ {
+ }
+
+ public void freeze()
+ {
+ frozen = true;
+ }
+
+ private void checkFrozen()
+ {
+ if (frozen)
+ {
+ throw new IllegalStateException("Cannot modify a frozen list");
+ }
+ }
+
+ @Override
+ public boolean add(Object o)
+ {
+ checkFrozen();
+ return super.add(o);
+ }
+
+ @Override
+ public boolean remove(Object o)
+ {
+ checkFrozen();
+ return super.remove(o);
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Object> c)
+ {
+ checkFrozen();
+ return super.addAll(c);
+ }
+
+ @Override
+ public boolean addAll(int index, Collection<? extends Object> c)
+ {
+ checkFrozen();
+ return super.addAll(index, c);
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c)
+ {
+ checkFrozen();
+ return super.removeAll(c);
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c)
+ {
+ checkFrozen();
+ return super.retainAll(c);
+ }
+
+ @Override
+ public void clear()
+ {
+ checkFrozen();
+ super.clear();
+ }
+
+ @Override
+ public Object set(int index, Object element)
+ {
+ checkFrozen();
+ return super.set(index, element);
+ }
+
+ @Override
+ public void add(int index, Object element)
+ {
+ checkFrozen();
+ super.add(index, element);
+ }
+
+ @Override
+ public Object remove(int index)
+ {
+ checkFrozen();
+ return super.remove(index);
+ }
+
+ public void setWithoutFrozenCheck(int index, Object element)
+ {
+ super.set(index, element);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListWithElementProxiesImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListWithElementProxiesImpl.java
index eb1cb667b5..2179d9b092 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListWithElementProxiesImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListWithElementProxiesImpl.java
@@ -1,91 +1,91 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.revision;
-
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.model.CDOType;
-import org.eclipse.emf.cdo.common.revision.CDOElementProxy;
-import org.eclipse.emf.cdo.common.revision.CDOList;
-import org.eclipse.emf.cdo.common.revision.CDOListFactory;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOList;
-
-import org.eclipse.emf.ecore.EClassifier;
-
-/**
- * @author Simon McDuff
- */
-public class CDOListWithElementProxiesImpl extends CDOListImpl
-{
- public static final CDOListFactory FACTORY = new CDOListFactory()
- {
- public CDOList createList(int initialCapacity, int size, int initialChunk)
- {
- return new CDOListWithElementProxiesImpl(initialCapacity, size, initialChunk);
- }
- };
-
- private static final long serialVersionUID = 1L;
-
- public CDOListWithElementProxiesImpl(int initialCapacity, int size, int initialChunk)
- {
- super(initialCapacity, initialChunk);
- for (int j = initialChunk; j < size; j++)
- {
- this.add(new CDOElementProxyImpl(j));
- }
- }
-
- @Override
- public Object get(int index, boolean resolve)
- {
- if (resolve == true)
- {
- return get(index);
- }
-
- Object element = super.get(index);
-
- return element instanceof CDOElementProxy ? UNINITIALIZED : element;
- }
-
- @Override
- protected void handleAdjustReference(int index, Object element)
- {
- if (element instanceof CDOElementProxy)
- {
- ((CDOElementProxyImpl)element).setIndex(index);
- }
- }
-
- @Override
- public InternalCDOList clone(EClassifier classifier)
- {
- CDOType type = CDOModelUtil.getType(classifier);
- int size = size();
- InternalCDOList list = new CDOListWithElementProxiesImpl(size, 0, 0);
- for (int j = 0; j < size; j++)
- {
- Object value = this.get(j);
-
- if (value instanceof CDOElementProxy)
- {
- list.add(j, new CDOElementProxyImpl(((CDOElementProxy)value).getIndex()));
- }
- else
- {
- list.add(j, type.copyValue(value));
- }
- }
-
- return list;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.common.revision;
+
+import org.eclipse.emf.cdo.common.model.CDOModelUtil;
+import org.eclipse.emf.cdo.common.model.CDOType;
+import org.eclipse.emf.cdo.common.revision.CDOElementProxy;
+import org.eclipse.emf.cdo.common.revision.CDOList;
+import org.eclipse.emf.cdo.common.revision.CDOListFactory;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDOList;
+
+import org.eclipse.emf.ecore.EClassifier;
+
+/**
+ * @author Simon McDuff
+ */
+public class CDOListWithElementProxiesImpl extends CDOListImpl
+{
+ public static final CDOListFactory FACTORY = new CDOListFactory()
+ {
+ public CDOList createList(int initialCapacity, int size, int initialChunk)
+ {
+ return new CDOListWithElementProxiesImpl(initialCapacity, size, initialChunk);
+ }
+ };
+
+ private static final long serialVersionUID = 1L;
+
+ public CDOListWithElementProxiesImpl(int initialCapacity, int size, int initialChunk)
+ {
+ super(initialCapacity, initialChunk);
+ for (int j = initialChunk; j < size; j++)
+ {
+ this.add(new CDOElementProxyImpl(j));
+ }
+ }
+
+ @Override
+ public Object get(int index, boolean resolve)
+ {
+ if (resolve == true)
+ {
+ return get(index);
+ }
+
+ Object element = super.get(index);
+
+ return element instanceof CDOElementProxy ? UNINITIALIZED : element;
+ }
+
+ @Override
+ protected void handleAdjustReference(int index, Object element)
+ {
+ if (element instanceof CDOElementProxy)
+ {
+ ((CDOElementProxyImpl)element).setIndex(index);
+ }
+ }
+
+ @Override
+ public InternalCDOList clone(EClassifier classifier)
+ {
+ CDOType type = CDOModelUtil.getType(classifier);
+ int size = size();
+ InternalCDOList list = new CDOListWithElementProxiesImpl(size, 0, 0);
+ for (int j = 0; j < size; j++)
+ {
+ Object value = this.get(j);
+
+ if (value instanceof CDOElementProxy)
+ {
+ list.add(j, new CDOElementProxyImpl(((CDOElementProxy)value).getIndex()));
+ }
+ else
+ {
+ list.add(j, type.copyValue(value));
+ }
+ }
+
+ return list;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisableImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisableImpl.java
index 6deff7e029..b9ce22a600 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisableImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisableImpl.java
@@ -1,90 +1,90 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.revision;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.revision.CDORevisable;
-import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
-import org.eclipse.emf.cdo.internal.common.branch.CDOBranchVersionImpl;
-
-import org.eclipse.net4j.util.ObjectUtil;
-
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public class CDORevisableImpl extends CDOBranchVersionImpl implements CDORevisable
-{
- private long timeStamp;
-
- private long revised;
-
- public CDORevisableImpl(CDOBranch branch, int version, long timeStamp, long revised)
- {
- super(branch, version);
- this.timeStamp = timeStamp;
- this.revised = revised;
- }
-
- public CDORevisableImpl(CDORevisable source)
- {
- super(source.getBranch(), source.getVersion());
- timeStamp = source.getTimeStamp();
- revised = source.getRevised();
- }
-
- public CDORevisableImpl(CDOBranch branch, int version)
- {
- super(branch, version);
- }
-
- public long getTimeStamp()
- {
- return timeStamp;
- }
-
- public long getRevised()
- {
- return revised;
- }
-
- @Override
- public int hashCode()
- {
- return ObjectUtil.hashCode(timeStamp) ^ ObjectUtil.hashCode(revised) ^ super.hashCode();
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj instanceof CDORevisable)
- {
- CDORevisable that = (CDORevisable)obj;
- return timeStamp == that.getTimeStamp() && revised == that.getRevised() && getBranch().equals(that.getBranch())
- && getVersion() == that.getVersion();
- }
-
- return false;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("{0}v{1}[{2}-{3}]", getBranch().getID(), getVersion(),
- CDOCommonUtil.formatTimeStamp(timeStamp), CDOCommonUtil.formatTimeStamp(revised));
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.revision;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.revision.CDORevisable;
+import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
+import org.eclipse.emf.cdo.internal.common.branch.CDOBranchVersionImpl;
+
+import org.eclipse.net4j.util.ObjectUtil;
+
+import java.text.MessageFormat;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDORevisableImpl extends CDOBranchVersionImpl implements CDORevisable
+{
+ private long timeStamp;
+
+ private long revised;
+
+ public CDORevisableImpl(CDOBranch branch, int version, long timeStamp, long revised)
+ {
+ super(branch, version);
+ this.timeStamp = timeStamp;
+ this.revised = revised;
+ }
+
+ public CDORevisableImpl(CDORevisable source)
+ {
+ super(source.getBranch(), source.getVersion());
+ timeStamp = source.getTimeStamp();
+ revised = source.getRevised();
+ }
+
+ public CDORevisableImpl(CDOBranch branch, int version)
+ {
+ super(branch, version);
+ }
+
+ public long getTimeStamp()
+ {
+ return timeStamp;
+ }
+
+ public long getRevised()
+ {
+ return revised;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return ObjectUtil.hashCode(timeStamp) ^ ObjectUtil.hashCode(revised) ^ super.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+
+ if (obj instanceof CDORevisable)
+ {
+ CDORevisable that = (CDORevisable)obj;
+ return timeStamp == that.getTimeStamp() && revised == that.getRevised() && getBranch().equals(that.getBranch())
+ && getVersion() == that.getVersion();
+ }
+
+ return false;
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("{0}v{1}[{2}-{3}]", getBranch().getID(), getVersion(),
+ CDOCommonUtil.formatTimeStamp(timeStamp), CDOCommonUtil.formatTimeStamp(revised));
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheAuditing.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheAuditing.java
index c19cf28a81..41125adba2 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheAuditing.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheAuditing.java
@@ -1,443 +1,443 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - bug 201266
- * Simon McDuff - bug 230832
- */
-package org.eclipse.emf.cdo.internal.common.revision;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-import org.eclipse.emf.cdo.internal.common.bundle.OM;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
-
-import org.eclipse.net4j.util.CheckUtil;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EClass;
-
-import java.lang.ref.Reference;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class CDORevisionCacheAuditing extends AbstractCDORevisionCache
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_REVISION, CDORevisionCacheAuditing.class);
-
- protected Map<Object, RevisionList> revisionLists = new HashMap<Object, RevisionList>();
-
- public CDORevisionCacheAuditing()
- {
- }
-
- public InternalCDORevisionCache instantiate(CDORevision revision)
- {
- return new CDORevisionCacheAuditing();
- }
-
- public EClass getObjectType(CDOID id)
- {
- synchronized (revisionLists)
- {
- RevisionList revisionList = revisionLists.get(id);
- if (revisionList != null && !revisionList.isEmpty())
- {
- Reference<InternalCDORevision> ref = revisionList.getFirst();
- InternalCDORevision revision = ref.get();
- if (revision != null)
- {
- return revision.getEClass();
- }
- }
-
- return null;
- }
- }
-
- public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint)
- {
- RevisionList revisionList = getRevisionList(id, branchPoint.getBranch());
- if (revisionList != null)
- {
- return revisionList.getRevision(branchPoint.getTimeStamp());
- }
-
- return null;
- }
-
- public InternalCDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion)
- {
- RevisionList revisionList = getRevisionList(id, branchVersion.getBranch());
- if (revisionList != null)
- {
- return revisionList.getRevisionByVersion(branchVersion.getVersion());
- }
-
- return null;
- }
-
- public List<CDORevision> getCurrentRevisions()
- {
- List<CDORevision> currentRevisions = new ArrayList<CDORevision>();
- synchronized (revisionLists)
- {
- for (RevisionList revisionList : revisionLists.values())
- {
- InternalCDORevision revision = revisionList.getRevision(CDORevision.UNSPECIFIED_DATE);
- if (revision != null)
- {
- currentRevisions.add(revision);
- }
- }
- }
-
- return currentRevisions;
- }
-
- public Map<CDOBranch, List<CDORevision>> getAllRevisions()
- {
- Map<CDOBranch, List<CDORevision>> result = new HashMap<CDOBranch, List<CDORevision>>();
- synchronized (revisionLists)
- {
- for (RevisionList list : revisionLists.values())
- {
- list.getAllRevisions(result);
- }
- }
-
- return result;
- }
-
- public List<CDORevision> getRevisions(CDOBranchPoint branchPoint)
- {
- List<CDORevision> result = new ArrayList<CDORevision>();
- CDOBranch branch = branchPoint.getBranch();
- synchronized (revisionLists)
- {
- for (Map.Entry<Object, RevisionList> entry : revisionLists.entrySet())
- {
- if (isKeyInBranch(entry.getKey(), branch))
- // if (ObjectUtil.equals(entry.getKey().getBranch(), branch))
- {
- RevisionList list = entry.getValue();
- InternalCDORevision revision = list.getRevision(branchPoint.getTimeStamp());
- if (revision != null)
- {
- result.add(revision);
- }
- }
- }
- }
-
- return result;
- }
-
- public void addRevision(CDORevision revision)
- {
- CheckUtil.checkArg(revision, "revision");
-
- CDOID id = revision.getID();
- Object key = createKey(id, revision.getBranch());
-
- synchronized (revisionLists)
- {
- RevisionList list = revisionLists.get(key);
- if (list == null)
- {
- list = new RevisionList();
- revisionLists.put(key, list);
- }
-
- list.addRevision((InternalCDORevision)revision, createReference(revision));
- typeRefIncrease(id, revision.getEClass());
- }
- }
-
- public InternalCDORevision removeRevision(CDOID id, CDOBranchVersion branchVersion)
- {
- Object key = createKey(id, branchVersion.getBranch());
- synchronized (revisionLists)
- {
- RevisionList list = revisionLists.get(key);
- if (list != null)
- {
- list.removeRevision(branchVersion.getVersion());
- if (list.isEmpty())
- {
- revisionLists.remove(key);
- typeRefDecrease(id);
-
- if (TRACER.isEnabled())
- {
- TRACER.format("Removed cache list of {0}", key); //$NON-NLS-1$
- }
- }
- }
- }
-
- return null;
- }
-
- public void clear()
- {
- synchronized (revisionLists)
- {
- revisionLists.clear();
- typeRefDispose();
- }
- }
-
- @Override
- public String toString()
- {
- synchronized (revisionLists)
- {
- return revisionLists.toString();
- }
- }
-
- protected void typeRefIncrease(CDOID id, EClass type)
- {
- // Do nothing
- }
-
- protected void typeRefDecrease(CDOID id)
- {
- // Do nothing
- }
-
- protected void typeRefDispose()
- {
- // Do nothing
- }
-
- protected Object createKey(CDOID id, CDOBranch branch)
- {
- return id;
- }
-
- protected boolean isKeyInBranch(Object key, CDOBranch branch)
- {
- return true;
- }
-
- protected RevisionList getRevisionList(CDOID id, CDOBranch branch)
- {
- Object key = createKey(id, branch);
- synchronized (revisionLists)
- {
- return revisionLists.get(key);
- }
- }
-
- /**
- * @author Eike Stepper
- */
- protected static final class RevisionList extends LinkedList<Reference<InternalCDORevision>>
- {
- private static final long serialVersionUID = 1L;
-
- public RevisionList()
- {
- }
-
- public synchronized InternalCDORevision getRevision(long timeStamp)
- {
- if (timeStamp == CDORevision.UNSPECIFIED_DATE)
- {
- Reference<InternalCDORevision> ref = isEmpty() ? null : getFirst();
- if (ref != null)
- {
- InternalCDORevision revision = ref.get();
- if (revision != null)
- {
- if (!revision.isHistorical())
- {
- return revision;
- }
- }
- else
- {
- removeFirst();
- }
- }
-
- return null;
- }
-
- for (Iterator<Reference<InternalCDORevision>> it = iterator(); it.hasNext();)
- {
- Reference<InternalCDORevision> ref = it.next();
- InternalCDORevision revision = ref.get();
- if (revision != null)
- {
- long created = revision.getTimeStamp();
- if (created <= timeStamp)
- {
- long revised = revision.getRevised();
- if (timeStamp <= revised || revised == CDORevision.UNSPECIFIED_DATE)
- {
- return revision;
- }
-
- break;
- }
- }
- else
- {
- it.remove();
- }
- }
-
- return null;
- }
-
- public synchronized InternalCDORevision getRevisionByVersion(int version)
- {
- for (Iterator<Reference<InternalCDORevision>> it = iterator(); it.hasNext();)
- {
- Reference<InternalCDORevision> ref = it.next();
- InternalCDORevision revision = ref.get();
- if (revision != null)
- {
- int v = revision.getVersion();
- if (v == version)
- {
- return revision;
- }
- else if (v < version)
- {
- break;
- }
- }
- else
- {
- it.remove();
- }
- }
-
- return null;
- }
-
- public synchronized boolean addRevision(InternalCDORevision revision, Reference<InternalCDORevision> reference)
- {
- int version = revision.getVersion();
- for (ListIterator<Reference<InternalCDORevision>> it = listIterator(); it.hasNext();)
- {
- Reference<InternalCDORevision> ref = it.next();
- InternalCDORevision foundRevision = ref.get();
- if (foundRevision != null)
- {
- CDORevisionKey key = (CDORevisionKey)ref;
- int v = key.getVersion();
- if (v == version)
- {
- return false;
- }
-
- if (v < version)
- {
- it.previous();
- it.add(reference);
- return true;
- }
- }
- else
- {
- it.remove();
- }
- }
-
- addLast(reference);
- return true;
- }
-
- public synchronized void removeRevision(int version)
- {
- for (Iterator<Reference<InternalCDORevision>> it = iterator(); it.hasNext();)
- {
- Reference<InternalCDORevision> ref = it.next();
- CDORevisionKey key = (CDORevisionKey)ref;
- int v = key.getVersion();
- if (v == version)
- {
- it.remove();
- if (TRACER.isEnabled())
- {
- TRACER.format("Removed version {0} from cache list of {1}", version, key.getID()); //$NON-NLS-1$
- }
-
- break;
- }
- else if (v < version)
- {
- break;
- }
- }
- }
-
- @Override
- public String toString()
- {
- StringBuffer buffer = new StringBuffer();
- for (Iterator<Reference<InternalCDORevision>> it = iterator(); it.hasNext();)
- {
- Reference<InternalCDORevision> ref = it.next();
- InternalCDORevision revision = ref.get();
- if (buffer.length() == 0)
- {
- buffer.append("{");
- }
- else
- {
- buffer.append(", ");
- }
-
- buffer.append(revision);
- }
-
- buffer.append("}");
- return buffer.toString();
- }
-
- public void getAllRevisions(Map<CDOBranch, List<CDORevision>> result)
- {
- for (Iterator<Reference<InternalCDORevision>> it = iterator(); it.hasNext();)
- {
- Reference<InternalCDORevision> ref = it.next();
- InternalCDORevision revision = ref.get();
- if (revision != null)
- {
- CDOBranch branch = revision.getBranch();
- List<CDORevision> resultList = result.get(branch);
- if (resultList == null)
- {
- resultList = new ArrayList<CDORevision>(1);
- result.put(branch, resultList);
- }
-
- resultList.add(revision);
- }
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Simon McDuff - bug 201266
+ * Simon McDuff - bug 230832
+ */
+package org.eclipse.emf.cdo.internal.common.revision;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
+import org.eclipse.emf.cdo.internal.common.bundle.OM;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
+
+import org.eclipse.net4j.util.CheckUtil;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.emf.ecore.EClass;
+
+import java.lang.ref.Reference;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDORevisionCacheAuditing extends AbstractCDORevisionCache
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_REVISION, CDORevisionCacheAuditing.class);
+
+ protected Map<Object, RevisionList> revisionLists = new HashMap<Object, RevisionList>();
+
+ public CDORevisionCacheAuditing()
+ {
+ }
+
+ public InternalCDORevisionCache instantiate(CDORevision revision)
+ {
+ return new CDORevisionCacheAuditing();
+ }
+
+ public EClass getObjectType(CDOID id)
+ {
+ synchronized (revisionLists)
+ {
+ RevisionList revisionList = revisionLists.get(id);
+ if (revisionList != null && !revisionList.isEmpty())
+ {
+ Reference<InternalCDORevision> ref = revisionList.getFirst();
+ InternalCDORevision revision = ref.get();
+ if (revision != null)
+ {
+ return revision.getEClass();
+ }
+ }
+
+ return null;
+ }
+ }
+
+ public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint)
+ {
+ RevisionList revisionList = getRevisionList(id, branchPoint.getBranch());
+ if (revisionList != null)
+ {
+ return revisionList.getRevision(branchPoint.getTimeStamp());
+ }
+
+ return null;
+ }
+
+ public InternalCDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion)
+ {
+ RevisionList revisionList = getRevisionList(id, branchVersion.getBranch());
+ if (revisionList != null)
+ {
+ return revisionList.getRevisionByVersion(branchVersion.getVersion());
+ }
+
+ return null;
+ }
+
+ public List<CDORevision> getCurrentRevisions()
+ {
+ List<CDORevision> currentRevisions = new ArrayList<CDORevision>();
+ synchronized (revisionLists)
+ {
+ for (RevisionList revisionList : revisionLists.values())
+ {
+ InternalCDORevision revision = revisionList.getRevision(CDORevision.UNSPECIFIED_DATE);
+ if (revision != null)
+ {
+ currentRevisions.add(revision);
+ }
+ }
+ }
+
+ return currentRevisions;
+ }
+
+ public Map<CDOBranch, List<CDORevision>> getAllRevisions()
+ {
+ Map<CDOBranch, List<CDORevision>> result = new HashMap<CDOBranch, List<CDORevision>>();
+ synchronized (revisionLists)
+ {
+ for (RevisionList list : revisionLists.values())
+ {
+ list.getAllRevisions(result);
+ }
+ }
+
+ return result;
+ }
+
+ public List<CDORevision> getRevisions(CDOBranchPoint branchPoint)
+ {
+ List<CDORevision> result = new ArrayList<CDORevision>();
+ CDOBranch branch = branchPoint.getBranch();
+ synchronized (revisionLists)
+ {
+ for (Map.Entry<Object, RevisionList> entry : revisionLists.entrySet())
+ {
+ if (isKeyInBranch(entry.getKey(), branch))
+ // if (ObjectUtil.equals(entry.getKey().getBranch(), branch))
+ {
+ RevisionList list = entry.getValue();
+ InternalCDORevision revision = list.getRevision(branchPoint.getTimeStamp());
+ if (revision != null)
+ {
+ result.add(revision);
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public void addRevision(CDORevision revision)
+ {
+ CheckUtil.checkArg(revision, "revision");
+
+ CDOID id = revision.getID();
+ Object key = createKey(id, revision.getBranch());
+
+ synchronized (revisionLists)
+ {
+ RevisionList list = revisionLists.get(key);
+ if (list == null)
+ {
+ list = new RevisionList();
+ revisionLists.put(key, list);
+ }
+
+ list.addRevision((InternalCDORevision)revision, createReference(revision));
+ typeRefIncrease(id, revision.getEClass());
+ }
+ }
+
+ public InternalCDORevision removeRevision(CDOID id, CDOBranchVersion branchVersion)
+ {
+ Object key = createKey(id, branchVersion.getBranch());
+ synchronized (revisionLists)
+ {
+ RevisionList list = revisionLists.get(key);
+ if (list != null)
+ {
+ list.removeRevision(branchVersion.getVersion());
+ if (list.isEmpty())
+ {
+ revisionLists.remove(key);
+ typeRefDecrease(id);
+
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Removed cache list of {0}", key); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public void clear()
+ {
+ synchronized (revisionLists)
+ {
+ revisionLists.clear();
+ typeRefDispose();
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ synchronized (revisionLists)
+ {
+ return revisionLists.toString();
+ }
+ }
+
+ protected void typeRefIncrease(CDOID id, EClass type)
+ {
+ // Do nothing
+ }
+
+ protected void typeRefDecrease(CDOID id)
+ {
+ // Do nothing
+ }
+
+ protected void typeRefDispose()
+ {
+ // Do nothing
+ }
+
+ protected Object createKey(CDOID id, CDOBranch branch)
+ {
+ return id;
+ }
+
+ protected boolean isKeyInBranch(Object key, CDOBranch branch)
+ {
+ return true;
+ }
+
+ protected RevisionList getRevisionList(CDOID id, CDOBranch branch)
+ {
+ Object key = createKey(id, branch);
+ synchronized (revisionLists)
+ {
+ return revisionLists.get(key);
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ protected static final class RevisionList extends LinkedList<Reference<InternalCDORevision>>
+ {
+ private static final long serialVersionUID = 1L;
+
+ public RevisionList()
+ {
+ }
+
+ public synchronized InternalCDORevision getRevision(long timeStamp)
+ {
+ if (timeStamp == CDORevision.UNSPECIFIED_DATE)
+ {
+ Reference<InternalCDORevision> ref = isEmpty() ? null : getFirst();
+ if (ref != null)
+ {
+ InternalCDORevision revision = ref.get();
+ if (revision != null)
+ {
+ if (!revision.isHistorical())
+ {
+ return revision;
+ }
+ }
+ else
+ {
+ removeFirst();
+ }
+ }
+
+ return null;
+ }
+
+ for (Iterator<Reference<InternalCDORevision>> it = iterator(); it.hasNext();)
+ {
+ Reference<InternalCDORevision> ref = it.next();
+ InternalCDORevision revision = ref.get();
+ if (revision != null)
+ {
+ long created = revision.getTimeStamp();
+ if (created <= timeStamp)
+ {
+ long revised = revision.getRevised();
+ if (timeStamp <= revised || revised == CDORevision.UNSPECIFIED_DATE)
+ {
+ return revision;
+ }
+
+ break;
+ }
+ }
+ else
+ {
+ it.remove();
+ }
+ }
+
+ return null;
+ }
+
+ public synchronized InternalCDORevision getRevisionByVersion(int version)
+ {
+ for (Iterator<Reference<InternalCDORevision>> it = iterator(); it.hasNext();)
+ {
+ Reference<InternalCDORevision> ref = it.next();
+ InternalCDORevision revision = ref.get();
+ if (revision != null)
+ {
+ int v = revision.getVersion();
+ if (v == version)
+ {
+ return revision;
+ }
+ else if (v < version)
+ {
+ break;
+ }
+ }
+ else
+ {
+ it.remove();
+ }
+ }
+
+ return null;
+ }
+
+ public synchronized boolean addRevision(InternalCDORevision revision, Reference<InternalCDORevision> reference)
+ {
+ int version = revision.getVersion();
+ for (ListIterator<Reference<InternalCDORevision>> it = listIterator(); it.hasNext();)
+ {
+ Reference<InternalCDORevision> ref = it.next();
+ InternalCDORevision foundRevision = ref.get();
+ if (foundRevision != null)
+ {
+ CDORevisionKey key = (CDORevisionKey)ref;
+ int v = key.getVersion();
+ if (v == version)
+ {
+ return false;
+ }
+
+ if (v < version)
+ {
+ it.previous();
+ it.add(reference);
+ return true;
+ }
+ }
+ else
+ {
+ it.remove();
+ }
+ }
+
+ addLast(reference);
+ return true;
+ }
+
+ public synchronized void removeRevision(int version)
+ {
+ for (Iterator<Reference<InternalCDORevision>> it = iterator(); it.hasNext();)
+ {
+ Reference<InternalCDORevision> ref = it.next();
+ CDORevisionKey key = (CDORevisionKey)ref;
+ int v = key.getVersion();
+ if (v == version)
+ {
+ it.remove();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Removed version {0} from cache list of {1}", version, key.getID()); //$NON-NLS-1$
+ }
+
+ break;
+ }
+ else if (v < version)
+ {
+ break;
+ }
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ for (Iterator<Reference<InternalCDORevision>> it = iterator(); it.hasNext();)
+ {
+ Reference<InternalCDORevision> ref = it.next();
+ InternalCDORevision revision = ref.get();
+ if (buffer.length() == 0)
+ {
+ buffer.append("{");
+ }
+ else
+ {
+ buffer.append(", ");
+ }
+
+ buffer.append(revision);
+ }
+
+ buffer.append("}");
+ return buffer.toString();
+ }
+
+ public void getAllRevisions(Map<CDOBranch, List<CDORevision>> result)
+ {
+ for (Iterator<Reference<InternalCDORevision>> it = iterator(); it.hasNext();)
+ {
+ Reference<InternalCDORevision> ref = it.next();
+ InternalCDORevision revision = ref.get();
+ if (revision != null)
+ {
+ CDOBranch branch = revision.getBranch();
+ List<CDORevision> resultList = result.get(branch);
+ if (resultList == null)
+ {
+ resultList = new ArrayList<CDORevision>(1);
+ result.put(branch, resultList);
+ }
+
+ resultList.add(revision);
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheBranching.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheBranching.java
index b6e14f108a..c099944732 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheBranching.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheBranching.java
@@ -1,131 +1,131 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - bug 201266
- * Simon McDuff - bug 230832
- */
-package org.eclipse.emf.cdo.internal.common.revision;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
-
-import org.eclipse.net4j.util.ObjectUtil;
-
-import org.eclipse.emf.ecore.EClass;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class CDORevisionCacheBranching extends CDORevisionCacheAuditing
-{
- private Map<CDOID, TypeAndRefCounter> typeMap = new HashMap<CDOID, TypeAndRefCounter>();
-
- public CDORevisionCacheBranching()
- {
- }
-
- @Override
- public InternalCDORevisionCache instantiate(CDORevision revision)
- {
- return new CDORevisionCacheBranching();
- }
-
- @Override
- public EClass getObjectType(CDOID id)
- {
- synchronized (revisionLists)
- {
- TypeAndRefCounter typeCounter = typeMap.get(id);
- if (typeCounter != null)
- {
- return typeCounter.getType();
- }
-
- return null;
- }
- }
-
- @Override
- protected void typeRefIncrease(CDOID id, EClass type)
- {
- TypeAndRefCounter typeCounter = typeMap.get(id);
- if (typeCounter == null)
- {
- typeCounter = new TypeAndRefCounter(type);
- typeMap.put(id, typeCounter);
- }
-
- typeCounter.increase();
- }
-
- @Override
- protected void typeRefDecrease(CDOID id)
- {
- TypeAndRefCounter typeCounter = typeMap.get(id);
- if (typeCounter != null && typeCounter.decreaseAndGet() == 0)
- {
- typeMap.remove(id);
- }
- }
-
- @Override
- protected void typeRefDispose()
- {
- typeMap.clear();
- }
-
- @Override
- protected boolean isKeyInBranch(Object key, CDOBranch branch)
- {
- return ObjectUtil.equals(((CDOIDAndBranch)key).getBranch(), branch);
- }
-
- @Override
- protected Object createKey(CDOID id, CDOBranch branch)
- {
- return CDOIDUtil.createIDAndBranch(id, branch);
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class TypeAndRefCounter
- {
- private EClass type;
-
- private int refCounter;
-
- public TypeAndRefCounter(EClass type)
- {
- this.type = type;
- }
-
- public EClass getType()
- {
- return type;
- }
-
- public void increase()
- {
- ++refCounter;
- }
-
- public int decreaseAndGet()
- {
- return --refCounter;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Simon McDuff - bug 201266
+ * Simon McDuff - bug 230832
+ */
+package org.eclipse.emf.cdo.internal.common.revision;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
+
+import org.eclipse.net4j.util.ObjectUtil;
+
+import org.eclipse.emf.ecore.EClass;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDORevisionCacheBranching extends CDORevisionCacheAuditing
+{
+ private Map<CDOID, TypeAndRefCounter> typeMap = new HashMap<CDOID, TypeAndRefCounter>();
+
+ public CDORevisionCacheBranching()
+ {
+ }
+
+ @Override
+ public InternalCDORevisionCache instantiate(CDORevision revision)
+ {
+ return new CDORevisionCacheBranching();
+ }
+
+ @Override
+ public EClass getObjectType(CDOID id)
+ {
+ synchronized (revisionLists)
+ {
+ TypeAndRefCounter typeCounter = typeMap.get(id);
+ if (typeCounter != null)
+ {
+ return typeCounter.getType();
+ }
+
+ return null;
+ }
+ }
+
+ @Override
+ protected void typeRefIncrease(CDOID id, EClass type)
+ {
+ TypeAndRefCounter typeCounter = typeMap.get(id);
+ if (typeCounter == null)
+ {
+ typeCounter = new TypeAndRefCounter(type);
+ typeMap.put(id, typeCounter);
+ }
+
+ typeCounter.increase();
+ }
+
+ @Override
+ protected void typeRefDecrease(CDOID id)
+ {
+ TypeAndRefCounter typeCounter = typeMap.get(id);
+ if (typeCounter != null && typeCounter.decreaseAndGet() == 0)
+ {
+ typeMap.remove(id);
+ }
+ }
+
+ @Override
+ protected void typeRefDispose()
+ {
+ typeMap.clear();
+ }
+
+ @Override
+ protected boolean isKeyInBranch(Object key, CDOBranch branch)
+ {
+ return ObjectUtil.equals(((CDOIDAndBranch)key).getBranch(), branch);
+ }
+
+ @Override
+ protected Object createKey(CDOID id, CDOBranch branch)
+ {
+ return CDOIDUtil.createIDAndBranch(id, branch);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class TypeAndRefCounter
+ {
+ private EClass type;
+
+ private int refCounter;
+
+ public TypeAndRefCounter(EClass type)
+ {
+ this.type = type;
+ }
+
+ public EClass getType()
+ {
+ return type;
+ }
+
+ public void increase()
+ {
+ ++refCounter;
+ }
+
+ public int decreaseAndGet()
+ {
+ return --refCounter;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheNonAuditing.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheNonAuditing.java
index a22694a0c4..4faa69bc04 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheNonAuditing.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheNonAuditing.java
@@ -1,217 +1,217 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - bug 201266
- * Simon McDuff - bug 230832
- */
-package org.eclipse.emf.cdo.internal.common.revision;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
-
-import org.eclipse.net4j.util.CheckUtil;
-
-import org.eclipse.emf.ecore.EClass;
-
-import java.lang.ref.Reference;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class CDORevisionCacheNonAuditing extends AbstractCDORevisionCache
-{
- private Map<CDOID, Reference<InternalCDORevision>> revisions = new HashMap<CDOID, Reference<InternalCDORevision>>();
-
- public CDORevisionCacheNonAuditing()
- {
- }
-
- public InternalCDORevisionCache instantiate(CDORevision revision)
- {
- return new CDORevisionCacheNonAuditing();
- }
-
- public EClass getObjectType(CDOID id)
- {
- synchronized (revisions)
- {
- Reference<InternalCDORevision> ref = revisions.get(id);
- if (ref != null)
- {
- InternalCDORevision revision = ref.get();
- if (revision != null)
- {
- return revision.getEClass();
- }
- }
-
- return null;
- }
- }
-
- public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint)
- {
- synchronized (revisions)
- {
- Reference<InternalCDORevision> ref = revisions.get(id);
- if (ref != null)
- {
- InternalCDORevision revision = ref.get();
- if (revision != null && revision.isValid(branchPoint))
- {
- return revision;
- }
- }
-
- return null;
- }
- }
-
- public InternalCDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion)
- {
- synchronized (revisions)
- {
- Reference<InternalCDORevision> ref = revisions.get(id);
- if (ref != null)
- {
- InternalCDORevision revision = ref.get();
- if (revision != null && revision.getVersion() == branchVersion.getVersion())
- {
- return revision;
- }
- }
-
- return null;
- }
- }
-
- public List<CDORevision> getCurrentRevisions()
- {
- List<CDORevision> currentRevisions = new ArrayList<CDORevision>();
- synchronized (revisions)
- {
- for (Reference<InternalCDORevision> ref : revisions.values())
- {
- InternalCDORevision revision = ref.get();
- if (revision != null && !revision.isHistorical())
- {
- currentRevisions.add(revision);
- }
- }
- }
-
- return currentRevisions;
- }
-
- public Map<CDOBranch, List<CDORevision>> getAllRevisions()
- {
- Map<CDOBranch, List<CDORevision>> result = new HashMap<CDOBranch, List<CDORevision>>();
- synchronized (revisions)
- {
- List<CDORevision> list = new ArrayList<CDORevision>();
- for (Reference<InternalCDORevision> ref : revisions.values())
- {
- InternalCDORevision revision = ref.get();
- if (revision != null)
- {
- list.add(revision);
- }
- }
-
- if (!list.isEmpty())
- {
- result.put(list.get(0).getBranch(), list);
- }
- }
-
- return result;
- }
-
- public List<CDORevision> getRevisions(CDOBranchPoint branchPoint)
- {
- List<CDORevision> result = new ArrayList<CDORevision>();
- synchronized (revisions)
- {
- for (Reference<InternalCDORevision> ref : revisions.values())
- {
- InternalCDORevision revision = ref.get();
- if (revision != null && revision.isValid(branchPoint))
- {
- result.add(revision);
- }
- }
- }
-
- return result;
- }
-
- public void addRevision(CDORevision revision)
- {
- CheckUtil.checkArg(revision, "revision");
- if (!revision.isHistorical())
- {
- synchronized (revisions)
- {
- revisions.put(revision.getID(), createReference(revision));
- }
- }
- }
-
- public InternalCDORevision removeRevision(CDOID id, CDOBranchVersion branchVersion)
- {
- synchronized (revisions)
- {
- Reference<InternalCDORevision> ref = revisions.get(id);
- if (ref != null)
- {
- InternalCDORevision revision = ref.get();
- if (revision != null)
- {
- if (revision.getVersion() == branchVersion.getVersion()) // No branch check needed in non-auditing
- {
- revisions.remove(id);
- return revision;
- }
- }
- else
- {
- revisions.remove(id);
- }
- }
- }
-
- return null;
- }
-
- public void clear()
- {
- synchronized (revisions)
- {
- revisions.clear();
- }
- }
-
- @Override
- public String toString()
- {
- synchronized (revisions)
- {
- return revisions.toString();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Simon McDuff - bug 201266
+ * Simon McDuff - bug 230832
+ */
+package org.eclipse.emf.cdo.internal.common.revision;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
+
+import org.eclipse.net4j.util.CheckUtil;
+
+import org.eclipse.emf.ecore.EClass;
+
+import java.lang.ref.Reference;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDORevisionCacheNonAuditing extends AbstractCDORevisionCache
+{
+ private Map<CDOID, Reference<InternalCDORevision>> revisions = new HashMap<CDOID, Reference<InternalCDORevision>>();
+
+ public CDORevisionCacheNonAuditing()
+ {
+ }
+
+ public InternalCDORevisionCache instantiate(CDORevision revision)
+ {
+ return new CDORevisionCacheNonAuditing();
+ }
+
+ public EClass getObjectType(CDOID id)
+ {
+ synchronized (revisions)
+ {
+ Reference<InternalCDORevision> ref = revisions.get(id);
+ if (ref != null)
+ {
+ InternalCDORevision revision = ref.get();
+ if (revision != null)
+ {
+ return revision.getEClass();
+ }
+ }
+
+ return null;
+ }
+ }
+
+ public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint)
+ {
+ synchronized (revisions)
+ {
+ Reference<InternalCDORevision> ref = revisions.get(id);
+ if (ref != null)
+ {
+ InternalCDORevision revision = ref.get();
+ if (revision != null && revision.isValid(branchPoint))
+ {
+ return revision;
+ }
+ }
+
+ return null;
+ }
+ }
+
+ public InternalCDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion)
+ {
+ synchronized (revisions)
+ {
+ Reference<InternalCDORevision> ref = revisions.get(id);
+ if (ref != null)
+ {
+ InternalCDORevision revision = ref.get();
+ if (revision != null && revision.getVersion() == branchVersion.getVersion())
+ {
+ return revision;
+ }
+ }
+
+ return null;
+ }
+ }
+
+ public List<CDORevision> getCurrentRevisions()
+ {
+ List<CDORevision> currentRevisions = new ArrayList<CDORevision>();
+ synchronized (revisions)
+ {
+ for (Reference<InternalCDORevision> ref : revisions.values())
+ {
+ InternalCDORevision revision = ref.get();
+ if (revision != null && !revision.isHistorical())
+ {
+ currentRevisions.add(revision);
+ }
+ }
+ }
+
+ return currentRevisions;
+ }
+
+ public Map<CDOBranch, List<CDORevision>> getAllRevisions()
+ {
+ Map<CDOBranch, List<CDORevision>> result = new HashMap<CDOBranch, List<CDORevision>>();
+ synchronized (revisions)
+ {
+ List<CDORevision> list = new ArrayList<CDORevision>();
+ for (Reference<InternalCDORevision> ref : revisions.values())
+ {
+ InternalCDORevision revision = ref.get();
+ if (revision != null)
+ {
+ list.add(revision);
+ }
+ }
+
+ if (!list.isEmpty())
+ {
+ result.put(list.get(0).getBranch(), list);
+ }
+ }
+
+ return result;
+ }
+
+ public List<CDORevision> getRevisions(CDOBranchPoint branchPoint)
+ {
+ List<CDORevision> result = new ArrayList<CDORevision>();
+ synchronized (revisions)
+ {
+ for (Reference<InternalCDORevision> ref : revisions.values())
+ {
+ InternalCDORevision revision = ref.get();
+ if (revision != null && revision.isValid(branchPoint))
+ {
+ result.add(revision);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public void addRevision(CDORevision revision)
+ {
+ CheckUtil.checkArg(revision, "revision");
+ if (!revision.isHistorical())
+ {
+ synchronized (revisions)
+ {
+ revisions.put(revision.getID(), createReference(revision));
+ }
+ }
+ }
+
+ public InternalCDORevision removeRevision(CDOID id, CDOBranchVersion branchVersion)
+ {
+ synchronized (revisions)
+ {
+ Reference<InternalCDORevision> ref = revisions.get(id);
+ if (ref != null)
+ {
+ InternalCDORevision revision = ref.get();
+ if (revision != null)
+ {
+ if (revision.getVersion() == branchVersion.getVersion()) // No branch check needed in non-auditing
+ {
+ revisions.remove(id);
+ return revision;
+ }
+ }
+ else
+ {
+ revisions.remove(id);
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public void clear()
+ {
+ synchronized (revisions)
+ {
+ revisions.clear();
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ synchronized (revisions)
+ {
+ return revisions.toString();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java
index 96e21a207c..a5822febd2 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java
@@ -1,143 +1,143 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - bug 201266
- * Simon McDuff - bug 212958
- * Simon McDuff - bug 213402
- * Caspar De Groot - bug 341081
- */
-package org.eclipse.emf.cdo.internal.common.revision;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDTemp;
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.model.CDOType;
-import org.eclipse.emf.cdo.spi.common.revision.BaseCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOList;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-/**
- * @author Eike Stepper
- */
-public class CDORevisionImpl extends BaseCDORevision
-{
- private Object[] values;
-
- private transient boolean frozen;
-
- public CDORevisionImpl(EClass eClass)
- {
- super(eClass);
- }
-
- protected CDORevisionImpl(CDORevisionImpl source)
- {
- super(source);
- EStructuralFeature[] features = CDOModelUtil.getAllPersistentFeatures(getEClass());
- initValues(features);
- for (int i = 0; i < features.length; i++)
- {
- EStructuralFeature feature = features[i];
- EClassifier classifier = feature.getEType();
- if (feature.isMany())
- {
- InternalCDOList sourceList = (InternalCDOList)source.values[i];
- if (sourceList != null)
- {
- setValue(i, sourceList.clone(classifier));
- }
- }
- else
- {
- CDOType type = CDOModelUtil.getType(feature);
- setValue(i, type.copyValue(source.values[i]));
- }
- }
- }
-
- public InternalCDORevision copy()
- {
- return new CDORevisionImpl(this);
- }
-
- @Override
- protected void initValues(EStructuralFeature[] allPersistentFeatures)
- {
- values = new Object[allPersistentFeatures.length];
- }
-
- @Override
- protected Object getValue(int featureIndex)
- {
- return values[featureIndex];
- }
-
- @Override
- protected void setValue(int featureIndex, Object value)
- {
- checkFrozen(featureIndex, value);
- values[featureIndex] = value;
- }
-
- public void freeze()
- {
- if (getEClass().getName().equals("Node"))
- {
- System.out.println();
- }
-
- frozen = true;
-
- EStructuralFeature[] features = CDOModelUtil.getAllPersistentFeatures(getEClass());
- for (int i = 0; i < features.length; i++)
- {
- EStructuralFeature feature = features[i];
- if (feature.isMany())
- {
- InternalCDOList list = (InternalCDOList)values[i];
- if (list != null)
- {
- list.freeze();
- }
- }
- }
- }
-
- private void checkFrozen(int featureIndex, Object value)
- {
- if (frozen)
- {
- Object oldValue = values[featureIndex];
-
- // Exception 1: Setting an empty list as the value for an isMany feature, is
- // allowed if the old value is null. This is a case of lazy initialization.
- boolean newIsEmptyList = value instanceof EList<?> && ((EList<?>)value).size() == 0;
- if (newIsEmptyList && oldValue == null)
- {
- return;
- }
-
- // Exception 2a: Replacing a temp ID with a regular ID is allowed (happens during
- // postCommit of new objects)
- // Exception 2b: Replacing a temp ID with another temp ID is also allowed (happens
- // when changes are imported in a PushTx).
- if (oldValue instanceof CDOIDTemp && value instanceof CDOID)
- {
- return;
- }
-
- throw new IllegalStateException("Cannot modify a frozen revision");
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Simon McDuff - bug 201266
+ * Simon McDuff - bug 212958
+ * Simon McDuff - bug 213402
+ * Caspar De Groot - bug 341081
+ */
+package org.eclipse.emf.cdo.internal.common.revision;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDTemp;
+import org.eclipse.emf.cdo.common.model.CDOModelUtil;
+import org.eclipse.emf.cdo.common.model.CDOType;
+import org.eclipse.emf.cdo.spi.common.revision.BaseCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDOList;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDORevisionImpl extends BaseCDORevision
+{
+ private Object[] values;
+
+ private transient boolean frozen;
+
+ public CDORevisionImpl(EClass eClass)
+ {
+ super(eClass);
+ }
+
+ protected CDORevisionImpl(CDORevisionImpl source)
+ {
+ super(source);
+ EStructuralFeature[] features = CDOModelUtil.getAllPersistentFeatures(getEClass());
+ initValues(features);
+ for (int i = 0; i < features.length; i++)
+ {
+ EStructuralFeature feature = features[i];
+ EClassifier classifier = feature.getEType();
+ if (feature.isMany())
+ {
+ InternalCDOList sourceList = (InternalCDOList)source.values[i];
+ if (sourceList != null)
+ {
+ setValue(i, sourceList.clone(classifier));
+ }
+ }
+ else
+ {
+ CDOType type = CDOModelUtil.getType(feature);
+ setValue(i, type.copyValue(source.values[i]));
+ }
+ }
+ }
+
+ public InternalCDORevision copy()
+ {
+ return new CDORevisionImpl(this);
+ }
+
+ @Override
+ protected void initValues(EStructuralFeature[] allPersistentFeatures)
+ {
+ values = new Object[allPersistentFeatures.length];
+ }
+
+ @Override
+ protected Object getValue(int featureIndex)
+ {
+ return values[featureIndex];
+ }
+
+ @Override
+ protected void setValue(int featureIndex, Object value)
+ {
+ checkFrozen(featureIndex, value);
+ values[featureIndex] = value;
+ }
+
+ public void freeze()
+ {
+ if (getEClass().getName().equals("Node"))
+ {
+ System.out.println();
+ }
+
+ frozen = true;
+
+ EStructuralFeature[] features = CDOModelUtil.getAllPersistentFeatures(getEClass());
+ for (int i = 0; i < features.length; i++)
+ {
+ EStructuralFeature feature = features[i];
+ if (feature.isMany())
+ {
+ InternalCDOList list = (InternalCDOList)values[i];
+ if (list != null)
+ {
+ list.freeze();
+ }
+ }
+ }
+ }
+
+ private void checkFrozen(int featureIndex, Object value)
+ {
+ if (frozen)
+ {
+ Object oldValue = values[featureIndex];
+
+ // Exception 1: Setting an empty list as the value for an isMany feature, is
+ // allowed if the old value is null. This is a case of lazy initialization.
+ boolean newIsEmptyList = value instanceof EList<?> && ((EList<?>)value).size() == 0;
+ if (newIsEmptyList && oldValue == null)
+ {
+ return;
+ }
+
+ // Exception 2a: Replacing a temp ID with a regular ID is allowed (happens during
+ // postCommit of new objects)
+ // Exception 2b: Replacing a temp ID with another temp ID is also allowed (happens
+ // when changes are imported in a PushTx).
+ if (oldValue instanceof CDOIDTemp && value instanceof CDOID)
+ {
+ return;
+ }
+
+ throw new IllegalStateException("Cannot modify a frozen revision");
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionKeyImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionKeyImpl.java
index 0c3e4a72f0..c220b309a6 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionKeyImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionKeyImpl.java
@@ -1,66 +1,66 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.revision;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-import org.eclipse.emf.cdo.internal.common.branch.CDOBranchVersionImpl;
-
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public class CDORevisionKeyImpl extends CDOBranchVersionImpl implements CDORevisionKey
-{
- private CDOID id;
-
- public CDORevisionKeyImpl(CDOID id, CDOBranch branch, int version)
- {
- super(branch, version);
- this.id = id;
- }
-
- public CDOID getID()
- {
- return id;
- }
-
- @Override
- public int hashCode()
- {
- return id.hashCode() ^ super.hashCode();
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj instanceof CDORevisionKey)
- {
- CDORevisionKey that = (CDORevisionKey)obj;
- return id.equals(that.getID()) && getBranch().equals(that.getBranch()) && getVersion() == that.getVersion();
- }
-
- return false;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("{0}:{1}v{2}", id, getBranch().getID(), getVersion());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.revision;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
+import org.eclipse.emf.cdo.internal.common.branch.CDOBranchVersionImpl;
+
+import java.text.MessageFormat;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDORevisionKeyImpl extends CDOBranchVersionImpl implements CDORevisionKey
+{
+ private CDOID id;
+
+ public CDORevisionKeyImpl(CDOID id, CDOBranch branch, int version)
+ {
+ super(branch, version);
+ this.id = id;
+ }
+
+ public CDOID getID()
+ {
+ return id;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return id.hashCode() ^ super.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+
+ if (obj instanceof CDORevisionKey)
+ {
+ CDORevisionKey that = (CDORevisionKey)obj;
+ return id.equals(that.getID()) && getBranch().equals(that.getBranch()) && getVersion() == that.getVersion();
+ }
+
+ return false;
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("{0}:{1}v{2}", id, getBranch().getID(), getVersion());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionManagerImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionManagerImpl.java
index 946938b0c0..00331a53d3 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionManagerImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionManagerImpl.java
@@ -1,539 +1,539 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - bug 201266
- * Simon McDuff - bug 230832
- */
-package org.eclipse.emf.cdo.internal.common.revision;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionCache;
-import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
-import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
-import org.eclipse.emf.cdo.internal.common.bundle.OM;
-import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
-import org.eclipse.emf.cdo.spi.common.revision.DetachedCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
-import org.eclipse.emf.cdo.spi.common.revision.PointerCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.RevisionInfo;
-import org.eclipse.emf.cdo.spi.common.revision.SyntheticCDORevision;
-
-import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
-import org.eclipse.net4j.util.lifecycle.Lifecycle;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EClass;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class CDORevisionManagerImpl extends Lifecycle implements InternalCDORevisionManager
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_REVISION, CDORevisionManagerImpl.class);
-
- private boolean supportingAudits;
-
- private boolean supportingBranches;
-
- private RevisionLoader revisionLoader;
-
- private RevisionLocker revisionLocker;
-
- private CDORevisionFactory factory;
-
- private InternalCDORevisionCache cache;
-
- @ExcludeFromDump
- private transient Object loadAndAddLock = new Object()
- {
- @Override
- public String toString()
- {
- return "LoadAndAddLock"; //$NON-NLS-1$
- }
- };
-
- @ExcludeFromDump
- private transient Object reviseLock = new Object()
- {
- @Override
- public String toString()
- {
- return "ReviseLock"; //$NON-NLS-1$
- }
- };
-
- public CDORevisionManagerImpl()
- {
- }
-
- public boolean isSupportingAudits()
- {
- return supportingAudits;
- }
-
- public void setSupportingAudits(boolean on)
- {
- checkInactive();
- supportingAudits = on;
- }
-
- public boolean isSupportingBranches()
- {
- return supportingBranches;
- }
-
- public void setSupportingBranches(boolean on)
- {
- checkInactive();
- supportingBranches = on;
- }
-
- public RevisionLoader getRevisionLoader()
- {
- return revisionLoader;
- }
-
- public void setRevisionLoader(RevisionLoader revisionLoader)
- {
- checkInactive();
- this.revisionLoader = revisionLoader;
- }
-
- public RevisionLocker getRevisionLocker()
- {
- return revisionLocker;
- }
-
- public void setRevisionLocker(RevisionLocker revisionLocker)
- {
- checkInactive();
- this.revisionLocker = revisionLocker;
- }
-
- public CDORevisionFactory getFactory()
- {
- return factory;
- }
-
- public void setFactory(CDORevisionFactory factory)
- {
- checkInactive();
- this.factory = factory;
- }
-
- public InternalCDORevisionCache getCache()
- {
- return cache;
- }
-
- public void setCache(CDORevisionCache cache)
- {
- checkInactive();
- this.cache = (InternalCDORevisionCache)cache;
- }
-
- public EClass getObjectType(CDOID id, CDOBranchManager branchManagerForLoadOnDemand)
- {
- EClass type = cache.getObjectType(id);
- if (type == null && branchManagerForLoadOnDemand != null)
- {
- CDOBranch mainBranch = branchManagerForLoadOnDemand.getMainBranch();
- CDORevision revision = getRevisionByVersion(id, mainBranch.getVersion(CDOBranchVersion.FIRST_VERSION), 0, true);
- if (revision != null)
- {
- type = revision.getEClass();
- }
- }
-
- return type;
- }
-
- public EClass getObjectType(CDOID id)
- {
- return getObjectType(id, null);
- }
-
- public boolean containsRevision(CDOID id, CDOBranchPoint branchPoint)
- {
- if (supportingBranches)
- {
- return getRevision(id, branchPoint, CDORevision.UNCHUNKED, CDORevision.DEPTH_NONE, false, null) != null;
- }
-
- return getCachedRevision(id, branchPoint) != null;
- }
-
- public boolean containsRevisionByVersion(CDOID id, CDOBranchVersion branchVersion)
- {
- return cache.getRevisionByVersion(id, branchVersion) != null;
- }
-
- public void reviseLatest(CDOID id, CDOBranch branch)
- {
- acquireAtomicRequestLock(reviseLock);
-
- try
- {
- InternalCDORevision revision = (InternalCDORevision)cache.getRevision(id, branch.getHead());
- if (revision != null)
- {
- cache.removeRevision(id, branch.getVersion(revision.getVersion()));
- }
- }
- finally
- {
- releaseAtomicRequestLock(reviseLock);
- }
- }
-
- public void reviseVersion(CDOID id, CDOBranchVersion branchVersion, long timeStamp)
- {
- acquireAtomicRequestLock(reviseLock);
-
- try
- {
- InternalCDORevision revision = getCachedRevisionByVersion(id, branchVersion);
- if (revision != null)
- {
- if (timeStamp == CDORevision.UNSPECIFIED_DATE)
- {
- cache.removeRevision(id, branchVersion);
- }
- else
- {
- revision.setRevised(timeStamp - 1);
- }
- }
- }
- finally
- {
- releaseAtomicRequestLock(reviseLock);
- }
- }
-
- public InternalCDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int referenceChunk,
- boolean loadOnDemand)
- {
- checkArg(branchVersion.getVersion() >= CDOBranchVersion.FIRST_VERSION,
- "Invalid version: " + branchVersion.getVersion());
- acquireAtomicRequestLock(loadAndAddLock);
-
- try
- {
- InternalCDORevision revision = getCachedRevisionByVersion(id, branchVersion);
- if (revision == null)
- {
- if (loadOnDemand)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Loading revision {0} from {1}", id, branchVersion); //$NON-NLS-1$
- }
-
- revision = revisionLoader.loadRevisionByVersion(id, branchVersion, referenceChunk);
- addRevision(revision);
- }
- }
-
- return revision;
- }
- finally
- {
- releaseAtomicRequestLock(loadAndAddLock);
- }
- }
-
- public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth,
- boolean loadOnDemand)
- {
- return getRevision(id, branchPoint, referenceChunk, prefetchDepth, loadOnDemand, null);
- }
-
- public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth,
- boolean loadOnDemand, SyntheticCDORevision[] synthetics)
- {
- List<CDOID> ids = Collections.singletonList(id);
- CDORevision result = getRevisions(ids, branchPoint, referenceChunk, prefetchDepth, loadOnDemand, synthetics).get(0);
- return (InternalCDORevision)result;
- }
-
- public List<CDORevision> getRevisions(List<CDOID> ids, CDOBranchPoint branchPoint, int referenceChunk,
- int prefetchDepth, boolean loadOnDemand)
- {
- return getRevisions(ids, branchPoint, referenceChunk, prefetchDepth, loadOnDemand, null);
- }
-
- public List<CDORevision> getRevisions(List<CDOID> ids, CDOBranchPoint branchPoint, int referenceChunk,
- int prefetchDepth, boolean loadOnDemand, SyntheticCDORevision[] synthetics)
- {
- RevisionInfo[] infos = new RevisionInfo[ids.size()];
- List<RevisionInfo> infosToLoad = createRevisionInfos(ids, branchPoint, prefetchDepth, loadOnDemand, infos);
- if (infosToLoad != null)
- {
- loadRevisions(infosToLoad, branchPoint, referenceChunk, prefetchDepth);
- }
-
- return getResultsAndSynthetics(infos, synthetics);
- }
-
- private List<RevisionInfo> createRevisionInfos(List<CDOID> ids, CDOBranchPoint branchPoint, int prefetchDepth,
- boolean loadOnDemand, RevisionInfo[] infos)
- {
- List<RevisionInfo> infosToLoad = null;
- Iterator<CDOID> idIterator = ids.iterator();
- for (int i = 0; i < infos.length; i++)
- {
- CDOID id = idIterator.next();
- RevisionInfo info = createRevisionInfo(id, branchPoint);
- infos[i] = info;
-
- if (loadOnDemand && (prefetchDepth != CDORevision.DEPTH_NONE || info.isLoadNeeded()))
- {
- if (infosToLoad == null)
- {
- infosToLoad = new ArrayList<RevisionInfo>(1);
- }
-
- infosToLoad.add(info);
- }
- }
-
- return infosToLoad;
- }
-
- private RevisionInfo createRevisionInfo(CDOID id, CDOBranchPoint branchPoint)
- {
- InternalCDORevision revision = getCachedRevision(id, branchPoint);
- if (revision != null)
- {
- return createRevisionInfoAvailable(revision, branchPoint);
- }
-
- if (supportingBranches)
- {
- revision = getCachedRevisionRecursively(id, branchPoint);
- if (revision != null)
- {
- return createRevisionInfoAvailable(revision, branchPoint);
- }
- }
-
- return createRevisionInfoMissing(id, branchPoint);
- }
-
- private RevisionInfo.Available createRevisionInfoAvailable(InternalCDORevision revision,
- CDOBranchPoint requestedBranchPoint)
- {
- if (revision instanceof PointerCDORevision)
- {
- PointerCDORevision pointer = (PointerCDORevision)revision;
- CDOBranchVersion target = pointer.getTarget();
- InternalCDORevision targetRevision = target == null ? null : getCachedRevisionByVersion(pointer.getID(), target);
- if (targetRevision != null)
- {
- target = targetRevision;
- }
-
- return new RevisionInfo.Available.Pointer(pointer.getID(), requestedBranchPoint, pointer, target);
- }
-
- if (revision instanceof DetachedCDORevision)
- {
- DetachedCDORevision detached = (DetachedCDORevision)revision;
- return new RevisionInfo.Available.Detached(detached.getID(), requestedBranchPoint, detached);
- }
-
- return new RevisionInfo.Available.Normal(revision.getID(), requestedBranchPoint, revision);
- }
-
- private RevisionInfo.Missing createRevisionInfoMissing(CDOID id, CDOBranchPoint requestedBranchPoint)
- {
- return new RevisionInfo.Missing(id, requestedBranchPoint);
- }
-
- protected List<InternalCDORevision> loadRevisions(List<RevisionInfo> infosToLoad, CDOBranchPoint branchPoint,
- int referenceChunk, int prefetchDepth)
- {
- acquireAtomicRequestLock(loadAndAddLock);
-
- try
- {
- List<InternalCDORevision> additionalRevisions = //
- revisionLoader.loadRevisions(infosToLoad, branchPoint, referenceChunk, prefetchDepth);
-
- if (additionalRevisions != null)
- {
- for (InternalCDORevision revision : additionalRevisions)
- {
- addRevision(revision);
- }
- }
-
- return additionalRevisions;
- }
- finally
- {
- releaseAtomicRequestLock(loadAndAddLock);
- }
- }
-
- private List<CDORevision> getResultsAndSynthetics(RevisionInfo[] infos, SyntheticCDORevision[] synthetics)
- {
- List<CDORevision> results = new ArrayList<CDORevision>(infos.length);
- for (int i = 0; i < infos.length; i++)
- {
- RevisionInfo info = infos[i];
- info.processResult(this, results, synthetics, i);
- }
-
- return results;
- }
-
- public void addRevision(CDORevision revision)
- {
- if (revision != null)
- {
- acquireAtomicRequestLock(loadAndAddLock);
-
- try
- {
- if (revision instanceof PointerCDORevision)
- {
- PointerCDORevision pointer = (PointerCDORevision)revision;
- CDOBranchVersion target = pointer.getTarget();
- if (target instanceof InternalCDORevision)
- {
- revision = new PointerCDORevision(pointer.getEClass(), pointer.getID(), pointer.getBranch(),
- pointer.getRevised(), CDOBranchUtil.copyBranchVersion(target));
- }
- }
-
- int oldVersion = revision.getVersion() - 1;
- if (oldVersion >= CDORevision.UNSPECIFIED_VERSION)
- {
- CDOBranchVersion old = revision.getBranch().getVersion(oldVersion);
- InternalCDORevision oldRevision = getCachedRevisionByVersion(revision.getID(), old);
- if (!revision.isHistorical())
- {
- if (oldRevision != null)
- {
- oldRevision.setRevised(revision.getTimeStamp() - 1);
- }
- else
- {
- // Remove last revision from cache, which is not revised
- InternalCDORevision cachedLatestRevision = getCachedRevision(revision.getID(), revision);
- if (cachedLatestRevision != null && !cachedLatestRevision.isHistorical())
- {
- // Found revision is stale.
- // We cannot revise it now because of lack information, thus remove it from the cache
- cache.removeRevision(cachedLatestRevision.getID(), cachedLatestRevision);
- }
- }
- }
- }
-
- cache.addRevision(revision);
- }
- finally
- {
- releaseAtomicRequestLock(loadAndAddLock);
- }
- }
- }
-
- @Override
- protected void doBeforeActivate() throws Exception
- {
- super.doBeforeActivate();
- if (factory == null)
- {
- factory = CDORevisionFactory.DEFAULT;
- }
-
- if (cache == null)
- {
- cache = (InternalCDORevisionCache)CDORevisionUtil.createRevisionCache(supportingAudits, supportingBranches);
- }
- }
-
- @Override
- protected void doActivate() throws Exception
- {
- super.doActivate();
- LifecycleUtil.activate(cache);
- }
-
- @Override
- protected void doDeactivate() throws Exception
- {
- LifecycleUtil.deactivate(cache);
- super.doDeactivate();
- }
-
- private void acquireAtomicRequestLock(Object key)
- {
- if (revisionLocker != null)
- {
- revisionLocker.acquireAtomicRequestLock(key);
- }
- }
-
- private void releaseAtomicRequestLock(Object key)
- {
- if (revisionLocker != null)
- {
- revisionLocker.releaseAtomicRequestLock(key);
- }
- }
-
- private InternalCDORevision getCachedRevisionByVersion(CDOID id, CDOBranchVersion branchVersion)
- {
- return (InternalCDORevision)cache.getRevisionByVersion(id, branchVersion);
- }
-
- private InternalCDORevision getCachedRevision(CDOID id, CDOBranchPoint branchPoint)
- {
- return (InternalCDORevision)cache.getRevision(id, branchPoint);
- }
-
- private InternalCDORevision getCachedRevisionRecursively(CDOID id, CDOBranchPoint branchPoint)
- {
- CDOBranch branch = branchPoint.getBranch();
- if (!branch.isMainBranch())
- {
- CDOBranchPoint base = branch.getBase();
- InternalCDORevision revision = getCachedRevision(id, base);
- if (revision != null)
- {
- return revision;
- }
-
- // Recurse
- return getCachedRevisionRecursively(id, base);
- }
-
- // Reached main branch
- return null;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Simon McDuff - bug 201266
+ * Simon McDuff - bug 230832
+ */
+package org.eclipse.emf.cdo.internal.common.revision;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionCache;
+import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
+import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
+import org.eclipse.emf.cdo.internal.common.bundle.OM;
+import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
+import org.eclipse.emf.cdo.spi.common.revision.DetachedCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
+import org.eclipse.emf.cdo.spi.common.revision.PointerCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.RevisionInfo;
+import org.eclipse.emf.cdo.spi.common.revision.SyntheticCDORevision;
+
+import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
+import org.eclipse.net4j.util.lifecycle.Lifecycle;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.emf.ecore.EClass;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDORevisionManagerImpl extends Lifecycle implements InternalCDORevisionManager
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_REVISION, CDORevisionManagerImpl.class);
+
+ private boolean supportingAudits;
+
+ private boolean supportingBranches;
+
+ private RevisionLoader revisionLoader;
+
+ private RevisionLocker revisionLocker;
+
+ private CDORevisionFactory factory;
+
+ private InternalCDORevisionCache cache;
+
+ @ExcludeFromDump
+ private transient Object loadAndAddLock = new Object()
+ {
+ @Override
+ public String toString()
+ {
+ return "LoadAndAddLock"; //$NON-NLS-1$
+ }
+ };
+
+ @ExcludeFromDump
+ private transient Object reviseLock = new Object()
+ {
+ @Override
+ public String toString()
+ {
+ return "ReviseLock"; //$NON-NLS-1$
+ }
+ };
+
+ public CDORevisionManagerImpl()
+ {
+ }
+
+ public boolean isSupportingAudits()
+ {
+ return supportingAudits;
+ }
+
+ public void setSupportingAudits(boolean on)
+ {
+ checkInactive();
+ supportingAudits = on;
+ }
+
+ public boolean isSupportingBranches()
+ {
+ return supportingBranches;
+ }
+
+ public void setSupportingBranches(boolean on)
+ {
+ checkInactive();
+ supportingBranches = on;
+ }
+
+ public RevisionLoader getRevisionLoader()
+ {
+ return revisionLoader;
+ }
+
+ public void setRevisionLoader(RevisionLoader revisionLoader)
+ {
+ checkInactive();
+ this.revisionLoader = revisionLoader;
+ }
+
+ public RevisionLocker getRevisionLocker()
+ {
+ return revisionLocker;
+ }
+
+ public void setRevisionLocker(RevisionLocker revisionLocker)
+ {
+ checkInactive();
+ this.revisionLocker = revisionLocker;
+ }
+
+ public CDORevisionFactory getFactory()
+ {
+ return factory;
+ }
+
+ public void setFactory(CDORevisionFactory factory)
+ {
+ checkInactive();
+ this.factory = factory;
+ }
+
+ public InternalCDORevisionCache getCache()
+ {
+ return cache;
+ }
+
+ public void setCache(CDORevisionCache cache)
+ {
+ checkInactive();
+ this.cache = (InternalCDORevisionCache)cache;
+ }
+
+ public EClass getObjectType(CDOID id, CDOBranchManager branchManagerForLoadOnDemand)
+ {
+ EClass type = cache.getObjectType(id);
+ if (type == null && branchManagerForLoadOnDemand != null)
+ {
+ CDOBranch mainBranch = branchManagerForLoadOnDemand.getMainBranch();
+ CDORevision revision = getRevisionByVersion(id, mainBranch.getVersion(CDOBranchVersion.FIRST_VERSION), 0, true);
+ if (revision != null)
+ {
+ type = revision.getEClass();
+ }
+ }
+
+ return type;
+ }
+
+ public EClass getObjectType(CDOID id)
+ {
+ return getObjectType(id, null);
+ }
+
+ public boolean containsRevision(CDOID id, CDOBranchPoint branchPoint)
+ {
+ if (supportingBranches)
+ {
+ return getRevision(id, branchPoint, CDORevision.UNCHUNKED, CDORevision.DEPTH_NONE, false, null) != null;
+ }
+
+ return getCachedRevision(id, branchPoint) != null;
+ }
+
+ public boolean containsRevisionByVersion(CDOID id, CDOBranchVersion branchVersion)
+ {
+ return cache.getRevisionByVersion(id, branchVersion) != null;
+ }
+
+ public void reviseLatest(CDOID id, CDOBranch branch)
+ {
+ acquireAtomicRequestLock(reviseLock);
+
+ try
+ {
+ InternalCDORevision revision = (InternalCDORevision)cache.getRevision(id, branch.getHead());
+ if (revision != null)
+ {
+ cache.removeRevision(id, branch.getVersion(revision.getVersion()));
+ }
+ }
+ finally
+ {
+ releaseAtomicRequestLock(reviseLock);
+ }
+ }
+
+ public void reviseVersion(CDOID id, CDOBranchVersion branchVersion, long timeStamp)
+ {
+ acquireAtomicRequestLock(reviseLock);
+
+ try
+ {
+ InternalCDORevision revision = getCachedRevisionByVersion(id, branchVersion);
+ if (revision != null)
+ {
+ if (timeStamp == CDORevision.UNSPECIFIED_DATE)
+ {
+ cache.removeRevision(id, branchVersion);
+ }
+ else
+ {
+ revision.setRevised(timeStamp - 1);
+ }
+ }
+ }
+ finally
+ {
+ releaseAtomicRequestLock(reviseLock);
+ }
+ }
+
+ public InternalCDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int referenceChunk,
+ boolean loadOnDemand)
+ {
+ checkArg(branchVersion.getVersion() >= CDOBranchVersion.FIRST_VERSION,
+ "Invalid version: " + branchVersion.getVersion());
+ acquireAtomicRequestLock(loadAndAddLock);
+
+ try
+ {
+ InternalCDORevision revision = getCachedRevisionByVersion(id, branchVersion);
+ if (revision == null)
+ {
+ if (loadOnDemand)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Loading revision {0} from {1}", id, branchVersion); //$NON-NLS-1$
+ }
+
+ revision = revisionLoader.loadRevisionByVersion(id, branchVersion, referenceChunk);
+ addRevision(revision);
+ }
+ }
+
+ return revision;
+ }
+ finally
+ {
+ releaseAtomicRequestLock(loadAndAddLock);
+ }
+ }
+
+ public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth,
+ boolean loadOnDemand)
+ {
+ return getRevision(id, branchPoint, referenceChunk, prefetchDepth, loadOnDemand, null);
+ }
+
+ public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth,
+ boolean loadOnDemand, SyntheticCDORevision[] synthetics)
+ {
+ List<CDOID> ids = Collections.singletonList(id);
+ CDORevision result = getRevisions(ids, branchPoint, referenceChunk, prefetchDepth, loadOnDemand, synthetics).get(0);
+ return (InternalCDORevision)result;
+ }
+
+ public List<CDORevision> getRevisions(List<CDOID> ids, CDOBranchPoint branchPoint, int referenceChunk,
+ int prefetchDepth, boolean loadOnDemand)
+ {
+ return getRevisions(ids, branchPoint, referenceChunk, prefetchDepth, loadOnDemand, null);
+ }
+
+ public List<CDORevision> getRevisions(List<CDOID> ids, CDOBranchPoint branchPoint, int referenceChunk,
+ int prefetchDepth, boolean loadOnDemand, SyntheticCDORevision[] synthetics)
+ {
+ RevisionInfo[] infos = new RevisionInfo[ids.size()];
+ List<RevisionInfo> infosToLoad = createRevisionInfos(ids, branchPoint, prefetchDepth, loadOnDemand, infos);
+ if (infosToLoad != null)
+ {
+ loadRevisions(infosToLoad, branchPoint, referenceChunk, prefetchDepth);
+ }
+
+ return getResultsAndSynthetics(infos, synthetics);
+ }
+
+ private List<RevisionInfo> createRevisionInfos(List<CDOID> ids, CDOBranchPoint branchPoint, int prefetchDepth,
+ boolean loadOnDemand, RevisionInfo[] infos)
+ {
+ List<RevisionInfo> infosToLoad = null;
+ Iterator<CDOID> idIterator = ids.iterator();
+ for (int i = 0; i < infos.length; i++)
+ {
+ CDOID id = idIterator.next();
+ RevisionInfo info = createRevisionInfo(id, branchPoint);
+ infos[i] = info;
+
+ if (loadOnDemand && (prefetchDepth != CDORevision.DEPTH_NONE || info.isLoadNeeded()))
+ {
+ if (infosToLoad == null)
+ {
+ infosToLoad = new ArrayList<RevisionInfo>(1);
+ }
+
+ infosToLoad.add(info);
+ }
+ }
+
+ return infosToLoad;
+ }
+
+ private RevisionInfo createRevisionInfo(CDOID id, CDOBranchPoint branchPoint)
+ {
+ InternalCDORevision revision = getCachedRevision(id, branchPoint);
+ if (revision != null)
+ {
+ return createRevisionInfoAvailable(revision, branchPoint);
+ }
+
+ if (supportingBranches)
+ {
+ revision = getCachedRevisionRecursively(id, branchPoint);
+ if (revision != null)
+ {
+ return createRevisionInfoAvailable(revision, branchPoint);
+ }
+ }
+
+ return createRevisionInfoMissing(id, branchPoint);
+ }
+
+ private RevisionInfo.Available createRevisionInfoAvailable(InternalCDORevision revision,
+ CDOBranchPoint requestedBranchPoint)
+ {
+ if (revision instanceof PointerCDORevision)
+ {
+ PointerCDORevision pointer = (PointerCDORevision)revision;
+ CDOBranchVersion target = pointer.getTarget();
+ InternalCDORevision targetRevision = target == null ? null : getCachedRevisionByVersion(pointer.getID(), target);
+ if (targetRevision != null)
+ {
+ target = targetRevision;
+ }
+
+ return new RevisionInfo.Available.Pointer(pointer.getID(), requestedBranchPoint, pointer, target);
+ }
+
+ if (revision instanceof DetachedCDORevision)
+ {
+ DetachedCDORevision detached = (DetachedCDORevision)revision;
+ return new RevisionInfo.Available.Detached(detached.getID(), requestedBranchPoint, detached);
+ }
+
+ return new RevisionInfo.Available.Normal(revision.getID(), requestedBranchPoint, revision);
+ }
+
+ private RevisionInfo.Missing createRevisionInfoMissing(CDOID id, CDOBranchPoint requestedBranchPoint)
+ {
+ return new RevisionInfo.Missing(id, requestedBranchPoint);
+ }
+
+ protected List<InternalCDORevision> loadRevisions(List<RevisionInfo> infosToLoad, CDOBranchPoint branchPoint,
+ int referenceChunk, int prefetchDepth)
+ {
+ acquireAtomicRequestLock(loadAndAddLock);
+
+ try
+ {
+ List<InternalCDORevision> additionalRevisions = //
+ revisionLoader.loadRevisions(infosToLoad, branchPoint, referenceChunk, prefetchDepth);
+
+ if (additionalRevisions != null)
+ {
+ for (InternalCDORevision revision : additionalRevisions)
+ {
+ addRevision(revision);
+ }
+ }
+
+ return additionalRevisions;
+ }
+ finally
+ {
+ releaseAtomicRequestLock(loadAndAddLock);
+ }
+ }
+
+ private List<CDORevision> getResultsAndSynthetics(RevisionInfo[] infos, SyntheticCDORevision[] synthetics)
+ {
+ List<CDORevision> results = new ArrayList<CDORevision>(infos.length);
+ for (int i = 0; i < infos.length; i++)
+ {
+ RevisionInfo info = infos[i];
+ info.processResult(this, results, synthetics, i);
+ }
+
+ return results;
+ }
+
+ public void addRevision(CDORevision revision)
+ {
+ if (revision != null)
+ {
+ acquireAtomicRequestLock(loadAndAddLock);
+
+ try
+ {
+ if (revision instanceof PointerCDORevision)
+ {
+ PointerCDORevision pointer = (PointerCDORevision)revision;
+ CDOBranchVersion target = pointer.getTarget();
+ if (target instanceof InternalCDORevision)
+ {
+ revision = new PointerCDORevision(pointer.getEClass(), pointer.getID(), pointer.getBranch(),
+ pointer.getRevised(), CDOBranchUtil.copyBranchVersion(target));
+ }
+ }
+
+ int oldVersion = revision.getVersion() - 1;
+ if (oldVersion >= CDORevision.UNSPECIFIED_VERSION)
+ {
+ CDOBranchVersion old = revision.getBranch().getVersion(oldVersion);
+ InternalCDORevision oldRevision = getCachedRevisionByVersion(revision.getID(), old);
+ if (!revision.isHistorical())
+ {
+ if (oldRevision != null)
+ {
+ oldRevision.setRevised(revision.getTimeStamp() - 1);
+ }
+ else
+ {
+ // Remove last revision from cache, which is not revised
+ InternalCDORevision cachedLatestRevision = getCachedRevision(revision.getID(), revision);
+ if (cachedLatestRevision != null && !cachedLatestRevision.isHistorical())
+ {
+ // Found revision is stale.
+ // We cannot revise it now because of lack information, thus remove it from the cache
+ cache.removeRevision(cachedLatestRevision.getID(), cachedLatestRevision);
+ }
+ }
+ }
+ }
+
+ cache.addRevision(revision);
+ }
+ finally
+ {
+ releaseAtomicRequestLock(loadAndAddLock);
+ }
+ }
+ }
+
+ @Override
+ protected void doBeforeActivate() throws Exception
+ {
+ super.doBeforeActivate();
+ if (factory == null)
+ {
+ factory = CDORevisionFactory.DEFAULT;
+ }
+
+ if (cache == null)
+ {
+ cache = (InternalCDORevisionCache)CDORevisionUtil.createRevisionCache(supportingAudits, supportingBranches);
+ }
+ }
+
+ @Override
+ protected void doActivate() throws Exception
+ {
+ super.doActivate();
+ LifecycleUtil.activate(cache);
+ }
+
+ @Override
+ protected void doDeactivate() throws Exception
+ {
+ LifecycleUtil.deactivate(cache);
+ super.doDeactivate();
+ }
+
+ private void acquireAtomicRequestLock(Object key)
+ {
+ if (revisionLocker != null)
+ {
+ revisionLocker.acquireAtomicRequestLock(key);
+ }
+ }
+
+ private void releaseAtomicRequestLock(Object key)
+ {
+ if (revisionLocker != null)
+ {
+ revisionLocker.releaseAtomicRequestLock(key);
+ }
+ }
+
+ private InternalCDORevision getCachedRevisionByVersion(CDOID id, CDOBranchVersion branchVersion)
+ {
+ return (InternalCDORevision)cache.getRevisionByVersion(id, branchVersion);
+ }
+
+ private InternalCDORevision getCachedRevision(CDOID id, CDOBranchPoint branchPoint)
+ {
+ return (InternalCDORevision)cache.getRevision(id, branchPoint);
+ }
+
+ private InternalCDORevision getCachedRevisionRecursively(CDOID id, CDOBranchPoint branchPoint)
+ {
+ CDOBranch branch = branchPoint.getBranch();
+ if (!branch.isMainBranch())
+ {
+ CDOBranchPoint base = branch.getBase();
+ InternalCDORevision revision = getCachedRevision(id, base);
+ if (revision != null)
+ {
+ return revision;
+ }
+
+ // Recurse
+ return getCachedRevisionRecursively(id, base);
+ }
+
+ // Reached main branch
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/EvictionEventImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/EvictionEventImpl.java
index 833b02309a..6decf1eada 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/EvictionEventImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/EvictionEventImpl.java
@@ -1,67 +1,67 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.revision;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevisionCache;
-import org.eclipse.emf.cdo.common.revision.CDORevisionCache.EvictionEvent;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.net4j.util.event.Event;
-
-/**
- * @author Eike Stepper
- */
-public class EvictionEventImpl extends Event implements EvictionEvent
-{
- private static final long serialVersionUID = 1L;
-
- private CDORevisionKey key;
-
- public EvictionEventImpl(CDORevisionCache cache, CDORevisionKey key)
- {
- super(cache);
- this.key = key;
- }
-
- @Override
- public CDORevisionCache getSource()
- {
- return (CDORevisionCache)super.getSource();
- }
-
- public CDOID getID()
- {
- return key.getID();
- }
-
- public CDOBranch getBranch()
- {
- return key.getBranch();
- }
-
- public int getVersion()
- {
- return key.getVersion();
- }
-
- public InternalCDORevision getRevision()
- {
- if (key instanceof InternalCDORevision)
- {
- return (InternalCDORevision)key;
- }
-
- return null;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.revision;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevisionCache;
+import org.eclipse.emf.cdo.common.revision.CDORevisionCache.EvictionEvent;
+import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+
+import org.eclipse.net4j.util.event.Event;
+
+/**
+ * @author Eike Stepper
+ */
+public class EvictionEventImpl extends Event implements EvictionEvent
+{
+ private static final long serialVersionUID = 1L;
+
+ private CDORevisionKey key;
+
+ public EvictionEventImpl(CDORevisionCache cache, CDORevisionKey key)
+ {
+ super(cache);
+ this.key = key;
+ }
+
+ @Override
+ public CDORevisionCache getSource()
+ {
+ return (CDORevisionCache)super.getSource();
+ }
+
+ public CDOID getID()
+ {
+ return key.getID();
+ }
+
+ public CDOBranch getBranch()
+ {
+ return key.getBranch();
+ }
+
+ public int getVersion()
+ {
+ return key.getVersion();
+ }
+
+ public InternalCDORevision getRevision()
+ {
+ if (key instanceof InternalCDORevision)
+ {
+ return (InternalCDORevision)key;
+ }
+
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/NOOPRevisionCache.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/NOOPRevisionCache.java
index a513aa7feb..60d392215b 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/NOOPRevisionCache.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/NOOPRevisionCache.java
@@ -1,101 +1,101 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.revision;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
-
-import org.eclipse.net4j.util.lifecycle.Lifecycle;
-
-import org.eclipse.emf.ecore.EClass;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class NOOPRevisionCache extends Lifecycle implements InternalCDORevisionCache
-{
- public static final NOOPRevisionCache INSTANCE = new NOOPRevisionCache();
-
- private static final List<CDORevision> EMPTY = Collections.emptyList();
-
- public NOOPRevisionCache()
- {
- }
-
- public InternalCDORevisionCache instantiate(CDORevision revision)
- {
- return this;
- }
-
- public boolean isSupportingBranches()
- {
- return true;
- }
-
- public EClass getObjectType(CDOID id)
- {
- return null;
- }
-
- public List<CDORevision> getCurrentRevisions()
- {
- return EMPTY;
- }
-
- public InternalCDORevision getRevision(CDOID id)
- {
- return null;
- }
-
- public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint)
- {
- return null;
- }
-
- public InternalCDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion)
- {
- return null;
- }
-
- public void addRevision(CDORevision revision)
- {
- // Do nothing
- }
-
- public InternalCDORevision removeRevision(CDOID id, CDOBranchVersion branchVersion)
- {
- return null;
- }
-
- public void clear()
- {
- // Do nothing
- }
-
- public Map<CDOBranch, List<CDORevision>> getAllRevisions()
- {
- return Collections.emptyMap();
- }
-
- public List<CDORevision> getRevisions(CDOBranchPoint branchPoint)
- {
- return Collections.emptyList();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.revision;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
+
+import org.eclipse.net4j.util.lifecycle.Lifecycle;
+
+import org.eclipse.emf.ecore.EClass;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class NOOPRevisionCache extends Lifecycle implements InternalCDORevisionCache
+{
+ public static final NOOPRevisionCache INSTANCE = new NOOPRevisionCache();
+
+ private static final List<CDORevision> EMPTY = Collections.emptyList();
+
+ public NOOPRevisionCache()
+ {
+ }
+
+ public InternalCDORevisionCache instantiate(CDORevision revision)
+ {
+ return this;
+ }
+
+ public boolean isSupportingBranches()
+ {
+ return true;
+ }
+
+ public EClass getObjectType(CDOID id)
+ {
+ return null;
+ }
+
+ public List<CDORevision> getCurrentRevisions()
+ {
+ return EMPTY;
+ }
+
+ public InternalCDORevision getRevision(CDOID id)
+ {
+ return null;
+ }
+
+ public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint)
+ {
+ return null;
+ }
+
+ public InternalCDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion)
+ {
+ return null;
+ }
+
+ public void addRevision(CDORevision revision)
+ {
+ // Do nothing
+ }
+
+ public InternalCDORevision removeRevision(CDOID id, CDOBranchVersion branchVersion)
+ {
+ return null;
+ }
+
+ public void clear()
+ {
+ // Do nothing
+ }
+
+ public Map<CDOBranch, List<CDORevision>> getAllRevisions()
+ {
+ return Collections.emptyMap();
+ }
+
+ public List<CDORevision> getRevisions(CDOBranchPoint branchPoint)
+ {
+ return Collections.emptyList();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOAddFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOAddFeatureDeltaImpl.java
index a42a4b4380..aa46c162ed 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOAddFeatureDeltaImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOAddFeatureDeltaImpl.java
@@ -1,79 +1,79 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.revision.delta;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.ListIndexAffecting;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.ListTargetAdding;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.io.IOException;
-
-/**
- * @author Simon McDuff
- */
-public class CDOAddFeatureDeltaImpl extends CDOSingleValueFeatureDeltaImpl implements CDOAddFeatureDelta,
- ListIndexAffecting, ListTargetAdding
-{
- public CDOAddFeatureDeltaImpl(EStructuralFeature feature, int index, Object value)
- {
- super(feature, index, value);
- }
-
- public CDOAddFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
- {
- super(in, eClass);
- }
-
- public Type getType()
- {
- return Type.ADD;
- }
-
- public void apply(CDORevision revision)
- {
- ((InternalCDORevision)revision).getList(getFeature()).add(getIndex(), getValue());
- }
-
- public void accept(CDOFeatureDeltaVisitor visitor)
- {
- visitor.visit(this);
- }
-
- public CDOAddFeatureDelta copy()
- {
- return new CDOAddFeatureDeltaImpl(getFeature(), getIndex(), getValue());
- }
-
- public void affectIndices(ListTargetAdding[] source, int[] indices)
- {
- int index = getIndex();
- if (index == NO_INDEX)
- {
- return;
- }
-
- for (int i = 1; i <= indices[0]; i++)
- {
- if (indices[i] >= index)
- {
- ++indices[i];
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.common.revision.delta;
+
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.ListIndexAffecting;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.ListTargetAdding;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import java.io.IOException;
+
+/**
+ * @author Simon McDuff
+ */
+public class CDOAddFeatureDeltaImpl extends CDOSingleValueFeatureDeltaImpl implements CDOAddFeatureDelta,
+ ListIndexAffecting, ListTargetAdding
+{
+ public CDOAddFeatureDeltaImpl(EStructuralFeature feature, int index, Object value)
+ {
+ super(feature, index, value);
+ }
+
+ public CDOAddFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
+ {
+ super(in, eClass);
+ }
+
+ public Type getType()
+ {
+ return Type.ADD;
+ }
+
+ public void apply(CDORevision revision)
+ {
+ ((InternalCDORevision)revision).getList(getFeature()).add(getIndex(), getValue());
+ }
+
+ public void accept(CDOFeatureDeltaVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ public CDOAddFeatureDelta copy()
+ {
+ return new CDOAddFeatureDeltaImpl(getFeature(), getIndex(), getValue());
+ }
+
+ public void affectIndices(ListTargetAdding[] source, int[] indices)
+ {
+ int index = getIndex();
+ if (index == NO_INDEX)
+ {
+ return;
+ }
+
+ for (int i = 1; i <= indices[0]; i++)
+ {
+ if (indices[i] >= index)
+ {
+ ++indices[i];
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOClearFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOClearFeatureDeltaImpl.java
index 440315be4a..6affdc1a20 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOClearFeatureDeltaImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOClearFeatureDeltaImpl.java
@@ -1,73 +1,73 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.revision.delta;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.delta.CDOClearFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
-import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.io.IOException;
-
-/**
- * @author Simon McDuff
- */
-public class CDOClearFeatureDeltaImpl extends CDOFeatureDeltaImpl implements CDOClearFeatureDelta
-{
- public CDOClearFeatureDeltaImpl(EStructuralFeature feature)
- {
- super(feature);
- }
-
- public CDOClearFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
- {
- super(in, eClass);
- }
-
- public Type getType()
- {
- return Type.CLEAR;
- }
-
- public CDOFeatureDelta copy()
- {
- return new CDOClearFeatureDeltaImpl(getFeature());
- }
-
- public void apply(CDORevision revision)
- {
- ((InternalCDORevision)revision).clear(getFeature());
- }
-
- public void accept(CDOFeatureDeltaVisitor visitor)
- {
- visitor.visit(this);
- }
-
- @Override
- public boolean adjustReferences(CDOReferenceAdjuster referenceAdjuster)
- {
- return false;
- }
-
- @Override
- protected String toStringAdditional()
- {
- return null;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.common.revision.delta;
+
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.delta.CDOClearFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
+import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import java.io.IOException;
+
+/**
+ * @author Simon McDuff
+ */
+public class CDOClearFeatureDeltaImpl extends CDOFeatureDeltaImpl implements CDOClearFeatureDelta
+{
+ public CDOClearFeatureDeltaImpl(EStructuralFeature feature)
+ {
+ super(feature);
+ }
+
+ public CDOClearFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
+ {
+ super(in, eClass);
+ }
+
+ public Type getType()
+ {
+ return Type.CLEAR;
+ }
+
+ public CDOFeatureDelta copy()
+ {
+ return new CDOClearFeatureDeltaImpl(getFeature());
+ }
+
+ public void apply(CDORevision revision)
+ {
+ ((InternalCDORevision)revision).clear(getFeature());
+ }
+
+ public void accept(CDOFeatureDeltaVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ @Override
+ public boolean adjustReferences(CDOReferenceAdjuster referenceAdjuster)
+ {
+ return false;
+ }
+
+ @Override
+ protected String toStringAdditional()
+ {
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOContainerFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOContainerFeatureDeltaImpl.java
index d7108db667..33eb961254 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOContainerFeatureDeltaImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOContainerFeatureDeltaImpl.java
@@ -1,173 +1,173 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- * Simon McDuff - bug 204890
- * Simon McDuff - bug 213402
- */
-package org.eclipse.emf.cdo.internal.common.revision.delta;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.delta.CDOContainerFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
-import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.net4j.util.ObjectUtil;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.impl.EReferenceImpl;
-
-import java.io.IOException;
-import java.text.MessageFormat;
-
-/**
- * @author Simon McDuff
- */
-public class CDOContainerFeatureDeltaImpl extends CDOFeatureDeltaImpl implements CDOContainerFeatureDelta
-{
- private CDOID newResourceID;
-
- private Object newContainerID;
-
- private int newContainerFeatureID;
-
- public CDOContainerFeatureDeltaImpl(CDOID newResourceID, Object newContainerID, int newContainerFeatureID)
- {
- super(CONTAINER_FEATURE);
- this.newResourceID = newResourceID;
- this.newContainerID = newContainerID;
- this.newContainerFeatureID = newContainerFeatureID;
- }
-
- public CDOContainerFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
- {
- super(CONTAINER_FEATURE);
- newContainerFeatureID = in.readInt();
- newContainerID = in.readCDOID();
- newResourceID = in.readCDOID();
- }
-
- public Type getType()
- {
- return Type.CONTAINER;
- }
-
- public CDOFeatureDelta copy()
- {
- return new CDOContainerFeatureDeltaImpl(newResourceID, newContainerID, newContainerFeatureID);
- }
-
- public CDOID getResourceID()
- {
- return newResourceID;
- }
-
- public Object getContainerID()
- {
- return newContainerID;
- }
-
- public int getContainerFeatureID()
- {
- return newContainerFeatureID;
- }
-
- public void apply(CDORevision revision)
- {
- ((InternalCDORevision)revision).setResourceID(newResourceID);
- ((InternalCDORevision)revision).setContainerID(newContainerID);
- ((InternalCDORevision)revision).setContainingFeatureID(newContainerFeatureID);
- }
-
- @Override
- public boolean adjustReferences(CDOReferenceAdjuster referenceAdjuster)
- {
- boolean changed = false;
-
- CDOID id1 = (CDOID)referenceAdjuster.adjustReference(newResourceID, CONTAINER_FEATURE, NO_INDEX);
- if (id1 != newResourceID)
- {
- newResourceID = id1;
- changed = true;
- }
-
- Object id2 = referenceAdjuster.adjustReference(newContainerID, CONTAINER_FEATURE, NO_INDEX);
- if (id2 != newContainerID)
- {
- newContainerID = id2;
- changed = true;
- }
-
- return changed;
- }
-
- @Override
- public void write(CDODataOutput out, EClass eClass) throws IOException
- {
- out.writeInt(getType().ordinal());
- out.writeInt(newContainerFeatureID);
- out.writeCDOID(out.getIDProvider().provideCDOID(newContainerID));
- out.writeCDOID(newResourceID);
- }
-
- public void accept(CDOFeatureDeltaVisitor visitor)
- {
- visitor.visit(this);
- }
-
- @Override
- public boolean isStructurallyEqual(Object obj)
- {
- if (!super.isStructurallyEqual(obj))
- {
- return false;
- }
-
- CDOContainerFeatureDelta that = (CDOContainerFeatureDelta)obj;
- return ObjectUtil.equals(newResourceID, that.getResourceID())
- && ObjectUtil.equals(newContainerID, that.getContainerID())
- && newContainerFeatureID == that.getContainerFeatureID();
- }
-
- @Override
- protected String toStringAdditional()
- {
- return MessageFormat.format("resource={0}, container={1}, feature={2}", newResourceID, newContainerID,
- newContainerFeatureID);
- }
-
- /**
- * @author Simon McDuff
- */
- public static final class ContainerFeature extends EReferenceImpl
- {
- public static final String NAME = "eContainer";
-
- public ContainerFeature()
- {
- }
-
- @Override
- public String getName()
- {
- return null;
- }
-
- @Override
- public String toString()
- {
- return NAME;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ * Simon McDuff - bug 204890
+ * Simon McDuff - bug 213402
+ */
+package org.eclipse.emf.cdo.internal.common.revision.delta;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.delta.CDOContainerFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
+import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+
+import org.eclipse.net4j.util.ObjectUtil;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.impl.EReferenceImpl;
+
+import java.io.IOException;
+import java.text.MessageFormat;
+
+/**
+ * @author Simon McDuff
+ */
+public class CDOContainerFeatureDeltaImpl extends CDOFeatureDeltaImpl implements CDOContainerFeatureDelta
+{
+ private CDOID newResourceID;
+
+ private Object newContainerID;
+
+ private int newContainerFeatureID;
+
+ public CDOContainerFeatureDeltaImpl(CDOID newResourceID, Object newContainerID, int newContainerFeatureID)
+ {
+ super(CONTAINER_FEATURE);
+ this.newResourceID = newResourceID;
+ this.newContainerID = newContainerID;
+ this.newContainerFeatureID = newContainerFeatureID;
+ }
+
+ public CDOContainerFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
+ {
+ super(CONTAINER_FEATURE);
+ newContainerFeatureID = in.readInt();
+ newContainerID = in.readCDOID();
+ newResourceID = in.readCDOID();
+ }
+
+ public Type getType()
+ {
+ return Type.CONTAINER;
+ }
+
+ public CDOFeatureDelta copy()
+ {
+ return new CDOContainerFeatureDeltaImpl(newResourceID, newContainerID, newContainerFeatureID);
+ }
+
+ public CDOID getResourceID()
+ {
+ return newResourceID;
+ }
+
+ public Object getContainerID()
+ {
+ return newContainerID;
+ }
+
+ public int getContainerFeatureID()
+ {
+ return newContainerFeatureID;
+ }
+
+ public void apply(CDORevision revision)
+ {
+ ((InternalCDORevision)revision).setResourceID(newResourceID);
+ ((InternalCDORevision)revision).setContainerID(newContainerID);
+ ((InternalCDORevision)revision).setContainingFeatureID(newContainerFeatureID);
+ }
+
+ @Override
+ public boolean adjustReferences(CDOReferenceAdjuster referenceAdjuster)
+ {
+ boolean changed = false;
+
+ CDOID id1 = (CDOID)referenceAdjuster.adjustReference(newResourceID, CONTAINER_FEATURE, NO_INDEX);
+ if (id1 != newResourceID)
+ {
+ newResourceID = id1;
+ changed = true;
+ }
+
+ Object id2 = referenceAdjuster.adjustReference(newContainerID, CONTAINER_FEATURE, NO_INDEX);
+ if (id2 != newContainerID)
+ {
+ newContainerID = id2;
+ changed = true;
+ }
+
+ return changed;
+ }
+
+ @Override
+ public void write(CDODataOutput out, EClass eClass) throws IOException
+ {
+ out.writeInt(getType().ordinal());
+ out.writeInt(newContainerFeatureID);
+ out.writeCDOID(out.getIDProvider().provideCDOID(newContainerID));
+ out.writeCDOID(newResourceID);
+ }
+
+ public void accept(CDOFeatureDeltaVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ @Override
+ public boolean isStructurallyEqual(Object obj)
+ {
+ if (!super.isStructurallyEqual(obj))
+ {
+ return false;
+ }
+
+ CDOContainerFeatureDelta that = (CDOContainerFeatureDelta)obj;
+ return ObjectUtil.equals(newResourceID, that.getResourceID())
+ && ObjectUtil.equals(newContainerID, that.getContainerID())
+ && newContainerFeatureID == that.getContainerFeatureID();
+ }
+
+ @Override
+ protected String toStringAdditional()
+ {
+ return MessageFormat.format("resource={0}, container={1}, feature={2}", newResourceID, newContainerID,
+ newContainerFeatureID);
+ }
+
+ /**
+ * @author Simon McDuff
+ */
+ public static final class ContainerFeature extends EReferenceImpl
+ {
+ public static final String NAME = "eContainer";
+
+ public ContainerFeature()
+ {
+ }
+
+ @Override
+ public String getName()
+ {
+ return null;
+ }
+
+ @Override
+ public String toString()
+ {
+ return NAME;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDODetachedRevisionDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDODetachedRevisionDeltaImpl.java
index 6daf5421b4..3a9ec9263f 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDODetachedRevisionDeltaImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDODetachedRevisionDeltaImpl.java
@@ -1,89 +1,89 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.revision.delta;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevisable;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class CDODetachedRevisionDeltaImpl implements CDORevisionDelta
-{
- public CDODetachedRevisionDeltaImpl()
- {
- }
-
- public CDOID getID()
- {
- throw new UnsupportedOperationException();
- }
-
- public CDOBranch getBranch()
- {
- throw new UnsupportedOperationException();
- }
-
- public int getVersion()
- {
- throw new UnsupportedOperationException();
- }
-
- public EClass getEClass()
- {
- throw new UnsupportedOperationException();
- }
-
- public CDORevisable getTarget()
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean isEmpty()
- {
- throw new UnsupportedOperationException();
- }
-
- public CDORevisionDelta copy()
- {
- return this;
- }
-
- public CDOFeatureDelta getFeatureDelta(EStructuralFeature feature)
- {
- throw new UnsupportedOperationException();
- }
-
- public List<CDOFeatureDelta> getFeatureDeltas()
- {
- throw new UnsupportedOperationException();
- }
-
- public void apply(CDORevision revision)
- {
- throw new UnsupportedOperationException();
- }
-
- public void accept(CDOFeatureDeltaVisitor visitor)
- {
- throw new UnsupportedOperationException();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.common.revision.delta;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevisable;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDODetachedRevisionDeltaImpl implements CDORevisionDelta
+{
+ public CDODetachedRevisionDeltaImpl()
+ {
+ }
+
+ public CDOID getID()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDOBranch getBranch()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getVersion()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public EClass getEClass()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDORevisable getTarget()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isEmpty()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDORevisionDelta copy()
+ {
+ return this;
+ }
+
+ public CDOFeatureDelta getFeatureDelta(EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public List<CDOFeatureDelta> getFeatureDeltas()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void apply(CDORevision revision)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void accept(CDOFeatureDeltaVisitor visitor)
+ {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOFeatureDeltaImpl.java
index c55f653dcc..647e781afe 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOFeatureDeltaImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOFeatureDeltaImpl.java
@@ -1,90 +1,90 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.revision.delta;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta;
-
-import org.eclipse.net4j.util.CheckUtil;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.io.IOException;
-import java.text.MessageFormat;
-
-/**
- * @author Simon McDuff
- */
-public abstract class CDOFeatureDeltaImpl implements InternalCDOFeatureDelta
-{
- private EStructuralFeature feature;
-
- protected CDOFeatureDeltaImpl(EStructuralFeature feature)
- {
- CheckUtil.checkArg(feature, "feature");
- this.feature = feature;
- }
-
- public CDOFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
- {
- int featureID = in.readInt();
- feature = eClass.getEStructuralFeature(featureID);
- CheckUtil.checkState(feature, "feature");
- }
-
- public void write(CDODataOutput out, EClass eClass) throws IOException
- {
- out.writeInt(getType().ordinal());
- out.writeInt(eClass.getFeatureID(feature));
- }
-
- public EStructuralFeature getFeature()
- {
- return feature;
- }
-
- public boolean isStructurallyEqual(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj instanceof CDOFeatureDelta)
- {
- CDOFeatureDelta that = (CDOFeatureDelta)obj;
- return feature.equals(that.getFeature()) && getType().equals(that.getType());
- }
-
- return false;
- }
-
- @Override
- public String toString()
- {
- String additional = toStringAdditional();
- if (additional == null)
- {
- return MessageFormat.format("CDOFeatureDelta[{0}, {1}]", feature.getName(), getType());
- }
-
- return MessageFormat.format("CDOFeatureDelta[{0}, {1}, {2}]", feature.getName(), getType(), additional);
- }
-
- public abstract boolean adjustReferences(CDOReferenceAdjuster referenceAdjuster);
-
- protected abstract String toStringAdditional();
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.common.revision.delta;
+
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta;
+
+import org.eclipse.net4j.util.CheckUtil;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import java.io.IOException;
+import java.text.MessageFormat;
+
+/**
+ * @author Simon McDuff
+ */
+public abstract class CDOFeatureDeltaImpl implements InternalCDOFeatureDelta
+{
+ private EStructuralFeature feature;
+
+ protected CDOFeatureDeltaImpl(EStructuralFeature feature)
+ {
+ CheckUtil.checkArg(feature, "feature");
+ this.feature = feature;
+ }
+
+ public CDOFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
+ {
+ int featureID = in.readInt();
+ feature = eClass.getEStructuralFeature(featureID);
+ CheckUtil.checkState(feature, "feature");
+ }
+
+ public void write(CDODataOutput out, EClass eClass) throws IOException
+ {
+ out.writeInt(getType().ordinal());
+ out.writeInt(eClass.getFeatureID(feature));
+ }
+
+ public EStructuralFeature getFeature()
+ {
+ return feature;
+ }
+
+ public boolean isStructurallyEqual(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+
+ if (obj instanceof CDOFeatureDelta)
+ {
+ CDOFeatureDelta that = (CDOFeatureDelta)obj;
+ return feature.equals(that.getFeature()) && getType().equals(that.getType());
+ }
+
+ return false;
+ }
+
+ @Override
+ public String toString()
+ {
+ String additional = toStringAdditional();
+ if (additional == null)
+ {
+ return MessageFormat.format("CDOFeatureDelta[{0}, {1}]", feature.getName(), getType());
+ }
+
+ return MessageFormat.format("CDOFeatureDelta[{0}, {1}, {2}]", feature.getName(), getType(), additional);
+ }
+
+ public abstract boolean adjustReferences(CDOReferenceAdjuster referenceAdjuster);
+
+ protected abstract String toStringAdditional();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOListFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOListFeatureDeltaImpl.java
index 9f31acf505..0bba475f15 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOListFeatureDeltaImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOListFeatureDeltaImpl.java
@@ -1,464 +1,464 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- * Cyril Jaquier - Bug 310574 (with the help of Pascal Lehmann)
- */
-package org.eclipse.emf.cdo.internal.common.revision.delta;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
-import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORemoveFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta;
-import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
-
-import org.eclipse.net4j.util.ObjectUtil;
-import org.eclipse.net4j.util.collection.Pair;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.util.FeatureMapUtil;
-
-import java.io.IOException;
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-
-/**
- * @author Simon McDuff
- */
-public class CDOListFeatureDeltaImpl extends CDOFeatureDeltaImpl implements CDOListFeatureDelta
-{
- private List<CDOFeatureDelta> featureDeltas = new ArrayList<CDOFeatureDelta>();
-
- private transient int[] cachedIndices;
-
- private transient ListTargetAdding[] cachedSources;
-
- private transient List<CDOFeatureDelta> unprocessedFeatureDeltas;
-
- public CDOListFeatureDeltaImpl(EStructuralFeature feature)
- {
- super(feature);
- }
-
- public CDOListFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
- {
- super(in, eClass);
- int size = in.readInt();
- for (int i = 0; i < size; i++)
- {
- featureDeltas.add(in.readCDOFeatureDelta(eClass));
- }
- }
-
- public CDOListFeatureDelta copy()
- {
- CDOListFeatureDeltaImpl result = new CDOListFeatureDeltaImpl(getFeature());
-
- Map<CDOFeatureDelta, CDOFeatureDelta> map = null;
- if (cachedSources != null || unprocessedFeatureDeltas != null)
- {
- map = new HashMap<CDOFeatureDelta, CDOFeatureDelta>();
- }
-
- for (CDOFeatureDelta delta : featureDeltas)
- {
- CDOFeatureDelta newDelta = delta.copy();
- result.featureDeltas.add(newDelta);
- if (map != null)
- {
- map.put(delta, newDelta);
- }
- }
-
- if (cachedIndices != null)
- {
- result.cachedIndices = copyOf(cachedIndices, cachedIndices.length);
- }
-
- if (cachedSources != null)
- {
- int length = cachedSources.length;
- result.cachedSources = new ListTargetAdding[length];
- for (int i = 0; i < length; i++)
- {
- ListTargetAdding oldElement = cachedSources[i];
- CDOFeatureDelta newElement = map.get(oldElement);
- if (newElement instanceof ListTargetAdding)
- {
- result.cachedSources[i] = (ListTargetAdding)newElement;
- }
- }
- }
-
- if (unprocessedFeatureDeltas != null)
- {
- int size = unprocessedFeatureDeltas.size();
- result.unprocessedFeatureDeltas = new ArrayList<CDOFeatureDelta>(size);
- for (CDOFeatureDelta oldDelta : unprocessedFeatureDeltas)
- {
- CDOFeatureDelta newDelta = map.get(oldDelta);
- if (newDelta != null)
- {
- result.unprocessedFeatureDeltas.add(newDelta);
- }
- }
- }
-
- return result;
- }
-
- @Override
- public void write(CDODataOutput out, EClass eClass) throws IOException
- {
- super.write(out, eClass);
- out.writeInt(featureDeltas.size());
- for (CDOFeatureDelta featureDelta : featureDeltas)
- {
- out.writeCDOFeatureDelta(eClass, featureDelta);
- }
- }
-
- public Type getType()
- {
- return Type.LIST;
- }
-
- public List<CDOFeatureDelta> getListChanges()
- {
- return featureDeltas;
- }
-
- /**
- * Returns the number of indices as the first element of the array.
- *
- * @return never <code>null</code>.
- */
- public Pair<ListTargetAdding[], int[]> reconstructAddedIndices()
- {
- reconstructAddedIndicesWithNoCopy();
- return new Pair<ListTargetAdding[], int[]>(copyOf(cachedSources, cachedSources.length, cachedSources.getClass()),
- copyOf(cachedIndices, cachedIndices.length));
- }
-
- private void reconstructAddedIndicesWithNoCopy()
- {
- // Note that cachedIndices and cachedSources are always either both null or
- // both non-null, and in the latter case, are always of the same length.
- // Furthermore, there can only be unprocessedFeatureDeltas if cachesIndices
- // and cachedSources are non-null.
-
- if (cachedIndices == null || unprocessedFeatureDeltas != null)
- {
- if (cachedIndices == null)
- {
- int initialCapacity = featureDeltas.size() + 1;
- cachedIndices = new int[initialCapacity];
- cachedSources = new ListTargetAdding[initialCapacity];
- }
- else
- // i.e. unprocessedFeatureDeltas != null
- {
- int requiredCapacity = 1 + cachedIndices[0] + unprocessedFeatureDeltas.size();
- if (cachedIndices.length < requiredCapacity)
- {
- int newCapacity = Math.max(requiredCapacity, cachedIndices.length * 2);
-
- int[] newIndices = new int[newCapacity];
- System.arraycopy(cachedIndices, 0, newIndices, 0, cachedIndices.length);
- cachedIndices = newIndices;
-
- ListTargetAdding[] newSources = new ListTargetAdding[newCapacity];
- System.arraycopy(cachedSources, 0, newSources, 0, cachedSources.length);
- cachedSources = newSources;
- }
- }
-
- List<CDOFeatureDelta> featureDeltasToBeProcessed = unprocessedFeatureDeltas == null ? featureDeltas
- : unprocessedFeatureDeltas;
- for (CDOFeatureDelta featureDelta : featureDeltasToBeProcessed)
- {
- if (featureDelta instanceof ListIndexAffecting)
- {
- ListIndexAffecting affecting = (ListIndexAffecting)featureDelta;
- affecting.affectIndices(cachedSources, cachedIndices);
- }
-
- if (featureDelta instanceof ListTargetAdding)
- {
- cachedIndices[++cachedIndices[0]] = ((ListTargetAdding)featureDelta).getIndex();
- cachedSources[cachedIndices[0]] = (ListTargetAdding)featureDelta;
- }
- }
-
- unprocessedFeatureDeltas = null;
- }
- }
-
- private boolean cleanupWithNewDelta(CDOFeatureDelta featureDelta)
- {
- EStructuralFeature feature = getFeature();
- if ((feature instanceof EReference || FeatureMapUtil.isFeatureMap(feature))
- && featureDelta instanceof CDORemoveFeatureDelta)
- {
- int indexToRemove = ((CDORemoveFeatureDelta)featureDelta).getIndex();
- reconstructAddedIndicesWithNoCopy();
-
- for (int i = 1; i <= cachedIndices[0]; i++)
- {
- int index = cachedIndices[i];
- if (indexToRemove == index)
- {
- // The previous implementation set the value of the feature delta to CDOID.NULL. Databinding and probably
- // others don't really like it. We now remove the ADD (or SET which seems to appear in CDOListFeatureDelta
- // during opposite adjustment!? Why???) and patch the other feature deltas.
- // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=310574
-
- ListTargetAdding delta = cachedSources[i];
-
- // We use a "floating" index which is the index (in the list) of the item to remove at the time when the
- // object was still in the list. This index evolves with the feature deltas.
- int floatingIndex = delta.getIndex();
-
- // First updates cachedSources and cachedIndices using CDORemoveFeatureDelta.
- ListIndexAffecting affecting = (ListIndexAffecting)featureDelta;
- affecting.affectIndices(cachedSources, cachedIndices);
-
- // Then adjusts the remaining feature deltas.
- boolean skip = true;
- ListIterator<CDOFeatureDelta> iterator = featureDeltas.listIterator();
-
- while (iterator.hasNext())
- {
- CDOFeatureDelta fd = iterator.next();
-
- // We only need to process feature deltas that come after the ADD (or SET) to be removed.
- if (skip)
- {
- if (fd == delta)
- {
- // Found the ADD (or SET) feature delta that we need to remove. So remove it from the list and start
- // processing the next feature deltas.
- skip = false;
- iterator.remove();
-
- // SET
- if (fd instanceof CDOSetFeatureDelta)
- {
- // If the removed delta is SET we add the REMOVE to the feature deltas. We do not need to adjust the
- // other feature deltas because SET do not modify the list.
- return true;
- }
- }
-
- continue;
- }
-
- // ADD
- if (fd instanceof CDOAddFeatureDelta)
- {
- // Increases the floating index if the ADD came in front of the item.
- if (((CDOAddFeatureDelta)fd).getIndex() <= floatingIndex)
- {
- ++floatingIndex;
- }
-
- // Adjusts the feature delta too.
- ((WithIndex)fd).adjustAfterRemoval(floatingIndex);
- }
-
- // REMOVE
- else if (fd instanceof CDORemoveFeatureDelta)
- {
- int idx = floatingIndex;
- // Decreases the floating index if the REMOVE came in front of the item.
- if (((CDORemoveFeatureDelta)fd).getIndex() <= floatingIndex)
- {
- --floatingIndex;
- }
-
- // Adjusts the feature delta too.
- ((WithIndex)fd).adjustAfterRemoval(idx);
- }
-
- // MOVE
- else if (fd instanceof CDOMoveFeatureDelta)
- {
- // Remembers the positions before we patch them.
- int from = ((CDOMoveFeatureDelta)fd).getOldPosition();
- int to = ((CDOMoveFeatureDelta)fd).getNewPosition();
-
- if (floatingIndex == from)
- {
- // We are moving the "to be deleted" item. So we update our floating index and remove the MOVE. It has
- // no effect on the list.
- floatingIndex = to;
- iterator.remove();
- }
- else
- {
- // In the other cases, we need to patch the positions.
-
- // If the old position is greater or equal to the current position of the item to be removed (remember,
- // that's our floating index), decrease the position.
- int patchedFrom = floatingIndex <= from ? from - 1 : from;
-
- // The new position requires more care. We need to know the direction of the move (left-to-right or
- // right-to-left).
- int patchedTo;
- if (from > to)
- {
- // left-to-right. Only decreases the position if it is strictly greater than the current item
- // position.
- patchedTo = floatingIndex < to ? to - 1 : to;
- }
- else
- {
- // right-to-left. Decreases the position if it is greater or equal than the current item position.
- patchedTo = floatingIndex <= to ? to - 1 : to;
- }
-
- // We can now update our floating index. We use the original positions because the floating index
- // represents the item "to be deleted" before it was actually removed.
- if (from < floatingIndex && floatingIndex <= to)
- {
- --floatingIndex;
- }
- else if (to <= floatingIndex && floatingIndex < from)
- {
- ++floatingIndex;
- }
-
- // And finally adjust the feature delta.
- if (patchedFrom == patchedTo)
- {
- // Source and destination are the same so just remove the feature delta.
- iterator.remove();
- }
- else
- {
- ((CDOMoveFeatureDeltaImpl)fd).setOldPosition(patchedFrom);
- ((CDOMoveFeatureDeltaImpl)fd).setNewPosition(patchedTo);
- }
- }
- }
-
- // SET
- else if (fd instanceof CDOSetFeatureDelta)
- {
- // Adjusts the feature delta too.
- ((WithIndex)fd).adjustAfterRemoval(floatingIndex);
- }
- }
-
- // If the removed delta was ADD so we do not add the REMOVE to the feature deltas.
- return false;
- }
- }
- }
-
- if (cachedIndices != null)
- {
- if (unprocessedFeatureDeltas == null)
- {
- unprocessedFeatureDeltas = new ArrayList<CDOFeatureDelta>();
- }
-
- unprocessedFeatureDeltas.add(featureDelta);
- }
-
- return true;
- }
-
- public void add(CDOFeatureDelta featureDelta)
- {
- // Only adds the feature delta to the list if required.
- if (cleanupWithNewDelta(featureDelta))
- {
- featureDeltas.add(featureDelta);
- }
- }
-
- public void apply(CDORevision revision)
- {
- for (CDOFeatureDelta featureDelta : featureDeltas)
- {
- ((CDOFeatureDeltaImpl)featureDelta).apply(revision);
- }
- }
-
- @Override
- public boolean adjustReferences(CDOReferenceAdjuster adjuster)
- {
- boolean changed = false;
- for (CDOFeatureDelta featureDelta : featureDeltas)
- {
- changed |= ((CDOFeatureDeltaImpl)featureDelta).adjustReferences(adjuster);
- }
-
- return changed;
- }
-
- public void accept(CDOFeatureDeltaVisitor visitor)
- {
- visitor.visit(this);
- }
-
- @Override
- public boolean isStructurallyEqual(Object obj)
- {
- if (!super.isStructurallyEqual(obj))
- {
- return false;
- }
-
- CDOListFeatureDelta that = (CDOListFeatureDelta)obj;
- return ObjectUtil.equals(featureDeltas, that.getListChanges());
- }
-
- @Override
- protected String toStringAdditional()
- {
- return "list=" + featureDeltas; //$NON-NLS-1$
- }
-
- /**
- * Copied from JAVA 1.6 {@link Arrays Arrays.copyOf}.
- */
- private static <T, U> T[] copyOf(U[] original, int newLength, Class<? extends T[]> newType)
- {
- @SuppressWarnings("unchecked")
- T[] copy = (Object)newType == (Object)Object[].class ? (T[])new Object[newLength] : (T[])Array.newInstance(
- newType.getComponentType(), newLength);
- System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
- return copy;
- }
-
- /**
- * Copied from JAVA 1.6 {@link Arrays Arrays.copyOf}.
- */
- private static int[] copyOf(int[] original, int newLength)
- {
- int[] copy = new int[newLength];
- System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
- return copy;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ * Cyril Jaquier - Bug 310574 (with the help of Pascal Lehmann)
+ */
+package org.eclipse.emf.cdo.internal.common.revision.delta;
+
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
+import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORemoveFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta;
+import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
+
+import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.collection.Pair;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.FeatureMapUtil;
+
+import java.io.IOException;
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+
+/**
+ * @author Simon McDuff
+ */
+public class CDOListFeatureDeltaImpl extends CDOFeatureDeltaImpl implements CDOListFeatureDelta
+{
+ private List<CDOFeatureDelta> featureDeltas = new ArrayList<CDOFeatureDelta>();
+
+ private transient int[] cachedIndices;
+
+ private transient ListTargetAdding[] cachedSources;
+
+ private transient List<CDOFeatureDelta> unprocessedFeatureDeltas;
+
+ public CDOListFeatureDeltaImpl(EStructuralFeature feature)
+ {
+ super(feature);
+ }
+
+ public CDOListFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
+ {
+ super(in, eClass);
+ int size = in.readInt();
+ for (int i = 0; i < size; i++)
+ {
+ featureDeltas.add(in.readCDOFeatureDelta(eClass));
+ }
+ }
+
+ public CDOListFeatureDelta copy()
+ {
+ CDOListFeatureDeltaImpl result = new CDOListFeatureDeltaImpl(getFeature());
+
+ Map<CDOFeatureDelta, CDOFeatureDelta> map = null;
+ if (cachedSources != null || unprocessedFeatureDeltas != null)
+ {
+ map = new HashMap<CDOFeatureDelta, CDOFeatureDelta>();
+ }
+
+ for (CDOFeatureDelta delta : featureDeltas)
+ {
+ CDOFeatureDelta newDelta = delta.copy();
+ result.featureDeltas.add(newDelta);
+ if (map != null)
+ {
+ map.put(delta, newDelta);
+ }
+ }
+
+ if (cachedIndices != null)
+ {
+ result.cachedIndices = copyOf(cachedIndices, cachedIndices.length);
+ }
+
+ if (cachedSources != null)
+ {
+ int length = cachedSources.length;
+ result.cachedSources = new ListTargetAdding[length];
+ for (int i = 0; i < length; i++)
+ {
+ ListTargetAdding oldElement = cachedSources[i];
+ CDOFeatureDelta newElement = map.get(oldElement);
+ if (newElement instanceof ListTargetAdding)
+ {
+ result.cachedSources[i] = (ListTargetAdding)newElement;
+ }
+ }
+ }
+
+ if (unprocessedFeatureDeltas != null)
+ {
+ int size = unprocessedFeatureDeltas.size();
+ result.unprocessedFeatureDeltas = new ArrayList<CDOFeatureDelta>(size);
+ for (CDOFeatureDelta oldDelta : unprocessedFeatureDeltas)
+ {
+ CDOFeatureDelta newDelta = map.get(oldDelta);
+ if (newDelta != null)
+ {
+ result.unprocessedFeatureDeltas.add(newDelta);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public void write(CDODataOutput out, EClass eClass) throws IOException
+ {
+ super.write(out, eClass);
+ out.writeInt(featureDeltas.size());
+ for (CDOFeatureDelta featureDelta : featureDeltas)
+ {
+ out.writeCDOFeatureDelta(eClass, featureDelta);
+ }
+ }
+
+ public Type getType()
+ {
+ return Type.LIST;
+ }
+
+ public List<CDOFeatureDelta> getListChanges()
+ {
+ return featureDeltas;
+ }
+
+ /**
+ * Returns the number of indices as the first element of the array.
+ *
+ * @return never <code>null</code>.
+ */
+ public Pair<ListTargetAdding[], int[]> reconstructAddedIndices()
+ {
+ reconstructAddedIndicesWithNoCopy();
+ return new Pair<ListTargetAdding[], int[]>(copyOf(cachedSources, cachedSources.length, cachedSources.getClass()),
+ copyOf(cachedIndices, cachedIndices.length));
+ }
+
+ private void reconstructAddedIndicesWithNoCopy()
+ {
+ // Note that cachedIndices and cachedSources are always either both null or
+ // both non-null, and in the latter case, are always of the same length.
+ // Furthermore, there can only be unprocessedFeatureDeltas if cachesIndices
+ // and cachedSources are non-null.
+
+ if (cachedIndices == null || unprocessedFeatureDeltas != null)
+ {
+ if (cachedIndices == null)
+ {
+ int initialCapacity = featureDeltas.size() + 1;
+ cachedIndices = new int[initialCapacity];
+ cachedSources = new ListTargetAdding[initialCapacity];
+ }
+ else
+ // i.e. unprocessedFeatureDeltas != null
+ {
+ int requiredCapacity = 1 + cachedIndices[0] + unprocessedFeatureDeltas.size();
+ if (cachedIndices.length < requiredCapacity)
+ {
+ int newCapacity = Math.max(requiredCapacity, cachedIndices.length * 2);
+
+ int[] newIndices = new int[newCapacity];
+ System.arraycopy(cachedIndices, 0, newIndices, 0, cachedIndices.length);
+ cachedIndices = newIndices;
+
+ ListTargetAdding[] newSources = new ListTargetAdding[newCapacity];
+ System.arraycopy(cachedSources, 0, newSources, 0, cachedSources.length);
+ cachedSources = newSources;
+ }
+ }
+
+ List<CDOFeatureDelta> featureDeltasToBeProcessed = unprocessedFeatureDeltas == null ? featureDeltas
+ : unprocessedFeatureDeltas;
+ for (CDOFeatureDelta featureDelta : featureDeltasToBeProcessed)
+ {
+ if (featureDelta instanceof ListIndexAffecting)
+ {
+ ListIndexAffecting affecting = (ListIndexAffecting)featureDelta;
+ affecting.affectIndices(cachedSources, cachedIndices);
+ }
+
+ if (featureDelta instanceof ListTargetAdding)
+ {
+ cachedIndices[++cachedIndices[0]] = ((ListTargetAdding)featureDelta).getIndex();
+ cachedSources[cachedIndices[0]] = (ListTargetAdding)featureDelta;
+ }
+ }
+
+ unprocessedFeatureDeltas = null;
+ }
+ }
+
+ private boolean cleanupWithNewDelta(CDOFeatureDelta featureDelta)
+ {
+ EStructuralFeature feature = getFeature();
+ if ((feature instanceof EReference || FeatureMapUtil.isFeatureMap(feature))
+ && featureDelta instanceof CDORemoveFeatureDelta)
+ {
+ int indexToRemove = ((CDORemoveFeatureDelta)featureDelta).getIndex();
+ reconstructAddedIndicesWithNoCopy();
+
+ for (int i = 1; i <= cachedIndices[0]; i++)
+ {
+ int index = cachedIndices[i];
+ if (indexToRemove == index)
+ {
+ // The previous implementation set the value of the feature delta to CDOID.NULL. Databinding and probably
+ // others don't really like it. We now remove the ADD (or SET which seems to appear in CDOListFeatureDelta
+ // during opposite adjustment!? Why???) and patch the other feature deltas.
+ // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=310574
+
+ ListTargetAdding delta = cachedSources[i];
+
+ // We use a "floating" index which is the index (in the list) of the item to remove at the time when the
+ // object was still in the list. This index evolves with the feature deltas.
+ int floatingIndex = delta.getIndex();
+
+ // First updates cachedSources and cachedIndices using CDORemoveFeatureDelta.
+ ListIndexAffecting affecting = (ListIndexAffecting)featureDelta;
+ affecting.affectIndices(cachedSources, cachedIndices);
+
+ // Then adjusts the remaining feature deltas.
+ boolean skip = true;
+ ListIterator<CDOFeatureDelta> iterator = featureDeltas.listIterator();
+
+ while (iterator.hasNext())
+ {
+ CDOFeatureDelta fd = iterator.next();
+
+ // We only need to process feature deltas that come after the ADD (or SET) to be removed.
+ if (skip)
+ {
+ if (fd == delta)
+ {
+ // Found the ADD (or SET) feature delta that we need to remove. So remove it from the list and start
+ // processing the next feature deltas.
+ skip = false;
+ iterator.remove();
+
+ // SET
+ if (fd instanceof CDOSetFeatureDelta)
+ {
+ // If the removed delta is SET we add the REMOVE to the feature deltas. We do not need to adjust the
+ // other feature deltas because SET do not modify the list.
+ return true;
+ }
+ }
+
+ continue;
+ }
+
+ // ADD
+ if (fd instanceof CDOAddFeatureDelta)
+ {
+ // Increases the floating index if the ADD came in front of the item.
+ if (((CDOAddFeatureDelta)fd).getIndex() <= floatingIndex)
+ {
+ ++floatingIndex;
+ }
+
+ // Adjusts the feature delta too.
+ ((WithIndex)fd).adjustAfterRemoval(floatingIndex);
+ }
+
+ // REMOVE
+ else if (fd instanceof CDORemoveFeatureDelta)
+ {
+ int idx = floatingIndex;
+ // Decreases the floating index if the REMOVE came in front of the item.
+ if (((CDORemoveFeatureDelta)fd).getIndex() <= floatingIndex)
+ {
+ --floatingIndex;
+ }
+
+ // Adjusts the feature delta too.
+ ((WithIndex)fd).adjustAfterRemoval(idx);
+ }
+
+ // MOVE
+ else if (fd instanceof CDOMoveFeatureDelta)
+ {
+ // Remembers the positions before we patch them.
+ int from = ((CDOMoveFeatureDelta)fd).getOldPosition();
+ int to = ((CDOMoveFeatureDelta)fd).getNewPosition();
+
+ if (floatingIndex == from)
+ {
+ // We are moving the "to be deleted" item. So we update our floating index and remove the MOVE. It has
+ // no effect on the list.
+ floatingIndex = to;
+ iterator.remove();
+ }
+ else
+ {
+ // In the other cases, we need to patch the positions.
+
+ // If the old position is greater or equal to the current position of the item to be removed (remember,
+ // that's our floating index), decrease the position.
+ int patchedFrom = floatingIndex <= from ? from - 1 : from;
+
+ // The new position requires more care. We need to know the direction of the move (left-to-right or
+ // right-to-left).
+ int patchedTo;
+ if (from > to)
+ {
+ // left-to-right. Only decreases the position if it is strictly greater than the current item
+ // position.
+ patchedTo = floatingIndex < to ? to - 1 : to;
+ }
+ else
+ {
+ // right-to-left. Decreases the position if it is greater or equal than the current item position.
+ patchedTo = floatingIndex <= to ? to - 1 : to;
+ }
+
+ // We can now update our floating index. We use the original positions because the floating index
+ // represents the item "to be deleted" before it was actually removed.
+ if (from < floatingIndex && floatingIndex <= to)
+ {
+ --floatingIndex;
+ }
+ else if (to <= floatingIndex && floatingIndex < from)
+ {
+ ++floatingIndex;
+ }
+
+ // And finally adjust the feature delta.
+ if (patchedFrom == patchedTo)
+ {
+ // Source and destination are the same so just remove the feature delta.
+ iterator.remove();
+ }
+ else
+ {
+ ((CDOMoveFeatureDeltaImpl)fd).setOldPosition(patchedFrom);
+ ((CDOMoveFeatureDeltaImpl)fd).setNewPosition(patchedTo);
+ }
+ }
+ }
+
+ // SET
+ else if (fd instanceof CDOSetFeatureDelta)
+ {
+ // Adjusts the feature delta too.
+ ((WithIndex)fd).adjustAfterRemoval(floatingIndex);
+ }
+ }
+
+ // If the removed delta was ADD so we do not add the REMOVE to the feature deltas.
+ return false;
+ }
+ }
+ }
+
+ if (cachedIndices != null)
+ {
+ if (unprocessedFeatureDeltas == null)
+ {
+ unprocessedFeatureDeltas = new ArrayList<CDOFeatureDelta>();
+ }
+
+ unprocessedFeatureDeltas.add(featureDelta);
+ }
+
+ return true;
+ }
+
+ public void add(CDOFeatureDelta featureDelta)
+ {
+ // Only adds the feature delta to the list if required.
+ if (cleanupWithNewDelta(featureDelta))
+ {
+ featureDeltas.add(featureDelta);
+ }
+ }
+
+ public void apply(CDORevision revision)
+ {
+ for (CDOFeatureDelta featureDelta : featureDeltas)
+ {
+ ((CDOFeatureDeltaImpl)featureDelta).apply(revision);
+ }
+ }
+
+ @Override
+ public boolean adjustReferences(CDOReferenceAdjuster adjuster)
+ {
+ boolean changed = false;
+ for (CDOFeatureDelta featureDelta : featureDeltas)
+ {
+ changed |= ((CDOFeatureDeltaImpl)featureDelta).adjustReferences(adjuster);
+ }
+
+ return changed;
+ }
+
+ public void accept(CDOFeatureDeltaVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ @Override
+ public boolean isStructurallyEqual(Object obj)
+ {
+ if (!super.isStructurallyEqual(obj))
+ {
+ return false;
+ }
+
+ CDOListFeatureDelta that = (CDOListFeatureDelta)obj;
+ return ObjectUtil.equals(featureDeltas, that.getListChanges());
+ }
+
+ @Override
+ protected String toStringAdditional()
+ {
+ return "list=" + featureDeltas; //$NON-NLS-1$
+ }
+
+ /**
+ * Copied from JAVA 1.6 {@link Arrays Arrays.copyOf}.
+ */
+ private static <T, U> T[] copyOf(U[] original, int newLength, Class<? extends T[]> newType)
+ {
+ @SuppressWarnings("unchecked")
+ T[] copy = (Object)newType == (Object)Object[].class ? (T[])new Object[newLength] : (T[])Array.newInstance(
+ newType.getComponentType(), newLength);
+ System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
+ return copy;
+ }
+
+ /**
+ * Copied from JAVA 1.6 {@link Arrays Arrays.copyOf}.
+ */
+ private static int[] copyOf(int[] original, int newLength)
+ {
+ int[] copy = new int[newLength];
+ System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
+ return copy;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOMoveFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOMoveFeatureDeltaImpl.java
index f3fa903d1e..e8c352afc6 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOMoveFeatureDeltaImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOMoveFeatureDeltaImpl.java
@@ -1,207 +1,207 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.revision.delta;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
-import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta;
-import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.ListIndexAffecting;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.WithIndex;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.io.IOException;
-import java.text.MessageFormat;
-
-/**
- * @author Simon McDuff
- */
-public class CDOMoveFeatureDeltaImpl extends CDOFeatureDeltaImpl implements CDOMoveFeatureDelta, ListIndexAffecting,
- WithIndex
-{
- private int oldPosition;
-
- private int newPosition;
-
- private Object value;
-
- public CDOMoveFeatureDeltaImpl(EStructuralFeature feature, int newPosition, int oldPosition)
- {
- super(feature);
- this.newPosition = newPosition;
- this.oldPosition = oldPosition;
- value = UNKNOWN_VALUE;
- }
-
- public CDOMoveFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
- {
- super(in, eClass);
- newPosition = in.readInt();
- oldPosition = in.readInt();
- value = UNKNOWN_VALUE;
- }
-
- @Override
- public void write(CDODataOutput out, EClass eClass) throws IOException
- {
- super.write(out, eClass);
- out.writeInt(newPosition);
- out.writeInt(oldPosition);
- }
-
- public int getNewPosition()
- {
- return newPosition;
- }
-
- public int getOldPosition()
- {
- return oldPosition;
- }
-
- public Type getType()
- {
- return Type.MOVE;
- }
-
- public Object getValue()
- {
- return value;
- }
-
- public void setValue(Object value)
- {
- this.value = value;
- }
-
- public void setOldPosition(int oldPosition)
- {
- this.oldPosition = oldPosition;
- }
-
- public void setNewPosition(int newPosition)
- {
- this.newPosition = newPosition;
- }
-
- public CDOFeatureDelta copy()
- {
- CDOFeatureDelta copy = new CDOMoveFeatureDeltaImpl(getFeature(), newPosition, oldPosition);
- ((CDOMoveFeatureDeltaImpl)copy).setValue(getValue());
- return copy;
- }
-
- public void apply(CDORevision revision)
- {
- ((InternalCDORevision)revision).getList(getFeature()).move(newPosition, oldPosition);
- }
-
- public void affectIndices(ListTargetAdding[] source, int[] indices)
- {
- if (oldPosition < newPosition)
- {
- for (int i = 1; i <= indices[0]; i++)
- {
- if (oldPosition < indices[i] && indices[i] <= newPosition)
- {
- --indices[i];
- }
- else if (indices[i] == oldPosition)
- {
- indices[i] = newPosition;
- }
- }
- }
- else if (newPosition < oldPosition)
- {
- for (int i = 1; i <= indices[0]; i++)
- {
- if (newPosition <= indices[i] && indices[i] < oldPosition)
- {
- ++indices[i];
- }
- else if (indices[i] == oldPosition)
- {
- indices[i] = newPosition;
- }
- }
- }
- }
-
- public void accept(CDOFeatureDeltaVisitor visitor)
- {
- visitor.visit(this);
- }
-
- public void adjustAfterAddition(int index)
- {
- if (index <= oldPosition)
- {
- ++oldPosition;
- }
-
- if (index <= newPosition)
- {
- ++newPosition;
- }
- }
-
- public void adjustAfterRemoval(int index)
- {
- if (index < oldPosition && oldPosition > 0)
- {
- --oldPosition;
- }
-
- // Index fix for moves from left to right.
- if (oldPosition < newPosition)
- {
- --index;
- }
-
- if (index < newPosition && newPosition > 0)
- {
- --newPosition;
- }
- }
-
- @Override
- public boolean adjustReferences(CDOReferenceAdjuster adjuster)
- {
- return false;
- }
-
- @Override
- public boolean isStructurallyEqual(Object obj)
- {
- if (!super.isStructurallyEqual(obj))
- {
- return false;
- }
-
- CDOMoveFeatureDelta that = (CDOMoveFeatureDelta)obj;
- return oldPosition == that.getOldPosition() && newPosition == that.getNewPosition();
- }
-
- @Override
- protected String toStringAdditional()
- {
- return MessageFormat.format("from={0}, to={1}, value={2}", oldPosition, newPosition, value);
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.common.revision.delta;
+
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
+import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta;
+import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.ListIndexAffecting;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.WithIndex;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import java.io.IOException;
+import java.text.MessageFormat;
+
+/**
+ * @author Simon McDuff
+ */
+public class CDOMoveFeatureDeltaImpl extends CDOFeatureDeltaImpl implements CDOMoveFeatureDelta, ListIndexAffecting,
+ WithIndex
+{
+ private int oldPosition;
+
+ private int newPosition;
+
+ private Object value;
+
+ public CDOMoveFeatureDeltaImpl(EStructuralFeature feature, int newPosition, int oldPosition)
+ {
+ super(feature);
+ this.newPosition = newPosition;
+ this.oldPosition = oldPosition;
+ value = UNKNOWN_VALUE;
+ }
+
+ public CDOMoveFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
+ {
+ super(in, eClass);
+ newPosition = in.readInt();
+ oldPosition = in.readInt();
+ value = UNKNOWN_VALUE;
+ }
+
+ @Override
+ public void write(CDODataOutput out, EClass eClass) throws IOException
+ {
+ super.write(out, eClass);
+ out.writeInt(newPosition);
+ out.writeInt(oldPosition);
+ }
+
+ public int getNewPosition()
+ {
+ return newPosition;
+ }
+
+ public int getOldPosition()
+ {
+ return oldPosition;
+ }
+
+ public Type getType()
+ {
+ return Type.MOVE;
+ }
+
+ public Object getValue()
+ {
+ return value;
+ }
+
+ public void setValue(Object value)
+ {
+ this.value = value;
+ }
+
+ public void setOldPosition(int oldPosition)
+ {
+ this.oldPosition = oldPosition;
+ }
+
+ public void setNewPosition(int newPosition)
+ {
+ this.newPosition = newPosition;
+ }
+
+ public CDOFeatureDelta copy()
+ {
+ CDOFeatureDelta copy = new CDOMoveFeatureDeltaImpl(getFeature(), newPosition, oldPosition);
+ ((CDOMoveFeatureDeltaImpl)copy).setValue(getValue());
+ return copy;
+ }
+
+ public void apply(CDORevision revision)
+ {
+ ((InternalCDORevision)revision).getList(getFeature()).move(newPosition, oldPosition);
+ }
+
+ public void affectIndices(ListTargetAdding[] source, int[] indices)
+ {
+ if (oldPosition < newPosition)
+ {
+ for (int i = 1; i <= indices[0]; i++)
+ {
+ if (oldPosition < indices[i] && indices[i] <= newPosition)
+ {
+ --indices[i];
+ }
+ else if (indices[i] == oldPosition)
+ {
+ indices[i] = newPosition;
+ }
+ }
+ }
+ else if (newPosition < oldPosition)
+ {
+ for (int i = 1; i <= indices[0]; i++)
+ {
+ if (newPosition <= indices[i] && indices[i] < oldPosition)
+ {
+ ++indices[i];
+ }
+ else if (indices[i] == oldPosition)
+ {
+ indices[i] = newPosition;
+ }
+ }
+ }
+ }
+
+ public void accept(CDOFeatureDeltaVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ public void adjustAfterAddition(int index)
+ {
+ if (index <= oldPosition)
+ {
+ ++oldPosition;
+ }
+
+ if (index <= newPosition)
+ {
+ ++newPosition;
+ }
+ }
+
+ public void adjustAfterRemoval(int index)
+ {
+ if (index < oldPosition && oldPosition > 0)
+ {
+ --oldPosition;
+ }
+
+ // Index fix for moves from left to right.
+ if (oldPosition < newPosition)
+ {
+ --index;
+ }
+
+ if (index < newPosition && newPosition > 0)
+ {
+ --newPosition;
+ }
+ }
+
+ @Override
+ public boolean adjustReferences(CDOReferenceAdjuster adjuster)
+ {
+ return false;
+ }
+
+ @Override
+ public boolean isStructurallyEqual(Object obj)
+ {
+ if (!super.isStructurallyEqual(obj))
+ {
+ return false;
+ }
+
+ CDOMoveFeatureDelta that = (CDOMoveFeatureDelta)obj;
+ return oldPosition == that.getOldPosition() && newPosition == that.getNewPosition();
+ }
+
+ @Override
+ protected String toStringAdditional()
+ {
+ return MessageFormat.format("from={0}, to={1}, value={2}", oldPosition, newPosition, value);
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORemoveFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORemoveFeatureDeltaImpl.java
index 0b8e303f68..4141ffc4c6 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORemoveFeatureDeltaImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORemoveFeatureDeltaImpl.java
@@ -1,99 +1,99 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.revision.delta;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
-import org.eclipse.emf.cdo.common.revision.delta.CDORemoveFeatureDelta;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.ListIndexAffecting;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.io.IOException;
-
-/**
- * @author Simon McDuff
- */
-public class CDORemoveFeatureDeltaImpl extends CDOSingleValueFeatureDeltaImpl implements CDORemoveFeatureDelta,
- ListIndexAffecting
-{
- public CDORemoveFeatureDeltaImpl(EStructuralFeature feature, int index)
- {
- super(feature, index, UNKNOWN_VALUE);
- }
-
- public CDORemoveFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
- {
- super(in, eClass);
- }
-
- @Override
- protected void writeValue(CDODataOutput out, EClass eClass) throws IOException
- {
- // Do nothing
- }
-
- @Override
- protected Object readValue(CDODataInput in, EClass eClass) throws IOException
- {
- return UNKNOWN_VALUE;
- }
-
- public Type getType()
- {
- return Type.REMOVE;
- }
-
- public CDOFeatureDelta copy()
- {
- CDORemoveFeatureDeltaImpl delta = new CDORemoveFeatureDeltaImpl(getFeature(), getIndex());
- delta.setValue(getValue());
- return delta;
- }
-
- public void apply(CDORevision revision)
- {
- ((InternalCDORevision)revision).getList(getFeature()).remove(getIndex());
- }
-
- public void accept(CDOFeatureDeltaVisitor visitor)
- {
- visitor.visit(this);
- }
-
- public void affectIndices(ListTargetAdding sources[], int[] indices)
- {
- int index = getIndex();
- for (int i = 1; i <= indices[0]; i++)
- {
- if (indices[i] > index)
- {
- --indices[i];
- }
- else if (indices[i] == index)
- {
- int rest = indices[0]-- - i;
- if (rest > 0)
- {
- System.arraycopy(indices, i + 1, indices, i, rest);
- System.arraycopy(sources, i + 1, sources, i, rest);
- --i;
- }
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.common.revision.delta;
+
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
+import org.eclipse.emf.cdo.common.revision.delta.CDORemoveFeatureDelta;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.ListIndexAffecting;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import java.io.IOException;
+
+/**
+ * @author Simon McDuff
+ */
+public class CDORemoveFeatureDeltaImpl extends CDOSingleValueFeatureDeltaImpl implements CDORemoveFeatureDelta,
+ ListIndexAffecting
+{
+ public CDORemoveFeatureDeltaImpl(EStructuralFeature feature, int index)
+ {
+ super(feature, index, UNKNOWN_VALUE);
+ }
+
+ public CDORemoveFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
+ {
+ super(in, eClass);
+ }
+
+ @Override
+ protected void writeValue(CDODataOutput out, EClass eClass) throws IOException
+ {
+ // Do nothing
+ }
+
+ @Override
+ protected Object readValue(CDODataInput in, EClass eClass) throws IOException
+ {
+ return UNKNOWN_VALUE;
+ }
+
+ public Type getType()
+ {
+ return Type.REMOVE;
+ }
+
+ public CDOFeatureDelta copy()
+ {
+ CDORemoveFeatureDeltaImpl delta = new CDORemoveFeatureDeltaImpl(getFeature(), getIndex());
+ delta.setValue(getValue());
+ return delta;
+ }
+
+ public void apply(CDORevision revision)
+ {
+ ((InternalCDORevision)revision).getList(getFeature()).remove(getIndex());
+ }
+
+ public void accept(CDOFeatureDeltaVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ public void affectIndices(ListTargetAdding sources[], int[] indices)
+ {
+ int index = getIndex();
+ for (int i = 1; i <= indices[0]; i++)
+ {
+ if (indices[i] > index)
+ {
+ --indices[i];
+ }
+ else if (indices[i] == index)
+ {
+ int rest = indices[0]-- - i;
+ if (rest > 0)
+ {
+ System.arraycopy(indices, i + 1, indices, i, rest);
+ System.arraycopy(sources, i + 1, sources, i, rest);
+ --i;
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java
index bd5b0ba57e..de4a5c3859 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java
@@ -1,551 +1,551 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - bug 201266
- * Simon McDuff - bug 204890
- */
-package org.eclipse.emf.cdo.internal.common.revision.delta;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOWithID;
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.revision.CDOElementProxy;
-import org.eclipse.emf.cdo.common.revision.CDOList;
-import org.eclipse.emf.cdo.common.revision.CDORevisable;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionData;
-import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
-import org.eclipse.emf.cdo.common.revision.delta.CDOClearFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
-import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta;
-import org.eclipse.emf.cdo.common.util.PartialCollectionLoadingNotSupportedException;
-import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta;
-
-import org.eclipse.emf.common.util.ECollections;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.change.ListChange;
-import org.eclipse.emf.ecore.change.util.ListDifferenceAnalyzer;
-
-import java.io.IOException;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class CDORevisionDeltaImpl implements InternalCDORevisionDelta
-{
- private EClass eClass;
-
- private CDOID id;
-
- private CDOBranch branch;
-
- private int version;
-
- private CDORevisable target;
-
- private Map<EStructuralFeature, CDOFeatureDelta> featureDeltas = new HashMap<EStructuralFeature, CDOFeatureDelta>();
-
- public CDORevisionDeltaImpl(CDORevision revision)
- {
- eClass = revision.getEClass();
- id = revision.getID();
- branch = revision.getBranch();
- version = revision.getVersion();
- }
-
- public CDORevisionDeltaImpl(CDORevisionDelta revisionDelta, boolean copyFeatureDeltas)
- {
- eClass = revisionDelta.getEClass();
- id = revisionDelta.getID();
- branch = revisionDelta.getBranch();
- version = revisionDelta.getVersion();
-
- if (copyFeatureDeltas)
- {
- for (CDOFeatureDelta delta : revisionDelta.getFeatureDeltas())
- {
- addFeatureDelta(((InternalCDOFeatureDelta)delta).copy());
- }
- }
- }
-
- public CDORevisionDeltaImpl(CDORevision sourceRevision, CDORevision targetRevision)
- {
- if (sourceRevision.getEClass() != targetRevision.getEClass())
- {
- throw new IllegalArgumentException();
- }
-
- eClass = sourceRevision.getEClass();
- id = sourceRevision.getID();
- branch = sourceRevision.getBranch();
- version = sourceRevision.getVersion();
- target = CDORevisionUtil.copyRevisable(targetRevision);
-
- compare(sourceRevision, targetRevision);
-
- CDORevisionData originData = sourceRevision.data();
- CDORevisionData dirtyData = targetRevision.data();
-
- Object dirtyContainerID = dirtyData.getContainerID();
- if (dirtyContainerID instanceof CDOWithID)
- {
- dirtyContainerID = ((CDOWithID)dirtyContainerID).cdoID();
- }
-
- if (!compare(originData.getContainerID(), dirtyContainerID)
- || !compare(originData.getContainingFeatureID(), dirtyData.getContainingFeatureID())
- || !compare(originData.getResourceID(), dirtyData.getResourceID()))
- {
- addFeatureDelta(new CDOContainerFeatureDeltaImpl(dirtyData.getResourceID(), dirtyContainerID,
- dirtyData.getContainingFeatureID()));
- }
- }
-
- public CDORevisionDeltaImpl(CDODataInput in) throws IOException
- {
- eClass = (EClass)in.readCDOClassifierRefAndResolve();
- id = in.readCDOID();
- branch = in.readCDOBranch();
- version = in.readInt();
- if (version < 0)
- {
- version = -version;
- target = in.readCDORevisable();
- }
-
- int size = in.readInt();
- for (int i = 0; i < size; i++)
- {
- CDOFeatureDelta featureDelta = in.readCDOFeatureDelta(eClass);
- featureDeltas.put(featureDelta.getFeature(), featureDelta);
- }
- }
-
- public void write(CDODataOutput out) throws IOException
- {
- out.writeCDOClassifierRef(eClass);
- out.writeCDOID(id);
- out.writeCDOBranch(branch);
- if (target == null)
- {
- out.writeInt(version);
- }
- else
- {
- out.writeInt(-version);
- out.writeCDORevisable(target);
- }
-
- out.writeInt(featureDeltas.size());
- for (CDOFeatureDelta featureDelta : featureDeltas.values())
- {
- out.writeCDOFeatureDelta(eClass, featureDelta);
- }
- }
-
- public EClass getEClass()
- {
- return eClass;
- }
-
- public CDOID getID()
- {
- return id;
- }
-
- public CDOBranch getBranch()
- {
- return branch;
- }
-
- public void setBranch(CDOBranch branch)
- {
- this.branch = branch;
- }
-
- public int getVersion()
- {
- return version;
- }
-
- public void setVersion(int version)
- {
- this.version = version;
- }
-
- public CDORevisable getTarget()
- {
- return target;
- }
-
- public void setTarget(CDORevisable target)
- {
- this.target = target;
- }
-
- public boolean isEmpty()
- {
- return featureDeltas.isEmpty();
- }
-
- public CDORevisionDelta copy()
- {
- return new CDORevisionDeltaImpl(this, true);
- }
-
- public Map<EStructuralFeature, CDOFeatureDelta> getFeatureDeltaMap()
- {
- return featureDeltas;
- }
-
- public CDOFeatureDelta getFeatureDelta(EStructuralFeature feature)
- {
- return featureDeltas.get(feature);
- }
-
- public List<CDOFeatureDelta> getFeatureDeltas()
- {
- return new ArrayList<CDOFeatureDelta>(featureDeltas.values());
- }
-
- public void apply(CDORevision revision)
- {
- for (CDOFeatureDelta featureDelta : featureDeltas.values())
- {
- ((CDOFeatureDeltaImpl)featureDelta).apply(revision);
- }
- }
-
- public void addFeatureDelta(CDOFeatureDelta delta)
- {
- if (delta instanceof CDOListFeatureDelta)
- {
- CDOListFeatureDelta deltas = (CDOListFeatureDelta)delta;
- for (CDOFeatureDelta childDelta : deltas.getListChanges())
- {
- addFeatureDelta(childDelta);
- }
- }
- else
- {
- addSingleFeatureDelta(delta);
- }
- }
-
- private void addSingleFeatureDelta(CDOFeatureDelta delta)
- {
- EStructuralFeature feature = delta.getFeature();
- if (feature.isMany())
- {
- CDOListFeatureDeltaImpl listDelta = (CDOListFeatureDeltaImpl)featureDeltas.get(feature);
- if (listDelta == null)
- {
- listDelta = new CDOListFeatureDeltaImpl(feature);
- featureDeltas.put(listDelta.getFeature(), listDelta);
- }
-
- // Remove all previous changes
- if (delta instanceof CDOClearFeatureDelta || delta instanceof CDOUnsetFeatureDelta)
- {
- listDelta.getListChanges().clear();
- }
-
- listDelta.add(delta);
- }
- else
- {
- featureDeltas.put(feature, delta);
- }
- }
-
- public boolean adjustReferences(CDOReferenceAdjuster referenceAdjuster)
- {
- boolean changed = false;
- for (CDOFeatureDelta featureDelta : featureDeltas.values())
- {
- changed |= ((CDOFeatureDeltaImpl)featureDelta).adjustReferences(referenceAdjuster);
- }
-
- return changed;
- }
-
- public void accept(CDOFeatureDeltaVisitor visitor)
- {
- for (CDOFeatureDelta featureDelta : featureDeltas.values())
- {
- ((CDOFeatureDeltaImpl)featureDelta).accept(visitor);
- }
- }
-
- private void compare(CDORevision originRevision, CDORevision dirtyRevision)
- {
- CDORevisionData originData = originRevision.data();
- CDORevisionData dirtyData = dirtyRevision.data();
-
- for (final EStructuralFeature feature : CDOModelUtil.getAllPersistentFeatures(eClass))
- {
- if (feature.isMany())
- {
- if (originData.size(feature) > 0 && dirtyData.size(feature) == 0)
- {
- addFeatureDelta(new CDOClearFeatureDeltaImpl(feature));
- }
- else
- {
- CDOListFeatureDelta listFeatureDelta = new CDOListFeatureDeltaImpl(feature);
- final List<CDOFeatureDelta> changes = listFeatureDelta.getListChanges();
-
- ListDifferenceAnalyzer analyzer = new ListDifferenceAnalyzer()
- {
- @Override
- public void analyzeLists(EList<Object> oldList, EList<?> newList, EList<ListChange> listChanges)
- {
- checkNoProxies(oldList);
- checkNoProxies(newList);
- super.analyzeLists(oldList, newList, listChanges);
- }
-
- @Override
- protected void createAddListChange(EList<Object> oldList, EList<ListChange> listChanges, Object value,
- int index)
- {
- CDOFeatureDelta delta = new CDOAddFeatureDeltaImpl(feature, index, value);
- changes.add(delta);
- oldList.add(index, value);
- }
-
- @Override
- protected void createRemoveListChange(EList<?> oldList, EList<ListChange> listChanges, Object value,
- int index)
- {
- CDORemoveFeatureDeltaImpl delta = new CDORemoveFeatureDeltaImpl(feature, index);
- // fix until ListDifferenceAnalyzer delivers the correct value (bug #308618).
- delta.setValue(oldList.get(index));
- changes.add(delta);
- oldList.remove(index);
- }
-
- @Override
- protected void createMoveListChange(EList<?> oldList, EList<ListChange> listChanges, Object value,
- int index, int toIndex)
- {
- CDOMoveFeatureDeltaImpl delta = new CDOMoveFeatureDeltaImpl(feature, toIndex, index);
- // fix until ListDifferenceAnalyzer delivers the correct value (same problem as bug #308618).
- delta.setValue(oldList.get(index));
- changes.add(delta);
- oldList.move(toIndex, index);
- }
-
- private void checkNoProxies(EList<?> list)
- {
- for (Object element : list)
- {
- if (element instanceof CDOElementProxy)
- {
- throw new PartialCollectionLoadingNotSupportedException("List contains proxy elements");
- }
- }
- }
- };
-
- CDOList originList = ((InternalCDORevision)originRevision).getList(feature);
- CDOList dirtyList = ((InternalCDORevision)dirtyRevision).getList(feature);
-
- analyzer.analyzeLists(originList, dirtyList, new NOOPList());
- if (!changes.isEmpty())
- {
- featureDeltas.put(feature, listFeatureDelta);
- }
- }
- }
- else
- {
- Object originValue = originData.get(feature, 0);
- Object dirtyValue = dirtyData.get(feature, 0);
- if (!compare(originValue, dirtyValue))
- {
- if (dirtyValue == null)
- {
- addFeatureDelta(new CDOUnsetFeatureDeltaImpl(feature));
- }
- else
- {
- addFeatureDelta(new CDOSetFeatureDeltaImpl(feature, 0, dirtyValue, originValue));
- }
- }
- }
- }
- }
-
- private boolean compare(Object originValue, Object dirtyValue)
- {
- return originValue == dirtyValue || originValue != null && dirtyValue != null && originValue.equals(dirtyValue);
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("CDORevisionDelta[{0}@{1}:{2}v{3} --> {4}]", eClass.getName(), id, branch.getID(),
- version, featureDeltas.values());
- }
-
- /**
- * @author Eike Stepper
- */
- public static class NOOPList implements EList<ListChange>
- {
- private static final EList<ListChange> LIST = ECollections.emptyEList();
-
- public NOOPList()
- {
- }
-
- public int size()
- {
- return 0;
- }
-
- public boolean isEmpty()
- {
- return true;
- }
-
- public boolean contains(Object o)
- {
- return false;
- }
-
- public Iterator<ListChange> iterator()
- {
- return LIST.iterator();
- }
-
- public Object[] toArray()
- {
- return LIST.toArray();
- }
-
- public <T> T[] toArray(T[] a)
- {
- return LIST.toArray(a);
- }
-
- public boolean add(ListChange o)
- {
- return false;
- }
-
- public boolean remove(Object o)
- {
- return false;
- }
-
- public boolean containsAll(Collection<?> c)
- {
- return false;
- }
-
- public boolean addAll(Collection<? extends ListChange> c)
- {
- return false;
- }
-
- public boolean addAll(int index, Collection<? extends ListChange> c)
- {
- return false;
- }
-
- public boolean removeAll(Collection<?> c)
- {
- return false;
- }
-
- public boolean retainAll(Collection<?> c)
- {
- return false;
- }
-
- public void clear()
- {
- }
-
- public ListChange get(int index)
- {
- return LIST.get(index);
- }
-
- public ListChange set(int index, ListChange element)
- {
- return null;
- }
-
- public void add(int index, ListChange element)
- {
- }
-
- public ListChange remove(int index)
- {
- return null;
- }
-
- public int indexOf(Object o)
- {
- return LIST.indexOf(o);
- }
-
- public int lastIndexOf(Object o)
- {
- return LIST.lastIndexOf(o);
- }
-
- public ListIterator<ListChange> listIterator()
- {
- return LIST.listIterator();
- }
-
- public ListIterator<ListChange> listIterator(int index)
- {
- return LIST.listIterator(index);
- }
-
- public List<ListChange> subList(int fromIndex, int toIndex)
- {
- return LIST.subList(fromIndex, toIndex);
- }
-
- public void move(int newPosition, ListChange object)
- {
- }
-
- public ListChange move(int newPosition, int oldPosition)
- {
- return null;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Simon McDuff - bug 201266
+ * Simon McDuff - bug 204890
+ */
+package org.eclipse.emf.cdo.internal.common.revision.delta;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOWithID;
+import org.eclipse.emf.cdo.common.model.CDOModelUtil;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.common.revision.CDOElementProxy;
+import org.eclipse.emf.cdo.common.revision.CDOList;
+import org.eclipse.emf.cdo.common.revision.CDORevisable;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionData;
+import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
+import org.eclipse.emf.cdo.common.revision.delta.CDOClearFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
+import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta;
+import org.eclipse.emf.cdo.common.util.PartialCollectionLoadingNotSupportedException;
+import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta;
+
+import org.eclipse.emf.common.util.ECollections;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.change.ListChange;
+import org.eclipse.emf.ecore.change.util.ListDifferenceAnalyzer;
+
+import java.io.IOException;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDORevisionDeltaImpl implements InternalCDORevisionDelta
+{
+ private EClass eClass;
+
+ private CDOID id;
+
+ private CDOBranch branch;
+
+ private int version;
+
+ private CDORevisable target;
+
+ private Map<EStructuralFeature, CDOFeatureDelta> featureDeltas = new HashMap<EStructuralFeature, CDOFeatureDelta>();
+
+ public CDORevisionDeltaImpl(CDORevision revision)
+ {
+ eClass = revision.getEClass();
+ id = revision.getID();
+ branch = revision.getBranch();
+ version = revision.getVersion();
+ }
+
+ public CDORevisionDeltaImpl(CDORevisionDelta revisionDelta, boolean copyFeatureDeltas)
+ {
+ eClass = revisionDelta.getEClass();
+ id = revisionDelta.getID();
+ branch = revisionDelta.getBranch();
+ version = revisionDelta.getVersion();
+
+ if (copyFeatureDeltas)
+ {
+ for (CDOFeatureDelta delta : revisionDelta.getFeatureDeltas())
+ {
+ addFeatureDelta(((InternalCDOFeatureDelta)delta).copy());
+ }
+ }
+ }
+
+ public CDORevisionDeltaImpl(CDORevision sourceRevision, CDORevision targetRevision)
+ {
+ if (sourceRevision.getEClass() != targetRevision.getEClass())
+ {
+ throw new IllegalArgumentException();
+ }
+
+ eClass = sourceRevision.getEClass();
+ id = sourceRevision.getID();
+ branch = sourceRevision.getBranch();
+ version = sourceRevision.getVersion();
+ target = CDORevisionUtil.copyRevisable(targetRevision);
+
+ compare(sourceRevision, targetRevision);
+
+ CDORevisionData originData = sourceRevision.data();
+ CDORevisionData dirtyData = targetRevision.data();
+
+ Object dirtyContainerID = dirtyData.getContainerID();
+ if (dirtyContainerID instanceof CDOWithID)
+ {
+ dirtyContainerID = ((CDOWithID)dirtyContainerID).cdoID();
+ }
+
+ if (!compare(originData.getContainerID(), dirtyContainerID)
+ || !compare(originData.getContainingFeatureID(), dirtyData.getContainingFeatureID())
+ || !compare(originData.getResourceID(), dirtyData.getResourceID()))
+ {
+ addFeatureDelta(new CDOContainerFeatureDeltaImpl(dirtyData.getResourceID(), dirtyContainerID,
+ dirtyData.getContainingFeatureID()));
+ }
+ }
+
+ public CDORevisionDeltaImpl(CDODataInput in) throws IOException
+ {
+ eClass = (EClass)in.readCDOClassifierRefAndResolve();
+ id = in.readCDOID();
+ branch = in.readCDOBranch();
+ version = in.readInt();
+ if (version < 0)
+ {
+ version = -version;
+ target = in.readCDORevisable();
+ }
+
+ int size = in.readInt();
+ for (int i = 0; i < size; i++)
+ {
+ CDOFeatureDelta featureDelta = in.readCDOFeatureDelta(eClass);
+ featureDeltas.put(featureDelta.getFeature(), featureDelta);
+ }
+ }
+
+ public void write(CDODataOutput out) throws IOException
+ {
+ out.writeCDOClassifierRef(eClass);
+ out.writeCDOID(id);
+ out.writeCDOBranch(branch);
+ if (target == null)
+ {
+ out.writeInt(version);
+ }
+ else
+ {
+ out.writeInt(-version);
+ out.writeCDORevisable(target);
+ }
+
+ out.writeInt(featureDeltas.size());
+ for (CDOFeatureDelta featureDelta : featureDeltas.values())
+ {
+ out.writeCDOFeatureDelta(eClass, featureDelta);
+ }
+ }
+
+ public EClass getEClass()
+ {
+ return eClass;
+ }
+
+ public CDOID getID()
+ {
+ return id;
+ }
+
+ public CDOBranch getBranch()
+ {
+ return branch;
+ }
+
+ public void setBranch(CDOBranch branch)
+ {
+ this.branch = branch;
+ }
+
+ public int getVersion()
+ {
+ return version;
+ }
+
+ public void setVersion(int version)
+ {
+ this.version = version;
+ }
+
+ public CDORevisable getTarget()
+ {
+ return target;
+ }
+
+ public void setTarget(CDORevisable target)
+ {
+ this.target = target;
+ }
+
+ public boolean isEmpty()
+ {
+ return featureDeltas.isEmpty();
+ }
+
+ public CDORevisionDelta copy()
+ {
+ return new CDORevisionDeltaImpl(this, true);
+ }
+
+ public Map<EStructuralFeature, CDOFeatureDelta> getFeatureDeltaMap()
+ {
+ return featureDeltas;
+ }
+
+ public CDOFeatureDelta getFeatureDelta(EStructuralFeature feature)
+ {
+ return featureDeltas.get(feature);
+ }
+
+ public List<CDOFeatureDelta> getFeatureDeltas()
+ {
+ return new ArrayList<CDOFeatureDelta>(featureDeltas.values());
+ }
+
+ public void apply(CDORevision revision)
+ {
+ for (CDOFeatureDelta featureDelta : featureDeltas.values())
+ {
+ ((CDOFeatureDeltaImpl)featureDelta).apply(revision);
+ }
+ }
+
+ public void addFeatureDelta(CDOFeatureDelta delta)
+ {
+ if (delta instanceof CDOListFeatureDelta)
+ {
+ CDOListFeatureDelta deltas = (CDOListFeatureDelta)delta;
+ for (CDOFeatureDelta childDelta : deltas.getListChanges())
+ {
+ addFeatureDelta(childDelta);
+ }
+ }
+ else
+ {
+ addSingleFeatureDelta(delta);
+ }
+ }
+
+ private void addSingleFeatureDelta(CDOFeatureDelta delta)
+ {
+ EStructuralFeature feature = delta.getFeature();
+ if (feature.isMany())
+ {
+ CDOListFeatureDeltaImpl listDelta = (CDOListFeatureDeltaImpl)featureDeltas.get(feature);
+ if (listDelta == null)
+ {
+ listDelta = new CDOListFeatureDeltaImpl(feature);
+ featureDeltas.put(listDelta.getFeature(), listDelta);
+ }
+
+ // Remove all previous changes
+ if (delta instanceof CDOClearFeatureDelta || delta instanceof CDOUnsetFeatureDelta)
+ {
+ listDelta.getListChanges().clear();
+ }
+
+ listDelta.add(delta);
+ }
+ else
+ {
+ featureDeltas.put(feature, delta);
+ }
+ }
+
+ public boolean adjustReferences(CDOReferenceAdjuster referenceAdjuster)
+ {
+ boolean changed = false;
+ for (CDOFeatureDelta featureDelta : featureDeltas.values())
+ {
+ changed |= ((CDOFeatureDeltaImpl)featureDelta).adjustReferences(referenceAdjuster);
+ }
+
+ return changed;
+ }
+
+ public void accept(CDOFeatureDeltaVisitor visitor)
+ {
+ for (CDOFeatureDelta featureDelta : featureDeltas.values())
+ {
+ ((CDOFeatureDeltaImpl)featureDelta).accept(visitor);
+ }
+ }
+
+ private void compare(CDORevision originRevision, CDORevision dirtyRevision)
+ {
+ CDORevisionData originData = originRevision.data();
+ CDORevisionData dirtyData = dirtyRevision.data();
+
+ for (final EStructuralFeature feature : CDOModelUtil.getAllPersistentFeatures(eClass))
+ {
+ if (feature.isMany())
+ {
+ if (originData.size(feature) > 0 && dirtyData.size(feature) == 0)
+ {
+ addFeatureDelta(new CDOClearFeatureDeltaImpl(feature));
+ }
+ else
+ {
+ CDOListFeatureDelta listFeatureDelta = new CDOListFeatureDeltaImpl(feature);
+ final List<CDOFeatureDelta> changes = listFeatureDelta.getListChanges();
+
+ ListDifferenceAnalyzer analyzer = new ListDifferenceAnalyzer()
+ {
+ @Override
+ public void analyzeLists(EList<Object> oldList, EList<?> newList, EList<ListChange> listChanges)
+ {
+ checkNoProxies(oldList);
+ checkNoProxies(newList);
+ super.analyzeLists(oldList, newList, listChanges);
+ }
+
+ @Override
+ protected void createAddListChange(EList<Object> oldList, EList<ListChange> listChanges, Object value,
+ int index)
+ {
+ CDOFeatureDelta delta = new CDOAddFeatureDeltaImpl(feature, index, value);
+ changes.add(delta);
+ oldList.add(index, value);
+ }
+
+ @Override
+ protected void createRemoveListChange(EList<?> oldList, EList<ListChange> listChanges, Object value,
+ int index)
+ {
+ CDORemoveFeatureDeltaImpl delta = new CDORemoveFeatureDeltaImpl(feature, index);
+ // fix until ListDifferenceAnalyzer delivers the correct value (bug #308618).
+ delta.setValue(oldList.get(index));
+ changes.add(delta);
+ oldList.remove(index);
+ }
+
+ @Override
+ protected void createMoveListChange(EList<?> oldList, EList<ListChange> listChanges, Object value,
+ int index, int toIndex)
+ {
+ CDOMoveFeatureDeltaImpl delta = new CDOMoveFeatureDeltaImpl(feature, toIndex, index);
+ // fix until ListDifferenceAnalyzer delivers the correct value (same problem as bug #308618).
+ delta.setValue(oldList.get(index));
+ changes.add(delta);
+ oldList.move(toIndex, index);
+ }
+
+ private void checkNoProxies(EList<?> list)
+ {
+ for (Object element : list)
+ {
+ if (element instanceof CDOElementProxy)
+ {
+ throw new PartialCollectionLoadingNotSupportedException("List contains proxy elements");
+ }
+ }
+ }
+ };
+
+ CDOList originList = ((InternalCDORevision)originRevision).getList(feature);
+ CDOList dirtyList = ((InternalCDORevision)dirtyRevision).getList(feature);
+
+ analyzer.analyzeLists(originList, dirtyList, new NOOPList());
+ if (!changes.isEmpty())
+ {
+ featureDeltas.put(feature, listFeatureDelta);
+ }
+ }
+ }
+ else
+ {
+ Object originValue = originData.get(feature, 0);
+ Object dirtyValue = dirtyData.get(feature, 0);
+ if (!compare(originValue, dirtyValue))
+ {
+ if (dirtyValue == null)
+ {
+ addFeatureDelta(new CDOUnsetFeatureDeltaImpl(feature));
+ }
+ else
+ {
+ addFeatureDelta(new CDOSetFeatureDeltaImpl(feature, 0, dirtyValue, originValue));
+ }
+ }
+ }
+ }
+ }
+
+ private boolean compare(Object originValue, Object dirtyValue)
+ {
+ return originValue == dirtyValue || originValue != null && dirtyValue != null && originValue.equals(dirtyValue);
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("CDORevisionDelta[{0}@{1}:{2}v{3} --> {4}]", eClass.getName(), id, branch.getID(),
+ version, featureDeltas.values());
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class NOOPList implements EList<ListChange>
+ {
+ private static final EList<ListChange> LIST = ECollections.emptyEList();
+
+ public NOOPList()
+ {
+ }
+
+ public int size()
+ {
+ return 0;
+ }
+
+ public boolean isEmpty()
+ {
+ return true;
+ }
+
+ public boolean contains(Object o)
+ {
+ return false;
+ }
+
+ public Iterator<ListChange> iterator()
+ {
+ return LIST.iterator();
+ }
+
+ public Object[] toArray()
+ {
+ return LIST.toArray();
+ }
+
+ public <T> T[] toArray(T[] a)
+ {
+ return LIST.toArray(a);
+ }
+
+ public boolean add(ListChange o)
+ {
+ return false;
+ }
+
+ public boolean remove(Object o)
+ {
+ return false;
+ }
+
+ public boolean containsAll(Collection<?> c)
+ {
+ return false;
+ }
+
+ public boolean addAll(Collection<? extends ListChange> c)
+ {
+ return false;
+ }
+
+ public boolean addAll(int index, Collection<? extends ListChange> c)
+ {
+ return false;
+ }
+
+ public boolean removeAll(Collection<?> c)
+ {
+ return false;
+ }
+
+ public boolean retainAll(Collection<?> c)
+ {
+ return false;
+ }
+
+ public void clear()
+ {
+ }
+
+ public ListChange get(int index)
+ {
+ return LIST.get(index);
+ }
+
+ public ListChange set(int index, ListChange element)
+ {
+ return null;
+ }
+
+ public void add(int index, ListChange element)
+ {
+ }
+
+ public ListChange remove(int index)
+ {
+ return null;
+ }
+
+ public int indexOf(Object o)
+ {
+ return LIST.indexOf(o);
+ }
+
+ public int lastIndexOf(Object o)
+ {
+ return LIST.lastIndexOf(o);
+ }
+
+ public ListIterator<ListChange> listIterator()
+ {
+ return LIST.listIterator();
+ }
+
+ public ListIterator<ListChange> listIterator(int index)
+ {
+ return LIST.listIterator(index);
+ }
+
+ public List<ListChange> subList(int fromIndex, int toIndex)
+ {
+ return LIST.subList(fromIndex, toIndex);
+ }
+
+ public void move(int newPosition, ListChange object)
+ {
+ }
+
+ public ListChange move(int newPosition, int oldPosition)
+ {
+ return null;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOSetFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOSetFeatureDeltaImpl.java
index 6887f655f3..859e7c72b7 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOSetFeatureDeltaImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOSetFeatureDeltaImpl.java
@@ -1,97 +1,97 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.revision.delta;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
-import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.ListTargetAdding;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.io.IOException;
-import java.text.MessageFormat;
-
-/**
- * @author Simon McDuff
- */
-public class CDOSetFeatureDeltaImpl extends CDOSingleValueFeatureDeltaImpl implements CDOSetFeatureDelta,
- ListTargetAdding
-{
- private Object oldValue = CDOSetFeatureDelta.UNSPECIFIED;
-
- public CDOSetFeatureDeltaImpl(EStructuralFeature feature, int index, Object value)
- {
- super(feature, index, value);
- }
-
- public CDOSetFeatureDeltaImpl(EStructuralFeature feature, int index, Object value, Object oldValue)
- {
- super(feature, index, value);
- this.oldValue = oldValue;
- }
-
- public CDOSetFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
- {
- super(in, eClass);
- }
-
- public Type getType()
- {
- return Type.SET;
- }
-
- public CDOFeatureDelta copy()
- {
- return new CDOSetFeatureDeltaImpl(getFeature(), getIndex(), getValue(), getOldValue());
- }
-
- public void apply(CDORevision revision)
- {
- ((InternalCDORevision)revision).set(getFeature(), getIndex(), getValue());
- }
-
- public void accept(CDOFeatureDeltaVisitor visitor)
- {
- visitor.visit(this);
- }
-
- public Object getOldValue()
- {
- return oldValue;
- }
-
- public void setOldValue(Object oldValue)
- {
- this.oldValue = oldValue;
- }
-
- @Override
- protected String toStringAdditional()
- {
- String oldValueForMessage;
- if (oldValue != CDOSetFeatureDelta.UNSPECIFIED)
- {
- oldValueForMessage = oldValue == null ? "null" : oldValue.toString();
- }
- else
- {
- oldValueForMessage = "UNSPECIFIED"; //$NON-NLS-1$
- }
-
- return super.toStringAdditional() + MessageFormat.format(", oldValue={0}", oldValueForMessage); //$NON-NLS-1$
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.common.revision.delta;
+
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
+import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.ListTargetAdding;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import java.io.IOException;
+import java.text.MessageFormat;
+
+/**
+ * @author Simon McDuff
+ */
+public class CDOSetFeatureDeltaImpl extends CDOSingleValueFeatureDeltaImpl implements CDOSetFeatureDelta,
+ ListTargetAdding
+{
+ private Object oldValue = CDOSetFeatureDelta.UNSPECIFIED;
+
+ public CDOSetFeatureDeltaImpl(EStructuralFeature feature, int index, Object value)
+ {
+ super(feature, index, value);
+ }
+
+ public CDOSetFeatureDeltaImpl(EStructuralFeature feature, int index, Object value, Object oldValue)
+ {
+ super(feature, index, value);
+ this.oldValue = oldValue;
+ }
+
+ public CDOSetFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
+ {
+ super(in, eClass);
+ }
+
+ public Type getType()
+ {
+ return Type.SET;
+ }
+
+ public CDOFeatureDelta copy()
+ {
+ return new CDOSetFeatureDeltaImpl(getFeature(), getIndex(), getValue(), getOldValue());
+ }
+
+ public void apply(CDORevision revision)
+ {
+ ((InternalCDORevision)revision).set(getFeature(), getIndex(), getValue());
+ }
+
+ public void accept(CDOFeatureDeltaVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ public Object getOldValue()
+ {
+ return oldValue;
+ }
+
+ public void setOldValue(Object oldValue)
+ {
+ this.oldValue = oldValue;
+ }
+
+ @Override
+ protected String toStringAdditional()
+ {
+ String oldValueForMessage;
+ if (oldValue != CDOSetFeatureDelta.UNSPECIFIED)
+ {
+ oldValueForMessage = oldValue == null ? "null" : oldValue.toString();
+ }
+ else
+ {
+ oldValueForMessage = "UNSPECIFIED"; //$NON-NLS-1$
+ }
+
+ return super.toStringAdditional() + MessageFormat.format(", oldValue={0}", oldValueForMessage); //$NON-NLS-1$
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOSingleValueFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOSingleValueFeatureDeltaImpl.java
index 8ebbdda3a6..4977e1da15 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOSingleValueFeatureDeltaImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOSingleValueFeatureDeltaImpl.java
@@ -1,185 +1,185 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.revision.delta;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
-import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.WithIndex;
-
-import org.eclipse.net4j.util.ObjectUtil;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.util.FeatureMap;
-import org.eclipse.emf.ecore.util.FeatureMap.Entry;
-import org.eclipse.emf.ecore.util.FeatureMapUtil;
-
-import java.io.IOException;
-import java.text.MessageFormat;
-
-/**
- * @author Simon McDuff
- */
-public abstract class CDOSingleValueFeatureDeltaImpl extends CDOFeatureDeltaImpl implements WithIndex
-{
- private int index;
-
- private Object value;
-
- public CDOSingleValueFeatureDeltaImpl(EStructuralFeature feature, int index, Object value)
- {
- super(feature);
- this.index = index;
- this.value = value;
- }
-
- public CDOSingleValueFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
- {
- super(in, eClass);
- index = in.readInt();
- value = readValue(in, eClass);
- }
-
- @Override
- public void write(CDODataOutput out, EClass eClass) throws IOException
- {
- super.write(out, eClass);
- out.writeInt(index);
- writeValue(out, eClass);
- }
-
- protected void writeValue(CDODataOutput out, EClass eClass) throws IOException
- {
- Object valueToWrite = value;
- if (valueToWrite == UNKNOWN_VALUE)
- {
- throw new IOException("Value is unknown");
- }
-
- EStructuralFeature feature = getFeature();
- if (FeatureMapUtil.isFeatureMap(feature))
- {
- FeatureMap.Entry entry = (Entry)valueToWrite;
- feature = entry.getEStructuralFeature();
- valueToWrite = entry.getValue();
-
- int featureID = eClass.getFeatureID(feature);
- out.writeInt(featureID);
- }
-
- if (valueToWrite != null && feature instanceof EReference)
- {
- valueToWrite = out.getIDProvider().provideCDOID(value);
- }
-
- out.writeCDOFeatureValue(feature, valueToWrite);
- }
-
- protected Object readValue(CDODataInput in, EClass eClass) throws IOException
- {
- EStructuralFeature feature = getFeature();
- if (FeatureMapUtil.isFeatureMap(feature))
- {
- int featureID = in.readInt();
- feature = eClass.getEStructuralFeature(featureID);
- Object innerValue = in.readCDOFeatureValue(feature);
- return CDORevisionUtil.createFeatureMapEntry(feature, innerValue);
- }
-
- return in.readCDOFeatureValue(feature);
- }
-
- public int getIndex()
- {
- return index;
- }
-
- public void setIndex(int index)
- {
- this.index = index;
- }
-
- public Object getValue()
- {
- return value;
- }
-
- public void setValue(Object value)
- {
- this.value = value;
- }
-
- public void clear()
- {
- setValue(CDOID.NULL);
- }
-
- public void adjustAfterAddition(int index)
- {
- if (index <= this.index)
- {
- ++this.index;
- }
- }
-
- public void adjustAfterRemoval(int index)
- {
- if (index < this.index && this.index > 0)
- {
- --this.index;
- }
- }
-
- @Override
- public boolean adjustReferences(CDOReferenceAdjuster referenceAdjuster)
- {
- if (value != UNKNOWN_VALUE)
- {
- Object adjustedValue = referenceAdjuster.adjustReference(value, getFeature(), NO_INDEX);
- if (adjustedValue != value)
- {
- value = adjustedValue;
- return true;
- }
- }
-
- return false;
- }
-
- @Override
- public boolean isStructurallyEqual(Object obj)
- {
- if (!super.isStructurallyEqual(obj))
- {
- return false;
- }
-
- CDOSingleValueFeatureDeltaImpl that = (CDOSingleValueFeatureDeltaImpl)obj;
- return index == that.getIndex() && ObjectUtil.equals(value, that.getValue());
- }
-
- @Override
- protected String toStringAdditional()
- {
- if (index == Notification.NO_INDEX)
- {
- return MessageFormat.format("value={0}", value); //$NON-NLS-1$
- }
-
- return MessageFormat.format("value={0}, index={1}", value, index); //$NON-NLS-1$
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.common.revision.delta;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
+import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.WithIndex;
+
+import org.eclipse.net4j.util.ObjectUtil;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.FeatureMap;
+import org.eclipse.emf.ecore.util.FeatureMap.Entry;
+import org.eclipse.emf.ecore.util.FeatureMapUtil;
+
+import java.io.IOException;
+import java.text.MessageFormat;
+
+/**
+ * @author Simon McDuff
+ */
+public abstract class CDOSingleValueFeatureDeltaImpl extends CDOFeatureDeltaImpl implements WithIndex
+{
+ private int index;
+
+ private Object value;
+
+ public CDOSingleValueFeatureDeltaImpl(EStructuralFeature feature, int index, Object value)
+ {
+ super(feature);
+ this.index = index;
+ this.value = value;
+ }
+
+ public CDOSingleValueFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
+ {
+ super(in, eClass);
+ index = in.readInt();
+ value = readValue(in, eClass);
+ }
+
+ @Override
+ public void write(CDODataOutput out, EClass eClass) throws IOException
+ {
+ super.write(out, eClass);
+ out.writeInt(index);
+ writeValue(out, eClass);
+ }
+
+ protected void writeValue(CDODataOutput out, EClass eClass) throws IOException
+ {
+ Object valueToWrite = value;
+ if (valueToWrite == UNKNOWN_VALUE)
+ {
+ throw new IOException("Value is unknown");
+ }
+
+ EStructuralFeature feature = getFeature();
+ if (FeatureMapUtil.isFeatureMap(feature))
+ {
+ FeatureMap.Entry entry = (Entry)valueToWrite;
+ feature = entry.getEStructuralFeature();
+ valueToWrite = entry.getValue();
+
+ int featureID = eClass.getFeatureID(feature);
+ out.writeInt(featureID);
+ }
+
+ if (valueToWrite != null && feature instanceof EReference)
+ {
+ valueToWrite = out.getIDProvider().provideCDOID(value);
+ }
+
+ out.writeCDOFeatureValue(feature, valueToWrite);
+ }
+
+ protected Object readValue(CDODataInput in, EClass eClass) throws IOException
+ {
+ EStructuralFeature feature = getFeature();
+ if (FeatureMapUtil.isFeatureMap(feature))
+ {
+ int featureID = in.readInt();
+ feature = eClass.getEStructuralFeature(featureID);
+ Object innerValue = in.readCDOFeatureValue(feature);
+ return CDORevisionUtil.createFeatureMapEntry(feature, innerValue);
+ }
+
+ return in.readCDOFeatureValue(feature);
+ }
+
+ public int getIndex()
+ {
+ return index;
+ }
+
+ public void setIndex(int index)
+ {
+ this.index = index;
+ }
+
+ public Object getValue()
+ {
+ return value;
+ }
+
+ public void setValue(Object value)
+ {
+ this.value = value;
+ }
+
+ public void clear()
+ {
+ setValue(CDOID.NULL);
+ }
+
+ public void adjustAfterAddition(int index)
+ {
+ if (index <= this.index)
+ {
+ ++this.index;
+ }
+ }
+
+ public void adjustAfterRemoval(int index)
+ {
+ if (index < this.index && this.index > 0)
+ {
+ --this.index;
+ }
+ }
+
+ @Override
+ public boolean adjustReferences(CDOReferenceAdjuster referenceAdjuster)
+ {
+ if (value != UNKNOWN_VALUE)
+ {
+ Object adjustedValue = referenceAdjuster.adjustReference(value, getFeature(), NO_INDEX);
+ if (adjustedValue != value)
+ {
+ value = adjustedValue;
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean isStructurallyEqual(Object obj)
+ {
+ if (!super.isStructurallyEqual(obj))
+ {
+ return false;
+ }
+
+ CDOSingleValueFeatureDeltaImpl that = (CDOSingleValueFeatureDeltaImpl)obj;
+ return index == that.getIndex() && ObjectUtil.equals(value, that.getValue());
+ }
+
+ @Override
+ protected String toStringAdditional()
+ {
+ if (index == Notification.NO_INDEX)
+ {
+ return MessageFormat.format("value={0}", value); //$NON-NLS-1$
+ }
+
+ return MessageFormat.format("value={0}, index={1}", value, index); //$NON-NLS-1$
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOUnsetFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOUnsetFeatureDeltaImpl.java
index 2d917a2e63..5c52f2a197 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOUnsetFeatureDeltaImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOUnsetFeatureDeltaImpl.java
@@ -1,73 +1,73 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.revision.delta;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
-import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta;
-import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.io.IOException;
-
-/**
- * @author Simon McDuff
- */
-public class CDOUnsetFeatureDeltaImpl extends CDOFeatureDeltaImpl implements CDOUnsetFeatureDelta
-{
- public CDOUnsetFeatureDeltaImpl(EStructuralFeature feature)
- {
- super(feature);
- }
-
- public CDOUnsetFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
- {
- super(in, eClass);
- }
-
- public Type getType()
- {
- return Type.UNSET;
- }
-
- public CDOFeatureDelta copy()
- {
- return new CDOUnsetFeatureDeltaImpl(getFeature());
- }
-
- public void apply(CDORevision revision)
- {
- ((InternalCDORevision)revision).unset(getFeature());
- }
-
- public void accept(CDOFeatureDeltaVisitor visitor)
- {
- visitor.visit(this);
- }
-
- @Override
- public boolean adjustReferences(CDOReferenceAdjuster adjuster)
- {
- return false;
- }
-
- @Override
- protected String toStringAdditional()
- {
- return null;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.internal.common.revision.delta;
+
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
+import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta;
+import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import java.io.IOException;
+
+/**
+ * @author Simon McDuff
+ */
+public class CDOUnsetFeatureDeltaImpl extends CDOFeatureDeltaImpl implements CDOUnsetFeatureDelta
+{
+ public CDOUnsetFeatureDeltaImpl(EStructuralFeature feature)
+ {
+ super(feature);
+ }
+
+ public CDOUnsetFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
+ {
+ super(in, eClass);
+ }
+
+ public Type getType()
+ {
+ return Type.UNSET;
+ }
+
+ public CDOFeatureDelta copy()
+ {
+ return new CDOUnsetFeatureDeltaImpl(getFeature());
+ }
+
+ public void apply(CDORevision revision)
+ {
+ ((InternalCDORevision)revision).unset(getFeature());
+ }
+
+ public void accept(CDOFeatureDeltaVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ @Override
+ public boolean adjustReferences(CDOReferenceAdjuster adjuster)
+ {
+ return false;
+ }
+
+ @Override
+ protected String toStringAdditional()
+ {
+ return null;
+ }
+}

Back to the top