Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-02-15 11:57:10 +0000
committerEike Stepper2013-02-15 12:54:48 +0000
commitacf908811a54aa2f41a1d1845dcf52752a07f198 (patch)
treeed466ac9d454b48d235f1ee3d9ac8cd2d2c908dc
parent8e489ae9615196803eced5c13a9bb001e3747988 (diff)
downloadcdo-acf908811a54aa2f41a1d1845dcf52752a07f198.tar.gz
cdo-acf908811a54aa2f41a1d1845dcf52752a07f198.tar.xz
cdo-acf908811a54aa2f41a1d1845dcf52752a07f198.zip
[400892] Intern all CDOIDs
https://bugs.eclipse.org/bugs/show_bug.cgi?id=400892
-rw-r--r--plugins/org.eclipse.emf.cdo.admin/src/org/eclipse/emf/cdo/internal/admin/CDOAdminClientRepositoryImpl.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.common.db/.settings/.api_filters32
-rw-r--r--plugins/org.eclipse.emf.cdo.common/.settings/.api_filters74
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOID.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDString.java25
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java348
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClassifierRef.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDExternalImpl.java125
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDNullImpl.java73
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectLongImpl.java106
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectLongWithClassifierImpl.java165
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectStringImpl.java111
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectStringWithClassifierImpl.java164
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectUUIDImpl.java118
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectExternalImpl.java134
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectImpl.java114
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOID.java74
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDByteArray.java97
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDInteger.java111
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDLong.java105
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDString.java103
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataInputImpl.java47
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataOutputImpl.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.examples.hibernate.client/src/org/eclipse/emf/cdo/examples/hibernate/client/HibernateQueryTest.java30
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionPhase2Request.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.server.admin/src/org/eclipse/emf/cdo/server/internal/admin/CDOAdminServerRepository.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateAuditHandler.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java60
-rw-r--r--plugins/org.eclipse.emf.cdo.server.lissome/src/org/eclipse/emf/cdo/server/internal/lissome/db/Index.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerLocal.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java48
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CDOIDTest.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DetachTest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java16
-rw-r--r--plugins/org.eclipse.emf.cdo/.settings/.api_filters32
36 files changed, 1343 insertions, 1059 deletions
diff --git a/plugins/org.eclipse.emf.cdo.admin/src/org/eclipse/emf/cdo/internal/admin/CDOAdminClientRepositoryImpl.java b/plugins/org.eclipse.emf.cdo.admin/src/org/eclipse/emf/cdo/internal/admin/CDOAdminClientRepositoryImpl.java
index 98e3196e2c..25d0265b6e 100644
--- a/plugins/org.eclipse.emf.cdo.admin/src/org/eclipse/emf/cdo/internal/admin/CDOAdminClientRepositoryImpl.java
+++ b/plugins/org.eclipse.emf.cdo.admin/src/org/eclipse/emf/cdo/internal/admin/CDOAdminClientRepositoryImpl.java
@@ -14,13 +14,13 @@ import org.eclipse.emf.cdo.admin.CDOAdminClient;
import org.eclipse.emf.cdo.admin.CDOAdminClientRepository;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOID.ObjectType;
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
import org.eclipse.emf.cdo.common.util.RepositoryStateChangedEvent;
import org.eclipse.emf.cdo.common.util.RepositoryTypeChangedEvent;
import org.eclipse.emf.cdo.net4j.CDONet4jSession;
import org.eclipse.emf.cdo.net4j.CDONet4jSessionConfiguration;
import org.eclipse.emf.cdo.net4j.CDONet4jUtil;
+import org.eclipse.emf.cdo.spi.common.protocol.CDODataInputImpl;
import org.eclipse.net4j.connector.IConnector;
import org.eclipse.net4j.util.event.Notifier;
@@ -87,7 +87,7 @@ public class CDOAdminClientRepositoryImpl extends Notifier implements CDOAdminCl
}
creationTime = in.readLong();
- rootResourceID = CDOIDUtil.read(in);
+ rootResourceID = new CDODataInputImpl.Default(in).readCDOID();
supportingAudits = in.readBoolean();
supportingBranches = in.readBoolean();
supportingEcore = in.readBoolean();
diff --git a/plugins/org.eclipse.emf.cdo.common.db/.settings/.api_filters b/plugins/org.eclipse.emf.cdo.common.db/.settings/.api_filters
index a6b4a15549..751c8a17f5 100644
--- a/plugins/org.eclipse.emf.cdo.common.db/.settings/.api_filters
+++ b/plugins/org.eclipse.emf.cdo.common.db/.settings/.api_filters
@@ -1,5 +1,37 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.emf.cdo.common.db" version="2">
+ <resource path="META-INF/MANIFEST.MF" type="org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDByteArray">
+ <filter id="305422471">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDByteArray"/>
+ <message_argument value="org.eclipse.emf.cdo.common.db_3.0.200"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="META-INF/MANIFEST.MF" type="org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDInteger">
+ <filter id="305422471">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDInteger"/>
+ <message_argument value="org.eclipse.emf.cdo.common.db_3.0.200"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="META-INF/MANIFEST.MF" type="org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong">
+ <filter id="305422471">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong"/>
+ <message_argument value="org.eclipse.emf.cdo.common.db_3.0.200"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="META-INF/MANIFEST.MF" type="org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDString">
+ <filter id="305422471">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDString"/>
+ <message_argument value="org.eclipse.emf.cdo.common.db_3.0.200"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="src/org/eclipse/emf/cdo/common/internal/db/cache/DBRevisionCache.java" type="org.eclipse.emf.cdo.common.internal.db.cache.DBRevisionCache">
<filter id="574660632">
<message_arguments>
diff --git a/plugins/org.eclipse.emf.cdo.common/.settings/.api_filters b/plugins/org.eclipse.emf.cdo.common/.settings/.api_filters
index 365504f10a..a83b062f11 100644
--- a/plugins/org.eclipse.emf.cdo.common/.settings/.api_filters
+++ b/plugins/org.eclipse.emf.cdo.common/.settings/.api_filters
@@ -8,6 +8,66 @@
</message_arguments>
</filter>
</resource>
+ <resource path="META-INF/MANIFEST.MF" type="org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDByteArray">
+ <filter id="305324134">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDByteArray"/>
+ <message_argument value="org.eclipse.emf.cdo.common_4.2.0"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="META-INF/MANIFEST.MF" type="org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDInteger">
+ <filter id="305324134">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDInteger"/>
+ <message_argument value="org.eclipse.emf.cdo.common_4.2.0"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="META-INF/MANIFEST.MF" type="org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong">
+ <filter id="305324134">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong"/>
+ <message_argument value="org.eclipse.emf.cdo.common_4.2.0"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="META-INF/MANIFEST.MF" type="org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDString">
+ <filter id="305324134">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDString"/>
+ <message_argument value="org.eclipse.emf.cdo.common_4.2.0"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/org/eclipse/emf/cdo/common/id/CDOID.java" type="org.eclipse.emf.cdo.common.id.CDOID">
+ <filter id="404791350">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.cdo.common.id.CDOID"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/org/eclipse/emf/cdo/common/id/CDOIDExternal.java" type="org.eclipse.emf.cdo.common.id.CDOIDExternal">
+ <filter id="404791350">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.cdo.common.id.CDOIDExternal"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/org/eclipse/emf/cdo/common/id/CDOIDObject.java" type="org.eclipse.emf.cdo.common.id.CDOIDObject">
+ <filter id="404791350">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.cdo.common.id.CDOIDObject"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/org/eclipse/emf/cdo/common/id/CDOIDTemp.java" type="org.eclipse.emf.cdo.common.id.CDOIDTemp">
+ <filter id="404791350">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.cdo.common.id.CDOIDTemp"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="src/org/eclipse/emf/cdo/common/model/CDOModelConstants.java" type="org.eclipse.emf.cdo.common.model.CDOModelConstants">
<filter id="389242988">
<message_arguments>
@@ -80,6 +140,20 @@
</message_arguments>
</filter>
</resource>
+ <resource path="src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOID.java" type="org.eclipse.emf.cdo.spi.common.id.AbstractCDOID">
+ <filter id="337682486">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.cdo.spi.common.id.AbstractCDOID"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/org/eclipse/emf/cdo/spi/common/id/InternalCDOIDObject.java" type="org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject">
+ <filter id="404791350">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="src/org/eclipse/emf/cdo/spi/common/revision/AbstractCDORevision.java" type="org.eclipse.emf.cdo.spi.common.revision.AbstractCDORevision">
<filter id="338792546">
<message_arguments>
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOID.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOID.java
index be107471c3..81c774b0b2 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOID.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOID.java
@@ -21,14 +21,14 @@ import java.lang.reflect.Array;
/**
* Identifies CDO objects uniquely in a CDO {@link CDOCommonRepository repository}.
- *
+ *
* @author Eike Stepper
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
* @apiviz.landmark
* @apiviz.has {@link CDOID.Type}
*/
-public interface CDOID extends Serializable, Comparable<CDOID>
+public interface CDOID extends Comparable<CDOID>, Serializable
{
public static final CDOID NULL = org.eclipse.emf.cdo.internal.common.id.CDOIDNullImpl.INSTANCE;
@@ -42,7 +42,9 @@ public interface CDOID extends Serializable, Comparable<CDOID>
/**
* @since 3.0
+ * @deprecated
*/
+ @Deprecated
public boolean isDangling();
/**
@@ -57,7 +59,7 @@ public interface CDOID extends Serializable, Comparable<CDOID>
/**
* Enumerates the possible types of CDO {@link CDOID IDs}.
- *
+ *
* @author Eike Stepper
*/
public enum Type
@@ -131,7 +133,7 @@ public interface CDOID extends Serializable, Comparable<CDOID>
/**
* Enumerates the possible <b>sub</b> types of CDO {@link CDOID IDs} with the main type {@link Type#OBJECT OBJECT}.
- *
+ *
* @author Eike Stepper
* @since 3.0
*/
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDString.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDString.java
new file mode 100644
index 0000000000..070f326d0e
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDString.java
@@ -0,0 +1,25 @@
+/*
+ * 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.common.id;
+
+/**
+ * A {@link CDOID} with a {@link String} value.
+ *
+ * @author Eike Stepper
+ * @since 4.2
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDOIDString extends CDOID
+{
+ public String getStringValue();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java
index 094cfd9a0e..8e1c6b7398 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java
@@ -17,6 +17,8 @@ import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.id.CDOID.ObjectType;
import org.eclipse.emf.cdo.common.id.CDOID.Type;
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.emf.cdo.common.revision.CDOIDAndBranch;
import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
import org.eclipse.emf.cdo.internal.common.bundle.OM;
@@ -32,9 +34,6 @@ 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.spi.common.id.AbstractCDOID;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDByteArray;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDString;
import org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject;
import org.eclipse.net4j.util.ObjectUtil;
@@ -61,6 +60,30 @@ public final class CDOIDUtil
}
/**
+ * @since 4.0
+ */
+ public static CDOIDAndVersion createIDAndVersion(CDOID id, int version)
+ {
+ return new CDOIDAndVersionImpl(id, version);
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static CDOIDAndVersion createIDAndVersion(CDOIDAndVersion source)
+ {
+ return createIDAndVersion(source.getID(), source.getVersion());
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static CDOIDAndBranch createIDAndBranch(CDOID id, CDOBranch branch)
+ {
+ return new CDOIDAndBranchImpl(id, branch);
+ }
+
+ /**
* @since 4.2
*/
public static CDOID getCDOID(Object object)
@@ -96,18 +119,23 @@ public final class CDOIDUtil
{
if (id == null)
{
- return AbstractCDOIDLong.NULL_VALUE;
+ return 0L;
}
switch (id.getType())
{
case NULL:
- return AbstractCDOIDLong.NULL_VALUE;
+ return 0L;
case OBJECT:
- if (id instanceof AbstractCDOIDLong)
+ if (id instanceof CDOIDObjectLongImpl)
{
- return ((AbstractCDOIDLong)id).getLongValue();
+ return ((CDOIDObjectLongImpl)id).getLongValue();
+ }
+
+ if (id instanceof CDOIDObjectLongWithClassifierImpl)
+ {
+ return ((CDOIDObjectLongWithClassifierImpl)id).getLongValue();
}
throw new IllegalArgumentException(MessageFormat.format(
@@ -131,42 +159,12 @@ public final class CDOIDUtil
*/
public static String getString(CDOID id)
{
- if (id == null)
+ if (id instanceof CDOIDString)
{
- return AbstractCDOIDString.NULL_VALUE;
+ return ((CDOIDString)id).getStringValue();
}
- switch (id.getType())
- {
- case NULL:
- return AbstractCDOIDString.NULL_VALUE;
-
- case OBJECT:
- if (id instanceof AbstractCDOIDString)
- {
- return ((AbstractCDOIDString)id).getStringValue();
- }
-
- throw new IllegalArgumentException(MessageFormat.format(
- Messages.getString("CDOIDUtil.0"), id.getClass().getName())); //$NON-NLS-1$
-
- case TEMP_OBJECT:
- throw new IllegalArgumentException(Messages.getString("CDOIDUtil.1")); //$NON-NLS-1$
-
- case EXTERNAL_OBJECT:
- case EXTERNAL_TEMP_OBJECT:
- if (id instanceof CDOIDExternalImpl)
- {
- return ((CDOIDExternalImpl)id).getURI();
- }
-
- throw new IllegalArgumentException(MessageFormat.format(
- Messages.getString("CDOIDUtil.0"), id.getClass().getName())); //$NON-NLS-1$
-
- default:
- throw new IllegalArgumentException(MessageFormat.format(
- Messages.getString("CDOIDUtil.3"), id.getClass().getName())); //$NON-NLS-1$
- }
+ return null;
}
/**
@@ -174,29 +172,12 @@ public final class CDOIDUtil
*/
public static byte[] getByteArray(CDOID id)
{
- if (id == null)
+ if (id instanceof CDOIDObjectUUIDImpl)
{
- return null;
+ return ((CDOIDObjectUUIDImpl)id).getByteArrayValue();
}
- switch (id.getType())
- {
- case NULL:
- return null;
-
- case OBJECT:
- if (id instanceof AbstractCDOIDByteArray)
- {
- return ((AbstractCDOIDByteArray)id).getByteArrayValue();
- }
-
- throw new IllegalArgumentException(MessageFormat.format(
- Messages.getString("CDOIDUtil.0"), id.getClass().getName())); //$NON-NLS-1$
-
- default:
- throw new IllegalArgumentException(MessageFormat.format(
- Messages.getString("CDOIDUtil.3"), id.getClass().getName())); //$NON-NLS-1$
- }
+ return null;
}
/**
@@ -214,7 +195,7 @@ public final class CDOIDUtil
public static CDOIDTemp createTempObject(int value)
{
- return new CDOIDTempObjectImpl(value);
+ return CDOIDTempObjectImpl.create(value);
}
/**
@@ -222,25 +203,25 @@ public final class CDOIDUtil
*/
public static CDOIDExternal createTempObjectExternal(String uri)
{
- return new CDOIDTempObjectExternalImpl(uri);
+ return CDOIDTempObjectExternalImpl.create(uri);
}
public static CDOID createLong(long value)
{
- if (value == AbstractCDOIDLong.NULL_VALUE)
+ if (value == 0L)
{
return CDOID.NULL;
}
- return new CDOIDObjectLongImpl(value);
+ return CDOIDObjectLongImpl.create(value);
}
/**
- * @since 3.0
+ * @since 4.2
*/
- public static CDOID createLongWithClassifier(CDOClassifierRef classifierRef, long value)
+ public static CDOID createLongWithClassifier(long value, CDOClassifierRef classifierRef)
{
- return new CDOIDObjectLongWithClassifierImpl(classifierRef, value);
+ return CDOIDObjectLongWithClassifierImpl.create(value, classifierRef);
}
/**
@@ -248,15 +229,15 @@ public final class CDOIDUtil
*/
public static CDOID createString(String value)
{
- return new CDOIDObjectStringImpl(value);
+ return CDOIDObjectStringImpl.create(value);
}
/**
- * @since 3.0
+ * @since 4.2
*/
- public static CDOID createStringWithClassifier(CDOClassifierRef classifierRef, String value)
+ public static CDOID createStringWithClassifier(String value, CDOClassifierRef classifierRef)
{
- return new CDOIDObjectStringWithClassifierImpl(classifierRef, value);
+ return CDOIDObjectStringWithClassifierImpl.create(value, classifierRef);
}
/**
@@ -264,7 +245,7 @@ public final class CDOIDUtil
*/
public static CDOID createUUID(byte[] value)
{
- return new CDOIDObjectUUIDImpl(value);
+ return CDOIDObjectUUIDImpl.create(value);
}
/**
@@ -298,82 +279,7 @@ public final class CDOIDUtil
*/
public static CDOIDExternal createExternal(String uri)
{
- return new CDOIDExternalImpl(uri);
- }
-
- /**
- * @since 4.0
- */
- public static CDOIDAndVersion createIDAndVersion(CDOID id, int version)
- {
- return new CDOIDAndVersionImpl(id, version);
- }
-
- /**
- * @since 4.0
- */
- public static CDOIDAndVersion createIDAndVersion(CDOIDAndVersion source)
- {
- return createIDAndVersion(source.getID(), source.getVersion());
- }
-
- /**
- * @since 4.0
- */
- public static CDOIDAndBranch createIDAndBranch(CDOID id, CDOBranch branch)
- {
- return new CDOIDAndBranchImpl(id, branch);
- }
-
- /**
- * Creates the correct implementation class for the passed {@link CDOID.ObjectType}.
- *
- * @param subType
- * the subType for which to create an empty CDOID instance
- * @return the instance of CDOIDObject which represents the subtype.
- * @since 3.0
- */
- public static AbstractCDOID createCDOIDObject(CDOID.ObjectType subType)
- {
- if (subType == null)
- {
- throw new IllegalArgumentException("SubType may not be null");
- }
-
- InternalCDOIDObject id;
- switch (subType)
- {
- case LONG:
- id = new CDOIDObjectLongImpl();
- break;
-
- case STRING:
- id = new CDOIDObjectStringImpl();
- break;
-
- case LONG_WITH_CLASSIFIER:
- id = new CDOIDObjectLongWithClassifierImpl();
- break;
-
- case STRING_WITH_CLASSIFIER:
- id = new CDOIDObjectStringWithClassifierImpl();
- break;
-
- case UUID:
- id = new CDOIDObjectUUIDImpl();
- break;
-
- default:
- throw new IllegalArgumentException("Subtype " + subType.name() + " not supported");
- }
-
- if (id.getSubType() != subType)
- {
- throw new IllegalStateException("Subtype of created id " + id + " is unequal (" + id.getSubType().name()
- + ") to requested subtype " + subType.name());
- }
-
- return (AbstractCDOID)id;
+ return CDOIDExternalImpl.create(uri);
}
/**
@@ -437,19 +343,13 @@ public final class CDOIDUtil
return CDOID.NULL;
case TEMP_OBJECT:
- return new CDOIDTempObjectImpl(Integer.valueOf(fragment));
+ return CDOIDTempObjectImpl.create(Integer.valueOf(fragment));
case EXTERNAL_OBJECT:
- return new CDOIDExternalImpl(fragment);
+ return CDOIDExternalImpl.create(fragment);
case EXTERNAL_TEMP_OBJECT:
- return new CDOIDTempObjectExternalImpl(fragment);
-
- case OBJECT:
- {
- // Normally this case should not occur (is an OBJECT subtype).
- throw new IllegalArgumentException();
- }
+ return CDOIDTempObjectExternalImpl.create(fragment);
default:
throw new IllegalArgumentException(MessageFormat.format(Messages.getString("CDOIDUtil.5"), uriFragment)); //$NON-NLS-1$
@@ -458,15 +358,32 @@ public final class CDOIDUtil
private static CDOID readCDOIDObject(String fragment, CDOID.ObjectType subType)
{
- AbstractCDOID id = createCDOIDObject(subType);
- id.read(fragment);
- return id;
+ switch (subType)
+ {
+ case LONG:
+ return CDOIDObjectLongImpl.create(fragment);
+
+ case STRING:
+ return CDOIDObjectStringImpl.create(fragment);
+
+ case LONG_WITH_CLASSIFIER:
+ return CDOIDObjectLongWithClassifierImpl.create(fragment);
+
+ case STRING_WITH_CLASSIFIER:
+ return CDOIDObjectStringWithClassifierImpl.create(fragment);
+
+ case UUID:
+ return CDOIDObjectUUIDImpl.create(fragment);
+
+ default:
+ throw new IllegalArgumentException("Subtype " + subType.name() + " not supported");
+ }
}
/**
- * @since 4.1
+ * @since 4.2
*/
- public static void write(ExtendedDataOutput out, CDOID id) throws IOException
+ public static void write(CDODataOutput out, CDOID id) throws IOException
{
if (id == null)
{
@@ -502,9 +419,9 @@ public final class CDOIDUtil
}
/**
- * @since 4.1
+ * @since 4.2
*/
- public static CDOID read(ExtendedDataInput in) throws IOException
+ public static CDOID read(CDODataInput in) throws IOException
{
byte ordinal = in.readByte();
@@ -538,30 +455,20 @@ public final class CDOIDUtil
return CDOID.NULL;
case TEMP_OBJECT:
- return new CDOIDTempObjectImpl(in.readInt());
+ return CDOIDTempObjectImpl.create(in.readInt());
case EXTERNAL_OBJECT:
- return new CDOIDExternalImpl(in.readString());
+ return CDOIDExternalImpl.create(in.readString());
case EXTERNAL_TEMP_OBJECT:
- return new CDOIDTempObjectExternalImpl(in.readString());
-
- case OBJECT:
- {
- // should normally not occur is handled by
- // readCDOIDObject, code remains here
- // for backward compatibility
- AbstractCDOID id = new CDOIDObjectLongImpl();
- id.read(in);
- return id;
- }
+ return CDOIDTempObjectExternalImpl.create(in.readString());
default:
throw new IOException("Illegal type: " + type);
}
}
- private static CDOID readCDOIDObject(ExtendedDataInput in, int subTypeOrdinal) throws IOException
+ private static CDOID readCDOIDObject(CDODataInput in, int subTypeOrdinal) throws IOException
{
if (TRACER.isEnabled())
{
@@ -576,13 +483,35 @@ public final class CDOIDUtil
subType = ex.getMessage();
}
- TRACER.format("Reading CDOIDObject of sub type {0} ({1})", subTypeOrdinal, subType); //$NON-NLS-1$
+ TRACER.format("Reading CDOIDObject of subtype {0} ({1})", subTypeOrdinal, subType); //$NON-NLS-1$
}
CDOID.ObjectType subType = CDOID.ObjectType.values()[subTypeOrdinal];
- AbstractCDOID id = CDOIDUtil.createCDOIDObject(subType);
- id.read(in);
- return id;
+ if (subType == null)
+ {
+ throw new IllegalArgumentException("Subtype may not be null");
+ }
+
+ switch (subType)
+ {
+ case LONG:
+ return CDOIDObjectLongImpl.create(in);
+
+ case STRING:
+ return CDOIDObjectStringImpl.create(in);
+
+ case LONG_WITH_CLASSIFIER:
+ return CDOIDObjectLongWithClassifierImpl.create(in);
+
+ case STRING_WITH_CLASSIFIER:
+ return CDOIDObjectStringWithClassifierImpl.create(in);
+
+ case UUID:
+ return CDOIDObjectUUIDImpl.create(in);
+
+ default:
+ throw new IllegalArgumentException("Subtype " + subType.name() + " not supported");
+ }
}
/**
@@ -602,4 +531,59 @@ public final class CDOIDUtil
return ObjectUtil.equals(id1, id2);
}
+
+ /**
+ * @since 3.0
+ * @deprecated As of 4.2 use {@link #createLongWithClassifier(long, CDOClassifierRef)}.
+ */
+ @Deprecated
+ public static CDOID createLongWithClassifier(CDOClassifierRef classifierRef, long value)
+ {
+ return createLongWithClassifier(value, classifierRef);
+ }
+
+ /**
+ * @since 3.0
+ * @deprecated As of 4.2 use {@link #createStringWithClassifier(String, CDOClassifierRef)}.
+ */
+ @Deprecated
+ public static CDOID createStringWithClassifier(CDOClassifierRef classifierRef, String value)
+ {
+ return createStringWithClassifier(value, classifierRef);
+ }
+
+ /**
+ * Creates the correct implementation class for the passed {@link CDOID.ObjectType}.
+ *
+ * @param subType
+ * the subType for which to create an empty CDOID instance
+ * @return the instance of CDOIDObject which represents the subtype.
+ * @since 3.0
+ * @deprecated As of 4.2 no longer supported. IDs can't be created without a value anymore.
+ */
+ @Deprecated
+ public static AbstractCDOID createCDOIDObject(CDOID.ObjectType subType)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @since 4.1
+ * @deprecated As of 4.2 use {@link #write(CDODataOutput, CDOID)}.
+ */
+ @Deprecated
+ public static void write(ExtendedDataOutput out, CDOID id) throws IOException
+ {
+ write((CDODataOutput)out, id);
+ }
+
+ /**
+ * @since 4.1
+ * @deprecated As of 4.2 use {@link #read(CDODataInput)}.
+ */
+ @Deprecated
+ public static CDOID read(ExtendedDataInput in) throws IOException
+ {
+ return read((CDODataInput)in);
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClassifierRef.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClassifierRef.java
index 7d7f8cfa71..40149185d8 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClassifierRef.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClassifierRef.java
@@ -20,16 +20,19 @@ import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EPackage;
import java.io.IOException;
+import java.io.Serializable;
import java.text.MessageFormat;
/**
* References an {@link EClassifier}.
- *
+ *
* @author Eike Stepper
* @since 2.0
*/
-public final class CDOClassifierRef
+public final class CDOClassifierRef implements Serializable
{
+ private static final long serialVersionUID = 1L;
+
public static final String URI_SEPARATOR = "#"; //$NON-NLS-1$
private String packageURI;
@@ -147,7 +150,7 @@ public final class CDOClassifierRef
/**
* Provides {@link CDOClassifierRef classifier references}.
- *
+ *
* @author Eike Stepper
* @since 3.0
* @apiviz.uses {@link CDOClassifierRef} - - provides
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 f3491c1e5c..8717d8ed7e 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
@@ -6,53 +6,70 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
+ * 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.CDOIDExternal;
+import org.eclipse.emf.cdo.common.id.CDOIDString;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
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 org.eclipse.net4j.util.CheckUtil;
+import org.eclipse.net4j.util.ref.Interner;
import java.io.IOException;
+import java.io.ObjectStreamException;
/**
- * @author Simon McDuff
+ * @author Eike Stepper
+ * @since 2.0
*/
-public class CDOIDExternalImpl extends AbstractCDOID implements CDOIDExternal
+public final class CDOIDExternalImpl extends AbstractCDOID implements CDOIDExternal, CDOIDString
{
private static final long serialVersionUID = 1L;
- private String uri;
+ private static final StringInterner INTERNER = new StringInterner();
- public CDOIDExternalImpl(String uri)
+ private final String uri;
+
+ private CDOIDExternalImpl(String uri)
{
+ CheckUtil.checkArg(uri, "Null not allowed");
this.uri = uri;
}
- public Type getType()
+ @Override
+ public void write(CDODataOutput out) throws IOException
{
- return Type.EXTERNAL_OBJECT;
+ out.writeString(uri);
}
- public boolean isDangling()
+ public String toURIFragment()
{
- return false;
+ return uri;
}
- public boolean isExternal()
+ public String getURI()
{
- return true;
+ return uri;
}
- public boolean isNull()
+ public String getStringValue()
{
- return false;
+ return uri;
+ }
+
+ public Type getType()
+ {
+ return Type.EXTERNAL_OBJECT;
+ }
+
+ public boolean isExternal()
+ {
+ return true;
}
public boolean isObject()
@@ -65,67 +82,71 @@ public class CDOIDExternalImpl extends AbstractCDOID implements CDOIDExternal
return false;
}
- public String getURI()
+ @Override
+ public int hashCode()
{
- return uri;
+ return uri.hashCode();
}
@Override
public String toString()
{
- return "oid:" + toURIFragment(); //$NON-NLS-1$
+ return "oid:" + uri; //$NON-NLS-1$
}
@Override
- public void read(String fragmentPart)
+ protected int doCompareTo(CDOID o) throws ClassCastException
{
- uri = fragmentPart;
+ return uri.compareTo(((CDOIDExternalImpl)o).uri);
}
- @Override
- public void read(ExtendedDataInput in) throws IOException
+ private Object readResolve() throws ObjectStreamException
{
- uri = in.readString();
+ return create(uri);
}
- @Override
- public void write(ExtendedDataOutput out) throws IOException
+ private static int getHashCode(String uri)
{
- out.writeString(uri);
+ return uri.hashCode();
}
- public String toURIFragment()
+ public static CDOIDExternalImpl create(String uri)
{
- return uri;
+ return INTERNER.intern(uri);
}
- @Override
- public boolean equals(Object obj)
+ public static CDOIDExternalImpl create(CDODataInput in) throws IOException
+ {
+ String uri = in.readString();
+ return create(uri);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class StringInterner extends Interner<CDOIDExternalImpl>
{
- if (obj == this)
+ public synchronized CDOIDExternalImpl intern(String uri)
{
- return true;
+ int hashCode = getHashCode(uri);
+ for (Entry<CDOIDExternalImpl> entry = getEntry(hashCode); entry != null; entry = entry.getNextEntry())
+ {
+ CDOIDExternalImpl id = entry.get();
+ if (id != null && id.uri.equals(uri))
+ {
+ return id;
+ }
+ }
+
+ CDOIDExternalImpl id = new CDOIDExternalImpl(uri);
+ addEntry(createEntry(id, hashCode));
+ return id;
}
- // Could CDOIDTempObjectExternalImpl and CDOIDExternalImpl have the same uri. We don't want to mixed them.
- if (obj != null && obj.getClass() == getClass())
+ @Override
+ protected int hashCode(CDOIDExternalImpl id)
{
- CDOIDExternal that = (CDOIDExternal)obj;
- return ObjectUtil.equals(getURI(), that.getURI());
+ return getHashCode(id.uri);
}
-
- 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 836db08673..eeb2c3c89e 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
@@ -15,93 +15,70 @@ 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.common.protocol.CDODataOutput;
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;
+import java.io.ObjectStreamException;
/**
* @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;
+ public static final CDOIDNullImpl INSTANCE = new CDOIDNullImpl();
+
private CDOIDNullImpl()
{
}
- public Type getType()
+ public int getIntValue()
{
- return Type.NULL;
+ return 0;
}
- public boolean isDangling()
+ public long getLongValue()
{
- return false;
+ return 0L;
}
- public boolean isExternal()
+ @Override
+ public void write(CDODataOutput out) throws IOException
{
- return false;
+ // Do nothing
}
- public boolean isNull()
+ public String toURIFragment()
{
- return true;
+ return "NULL"; //$NON-NLS-1$
}
- public boolean isObject()
+ public Type getType()
{
- return false;
+ return Type.NULL;
}
- public boolean isTemporary()
+ public boolean isExternal()
{
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
+ public boolean isNull()
{
- // Do nothing
+ return true;
}
- @Override
- public void write(ExtendedDataOutput out) throws IOException
+ public boolean isObject()
{
- // Do nothing
+ return false;
}
- @Override
- public boolean equals(Object obj)
+ public boolean isTemporary()
{
- return obj == INSTANCE;
+ return false;
}
@Override
@@ -119,7 +96,11 @@ public final class CDOIDNullImpl extends AbstractCDOID implements CDOIDTemp, CDO
@Override
protected int doCompareTo(CDOID o) throws ClassCastException
{
- ((CDOIDNullImpl)o).getIntValue(); // Possibly throw ClassCastException
return 0; // NULL == NULL
}
+
+ private Object readResolve() throws ObjectStreamException
+ {
+ return INSTANCE;
+ }
}
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 a4d17b3855..48f267696c 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
@@ -11,42 +11,58 @@
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.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.spi.common.id.AbstractCDOID;
import org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject;
+import org.eclipse.net4j.util.CheckUtil;
+import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.ref.Interner;
+
+import java.io.IOException;
+import java.io.ObjectStreamException;
+
/**
* @author Eike Stepper
* @since 2.0
*/
-public class CDOIDObjectLongImpl extends AbstractCDOIDLong implements InternalCDOIDObject
+public final class CDOIDObjectLongImpl extends AbstractCDOID implements InternalCDOIDObject
{
private static final long serialVersionUID = 1L;
- public CDOIDObjectLongImpl()
+ private static final LongInterner INTERNER = new LongInterner();
+
+ private final long value;
+
+ private CDOIDObjectLongImpl(long value)
{
+ CheckUtil.checkArg(value != 0L, "Zero not allowed");
+ this.value = value;
}
- public CDOIDObjectLongImpl(long value)
+ public long getLongValue()
{
- super(value);
+ return value;
}
- public Type getType()
+ @Override
+ public void write(CDODataOutput out) throws IOException
{
- return Type.OBJECT;
+ out.writeLong(value);
}
- public boolean isDangling()
+ public String toURIFragment()
{
- return false;
+ return String.valueOf(value);
}
- public boolean isExternal()
+ public Type getType()
{
- return false;
+ return Type.OBJECT;
}
- public boolean isNull()
+ public boolean isExternal()
{
return false;
}
@@ -70,14 +86,76 @@ public class CDOIDObjectLongImpl extends AbstractCDOIDLong implements InternalCD
}
@Override
+ public int hashCode()
+ {
+ return ObjectUtil.hashCode(value);
+ }
+
+ @Override
public String toString()
{
- return "OID" + getLongValue(); //$NON-NLS-1$
+ return "OID" + value; //$NON-NLS-1$
}
@Override
protected int doCompareTo(CDOID o) throws ClassCastException
{
- return new Long(getLongValue()).compareTo(((CDOIDObjectLongImpl)o).getLongValue());
+ return new Long(value).compareTo(((CDOIDObjectLongImpl)o).value);
+ }
+
+ private Object readResolve() throws ObjectStreamException
+ {
+ return create(value);
+ }
+
+ private static int getHashCode(long value)
+ {
+ return ObjectUtil.hashCode(value);
+ }
+
+ public static CDOIDObjectLongImpl create(long value)
+ {
+ return INTERNER.intern(value);
+ }
+
+ public static CDOIDObjectLongImpl create(CDODataInput in) throws IOException
+ {
+ long value = in.readLong();
+ return create(value);
+ }
+
+ public static CDOIDObjectLongImpl create(String fragmentPart)
+ {
+ long value = Long.parseLong(fragmentPart);
+ return create(value);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class LongInterner extends Interner<CDOIDObjectLongImpl>
+ {
+ public synchronized CDOIDObjectLongImpl intern(long value)
+ {
+ int hashCode = getHashCode(value);
+ for (Entry<CDOIDObjectLongImpl> entry = getEntry(hashCode); entry != null; entry = entry.getNextEntry())
+ {
+ CDOIDObjectLongImpl id = entry.get();
+ if (id != null && id.value == value)
+ {
+ return id;
+ }
+ }
+
+ CDOIDObjectLongImpl id = new CDOIDObjectLongImpl(value);
+ addEntry(createEntry(id, hashCode));
+ return id;
+ }
+
+ @Override
+ protected int hashCode(CDOIDObjectLongImpl id)
+ {
+ return getHashCode(id.value);
+ }
}
}
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 eb781efea5..c8f9d9893f 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
@@ -15,31 +15,41 @@ 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.emf.cdo.spi.common.id.AbstractCDOID;
+import org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject;
+import org.eclipse.net4j.util.CheckUtil;
import org.eclipse.net4j.util.ObjectUtil;
-import org.eclipse.net4j.util.io.ExtendedDataInput;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
+import org.eclipse.net4j.util.ref.Interner;
import java.io.IOException;
+import java.io.ObjectStreamException;
/**
* @author Martin Taal
* @since 3.0
*/
-public class CDOIDObjectLongWithClassifierImpl extends CDOIDObjectLongImpl implements CDOClassifierRef.Provider
+public final class CDOIDObjectLongWithClassifierImpl extends AbstractCDOID implements InternalCDOIDObject,
+ CDOClassifierRef.Provider
{
private static final long serialVersionUID = 1L;
- private CDOClassifierRef classifierRef;
+ private static final LongWithClassifierInterner INTERNER = new LongWithClassifierInterner();
- public CDOIDObjectLongWithClassifierImpl()
+ private final long value;
+
+ private final CDOClassifierRef classifierRef;
+
+ private CDOIDObjectLongWithClassifierImpl(long value, CDOClassifierRef classifierRef)
{
+ CheckUtil.checkArg(value != 0L, "Zero not allowed");
+ this.value = value;
+ this.classifierRef = classifierRef;
}
- public CDOIDObjectLongWithClassifierImpl(CDOClassifierRef classifierRef, long value)
+ public long getLongValue()
{
- super(value);
- this.classifierRef = classifierRef;
+ return value;
}
public CDOClassifierRef getClassifierRef()
@@ -48,98 +58,127 @@ public class CDOIDObjectLongWithClassifierImpl extends CDOIDObjectLongImpl imple
}
@Override
+ public void write(CDODataOutput out) throws IOException
+ {
+ out.writeLong(value);
+ out.writeCDOClassifierRef(classifierRef);
+ }
+
+ public String toURIFragment()
+ {
+ return classifierRef.getPackageURI() + CDOClassifierRef.URI_SEPARATOR + classifierRef.getClassifierName()
+ + CDOClassifierRef.URI_SEPARATOR + value;
+ }
+
public Type getType()
{
return Type.OBJECT;
}
- @Override
public CDOID.ObjectType getSubType()
{
return CDOID.ObjectType.LONG_WITH_CLASSIFIER;
}
- @Override
- public String toURIFragment()
+ public boolean isExternal()
{
- return getClassifierRef().getPackageURI() + CDOClassifierRef.URI_SEPARATOR + getClassifierRef().getClassifierName()
- + CDOClassifierRef.URI_SEPARATOR + super.toURIFragment();
+ return false;
}
- @Override
- public void read(String fragmentPart)
+ public boolean isObject()
{
- // 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));
+ return true;
+ }
- // let the super take care of the rest
- super.read(fragmentPart.substring(index2 + 1));
+ public boolean isTemporary()
+ {
+ return false;
}
@Override
- public void read(ExtendedDataInput in) throws IOException
+ public int hashCode()
{
- // 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);
+ return getHashCode(value, classifierRef);
}
@Override
- public void write(ExtendedDataOutput out) throws IOException
+ public String toString()
{
- // 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);
+ return "OID:" + toURIFragment(); //$NON-NLS-1$
}
@Override
- public boolean equals(Object obj)
+ protected int doCompareTo(CDOID o) throws ClassCastException
{
- if (obj == this)
- {
- return true;
- }
+ return toURIFragment().compareTo(o.toURIFragment());
+ }
- if (obj != null && obj.getClass() == getClass())
- {
- CDOIDObjectLongWithClassifierImpl that = (CDOIDObjectLongWithClassifierImpl)obj;
- return ObjectUtil.equals(classifierRef, that.classifierRef) && getLongValue() == that.getLongValue();
- }
+ private Object readResolve() throws ObjectStreamException
+ {
+ return create(value, classifierRef);
+ }
- return false;
+ private static int getHashCode(long value, CDOClassifierRef classifierRef)
+ {
+ return ObjectUtil.hashCode(value) ^ classifierRef.hashCode();
}
- @Override
- public int hashCode()
+ public static CDOIDObjectLongWithClassifierImpl create(long value, CDOClassifierRef classifierRef)
{
- int hashCode = classifierRef.hashCode() ^ ObjectUtil.hashCode(getLongValue());
- return getClass().hashCode() ^ hashCode;
+ return INTERNER.intern(value, classifierRef);
}
- @Override
- public String toString()
+ public static CDOIDObjectLongWithClassifierImpl create(CDODataInput in) throws IOException
{
- return "OID:" + toURIFragment(); //$NON-NLS-1$
+ long value = in.readLong();
+ CDOClassifierRef classifierRef = in.readCDOClassifierRef();
+ return create(value, classifierRef);
}
- @Override
- protected int doCompareTo(CDOID o) throws ClassCastException
+ public static CDOIDObjectLongWithClassifierImpl create(String fragmentPart)
{
- // conversion to uri fragment is pretty heavy but afaics the compareTo
- // is not used in a critical place.
- return toURIFragment().compareTo(o.toURIFragment());
+ 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");
+ }
+
+ String packageURI = fragmentPart.substring(0, index1);
+ String classifierName = fragmentPart.substring(index1 + 1, index2);
+ CDOClassifierRef classifierRef = new CDOClassifierRef(packageURI, classifierName);
+
+ long value = Long.parseLong(fragmentPart.substring(index2 + 1));
+ return create(value, classifierRef);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class LongWithClassifierInterner extends Interner<CDOIDObjectLongWithClassifierImpl>
+ {
+ public synchronized CDOIDObjectLongWithClassifierImpl intern(long value, CDOClassifierRef classifierRef)
+ {
+ int hashCode = getHashCode(value, classifierRef);
+ for (Entry<CDOIDObjectLongWithClassifierImpl> entry = getEntry(hashCode); entry != null; entry = entry
+ .getNextEntry())
+ {
+ CDOIDObjectLongWithClassifierImpl id = entry.get();
+ if (id != null && id.value == value && id.classifierRef.equals(classifierRef))
+ {
+ return id;
+ }
+ }
+
+ CDOIDObjectLongWithClassifierImpl id = new CDOIDObjectLongWithClassifierImpl(value, classifierRef);
+ addEntry(createEntry(id, hashCode));
+ return id;
+ }
+
+ @Override
+ protected int hashCode(CDOIDObjectLongWithClassifierImpl id)
+ {
+ return getHashCode(id.value, id.classifierRef);
+ }
}
}
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 376a113b81..12cce04f7d 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
@@ -6,48 +6,68 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Martin Taal - initial API and implementation
- * Eike Stepper - maintenance
+ * 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.AbstractCDOIDString;
+import org.eclipse.emf.cdo.common.id.CDOIDString;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.spi.common.id.AbstractCDOID;
import org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject;
+import org.eclipse.net4j.util.CheckUtil;
+import org.eclipse.net4j.util.ref.Interner;
+
+import java.io.IOException;
+import java.io.ObjectStreamException;
+
/**
- * @author Martin Taal
- * @since 3.0
+ * @author Eike Stepper
+ * @since 2.0
*/
-public class CDOIDObjectStringImpl extends AbstractCDOIDString implements InternalCDOIDObject
+public final class CDOIDObjectStringImpl extends AbstractCDOID implements InternalCDOIDObject, CDOIDString
{
private static final long serialVersionUID = 1L;
- public CDOIDObjectStringImpl()
+ private static final StringInterner INTERNER = new StringInterner();
+
+ private final String value;
+
+ private CDOIDObjectStringImpl(String value)
{
+ CheckUtil.checkArg(value, "Null not allowed");
+ this.value = value;
}
- public CDOIDObjectStringImpl(String value)
+ @Override
+ public void write(CDODataOutput out) throws IOException
{
- super(value);
+ out.writeString(value);
}
- public Type getType()
+ public String toURIFragment()
{
- return Type.OBJECT;
+ return value;
}
- public boolean isDangling()
+ public String getStringValue()
{
- return false;
+ return value;
}
- public boolean isExternal()
+ public Type getType()
{
- return false;
+ return Type.OBJECT;
}
- public boolean isNull()
+ public CDOID.ObjectType getSubType()
+ {
+ return CDOID.ObjectType.STRING;
+ }
+
+ public boolean isExternal()
{
return false;
}
@@ -62,20 +82,71 @@ public class CDOIDObjectStringImpl extends AbstractCDOIDString implements Intern
return false;
}
- public CDOID.ObjectType getSubType()
+ @Override
+ public int hashCode()
{
- return CDOID.ObjectType.STRING;
+ return value.hashCode();
}
@Override
public String toString()
{
- return "OID" + getStringValue(); //$NON-NLS-1$
+ return "OID" + value; //$NON-NLS-1$
}
@Override
protected int doCompareTo(CDOID o) throws ClassCastException
{
- return getStringValue().compareTo(((CDOIDObjectStringImpl)o).getStringValue());
+ return value.compareTo(((CDOIDObjectStringImpl)o).value);
+ }
+
+ private Object readResolve() throws ObjectStreamException
+ {
+ return create(value);
+ }
+
+ private static int getHashCode(String value)
+ {
+ return value.hashCode();
+ }
+
+ public static CDOIDObjectStringImpl create(String value)
+ {
+ return INTERNER.intern(value);
+ }
+
+ public static CDOIDObjectStringImpl create(CDODataInput in) throws IOException
+ {
+ String value = in.readString();
+ return create(value);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class StringInterner extends Interner<CDOIDObjectStringImpl>
+ {
+ public synchronized CDOIDObjectStringImpl intern(String value)
+ {
+ int hashCode = getHashCode(value);
+ for (Entry<CDOIDObjectStringImpl> entry = getEntry(hashCode); entry != null; entry = entry.getNextEntry())
+ {
+ CDOIDObjectStringImpl id = entry.get();
+ if (id != null && id.value.equals(value))
+ {
+ return id;
+ }
+ }
+
+ CDOIDObjectStringImpl id = new CDOIDObjectStringImpl(value);
+ addEntry(createEntry(id, hashCode));
+ return id;
+ }
+
+ @Override
+ protected int hashCode(CDOIDObjectStringImpl id)
+ {
+ return getHashCode(id.value);
+ }
}
}
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 6b6ed62ff2..f032d53dcb 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
@@ -12,34 +12,44 @@
package org.eclipse.emf.cdo.internal.common.id;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDString;
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.emf.cdo.spi.common.id.AbstractCDOID;
+import org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject;
-import org.eclipse.net4j.util.ObjectUtil;
-import org.eclipse.net4j.util.io.ExtendedDataInput;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
+import org.eclipse.net4j.util.CheckUtil;
+import org.eclipse.net4j.util.ref.Interner;
import java.io.IOException;
+import java.io.ObjectStreamException;
/**
* @author Martin Taal
* @since 3.0
*/
-public class CDOIDObjectStringWithClassifierImpl extends CDOIDObjectStringImpl implements CDOClassifierRef.Provider
+public final class CDOIDObjectStringWithClassifierImpl extends AbstractCDOID implements InternalCDOIDObject,
+ CDOIDString, CDOClassifierRef.Provider
{
private static final long serialVersionUID = 1L;
- private CDOClassifierRef classifierRef;
+ private static final StringWithClassifierInterner INTERNER = new StringWithClassifierInterner();
- public CDOIDObjectStringWithClassifierImpl()
+ private final String value;
+
+ private final CDOClassifierRef classifierRef;
+
+ private CDOIDObjectStringWithClassifierImpl(String value, CDOClassifierRef classifierRef)
{
+ CheckUtil.checkArg(value, "Null not allowed");
+ this.value = value;
+ this.classifierRef = classifierRef;
}
- public CDOIDObjectStringWithClassifierImpl(CDOClassifierRef classifierRef, String value)
+ public String getStringValue()
{
- super(value);
- this.classifierRef = classifierRef;
+ return value;
}
public CDOClassifierRef getClassifierRef()
@@ -48,78 +58,47 @@ public class CDOIDObjectStringWithClassifierImpl extends CDOIDObjectStringImpl i
}
@Override
- public CDOID.ObjectType getSubType()
+ public void write(CDODataOutput out) throws IOException
{
- return CDOID.ObjectType.STRING_WITH_CLASSIFIER;
+ out.writeString(value);
+ out.writeCDOClassifierRef(classifierRef);
}
- @Override
public String toURIFragment()
{
- return getClassifierRef().getPackageURI() + CDOClassifierRef.URI_SEPARATOR + getClassifierRef().getClassifierName()
- + CDOClassifierRef.URI_SEPARATOR + super.toURIFragment();
+ return classifierRef.getPackageURI() + CDOClassifierRef.URI_SEPARATOR + classifierRef.getClassifierName()
+ + CDOClassifierRef.URI_SEPARATOR + value;
}
- @Override
- public void read(String fragmentPart)
+ public Type getType()
{
- // 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));
+ return Type.OBJECT;
}
- @Override
- public void read(ExtendedDataInput in) throws IOException
+ public CDOID.ObjectType getSubType()
{
- CDODataInput cdoDataInput = (CDODataInput)in;
- classifierRef = cdoDataInput.readCDOClassifierRef();
-
- // and let the super take care of the rest
- super.read(in);
+ return CDOID.ObjectType.STRING_WITH_CLASSIFIER;
}
- @Override
- public void write(ExtendedDataOutput out) throws IOException
+ public boolean isExternal()
{
- // 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);
+ return false;
}
- @Override
- public boolean equals(Object obj)
+ public boolean isObject()
{
- 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 true;
+ }
+ public boolean isTemporary()
+ {
return false;
}
@Override
public int hashCode()
{
- int hashCode = classifierRef.hashCode() ^ ObjectUtil.hashCode(getStringValue());
- return getClass().hashCode() ^ hashCode;
+ return getHashCode(value, classifierRef);
}
@Override
@@ -131,8 +110,75 @@ public class CDOIDObjectStringWithClassifierImpl extends CDOIDObjectStringImpl i
@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());
}
+
+ private Object readResolve() throws ObjectStreamException
+ {
+ return create(value, classifierRef);
+ }
+
+ private static int getHashCode(String value, CDOClassifierRef classifierRef)
+ {
+ return value.hashCode() ^ classifierRef.hashCode();
+ }
+
+ public static CDOIDObjectStringWithClassifierImpl create(String value, CDOClassifierRef classifierRef)
+ {
+ return INTERNER.intern(value, classifierRef);
+ }
+
+ public static CDOIDObjectStringWithClassifierImpl create(CDODataInput in) throws IOException
+ {
+ String value = in.readString();
+ CDOClassifierRef classifierRef = in.readCDOClassifierRef();
+ return create(value, classifierRef);
+ }
+
+ public static CDOIDObjectStringWithClassifierImpl create(String fragmentPart)
+ {
+ 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");
+ }
+
+ String packageURI = fragmentPart.substring(0, index1);
+ String classifierName = fragmentPart.substring(index1 + 1, index2);
+ CDOClassifierRef classifierRef = new CDOClassifierRef(packageURI, classifierName);
+
+ String value = fragmentPart.substring(index2 + 1);
+ return create(value, classifierRef);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class StringWithClassifierInterner extends Interner<CDOIDObjectStringWithClassifierImpl>
+ {
+ public synchronized CDOIDObjectStringWithClassifierImpl intern(String value, CDOClassifierRef classifierRef)
+ {
+ int hashCode = getHashCode(value, classifierRef);
+ for (Entry<CDOIDObjectStringWithClassifierImpl> entry = getEntry(hashCode); entry != null; entry = entry
+ .getNextEntry())
+ {
+ CDOIDObjectStringWithClassifierImpl id = entry.get();
+ if (id != null && id.value.equals(value) && id.classifierRef.equals(classifierRef))
+ {
+ return id;
+ }
+ }
+
+ CDOIDObjectStringWithClassifierImpl id = new CDOIDObjectStringWithClassifierImpl(value, classifierRef);
+ addEntry(createEntry(id, hashCode));
+ return id;
+ }
+
+ @Override
+ protected int hashCode(CDOIDObjectStringWithClassifierImpl id)
+ {
+ return getHashCode(id.value, id.classifierRef);
+ }
+ }
}
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 fd76f4f4b4..70ca6411b5 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
@@ -12,42 +12,64 @@
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.common.id.CDOIDUtil;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.spi.common.id.AbstractCDOID;
import org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject;
+import org.eclipse.net4j.util.CheckUtil;
+import org.eclipse.net4j.util.ref.Interner;
+
+import java.io.IOException;
+import java.io.ObjectStreamException;
+import java.util.Arrays;
+
/**
* @author Martin Taal
* @since 3.0
*/
-public class CDOIDObjectUUIDImpl extends AbstractCDOIDByteArray implements InternalCDOIDObject
+public final class CDOIDObjectUUIDImpl extends AbstractCDOID implements InternalCDOIDObject
{
private static final long serialVersionUID = 1L;
- public CDOIDObjectUUIDImpl()
+ private static final UUIDInterner INTERNER = new UUIDInterner();
+
+ private final byte[] value;
+
+ private CDOIDObjectUUIDImpl(byte[] value)
{
+ CheckUtil.checkArg(value, "Null not allowed");
+ this.value = value;
}
- public CDOIDObjectUUIDImpl(byte[] value)
+ public byte[] getByteArrayValue()
{
- super(value);
+ return value;
}
- public Type getType()
+ @Override
+ public void write(CDODataOutput out) throws IOException
{
- return Type.OBJECT;
+ out.writeByteArray(value);
}
- public boolean isDangling()
+ public String toURIFragment()
{
- return false;
+ return CDOIDUtil.encodeUUID(value);
}
- public boolean isExternal()
+ public Type getType()
{
- return false;
+ return Type.OBJECT;
}
- public boolean isNull()
+ public CDOID.ObjectType getSubType()
+ {
+ return CDOID.ObjectType.UUID;
+ }
+
+ public boolean isExternal()
{
return false;
}
@@ -62,21 +84,21 @@ public class CDOIDObjectUUIDImpl extends AbstractCDOIDByteArray implements Inter
return false;
}
- public CDOID.ObjectType getSubType()
+ @Override
+ public int hashCode()
{
- return CDOID.ObjectType.UUID;
+ return getHashCode(value);
}
@Override
protected int doCompareTo(CDOID o) throws ClassCastException
{
- byte[] thisValue = getByteArrayValue();
- byte[] thatValue = ((CDOIDObjectUUIDImpl)o).getByteArrayValue();
- int minLength = Math.min(thisValue.length, thatValue.length);
+ byte[] thatValue = ((CDOIDObjectUUIDImpl)o).value;
+ int minLength = Math.min(value.length, thatValue.length);
for (int i = 0; i < minLength; i++)
{
- byte thisByte = thisValue[i];
+ byte thisByte = value[i];
byte thatByte = thatValue[i];
if (thisByte < thatByte)
{
@@ -89,16 +111,72 @@ public class CDOIDObjectUUIDImpl extends AbstractCDOIDByteArray implements Inter
}
}
- if (thisValue.length < thatValue.length)
+ if (value.length < thatValue.length)
{
return -1;
}
- if (thisValue.length > thatValue.length)
+ if (value.length > thatValue.length)
{
return 1;
}
return 0;
}
+
+ private Object readResolve() throws ObjectStreamException
+ {
+ return create(value);
+ }
+
+ private static int getHashCode(byte[] value)
+ {
+ return Arrays.hashCode(value);
+ }
+
+ public static CDOIDObjectUUIDImpl create(byte[] value)
+ {
+ return INTERNER.intern(value);
+ }
+
+ public static CDOIDObjectUUIDImpl create(CDODataInput in) throws IOException
+ {
+ byte[] value = in.readByteArray();
+ return create(value);
+ }
+
+ public static CDOIDObjectUUIDImpl create(String fragmentPart)
+ {
+ byte[] value = CDOIDUtil.decodeUUID(fragmentPart);
+ return create(value);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class UUIDInterner extends Interner<CDOIDObjectUUIDImpl>
+ {
+ public synchronized CDOIDObjectUUIDImpl intern(byte[] value)
+ {
+ int hashCode = getHashCode(value);
+ for (Entry<CDOIDObjectUUIDImpl> entry = getEntry(hashCode); entry != null; entry = entry.getNextEntry())
+ {
+ CDOIDObjectUUIDImpl id = entry.get();
+ if (id != null && Arrays.equals(id.value, value))
+ {
+ return id;
+ }
+ }
+
+ CDOIDObjectUUIDImpl id = new CDOIDObjectUUIDImpl(value);
+ addEntry(createEntry(id, hashCode));
+ return id;
+ }
+
+ @Override
+ protected int hashCode(CDOIDObjectUUIDImpl id)
+ {
+ return getHashCode(id.value);
+ }
+ }
}
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 b72babdd7e..ac1cb3a843 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
@@ -4,30 +4,150 @@
* 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
+ * 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.CDOIDExternal;
+import org.eclipse.emf.cdo.common.id.CDOIDString;
import org.eclipse.emf.cdo.common.id.CDOIDTemp;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.spi.common.id.AbstractCDOID;
+
+import org.eclipse.net4j.util.CheckUtil;
+import org.eclipse.net4j.util.ref.Interner;
+
+import java.io.IOException;
+import java.io.ObjectStreamException;
/**
- * @author Simon McDuff
+ * @author Eike Stepper
+ * @since 2.0
*/
-public class CDOIDTempObjectExternalImpl extends CDOIDExternalImpl implements CDOIDTemp
+public final class CDOIDTempObjectExternalImpl extends AbstractCDOID implements CDOIDExternal, CDOIDTemp, CDOIDString
{
private static final long serialVersionUID = 1L;
- public CDOIDTempObjectExternalImpl(String uri)
+ private static final StringInterner INTERNER = new StringInterner();
+
+ private final String uri;
+
+ private CDOIDTempObjectExternalImpl(String uri)
{
- super(uri);
+ CheckUtil.checkArg(uri, "Null not allowed");
+ this.uri = uri;
}
@Override
+ public void write(CDODataOutput out) throws IOException
+ {
+ out.writeString(uri);
+ }
+
+ public String toURIFragment()
+ {
+ return uri;
+ }
+
+ public String getURI()
+ {
+ return uri;
+ }
+
+ public String getStringValue()
+ {
+ return uri;
+ }
+
public Type getType()
{
return Type.EXTERNAL_TEMP_OBJECT;
}
+
+ public boolean isExternal()
+ {
+ return true;
+ }
+
+ public boolean isObject()
+ {
+ return true;
+ }
+
+ public boolean isTemporary()
+ {
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return uri.hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return "oid:" + uri; //$NON-NLS-1$
+ }
+
+ @Override
+ protected int doCompareTo(CDOID o) throws ClassCastException
+ {
+ return uri.compareTo(((CDOIDTempObjectExternalImpl)o).uri);
+ }
+
+ private Object readResolve() throws ObjectStreamException
+ {
+ return create(uri);
+ }
+
+ private static int getHashCode(String uri)
+ {
+ return uri.hashCode();
+ }
+
+ public static CDOIDTempObjectExternalImpl create(String uri)
+ {
+ return INTERNER.intern(uri);
+ }
+
+ public static CDOIDTempObjectExternalImpl create(CDODataInput in) throws IOException
+ {
+ String uri = in.readString();
+ return create(uri);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class StringInterner extends Interner<CDOIDTempObjectExternalImpl>
+ {
+ public synchronized CDOIDTempObjectExternalImpl intern(String uri)
+ {
+ int hashCode = getHashCode(uri);
+ for (Entry<CDOIDTempObjectExternalImpl> entry = getEntry(hashCode); entry != null; entry = entry.getNextEntry())
+ {
+ CDOIDTempObjectExternalImpl id = entry.get();
+ if (id != null && id.uri.equals(uri))
+ {
+ return id;
+ }
+ }
+
+ CDOIDTempObjectExternalImpl id = new CDOIDTempObjectExternalImpl(uri);
+ addEntry(createEntry(id, hashCode));
+ return id;
+ }
+
+ @Override
+ protected int hashCode(CDOIDTempObjectExternalImpl id)
+ {
+ return getHashCode(id.uri);
+ }
+ }
}
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 2cc4034065..54232a02da 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
@@ -12,36 +12,56 @@ 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;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.spi.common.id.AbstractCDOID;
+
+import org.eclipse.net4j.util.CheckUtil;
+import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.ref.Interner;
+
+import java.io.IOException;
/**
* @author Eike Stepper
+ * @since 2.0
*/
-public class CDOIDTempObjectImpl extends AbstractCDOIDInteger implements CDOIDTemp
+public final class CDOIDTempObjectImpl extends AbstractCDOID implements CDOIDTemp
{
private static final long serialVersionUID = 1L;
- public CDOIDTempObjectImpl(int value)
+ private static final IntInterner INTERNER = new IntInterner();
+
+ private final int value;
+
+ private CDOIDTempObjectImpl(int value)
{
- super(value);
+ CheckUtil.checkArg(value != 0, "Zero not allowed");
+ this.value = value;
}
- public Type getType()
+ public int getIntValue()
{
- return Type.TEMP_OBJECT;
+ return value;
}
- public boolean isDangling()
+ @Override
+ public void write(CDODataOutput out) throws IOException
{
- return false;
+ out.writeInt(value);
}
- public boolean isExternal()
+ public String toURIFragment()
{
- return false;
+ return String.valueOf(value);
}
- public boolean isNull()
+ public Type getType()
+ {
+ return Type.TEMP_OBJECT;
+ }
+
+ public boolean isExternal()
{
return false;
}
@@ -57,14 +77,82 @@ public class CDOIDTempObjectImpl extends AbstractCDOIDInteger implements CDOIDTe
}
@Override
+ public int hashCode()
+ {
+ return ObjectUtil.hashCode(value);
+ }
+
+ @Override
public String toString()
{
- return "oid" + getIntValue(); //$NON-NLS-1$
+ return "oid" + value; //$NON-NLS-1$
}
@Override
protected int doCompareTo(CDOID o) throws ClassCastException
{
- return new Integer(getIntValue()).compareTo(((CDOIDTempObjectImpl)o).getIntValue());
+ CDOIDTempObjectImpl that = (CDOIDTempObjectImpl)o;
+ if (value < that.value)
+ {
+ return -1;
+ }
+
+ if (value > that.value)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ private static int getHashCode(int value)
+ {
+ return value;
+ }
+
+ public static CDOIDTempObjectImpl create(int value)
+ {
+ return INTERNER.intern(value);
+ }
+
+ public static CDOIDTempObjectImpl create(CDODataInput in) throws IOException
+ {
+ int value = in.readInt();
+ return create(value);
+ }
+
+ public static CDOIDTempObjectImpl create(String fragmentPart)
+ {
+ int value = Integer.parseInt(fragmentPart);
+ return create(value);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class IntInterner extends Interner<CDOIDTempObjectImpl>
+ {
+ public synchronized CDOIDTempObjectImpl intern(int value)
+ {
+ int hashCode = getHashCode(value);
+ for (Entry<CDOIDTempObjectImpl> entry = getEntry(hashCode); entry != null; entry = entry.getNextEntry())
+ {
+ CDOIDTempObjectImpl id = entry.get();
+ if (id != null && id.value == value)
+ {
+ return id;
+ }
+ }
+
+ CDOIDTempObjectImpl id = new CDOIDTempObjectImpl(value);
+ addEntry(createEntry(id, hashCode));
+ return id;
+ }
+
+ @Override
+ protected int hashCode(CDOIDTempObjectImpl id)
+ {
+ return getHashCode(id.value);
+ }
}
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOID.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOID.java
index fff20d46dc..dba32b576c 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOID.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOID.java
@@ -12,6 +12,7 @@
package org.eclipse.emf.cdo.spi.common.id;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
import org.eclipse.net4j.util.io.ExtendedDataInput;
import org.eclipse.net4j.util.io.ExtendedDataOutput;
@@ -29,10 +30,59 @@ public abstract class AbstractCDOID implements CDOID
{
private static final long serialVersionUID = 1L;
- public AbstractCDOID()
+ protected AbstractCDOID()
{
}
+ /**
+ * @since 4.2
+ */
+ public boolean isNull()
+ {
+ return false;
+ }
+
+ /**
+ * @since 4.2
+ */
+ @Deprecated
+ public final boolean isDangling()
+ {
+ return false;
+ }
+
+ /**
+ * @deprecated As of 4.2 not called anymore.
+ */
+ @Deprecated
+ public final void read(String fragmentPart)
+ {
+ // Do nothing
+ }
+
+ /**
+ * @deprecated As of 4.2 not called anymore.
+ */
+ @Deprecated
+ public final void read(ExtendedDataInput in) throws IOException
+ {
+ // Do nothing
+ }
+
+ /**
+ * @deprecated As of 4.2 {@link #write(CDODataOutput)} is called.
+ */
+ @Deprecated
+ public void write(ExtendedDataOutput out) throws IOException
+ {
+ // Do nothing
+ }
+
+ /**
+ * @since 4.2
+ */
+ public abstract void write(CDODataOutput out) throws IOException;
+
@Override
public String toString()
{
@@ -51,20 +101,14 @@ public abstract class AbstractCDOID implements CDOID
}
}
- protected abstract int doCompareTo(CDOID o) throws ClassCastException;
-
- /**
- * <b>Note:</b> {@link CDOID#toURIFragment()} and {@link AbstractCDOID#read(String)} need to match.
- */
- public abstract void read(String fragmentPart);
+ @Override
+ public boolean equals(Object obj)
+ {
+ return obj == this;
+ }
- /**
- * TODO: Change the parameter to CDODataInput to prevent casting in IDs with classifier.
- */
- public abstract void read(ExtendedDataInput in) throws IOException;
+ @Override
+ public abstract int hashCode();
- /**
- * TODO: Change the parameter to CDODataInput to prevent casting in IDs with classifier.
- */
- public abstract void write(ExtendedDataOutput out) throws IOException;
+ protected abstract int doCompareTo(CDOID o) throws ClassCastException;
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDByteArray.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDByteArray.java
deleted file mode 100644
index e51369a1e3..0000000000
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDByteArray.java
+++ /dev/null
@@ -1,97 +0,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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.spi.common.id;
-
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-
-import org.eclipse.net4j.util.CheckUtil;
-import org.eclipse.net4j.util.io.ExtendedDataInput;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-/**
- * If the meaning of this type isn't clear, there really should be more of a description here...
- *
- * @author Eike Stepper
- * @since 4.1
- * @noextend This interface is not intended to be extended by clients.
- */
-public abstract class AbstractCDOIDByteArray extends AbstractCDOID
-{
- public static final String NULL_VALUE = null;
-
- private static final long serialVersionUID = 1L;
-
- private byte[] value;
-
- public AbstractCDOIDByteArray()
- {
- }
-
- public AbstractCDOIDByteArray(byte[] value)
- {
- CheckUtil.checkArg(value != null && value.length == 16, "Illegal UUID value");
- this.value = value;
- }
-
- public byte[] getByteArrayValue()
- {
- return value;
- }
-
- public String toURIFragment()
- {
- return CDOIDUtil.encodeUUID(value);
- }
-
- @Override
- public void read(String fragmentPart)
- {
- value = CDOIDUtil.decodeUUID(fragmentPart);
- }
-
- @Override
- public void read(ExtendedDataInput in) throws IOException
- {
- value = in.readByteArray();
- }
-
- @Override
- public void write(ExtendedDataOutput out) throws IOException
- {
- out.writeByteArray(value);
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj != null && obj.getClass() == getClass())
- {
- AbstractCDOIDByteArray that = (AbstractCDOIDByteArray)obj;
- return Arrays.equals(value, that.value);
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- return getClass().hashCode() ^ Arrays.hashCode(value);
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDInteger.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDInteger.java
deleted file mode 100644
index 3af3337111..0000000000
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDInteger.java
+++ /dev/null
@@ -1,111 +0,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:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - bug 226778
- */
-package org.eclipse.emf.cdo.spi.common.id;
-
-import org.eclipse.net4j.util.io.ExtendedDataInput;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
-
-import java.io.IOException;
-
-/**
- * If the meaning of this type isn't clear, there really should be more of a description here...
- *
- * @author Eike Stepper
- * @since 2.0
- * @noextend This interface is not intended to be extended by clients.
- */
-public abstract class AbstractCDOIDInteger extends AbstractCDOID
-{
- private static final long serialVersionUID = 1L;
-
- private int value;
-
- public AbstractCDOIDInteger()
- {
- }
-
- public AbstractCDOIDInteger(int value)
- {
- if (value == 0)
- {
- throw new IllegalArgumentException("value == 0"); //$NON-NLS-1$
- }
-
- this.value = value;
- }
-
- public int getIntValue()
- {
- return value;
- }
-
- public String toURIFragment()
- {
- return String.valueOf(value);
- }
-
- @Override
- public void read(String fragmentPart)
- {
- value = Integer.valueOf(fragmentPart);
- }
-
- @Override
- public void read(ExtendedDataInput in) throws IOException
- {
- value = in.readInt();
- }
-
- @Override
- public void write(ExtendedDataOutput out) throws IOException
- {
- out.writeInt(value);
- }
-
- public int compareTo(AbstractCDOIDInteger that)
- {
- if (value < that.value)
- {
- return -1;
- }
-
- if (value > that.value)
- {
- return 1;
- }
-
- return 0;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj != null && obj.getClass() == getClass())
- {
- AbstractCDOIDInteger that = (AbstractCDOIDInteger)obj;
- return value == that.value;
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- return getClass().hashCode() ^ value;
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDLong.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDLong.java
deleted file mode 100644
index 1cb2895608..0000000000
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDLong.java
+++ /dev/null
@@ -1,105 +0,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:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - bug 226778
- */
-package org.eclipse.emf.cdo.spi.common.id;
-
-import org.eclipse.net4j.util.ObjectUtil;
-import org.eclipse.net4j.util.io.ExtendedDataInput;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
-
-import java.io.IOException;
-
-/**
- * If the meaning of this type isn't clear, there really should be more of a description here...
- *
- * @author Eike Stepper
- * @since 2.0
- * @noextend This interface is not intended to be extended by clients.
- */
-public abstract class AbstractCDOIDLong extends AbstractCDOID
-{
- public static final long NULL_VALUE = 0L;
-
- private static final long serialVersionUID = 1L;
-
- private long value;
-
- public AbstractCDOIDLong()
- {
- }
-
- public AbstractCDOIDLong(long value)
- {
- if (value == NULL_VALUE)
- {
- throw new IllegalArgumentException("value == NULL_VALUE"); //$NON-NLS-1$
- }
-
- this.value = value;
- }
-
- public long getLongValue()
- {
- return value;
- }
-
- public String toURIFragment()
- {
- return String.valueOf(value);
- }
-
- @Override
- public void read(String fragmentPart)
- {
- value = Long.valueOf(fragmentPart);
- }
-
- @Override
- public void read(ExtendedDataInput in) throws IOException
- {
- value = in.readLong();
- }
-
- @Override
- public void write(ExtendedDataOutput out) throws IOException
- {
- out.writeLong(value);
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj != null && obj.getClass() == getClass())
- {
- AbstractCDOIDLong that = (AbstractCDOIDLong)obj;
- return value == that.value;
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- return getClass().hashCode() ^ ObjectUtil.hashCode(value);
- }
-
- @Override
- public String toString()
- {
- return String.valueOf(value);
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDString.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDString.java
deleted file mode 100644
index 546cf063d4..0000000000
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDString.java
+++ /dev/null
@@ -1,103 +0,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.spi.common.id;
-
-import org.eclipse.net4j.util.ObjectUtil;
-import org.eclipse.net4j.util.io.ExtendedDataInput;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
-
-import java.io.IOException;
-
-/**
- * If the meaning of this type isn't clear, there really should be more of a description here...
- *
- * @author Martin Taal
- * @since 3.0
- * @noextend This interface is not intended to be extended by clients.
- */
-public abstract class AbstractCDOIDString extends AbstractCDOID
-{
- /**
- * @since 4.0
- */
- public static final String NULL_VALUE = null;
-
- private static final long serialVersionUID = 1L;
-
- private String value;
-
- public AbstractCDOIDString()
- {
- }
-
- public AbstractCDOIDString(String value)
- {
- this.value = value;
- }
-
- public String getStringValue()
- {
- return value;
- }
-
- public String toURIFragment()
- {
- return value;
- }
-
- @Override
- public void read(String fragmentPart)
- {
- value = fragmentPart;
- }
-
- @Override
- public void read(ExtendedDataInput in) throws IOException
- {
- value = in.readString();
- }
-
- @Override
- public void write(ExtendedDataOutput out) throws IOException
- {
- out.writeString(value);
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj != null && obj.getClass() == getClass())
- {
- AbstractCDOIDString that = (AbstractCDOIDString)obj;
- return value.equals(that.value);
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- return getClass().hashCode() ^ ObjectUtil.hashCode(value);
- }
-
- @Override
- public String toString()
- {
- return value;
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataInputImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataInputImpl.java
index 12eef1d472..d4071cbafb 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataInputImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataInputImpl.java
@@ -632,4 +632,51 @@ public abstract class CDODataInputImpl extends ExtendedDataInput.Delegating impl
protected abstract CDOListFactory getListFactory();
protected abstract CDOLobStore getLobStore();
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class Default extends CDODataInputImpl
+ {
+ public Default(ExtendedDataInput delegate)
+ {
+ super(delegate);
+ }
+
+ @Override
+ protected CDORevisionFactory getRevisionFactory()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected CDOPackageRegistry getPackageRegistry()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected CDOLobStore getLobStore()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected CDOListFactory getListFactory()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected CDOCommitInfoManager getCommitInfoManager()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected CDOBranchManager getBranchManager()
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataOutputImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataOutputImpl.java
index 34ab1892f5..da68b883bf 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataOutputImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataOutputImpl.java
@@ -77,7 +77,7 @@ import java.util.Set;
* @author Eike Stepper
* @since 4.2
*/
-public abstract class CDODataOutputImpl extends ExtendedDataOutput.Delegating implements CDODataOutput
+public class CDODataOutputImpl extends ExtendedDataOutput.Delegating implements CDODataOutput
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, CDODataOutputImpl.class);
diff --git a/plugins/org.eclipse.emf.cdo.examples.hibernate.client/src/org/eclipse/emf/cdo/examples/hibernate/client/HibernateQueryTest.java b/plugins/org.eclipse.emf.cdo.examples.hibernate.client/src/org/eclipse/emf/cdo/examples/hibernate/client/HibernateQueryTest.java
index 34c24fef47..b1e8578274 100644
--- a/plugins/org.eclipse.emf.cdo.examples.hibernate.client/src/org/eclipse/emf/cdo/examples/hibernate/client/HibernateQueryTest.java
+++ b/plugins/org.eclipse.emf.cdo.examples.hibernate.client/src/org/eclipse/emf/cdo/examples/hibernate/client/HibernateQueryTest.java
@@ -10,12 +10,9 @@
*/
package org.eclipse.emf.cdo.examples.hibernate.client;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.examples.company.CompanyFactory;
import org.eclipse.emf.cdo.examples.company.Customer;
@@ -25,19 +22,23 @@ import org.eclipse.emf.cdo.examples.company.Product;
import org.eclipse.emf.cdo.examples.company.SalesOrder;
import org.eclipse.emf.cdo.examples.company.VAT;
import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDString;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.view.CDOQuery;
+
import org.eclipse.net4j.util.collection.CloseableIterator;
+
import org.junit.Before;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Test different aspects of HQL querying using the CDO query api.
* <p/>
* The queries are done on a test set which is created automatically. The size of the testdata is controlled by the
* static final int's in the top of this class.
- *
+ *
* @author Martin Taal
*/
public class HibernateQueryTest extends BaseTest
@@ -118,7 +119,7 @@ public class HibernateQueryTest extends BaseTest
{
CDOQuery cdoQuery = transaction.createQuery("hql", "from Product where vat=:vat"); //$NON-NLS-1$ //$NON-NLS-2$
- cdoQuery.setParameter("vat", VAT.VAT15); //$NON-NLS-1$
+ cdoQuery.setParameter("vat", VAT.VAT15); //$NON-NLS-1$
final List<Product> products = cdoQuery.getResult(Product.class);
// MT: re-enable after https://bugs.eclipse.org/bugs/show_bug.cgi?id=309920
// gets resolved
@@ -440,17 +441,6 @@ public class HibernateQueryTest extends BaseTest
public Serializable getIdValue(CDOID id)
{
- if (id instanceof AbstractCDOIDString)
- {
- return ((AbstractCDOIDString)id).getStringValue();
- }
-
- if (id instanceof AbstractCDOIDLong)
- {
- return ((AbstractCDOIDLong)id).getLongValue();
- }
-
- throw new IllegalArgumentException("This CDOID type " + id + " is not supported by this store."); //$NON-NLS-1$//$NON-NLS-2$
+ return CDOIDUtil.getString(id);
}
-
}
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionPhase2Request.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionPhase2Request.java
index c91980f524..94b21986be 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionPhase2Request.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionPhase2Request.java
@@ -38,7 +38,7 @@ import java.util.Map.Entry;
* Phase 2 consist of sending the mapping of temporary/persistent CDOID from other CDOTransaction.
* <p>
* It will return confirmation only when the commit is ready to flush to disk.
- *
+ *
* @author Simon McDuff
*/
public class CommitXATransactionPhase2Request extends CommitXATransactionRequest
@@ -71,13 +71,13 @@ public class CommitXATransactionPhase2Request extends CommitXATransactionRequest
{
PROTOCOL.format("Number of ids requested: {0}", size); //$NON-NLS-1$
}
-
+
for (Entry<CDOIDTempObjectExternalImpl, InternalCDOTransaction> entry : requestedIDs.entrySet())
{
CDOIDTempObjectExternalImpl tempID = entry.getKey();
URI oldURIExternal = URI.createURI(tempID.toURIFragment());
CDOID oldCDOID = CDOIDUtil.read(oldURIExternal.fragment());
-
+
InternalCDOXACommitContext commitContext = context.getTransactionManager().getCommitContext(entry.getValue());
if (commitContext == null)
{
@@ -85,7 +85,7 @@ public class CommitXATransactionPhase2Request extends CommitXATransactionRequest
Messages.getString("CommitTransactionPhase2Request.1"), entry //$NON-NLS-1$
.getValue()));
}
-
+
CDOID newID = commitContext.getResult().getIDMappings().get(oldCDOID);
if (newID == null)
{
@@ -93,16 +93,16 @@ public class CommitXATransactionPhase2Request extends CommitXATransactionRequest
Messages.getString("CommitTransactionPhase2Request.2"), oldCDOID //$NON-NLS-1$
.toURIFragment()));
}
-
+
CDOID newIDExternal = CDOURIUtil.convertExternalCDOID(oldURIExternal, newID);
if (PROTOCOL.isEnabled())
{
PROTOCOL.format("ID mapping: {0} --> {1}", tempID.toURIFragment(), newIDExternal.toURIFragment()); //$NON-NLS-1$
}
-
+
out.writeCDOID(tempID);
out.writeCDOID(newIDExternal);
-
+
context.getResult().addIDMapping(tempID, newIDExternal);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.admin/src/org/eclipse/emf/cdo/server/internal/admin/CDOAdminServerRepository.java b/plugins/org.eclipse.emf.cdo.server.admin/src/org/eclipse/emf/cdo/server/internal/admin/CDOAdminServerRepository.java
index 4bd615395c..0fa301e91c 100644
--- a/plugins/org.eclipse.emf.cdo.server.admin/src/org/eclipse/emf/cdo/server/internal/admin/CDOAdminServerRepository.java
+++ b/plugins/org.eclipse.emf.cdo.server.admin/src/org/eclipse/emf/cdo/server/internal/admin/CDOAdminServerRepository.java
@@ -14,12 +14,12 @@ import org.eclipse.emf.cdo.common.admin.CDOAdmin;
import org.eclipse.emf.cdo.common.admin.CDOAdminRepository;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOID.ObjectType;
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.util.RepositoryStateChangedEvent;
import org.eclipse.emf.cdo.common.util.RepositoryTypeChangedEvent;
import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.IRepositorySynchronizer;
import org.eclipse.emf.cdo.server.ISynchronizableRepository;
+import org.eclipse.emf.cdo.spi.common.protocol.CDODataOutputImpl;
import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.event.IListener;
@@ -220,7 +220,7 @@ public class CDOAdminServerRepository extends Notifier implements CDOAdminReposi
}
out.writeLong(getCreationTime());
- CDOIDUtil.write(out, getRootResourceID());
+ new CDODataOutputImpl(out).writeCDOID(getRootResourceID());
out.writeBoolean(isSupportingAudits());
out.writeBoolean(isSupportingBranches());
out.writeBoolean(isSupportingEcore());
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateAuditHandler.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateAuditHandler.java
index d0accd09a6..401beb550a 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateAuditHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateAuditHandler.java
@@ -19,7 +19,6 @@ import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionData;
import org.eclipse.emf.cdo.common.revision.CDORevisionHandler;
import org.eclipse.emf.cdo.eresource.EresourcePackage;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong;
import org.eclipse.emf.cdo.spi.common.revision.DetachedCDORevision;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
@@ -44,7 +43,7 @@ import java.util.List;
/**
* Utility methods to support auditing in the hibernate store.
* An internal class.
- *
+ *
* @author Martin Taal
*/
public class HibernateAuditHandler
@@ -234,8 +233,7 @@ public class HibernateAuditHandler
String idStr = null;
if (folderId != null)
{
- idStr = auditHandler.idToString(EresourcePackage.eINSTANCE.getCDOResourceFolder(),
- ((AbstractCDOIDLong)folderId).getLongValue());
+ idStr = auditHandler.idToString(EresourcePackage.eINSTANCE.getCDOResourceFolder(), CDOIDUtil.getLong(folderId));
}
final String qryStr = "select e from " + entityName + " e where e.folder"
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
index f0b9036d05..f74f54de3e 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
@@ -41,7 +41,6 @@ import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.WrappedHibernateLi
import org.eclipse.emf.cdo.spi.common.commit.CDOChangeSetSegment;
import org.eclipse.emf.cdo.spi.common.commit.CDOCommitInfoUtil;
import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
import org.eclipse.emf.cdo.spi.common.revision.DetachedCDORevision;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
@@ -276,7 +275,7 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS
/**
* @return the current hibernate session. If there is none then a new one is created and a transaction is started.
- *
+ *
* Note the default is a readonly flushmode manual session.
*/
public Session getHibernateSession()
@@ -638,8 +637,7 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS
}
else
{
- criteria
- .add(org.hibernate.criterion.Restrictions.eq("folder.id", ((AbstractCDOIDLong)folderID).getLongValue()));
+ criteria.add(org.hibernate.criterion.Restrictions.eq("folder.id", CDOIDUtil.getLong(folderID)));
}
result = criteria.list();
@@ -802,8 +800,8 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS
// TODO Can this happen? When?
// the folder id is always a long
final Long idValue = CDOIDUtil.getLong(id);
- return CDOIDUtil.createLongWithClassifier(new CDOClassifierRef(EresourcePackage.eINSTANCE.getCDOResourceNode()),
- idValue);
+ return CDOIDUtil.createLongWithClassifier(idValue,
+ new CDOClassifierRef(EresourcePackage.eINSTANCE.getCDOResourceNode()));
}
return null;
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java
index da51fe8c62..465ab0addd 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java
@@ -25,8 +25,6 @@ import org.eclipse.emf.cdo.server.IStoreAccessor.CommitContext;
import org.eclipse.emf.cdo.server.hibernate.IHibernateMappingProvider;
import org.eclipse.emf.cdo.server.hibernate.IHibernateStore;
import org.eclipse.emf.cdo.server.internal.hibernate.bundle.OM;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDString;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.util.CDOUtil;
@@ -63,7 +61,7 @@ import java.util.Properties;
/**
* Provides several utility and convenience methods. Mostly related to {@link CDOID} and {@link CDORevision}.
- *
+ *
* @author Martin Taal
*/
public class HibernateUtil
@@ -103,7 +101,7 @@ public class HibernateUtil
/**
* Sets the singleton used by the Hibernate store.
- *
+ *
* @param instance
* the instance to set
*/
@@ -139,7 +137,7 @@ public class HibernateUtil
/**
* Uses the repository package repository to find the EClass of the identified by the CDOClassifierRef.
- *
+ *
* @param classifierRef
* {@link CDOClassifierRef} which identifies an EClass
* @return the EClass instance identified by the EPackage nsuri and classifier name in the CDOClassifierRef
@@ -179,7 +177,7 @@ public class HibernateUtil
/**
* Creates an instance of {@link IHibernateStore}.
- *
+ *
* @param mappingProvider
* the provider which generates a mapping.
* @param properties
@@ -198,7 +196,7 @@ public class HibernateUtil
/**
* Can only be used when Eclipse is running. In standalone scenarios create the mapping strategy instance by directly
* calling the constructor of the mapping strategy class.
- *
+ *
* @see #createFileMappingProvider(String)
* @since 2.0
*/
@@ -234,7 +232,7 @@ public class HibernateUtil
/**
* Creates a FileMappingProvider using the passed locations.
- *
+ *
* @param location
* the locations to load the mappings from
* @return a {@link FileHibernateMappingProvider}
@@ -248,7 +246,7 @@ public class HibernateUtil
/**
* Retrieves the Hibernate Session from the current {@link HibernateStoreAccessor}. The current HibernateStoreAccessor
* is maintained in the {@link HibernateThreadContext}.
- *
+ *
* @return the current hibernate session, if none is there a new one is created and a transaction is started.
* @since 2.0
*/
@@ -261,7 +259,7 @@ public class HibernateUtil
/**
* Convenience method to convert the properties of the {@link IStore#getRepository()} to a real java Properties
* object.
- *
+ *
* @param store
* the properties of this store are converted to a real Properties object
* @return a Properties object with the store properties
@@ -347,7 +345,7 @@ public class HibernateUtil
/**
* Converts a CDOID to an unique String representations. Null, {@link CDOIDTemp} and null CDOID's are returned as null
* value. Supports {@link CDOID} and {@link CDOIDExternal}.
- *
+ *
* @param id
* the id to convert
* @return a unique String
@@ -367,7 +365,7 @@ public class HibernateUtil
/**
* Converts a String back to its CDOID representation. The same types as in the {@link #convertCDOIDToString(CDOID)}
* method are supported.
- *
+ *
* @param strID
* the String representation of the CDOID
* @return a valid CDOID, can be null
@@ -386,7 +384,7 @@ public class HibernateUtil
* Translates a temporary {@link CDOID} into a hibernate ID, by finding the object it refers to in the
* {@link CommitContext} and then returning or by persisting the object. Note assumes that the hibernate session and
* CommitContext are set in HibernateThreadContext.
- *
+ *
* @param id
* the CDOID to translate to a valid id, if the id is already valid then it is returned.
* @return the passed id or an instance of CDOID which is valid.
@@ -410,7 +408,7 @@ public class HibernateUtil
/**
* Retrieves a {@link CDOID} from the passed CDORevision. If the revision has a non-supported CDOID then the revision
* is saved to the database.
- *
+ *
* @param revision
* the revision to get the id from
* @return a CDOID supported by this store
@@ -431,7 +429,7 @@ public class HibernateUtil
/**
* Retrieves the {@link InternalCDORevision} if the target is a {@link CDOObject} then the CDORevision is retrieved
* using: {@link CDOObject#cdoRevision()}.
- *
+ *
* @param target
* the object which can be a CDOObject or an InternalCDORevision
* @return the found {@link InternalCDORevision}
@@ -448,7 +446,7 @@ public class HibernateUtil
/**
* Gets a current object, first checks the new and dirty objects from the {@link CommitContext}. Otherwise reads it
* from the session.
- *
+ *
* @param id
* the {@link CDOID}, the {@link CDOIDTemp} is resolved against the CommitContext.
* @return the retrieved {@link CDORevision} or null if the id is a null ({@link CDOIDUtil#isNull(CDOID)})
@@ -492,7 +490,7 @@ public class HibernateUtil
/**
* Retrieves a {@link InternalCDORevision} from the {@link CommitContext} or from the database/hibernate session.
* Resolves temporary id's: {@link CDOIDTemp}.
- *
+ *
* @param id
* the {@link CDOID} identifying the object,
* @return the retrieved CDORevision or null if the revision is not found
@@ -542,7 +540,7 @@ public class HibernateUtil
/**
* Converts a String to a containing feature id. Note this is not the same as the feature id. The feature is the
* containing feature of the passed EObject.
- *
+ *
* @param contained
* the object which is contained
* @param value
@@ -571,7 +569,7 @@ public class HibernateUtil
/**
* Computes a valid containing feature id for a passed containing EClass, the contained object and the
* EStructuralFeature which can be the container or the containment feature.
- *
+ *
* @param containingEClass
* the EClass representing the container
* @param contained
@@ -598,7 +596,7 @@ public class HibernateUtil
/**
* Creates the correct subclass of {@link CDOID} for the passed EClass and hibernate id object.
- *
+ *
* @param classifierRef
* the EClass to set in the CDOID
* @param idValue
@@ -610,12 +608,12 @@ public class HibernateUtil
{
if (idValue instanceof String)
{
- return CDOIDUtil.createStringWithClassifier(classifierRef, (String)idValue);
+ return CDOIDUtil.createStringWithClassifier((String)idValue, classifierRef);
}
if (idValue instanceof Long)
{
- return CDOIDUtil.createLongWithClassifier(classifierRef, (Long)idValue);
+ return CDOIDUtil.createLongWithClassifier((Long)idValue, classifierRef);
}
throw new IllegalArgumentException("The ID value type " + idValue.getClass() //$NON-NLS-1$
@@ -624,7 +622,7 @@ public class HibernateUtil
/**
* Checks if the passed id is created/used by this store.
- *
+ *
* @param id
* the {@link CDOID} to check
* @return true if this is a CDOID which is used/created by this store.
@@ -638,7 +636,7 @@ public class HibernateUtil
/**
* Checks if the passed {@link CDOID} is a type supported by this store.
- *
+ *
* @param id
* the CDOID instance to check
* @throws IllegalArgumentException
@@ -660,22 +658,12 @@ public class HibernateUtil
*/
public Serializable getIdValue(CDOID id)
{
- if (id instanceof AbstractCDOIDString)
- {
- return ((AbstractCDOIDString)id).getStringValue();
- }
-
- if (id instanceof AbstractCDOIDLong)
- {
- return ((AbstractCDOIDLong)id).getLongValue();
- }
-
- throw new IllegalArgumentException("This CDOID type " + id + " is not supported by this store."); //$NON-NLS-1$ //$NON-NLS-2$
+ return CDOIDUtil.getLong(id);
}
/**
* Retrieves the entity name for the EClass present in the CDOID.
- *
+ *
* @param id
* the {@link CDOID} to get the EClass from
* @return the entity name for the EClass of the CDOID.
diff --git a/plugins/org.eclipse.emf.cdo.server.lissome/src/org/eclipse/emf/cdo/server/internal/lissome/db/Index.java b/plugins/org.eclipse.emf.cdo.server.lissome/src/org/eclipse/emf/cdo/server/internal/lissome/db/Index.java
index 8b32e6d2fd..d3a2ed49e9 100644
--- a/plugins/org.eclipse.emf.cdo.server.lissome/src/org/eclipse/emf/cdo/server/internal/lissome/db/Index.java
+++ b/plugins/org.eclipse.emf.cdo.server.lissome/src/org/eclipse/emf/cdo/server/internal/lissome/db/Index.java
@@ -14,7 +14,6 @@ import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.server.internal.lissome.LissomeStore;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDByteArray;
import org.eclipse.emf.cdo.spi.server.InternalRepository;
import org.eclipse.net4j.db.DBException;
@@ -126,7 +125,7 @@ public class Index extends DBSchema implements IDBConnectionProvider
{
if (getIDGenerationLocation() == IDGenerationLocation.CLIENT)
{
- byte[] value = ((AbstractCDOIDByteArray)id).getByteArrayValue();
+ byte[] value = CDOIDUtil.getByteArray(id);
statement.setBytes(column, value);
}
else
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerLocal.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerLocal.java
index 69b604c6bb..d0021718d4 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerLocal.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerLocal.java
@@ -11,7 +11,6 @@
package org.eclipse.emf.cdo.server.internal.objectivity.clustering;
import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDTemp;
import org.eclipse.emf.cdo.eresource.EresourcePackage;
import org.eclipse.emf.cdo.server.internal.objectivity.ObjectivityStore;
import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
@@ -19,7 +18,6 @@ import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyScope;
import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySession;
import org.eclipse.emf.cdo.server.internal.objectivity.utils.OBJYCDOIDUtil;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.spi.server.InternalCommitContext;
@@ -35,7 +33,7 @@ import java.util.Map;
/***
* This class will attempt to cluster objects with their container, or with a resource. It should be able to use the
* global clustering which will use model elements to locate where an object will end up.
- *
+ *
* @author Ibrahim Sallam
*/
public class ObjyPlacementManagerLocal
@@ -218,11 +216,7 @@ public class ObjyPlacementManagerLocal
// if (OBJYCDOIDUtil.isValidObjyId(id))
// oid = OBJYCDOIDUtil.getooId(id);
- if (id instanceof AbstractCDOIDLong)
- {
- oid = OBJYCDOIDUtil.getooId(id);
- }
- else if (id instanceof CDOIDTemp)
+ if (id.isTemporary())
{
// see if we've seen it before
CDOID nearId = idMapper.get(id);
@@ -240,6 +234,10 @@ public class ObjyPlacementManagerLocal
}
}
}
+ else
+ {
+ oid = OBJYCDOIDUtil.getooId(id);
+ }
return oid;
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java
index d211353e54..755285b5dc 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java
@@ -28,6 +28,7 @@ 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.model.CDOPackageUnit;
+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.CDORevision;
@@ -76,9 +77,7 @@ import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.collection.IndexedList;
import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
import org.eclipse.net4j.util.concurrent.RWOLockManager.LockState;
-import org.eclipse.net4j.util.io.ExtendedDataInput;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.om.monitor.Monitor;
import org.eclipse.net4j.util.om.monitor.OMMonitor;
@@ -1451,14 +1450,20 @@ public class TransactionCommitContext implements InternalCommitContext
public abstract CDOID getID();
- public Type getType()
+ @Override
+ public void write(CDODataOutput out) throws IOException
{
- return getID().getType();
+ ((AbstractCDOID)getID()).write(out);
+ }
+
+ public String toURIFragment()
+ {
+ return getID().toURIFragment();
}
- public boolean isNull()
+ public Type getType()
{
- return getID().isNull();
+ return getID().getType();
}
public boolean isObject()
@@ -1471,21 +1476,11 @@ public class TransactionCommitContext implements InternalCommitContext
return getID().isTemporary();
}
- public boolean isDangling()
- {
- return getID().isDangling();
- }
-
public boolean isExternal()
{
return getID().isExternal();
}
- public String toURIFragment()
- {
- return getID().toURIFragment();
- }
-
@Override
protected int doCompareTo(CDOID o) throws ClassCastException
{
@@ -1493,26 +1488,6 @@ public class TransactionCommitContext implements InternalCommitContext
}
@Override
- public void write(ExtendedDataOutput out) throws IOException
- {
- ((AbstractCDOID)getID()).write(out);
- }
-
- @Override
- public void read(ExtendedDataInput in) throws IOException
- {
- // Not called on the server-side
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void read(String fragmentPart)
- {
- // Not called on the server-side
- throw new UnsupportedOperationException();
- }
-
- @Override
public boolean equals(Object obj)
{
if (obj instanceof DeltaLockWrapper)
@@ -1541,6 +1516,7 @@ public class TransactionCommitContext implements InternalCommitContext
*/
private static final class ForID extends DeltaLockWrapper
{
+
private static final long serialVersionUID = 1L;
public ForID(CDOID key, InternalCDORevisionDelta delta)
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CDOIDTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CDOIDTest.java
index 1ab61c5041..632f36a349 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CDOIDTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CDOIDTest.java
@@ -19,7 +19,6 @@ 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.session.CDOSession;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong;
import org.eclipse.emf.cdo.tests.model1.Supplier;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CDOUtil;
@@ -31,30 +30,30 @@ public class CDOIDTest extends AbstractCDOTest
{
public void testGetLong_Null()
{
- assertEquals(AbstractCDOIDLong.NULL_VALUE, CDOIDUtil.getLong(null));
+ assertEquals(0L, CDOIDUtil.getLong(null));
}
public void testGetLong_NullId()
{
CDOIDNullImpl id = CDOIDNullImpl.INSTANCE;
- assertEquals(AbstractCDOIDLong.NULL_VALUE, CDOIDUtil.getLong(id));
+ assertEquals(0L, CDOIDUtil.getLong(id));
}
public void testGetLong_LongId()
{
- CDOIDObjectLongImpl id = new CDOIDObjectLongImpl(123L);
+ CDOIDObjectLongImpl id = CDOIDObjectLongImpl.create(123L);
assertEquals(123L, CDOIDUtil.getLong(id));
}
public void testGetLong_TempId()
{
- CDOIDTempObjectImpl id = new CDOIDTempObjectImpl(456);
+ CDOIDTempObjectImpl id = CDOIDTempObjectImpl.create(456);
assertIllegalArgument(id);
}
public void testGetLong_ExtTempId()
{
- CDOIDTempObjectExternalImpl id = new CDOIDTempObjectExternalImpl("cdo://repo123/resource456");
+ CDOIDTempObjectExternalImpl id = CDOIDTempObjectExternalImpl.create("cdo://repo123/resource456");
assertIllegalArgument(id);
}
@@ -67,6 +66,7 @@ public class CDOIDTest extends AbstractCDOTest
private void assertIllegalArgument(CDOID id)
{
boolean thrown = false;
+
try
{
CDOIDUtil.getLong(id);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DetachTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DetachTest.java
index 17eb308e08..9463251810 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DetachTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DetachTest.java
@@ -51,7 +51,7 @@ public class DetachTest extends AbstractCDOTest
c1.setName("Test");
resource.getContents().add(c1);
- final URI uriC1 = EcoreUtil.getURI(c1);
+ URI uriC1 = EcoreUtil.getURI(c1);
assertEquals(c1, transaction.getResourceSet().getEObject(uriC1, false));
resource.getContents().remove(0); // remove object by index
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java
index a47bff5f9b..4d56a30993 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java
@@ -754,39 +754,27 @@ public class InitialTest extends AbstractCDOTest
public void testResourceAccessor() throws Exception
{
- msg("Opening session");
CDOSession session = openSession();
-
- msg("Opening transaction");
CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- msg("Creating supplier");
Supplier supplier = getModel1Factory().createSupplier();
-
- msg("Setting name");
supplier.setName("Stepper");
- msg("Adding supplier");
resource.getContents().add(supplier);
URI supplierTempURI = EcoreUtil.getURI(supplier);
- msg("Retrieving supplier from URI before commit");
+ // Retrieving supplier from URI before commit
EObject supplier1 = transaction.getResourceSet().getEObject(supplierTempURI, true);
-
assertEquals(supplier, CDOUtil.getEObject(supplier1));
- msg("Committing");
transaction.commit();
URI supplierURI = EcoreUtil.getURI(supplier);
- msg("Retrieving supplier from URI after commit");
+ // Retrieving supplier from URI after commit
EObject supplierFromURI = transaction.getResourceSet().getEObject(supplierURI, true);
-
assertEquals(supplier, CDOUtil.getEObject(supplierFromURI));
EObject supplierAfterCommit2 = transaction.getResourceSet().getEObject(supplierTempURI, true);
diff --git a/plugins/org.eclipse.emf.cdo/.settings/.api_filters b/plugins/org.eclipse.emf.cdo/.settings/.api_filters
index 9182fdb67d..bc4fc62718 100644
--- a/plugins/org.eclipse.emf.cdo/.settings/.api_filters
+++ b/plugins/org.eclipse.emf.cdo/.settings/.api_filters
@@ -1,5 +1,37 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.emf.cdo" version="2">
+ <resource path="META-INF/MANIFEST.MF" type="org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDByteArray">
+ <filter id="305422471">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDByteArray"/>
+ <message_argument value="org.eclipse.emf.cdo_4.1.0"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="META-INF/MANIFEST.MF" type="org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDInteger">
+ <filter id="305422471">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDInteger"/>
+ <message_argument value="org.eclipse.emf.cdo_4.1.0"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="META-INF/MANIFEST.MF" type="org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong">
+ <filter id="305422471">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong"/>
+ <message_argument value="org.eclipse.emf.cdo_4.1.0"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="META-INF/MANIFEST.MF" type="org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDString">
+ <filter id="305422471">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDString"/>
+ <message_argument value="org.eclipse.emf.cdo_4.1.0"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="src/org/eclipse/emf/cdo/CDOObject.java" type="org.eclipse.emf.cdo.CDOObject">
<filter id="403804204">
<message_arguments>

Back to the top