jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1604120 - in /jena/trunk/jena-tdb/src: main/java/com/hp/hpl/jena/tdb/store/NodeId.java test/java/com/hp/hpl/jena/tdb/store/TestNodeId.java
Date Fri, 20 Jun 2014 09:57:51 GMT
Author: andy
Date: Fri Jun 20 09:57:51 2014
New Revision: 1604120

URL: http://svn.apache.org/r1604120
Log:
JENA-720 - Avoid engineering notation when recovering xsd:decimal values.

Modified:
    jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/NodeId.java
    jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestNodeId.java

Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/NodeId.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/NodeId.java?rev=1604120&r1=1604119&r2=1604120&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/NodeId.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/NodeId.java Fri Jun 20 09:57:51
2014
@@ -291,45 +291,40 @@ public class NodeId
         long v = nodeId.value ;
         int type = nodeId.type() ;
 
-        switch (type)
-        {
+        switch (type) {
             case NONE:      return null ;
             case SPECIAL:   return null ;
                 
-            case INTEGER:
-            {
+            case INTEGER : {
                 long val = IntegerNode.unpack(v) ;
                 Node n = NodeFactory.createLiteral(Long.toString(val), null, XSDDatatype.XSDinteger)
;
                 return n ;
             }
-            case DECIMAL:
-            {
+            case DECIMAL : {
                 BigDecimal d = DecimalNode.unpackAsBigDecimal(v) ;
-                String x = d.toEngineeringString() ;
+                String x = d.toPlainString() ;
                 return NodeFactory.createLiteral(x, null, XSDDatatype.XSDdecimal) ;
             }
-
-            case DATETIME:
-            {
+            case DATETIME : {
                 long val = BitsLong.clear(v, 56, 64) ;
-                String lex = DateTimeNode.unpackDateTime(val) ; 
+                String lex = DateTimeNode.unpackDateTime(val) ;
                 return NodeFactory.createLiteral(lex, null, XSDDatatype.XSDdateTime) ;
             }
-            case DATE:
-            {
+            case DATE : {
                 long val = BitsLong.clear(v, 56, 64) ;
                 String lex = DateTimeNode.unpackDate(val) ;
                 return NodeFactory.createLiteral(lex, null, XSDDatatype.XSDdate) ;
             }
-            case BOOLEAN:
-            {
+            case BOOLEAN : {
                 long val = BitsLong.clear(v, 56, 64) ;
-                if ( val == 0 ) return NodeConst.nodeFalse ; 
-                if ( val == 1 ) return NodeConst.nodeTrue ;
-                throw new TDBException("Unrecognized boolean node id : "+val) ;
+                if ( val == 0 )
+                    return NodeConst.nodeFalse ;
+                if ( val == 1 )
+                    return NodeConst.nodeTrue ;
+                throw new TDBException("Unrecognized boolean node id : " + val) ;
             }
-            default:
-                throw new TDBException("Unrecognized node id type: "+type) ;
+            default :
+                throw new TDBException("Unrecognized node id type: " + type) ;
         }
     }
     

Modified: jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestNodeId.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestNodeId.java?rev=1604120&r1=1604119&r2=1604120&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestNodeId.java (original)
+++ jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestNodeId.java Fri Jun 20
09:57:51 2014
@@ -23,6 +23,7 @@ import org.junit.Test ;
 
 import com.hp.hpl.jena.datatypes.xsd.XSDDatatype ;
 import com.hp.hpl.jena.graph.Node ;
+import com.hp.hpl.jena.graph.NodeFactory ;
 import com.hp.hpl.jena.sparql.expr.NodeValue ;
 import com.hp.hpl.jena.sparql.util.NodeFactoryExtra ;
 
@@ -105,7 +106,7 @@ public class TestNodeId extends BaseTest
     
     // Just this once, directly create the Node.
     @Test public void nodeId_decimal_3()
-    { test("12.89", com.hp.hpl.jena.graph.NodeFactory.createLiteral("12.89", null, XSDDatatype.XSDdecimal))
; }
+    { test("12.89", NodeFactory.createLiteral("12.89", null, XSDDatatype.XSDdecimal)) ; }
 
     @Test public void nodeId_decimal_4()
     { test("-1.0",  NodeFactoryExtra.parseNode("-1.0")) ; }
@@ -118,7 +119,14 @@ public class TestNodeId extends BaseTest
     @Test public void nodeId_decimal_6()
     { test("-2412.80478192688",  (Node)null) ; }
 
-    
+    @Test public void nodeId_decimal_7()
+    { test("'0.00000001'^^xsd:decimal",  
+           NodeFactory.createLiteral("0.00000001", null, XSDDatatype.XSDdecimal)) ; 
+    }
+
+    @Test public void nodeId_decimal_8()
+    { test("0.00000001", NodeFactory.createLiteral("0.00000001", null, XSDDatatype.XSDdecimal))
; }
+
     @Test public void nodeId_dateTime_01()
     { test("'2008-04-28T15:36:15+01:00'^^xsd:dateTime") ; }
 



Mime
View raw message