You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vxquery.apache.org by vi...@apache.org on 2012/07/10 04:38:47 UTC

svn commit: r1359464 - in /incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src: main/java/org/apache/vxquery/datamodel/accessors/atomic/ main/java/org/apache/vxquery/xmlquery/translator/ test/java/org/apache/vxquery/xmlquery/query/

Author: vinayakb
Date: Tue Jul 10 02:38:47 2012
New Revision: 1359464

URL: http://svn.apache.org/viewvc?rev=1359464&view=rev
Log:
Added translation for xs:decimal

Modified:
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/atomic/XSDecimalPointable.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java
    incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/test/java/org/apache/vxquery/xmlquery/query/SimpleXQueryTest.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=1359464&r1=1359463&r2=1359464&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 10 02:38:47 2012
@@ -99,7 +99,7 @@ public class XSDecimalPointable extends 
                 pastDecimal = true;
             }
         }
-        
+
         BytePointable.setByte(bytes, start + DECIMAL_PLACE_OFFSET, decimalPlace);
         LongPointable.setLong(bytes, start + VALUE_OFFSET, value);
         normalize(bytes, start);

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java?rev=1359464&r1=1359463&r2=1359464&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java Tue Jul 10 02:38:47 2012
@@ -23,6 +23,7 @@ import org.apache.vxquery.context.Static
 import org.apache.vxquery.context.StaticContextImpl;
 import org.apache.vxquery.context.ThinStaticContextImpl;
 import org.apache.vxquery.context.XQueryVariable;
+import org.apache.vxquery.datamodel.accessors.atomic.XSDecimalPointable;
 import org.apache.vxquery.datamodel.builders.atomic.StringValueBuilder;
 import org.apache.vxquery.datamodel.values.ValueTag;
 import org.apache.vxquery.exceptions.ErrorCode;
@@ -39,6 +40,7 @@ import org.apache.vxquery.types.AnyNodeT
 import org.apache.vxquery.types.AnyType;
 import org.apache.vxquery.types.AtomicType;
 import org.apache.vxquery.types.AttributeType;
+import org.apache.vxquery.types.BuiltinTypeConstants;
 import org.apache.vxquery.types.BuiltinTypeRegistry;
 import org.apache.vxquery.types.CommentType;
 import org.apache.vxquery.types.DocumentType;
@@ -1220,6 +1222,7 @@ public class XMLQueryTranslator {
         switch (lType) {
             case DECIMAL:
                 t = SequenceType.create(BuiltinTypeRegistry.XS_DECIMAL, Quantifier.QUANT_ONE);
+                value = Double.parseDouble(image);
                 break;
             case DOUBLE:
                 t = SequenceType.create(BuiltinTypeRegistry.XS_DOUBLE, Quantifier.QUANT_ONE);
@@ -1806,7 +1809,7 @@ public class XMLQueryTranslator {
             AtomicType at = (AtomicType) it;
             byte[] bytes = null;
             switch (at.getTypeId()) {
-                case ValueTag.XS_BOOLEAN_TAG: {
+                case BuiltinTypeConstants.XS_BOOLEAN_TYPE_ID: {
                     baaos.reset();
                     try {
                         dOut.write((byte) ValueTag.XS_BOOLEAN_TAG);
@@ -1816,7 +1819,7 @@ public class XMLQueryTranslator {
                     }
                     break;
                 }
-                case ValueTag.XS_INT_TAG: {
+                case BuiltinTypeConstants.XS_INT_TYPE_ID: {
                     baaos.reset();
                     try {
                         dOut.write((byte) ValueTag.XS_INT_TAG);
@@ -1826,7 +1829,7 @@ public class XMLQueryTranslator {
                     }
                     break;
                 }
-                case ValueTag.XS_INTEGER_TAG: {
+                case BuiltinTypeConstants.XS_INTEGER_TYPE_ID: {
                     baaos.reset();
                     try {
                         dOut.write((byte) ValueTag.XS_INTEGER_TAG);
@@ -1836,7 +1839,7 @@ public class XMLQueryTranslator {
                     }
                     break;
                 }
-                case ValueTag.XS_DOUBLE_TAG: {
+                case BuiltinTypeConstants.XS_DOUBLE_TYPE_ID: {
                     baaos.reset();
                     try {
                         dOut.write((byte) ValueTag.XS_DOUBLE_TAG);
@@ -1846,7 +1849,7 @@ public class XMLQueryTranslator {
                     }
                     break;
                 }
-                case ValueTag.XS_STRING_TAG: {
+                case BuiltinTypeConstants.XS_STRING_TYPE_ID: {
                     baaos.reset();
                     try {
                         dOut.write((byte) ValueTag.XS_STRING_TAG);
@@ -1856,6 +1859,18 @@ public class XMLQueryTranslator {
                     }
                     break;
                 }
+                case BuiltinTypeConstants.XS_DECIMAL_TYPE_ID: {
+                    baaos.reset();
+                    try {
+                        dOut.write((byte) ValueTag.XS_DECIMAL_TAG);
+                        byte[] dBytes = new byte[XSDecimalPointable.TYPE_TRAITS.getFixedLength()];
+                        XSDecimalPointable.setDecimal(((Number) value).doubleValue(), dBytes, 0);
+                        dOut.write(dBytes);
+                    } catch (IOException e) {
+                        throw new SystemException(ErrorCode.SYSE0001, e);
+                    }
+                    break;
+                }
                 default:
                     throw new SystemException(ErrorCode.SYSE0001);
             }

Modified: incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/test/java/org/apache/vxquery/xmlquery/query/SimpleXQueryTest.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/test/java/org/apache/vxquery/xmlquery/query/SimpleXQueryTest.java?rev=1359464&r1=1359463&r2=1359464&view=diff
==============================================================================
--- incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/test/java/org/apache/vxquery/xmlquery/query/SimpleXQueryTest.java (original)
+++ incubator/vxquery/branches/vxquery_algebricks/vxquery-core/src/test/java/org/apache/vxquery/xmlquery/query/SimpleXQueryTest.java Tue Jul 10 02:38:47 2012
@@ -69,7 +69,7 @@ public class SimpleXQueryTest {
 
     @Test
     public void simple008() {
-        runNegTest("simple008", "fn:boolean((fn:false(), fn:false()))");
+        runTest("simple008", "fn:boolean((fn:false(), fn:false()))");
     }
 
     @Test