Reverted changes to this file so that the system compiles. Once the cast functionality has been added it can go back.
git-svn-id: https://svn.apache.org/repos/asf/incubator/vxquery/branches/vxquery_algebricks@1365305 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/atomic/XSDecimalPointable.java b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/atomic/XSDecimalPointable.java
index f8a8b93..2ab5a13 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/atomic/XSDecimalPointable.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/atomic/XSDecimalPointable.java
@@ -73,6 +73,37 @@
normalize();
}
+ public void setDecimal(double doubleValue) {
+ setDecimal(doubleValue, bytes, start);
+ }
+
+ public static void setDecimal(double doubleValue, byte[] bytes, int start) {
+ byte decimalPlace = 0;
+ long value = 0;
+ boolean pastDecimal = false;
+ int count = 0;
+ int c;
+ Double doubleObject = new Double(doubleValue);
+ String strTest = doubleObject.toString();
+
+ for (int i = 0; i < strTest.length() && count < PRECISION; ++i) {
+ c = strTest.charAt(i);
+ if (Character.isDigit(c)) {
+ value = value * 10 + Character.getNumericValue(c);
+ if (pastDecimal) {
+ decimalPlace++;
+ }
+ count++;
+ } else {
+ pastDecimal = true;
+ }
+ }
+
+ BytePointable.setByte(bytes, start + DECIMAL_PLACE_OFFSET, decimalPlace);
+ LongPointable.setLong(bytes, start + VALUE_OFFSET, value);
+ normalize(bytes, start);
+ }
+
public void normalize() {
normalize(bytes, start);
}