diff options
author | Eike Stepper | 2009-04-26 16:20:13 +0000 |
---|---|---|
committer | Eike Stepper | 2009-04-26 16:20:13 +0000 |
commit | d2fb30e856c3bd7d0bdc0ebdd66c2b7bb5a632b0 (patch) | |
tree | c1b43ff20149bea1978cdd2551b61509105e522f /plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOTypeImpl.java | |
parent | 9e2f1741e0673b1600fcb99a703f85d077ae1722 (diff) | |
download | cdo-d2fb30e856c3bd7d0bdc0ebdd66c2b7bb5a632b0.tar.gz cdo-d2fb30e856c3bd7d0bdc0ebdd66c2b7bb5a632b0.tar.xz cdo-d2fb30e856c3bd7d0bdc0ebdd66c2b7bb5a632b0.zip |
[269789] Support EMF BigInteger and BigDecimal data types
https://bugs.eclipse.org/bugs/show_bug.cgi?id=269789
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOTypeImpl.java')
-rw-r--r-- | plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOTypeImpl.java | 58 |
1 files changed, 58 insertions, 0 deletions
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 774d4588ae..45d407aa88 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 @@ -24,6 +24,8 @@ import org.eclipse.emf.ecore.EcorePackage; import org.eclipse.emf.ecore.util.EcoreUtil; import java.io.IOException; +import java.math.BigDecimal; +import java.math.BigInteger; import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -164,6 +166,62 @@ public abstract class CDOTypeImpl implements CDOType } }; + public static final CDOType BIG_DECIMAL = new CDOTypeImpl("BIG_DECIMAL", EcorePackage.EBIG_DECIMAL, true) + { + public void writeValue(CDODataOutput out, Object value) throws IOException + { + if (value == null) + { + out.writeByteArray(null); + } + else + { + BigDecimal bigDecimal = (BigDecimal)value; + out.writeByteArray(bigDecimal.unscaledValue().toByteArray()); + out.writeInt(bigDecimal.scale()); + } + } + + public Object readValue(CDODataInput in) throws IOException + { + byte[] array = in.readByteArray(); + if (array == null) + { + return null; + } + + BigInteger unscaled = new BigInteger(array); + int scale = in.readInt(); + return new BigDecimal(unscaled, scale); + } + }; + + public static final CDOType BIG_INTEGER = new CDOTypeImpl("BIG_INTEGER", EcorePackage.EBIG_INTEGER, true) + { + public void writeValue(CDODataOutput out, Object value) throws IOException + { + if (value == null) + { + out.writeByteArray(null); + } + else + { + out.writeByteArray(((BigInteger)value).toByteArray()); + } + } + + public Object readValue(CDODataInput in) throws IOException + { + byte[] array = in.readByteArray(); + if (array == null) + { + return null; + } + + return new BigInteger(array); + } + }; + public static final CDOType OBJECT = new CDOTypeImpl("OBJECT", EcorePackage.EOBJECT, true, CDOID.NULL) { public void writeValue(CDODataOutput out, Object value) throws IOException |