Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-04-09 05:13:36 -0400
committerEike Stepper2013-04-09 05:13:36 -0400
commited267ead6fc66ede32b61d5a3b945f70f7f8edc2 (patch)
tree10955d453b832f87a806e6ab95c00adbd70c7000
parent7bd7e0f38314694edc138589905b1a7d31920ef4 (diff)
downloadcdo-bugs/405191.tar.gz
cdo-bugs/405191.tar.xz
cdo-bugs/405191.zip
[405191] NIL value not committed for unsettable attribute bugs/405191
https://bugs.eclipse.org/bugs/show_bug.cgi?id=405191
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionData.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOTypeImpl.java168
2 files changed, 85 insertions, 99 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionData.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionData.java
index 13c348bf32..666b380b3d 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionData.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionData.java
@@ -13,12 +13,12 @@ package org.eclipse.emf.cdo.common.revision;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EStructuralFeature.Internal.DynamicValueHolder;
import org.eclipse.emf.ecore.impl.BasicEObjectImpl;
-import org.eclipse.emf.ecore.impl.EStoreEObjectImpl;
/**
* Encapsulates the modeled information and the EMF system values of a {@link CDORevision revision}.
- *
+ *
* @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.
@@ -26,11 +26,11 @@ import org.eclipse.emf.ecore.impl.EStoreEObjectImpl;
public interface CDORevisionData
{
/**
- * The equivalent of <code>EStructuralFeatureImpl.NIL</code> (i.e. explicit <code>null</code>).
- *
+ * The equivalent of <code>DynamicValueHolder.NIL</code> (i.e. explicit <code>null</code>).
+ *
* @since 3.0
*/
- public static final Object NIL = EStoreEObjectImpl.NIL;
+ public static final Object NIL = DynamicValueHolder.NIL;
/**
* @since 2.0
@@ -52,13 +52,13 @@ public interface CDORevisionData
* <code><pre>
* CDORevision revision = ...;
* CDORevision container = <i>Util.getRevision</i>(revision.data().getContainerID());
- *
+ *
* int containingFeatureID = revision.data().getContainingFeatureID();
- *
+ *
* EStructuralFeature feature = containingFeatureID <= InternalEObject.EOPPOSITE_FEATURE_BASE ?
* container.getEClass().getEStructuralFeature(InternalEObject.EOPPOSITE_FEATURE_BASE - containingFeatureID) :
* ((EReference)revision.getEClass().getEStructuralFeature(containingFeatureID)).getEOpposite();</pre></code>
- *
+ *
* @see BasicEObjectImpl#eContainingFeature()
* @see #getContainerID()
*/
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOTypeImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOTypeImpl.java
index cfb23b8e55..1dc28578a7 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOTypeImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOTypeImpl.java
@@ -60,6 +60,12 @@ public abstract class CDOTypeImpl implements CDOType
{
private static CDOTypeImpl[] ids = new CDOTypeImpl[Byte.MAX_VALUE - Byte.MIN_VALUE + 1];
+ private static final byte OPCODE_NORMAL = 0;
+
+ private static final byte OPCODE_NULL = 1;
+
+ private static final byte OPCODE_NIL = 2;
+
private static final byte BOOLEAN_DEFAULT_PRIMITIVE = 0;
private static final char CHARACTER_DEFAULT_PRIMITIVE = 0;
@@ -187,58 +193,38 @@ public abstract class CDOTypeImpl implements CDOType
}
};
- public static final CDOType BIG_DECIMAL = new CDOTypeImpl("BIG_DECIMAL", EcorePackage.EBIG_DECIMAL, true) //$NON-NLS-1$
+ public static final CDOType BIG_DECIMAL = new ObjectType("BIG_DECIMAL", EcorePackage.EBIG_DECIMAL) //$NON-NLS-1$
{
- public void writeValue(CDODataOutput out, Object value) throws IOException
+ @Override
+ public void doWriteValue(CDODataOutput out, Object value) throws IOException
{
- if (value == null)
- {
- out.writeByteArray(null);
- }
- else
- {
- BigDecimal bigDecimal = (BigDecimal)value;
- out.writeByteArray(bigDecimal.unscaledValue().toByteArray());
- out.writeInt(bigDecimal.scale());
- }
+ BigDecimal bigDecimal = (BigDecimal)value;
+ out.writeByteArray(bigDecimal.unscaledValue().toByteArray());
+ out.writeInt(bigDecimal.scale());
}
- public BigDecimal readValue(CDODataInput in) throws IOException
+ @Override
+ public BigDecimal doReadValue(CDODataInput in) throws IOException
{
byte[] array = in.readByteArray();
- if (array == null)
- {
- return null;
- }
-
BigInteger unscaled = new BigInteger(array);
int scale = in.readInt();
return new BigDecimal(unscaled, scale);
}
};
- public static final CDOType BIG_INTEGER = new CDOTypeImpl("BIG_INTEGER", EcorePackage.EBIG_INTEGER, true) //$NON-NLS-1$
+ public static final CDOType BIG_INTEGER = new ObjectType("BIG_INTEGER", EcorePackage.EBIG_INTEGER) //$NON-NLS-1$
{
- public void writeValue(CDODataOutput out, Object value) throws IOException
+ @Override
+ public void doWriteValue(CDODataOutput out, Object value) throws IOException
{
- if (value == null)
- {
- out.writeByteArray(null);
- }
- else
- {
- out.writeByteArray(((BigInteger)value).toByteArray());
- }
+ out.writeByteArray(((BigInteger)value).toByteArray());
}
- public BigInteger readValue(CDODataInput in) throws IOException
+ @Override
+ public BigInteger doReadValue(CDODataInput in) throws IOException
{
byte[] array = in.readByteArray();
- if (array == null)
- {
- return null;
- }
-
return new BigInteger(array);
}
};
@@ -404,7 +390,7 @@ public abstract class CDOTypeImpl implements CDOType
}
};
- public static final CDOType STRING = new CDOTypeImpl("STRING", EcorePackage.ESTRING, true) //$NON-NLS-1$
+ public static final CDOType STRING = new ObjectType("STRING", EcorePackage.ESTRING) //$NON-NLS-1$
{
@Override
protected String doCopyValue(Object value)
@@ -412,18 +398,20 @@ public abstract class CDOTypeImpl implements CDOType
return (String)value;
}
- public void writeValue(CDODataOutput out, Object value) throws IOException
+ @Override
+ public void doWriteValue(CDODataOutput out, Object value) throws IOException
{
out.writeString((String)value);
}
- public String readValue(CDODataInput in) throws IOException
+ @Override
+ public String doReadValue(CDODataInput in) throws IOException
{
return in.readString();
}
};
- public static final CDOType BYTE_ARRAY = new CDOTypeImpl("BYTE_ARRAY", EcorePackage.EBYTE_ARRAY, true) //$NON-NLS-1$
+ public static final CDOType BYTE_ARRAY = new ObjectType("BYTE_ARRAY", EcorePackage.EBYTE_ARRAY) //$NON-NLS-1$
{
@Override
protected byte[] doCopyValue(Object value)
@@ -434,12 +422,14 @@ public abstract class CDOTypeImpl implements CDOType
return result;
}
- public void writeValue(CDODataOutput out, Object value) throws IOException
+ @Override
+ public void doWriteValue(CDODataOutput out, Object value) throws IOException
{
out.writeByteArray((byte[])value);
}
- public byte[] readValue(CDODataInput in) throws IOException
+ @Override
+ public byte[] doReadValue(CDODataInput in) throws IOException
{
return in.readByteArray();
}
@@ -488,7 +478,7 @@ public abstract class CDOTypeImpl implements CDOType
}
};
- public static final CDOType JAVA_CLASS = new CDOTypeImpl("JAVA_CLASS", EcorePackage.EJAVA_CLASS, true) //$NON-NLS-1$
+ public static final CDOType JAVA_CLASS = new ObjectType("JAVA_CLASS", EcorePackage.EJAVA_CLASS) //$NON-NLS-1$
{
@Override
protected String doCopyValue(Object value)
@@ -496,12 +486,14 @@ public abstract class CDOTypeImpl implements CDOType
return (String)value;
}
- public void writeValue(CDODataOutput out, Object value) throws IOException
+ @Override
+ public void doWriteValue(CDODataOutput out, Object value) throws IOException
{
out.writeString((String)value);
}
- public String readValue(CDODataInput in) throws IOException
+ @Override
+ public String doReadValue(CDODataInput in) throws IOException
{
return in.readString();
}
@@ -519,7 +511,7 @@ public abstract class CDOTypeImpl implements CDOType
}
};
- public static final CDOType JAVA_OBJECT = new CDOTypeImpl("JAVA_OBJECT", EcorePackage.EJAVA_CLASS, true) //$NON-NLS-1$
+ public static final CDOType JAVA_OBJECT = new ObjectType("JAVA_OBJECT", EcorePackage.EJAVA_CLASS) //$NON-NLS-1$
{
@Override
protected Object doCopyValue(Object value)
@@ -527,12 +519,14 @@ public abstract class CDOTypeImpl implements CDOType
return value;
}
- public void writeValue(CDODataOutput out, Object value) throws IOException
+ @Override
+ public void doWriteValue(CDODataOutput out, Object value) throws IOException
{
out.writeByteArray((byte[])value);
}
- public byte[] readValue(CDODataInput in) throws IOException
+ @Override
+ public byte[] doReadValue(CDODataInput in) throws IOException
{
return in.readByteArray();
}
@@ -550,7 +544,7 @@ public abstract class CDOTypeImpl implements CDOType
}
};
- public static final CDOType CUSTOM = new CDOTypeImpl("CUSTOM", 0, true) //$NON-NLS-1$
+ public static final CDOType CUSTOM = new ObjectType("CUSTOM", 0) //$NON-NLS-1$
{
@Override
protected String doCopyValue(Object value)
@@ -558,12 +552,14 @@ public abstract class CDOTypeImpl implements CDOType
return (String)value;
}
- public void writeValue(CDODataOutput out, Object value) throws IOException
+ @Override
+ public void doWriteValue(CDODataOutput out, Object value) throws IOException
{
out.writeString((String)value);
}
- public String readValue(CDODataInput in) throws IOException
+ @Override
+ public String doReadValue(CDODataInput in) throws IOException
{
return in.readString();
}
@@ -715,55 +711,33 @@ public abstract class CDOTypeImpl implements CDOType
}
};
- public static final CDOType BLOB = new CDOTypeImpl("BLOB", -3, true) //$NON-NLS-1$
+ public static final CDOType BLOB = new ObjectType("BLOB", -3) //$NON-NLS-1$
{
- public CDOBlob readValue(CDODataInput in) throws IOException
+ @Override
+ public void doWriteValue(CDODataOutput out, Object value) throws IOException
{
- if (in.readBoolean())
- {
- return CDOLobUtil.readBlob(in);
- }
-
- return null;
+ CDOLobUtil.write(out, (CDOBlob)value);
}
- public void writeValue(CDODataOutput out, Object value) throws IOException
+ @Override
+ public CDOBlob doReadValue(CDODataInput in) throws IOException
{
- if (value != null)
- {
- out.writeBoolean(true);
- CDOLobUtil.write(out, (CDOBlob)value);
- }
- else
- {
- out.writeBoolean(false);
- }
+ return CDOLobUtil.readBlob(in);
}
};
- public static final CDOType CLOB = new CDOTypeImpl("CLOB", -4, true) //$NON-NLS-1$
+ public static final CDOType CLOB = new ObjectType("CLOB", -4) //$NON-NLS-1$
{
- public CDOClob readValue(CDODataInput in) throws IOException
+ @Override
+ public void doWriteValue(CDODataOutput out, Object value) throws IOException
{
- if (in.readBoolean())
- {
- return CDOLobUtil.readClob(in);
- }
-
- return null;
+ CDOLobUtil.write(out, (CDOClob)value);
}
- public void writeValue(CDODataOutput out, Object value) throws IOException
+ @Override
+ public CDOClob doReadValue(CDODataInput in) throws IOException
{
- if (value != null)
- {
- out.writeBoolean(true);
- CDOLobUtil.write(out, (CDOClob)value);
- }
- else
- {
- out.writeBoolean(false);
- }
+ return CDOLobUtil.readClob(in);
}
};
@@ -1042,11 +1016,15 @@ public abstract class CDOTypeImpl implements CDOType
{
if (value == null)
{
- out.writeBoolean(false);
+ out.writeByte(OPCODE_NULL);
+ }
+ else if (value == CDORevisionData.NIL)
+ {
+ out.writeByte(OPCODE_NIL);
}
else
{
- out.writeBoolean(true);
+ out.writeByte(OPCODE_NORMAL);
doWriteValue(out, value);
}
}
@@ -1055,13 +1033,21 @@ public abstract class CDOTypeImpl implements CDOType
public final Object readValue(CDODataInput in) throws IOException
{
- boolean notNull = in.readBoolean();
- if (notNull)
+ byte opcode = in.readByte();
+ switch (opcode)
{
+ case OPCODE_NORMAL:
return doReadValue(in);
- }
- return null;
+ case OPCODE_NULL:
+ return null;
+
+ case OPCODE_NIL:
+ return CDORevisionData.NIL;
+
+ default:
+ throw new IllegalStateException("Illegal opcode: " + opcode);
+ }
}
protected abstract Object doReadValue(CDODataInput in) throws IOException;

Back to the top