You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vxquery.apache.org by pr...@apache.org on 2012/07/24 23:32:19 UTC
svn commit: r1365305 -
/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/atomic/XSDecimalPointable.java
Author: prestonc
Date: Tue Jul 24 21:32:18 2012
New Revision: 1365305
URL: http://svn.apache.org/viewvc?rev=1365305&view=rev
Log:
Reverted changes to this file so that the system compiles. Once the cast functionality has been added it can go back.
Modified:
incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/atomic/XSDecimalPointable.java
Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/atomic/XSDecimalPointable.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/atomic/XSDecimalPointable.java?rev=1365305&r1=1365304&r2=1365305&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/atomic/XSDecimalPointable.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/atomic/XSDecimalPointable.java Tue Jul 24 21:32:18 2012
@@ -73,6 +73,37 @@ public class XSDecimalPointable extends
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);
}