jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1616500 - in /jena/trunk: jena-arq/src/main/java/org/apache/jena/riot/out/ jena-arq/src/test/java/org/apache/jena/riot/out/ jena-tdb/src/main/java/com/hp/hpl/jena/tdb/lib/ jena-tdb/src/main/java/com/hp/hpl/jena/tdb/nodetable/
Date Thu, 07 Aug 2014 14:38:52 GMT
Author: andy
Date: Thu Aug  7 14:38:51 2014
New Revision: 1616500

URL: http://svn.apache.org/r1616500
Log:
JENA-760 : Correct the implementation of str(Node)

Modified:
    jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/out/NodeFmtLib.java
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/out/TestNodeFmtLib.java
    jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/lib/DumpOps.java
    jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodecLib.java

Modified: jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/out/NodeFmtLib.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/out/NodeFmtLib.java?rev=1616500&r1=1616499&r2=1616500&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/out/NodeFmtLib.java (original)
+++ jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/out/NodeFmtLib.java Thu Aug  7
14:38:51 2014
@@ -39,7 +39,6 @@ import com.hp.hpl.jena.rdf.model.RDFNode
 import com.hp.hpl.jena.shared.PrefixMapping ;
 import com.hp.hpl.jena.sparql.ARQConstants ;
 import com.hp.hpl.jena.sparql.core.Quad ;
-import com.hp.hpl.jena.sparql.util.FmtUtils ;
 
 /** Presentation utilitiles for Nodes, Triples, Quads and more.
  * <p>
@@ -54,7 +53,9 @@ public class NodeFmtLib
     // See OutputLangUtils.
     // See and use EscapeStr
     
-    static PrefixMap dftPrefixMap = PrefixMapFactory.create() ;
+    private static final NodeFormatter plainFormatter = new NodeFormatterNT() ;
+    
+    private static PrefixMap dftPrefixMap = PrefixMapFactory.create() ;
     static {
         PrefixMapping pm = ARQConstants.getGlobalPrefixMap() ;
         Map<String, String> map = pm.getNsPrefixMap() ;
@@ -82,11 +83,13 @@ public class NodeFmtLib
     /** A displayable string for an RDFNode. Includes common abbreviations */
     public static String displayStr(RDFNode obj)
     {
-        //XXX Move code over
-        return FmtUtils.stringForRDFNode(obj) ;
+        return displayStr(obj.asNode()) ;
     }
     
-    public static String displayStr(Node n) { return FmtUtils.stringForNode(n) ; }
+    public static String displayStr(Node n)
+    { 
+        return str(n, null, dftPrefixMap) ;
+    }
 
     
     // Worker
@@ -126,9 +129,11 @@ public class NodeFmtLib
     
     public static void serialize(IndentedWriter w, Node n, String base, PrefixMap prefixMap)
     {
-        if ( prefixMap == null )
-            prefixMap = dftPrefixMap ;
-        NodeFormatter formatter = new NodeFormatterTTL(base, prefixMap) ;
+        NodeFormatter formatter ;
+        if ( base == null && prefixMap == null )
+            formatter = plainFormatter ;
+        else 
+            formatter = new NodeFormatterTTL(base, prefixMap) ;
         formatter.format(w, n) ;
     }
     

Modified: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/out/TestNodeFmtLib.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/out/TestNodeFmtLib.java?rev=1616500&r1=1616499&r2=1616500&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/out/TestNodeFmtLib.java (original)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/out/TestNodeFmtLib.java Thu Aug
 7 14:38:51 2014
@@ -61,9 +61,14 @@ public class TestNodeFmtLib extends Base
     }
 
     @Test public void fmtNode_01() { test ("<a>", "<a>") ; }
-    @Test public void fmtNode_02() { test ("<"+RDF.getURI()+"type>", "rdf:type") ;
}
-    @Test public void fmtNode_03() { test ("'123'^^xsd:integer", "123") ; }
-    @Test public void fmtNode_04() { test ("'abc'^^xsd:integer", "\"abc\"^^xsd:integer")
; }
+    
+    @Test public void fmtNode_02() { test ("<"+RDF.getURI()+"type>", "<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>")
; }
+    @Test public void fmtNode_03() { test ("'123'^^xsd:integer", "\"123\"^^<http://www.w3.org/2001/XMLSchema#integer>")
; }
+    @Test public void fmtNode_04() { test ("'abc'^^xsd:integer", "\"abc\"^^<http://www.w3.org/2001/XMLSchema#integer>")
; }
+
+    @Test public void fmtNode_05() { testDisplay ("<"+RDF.getURI()+"type>", "rdf:type")
; }
+    @Test public void fmtNode_06() { testDisplay ("'123'^^xsd:integer", "123") ; }
+    @Test public void fmtNode_07() { testDisplay ("'abc'^^xsd:integer", "\"abc\"^^xsd:integer")
; }
     
     private static void test(String node, String output)
     { test(NodeFactoryExtra.parseNode(node) , output) ; }
@@ -73,4 +78,14 @@ public class TestNodeFmtLib extends Base
         String x = NodeFmtLib.str(node) ;
         assertEquals(output, x) ;
     }
+    
+    private static void testDisplay(String node, String output)
+    { testDisplay(NodeFactoryExtra.parseNode(node) , output) ; }
+    
+    private static void testDisplay(Node node, String output)
+    {
+        String x = NodeFmtLib.displayStr(node) ;
+        assertEquals(output, x) ;
+    }
+
 }

Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/lib/DumpOps.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/lib/DumpOps.java?rev=1616500&r1=1616499&r2=1616500&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/lib/DumpOps.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/lib/DumpOps.java Thu Aug  7 14:38:51
2014
@@ -111,7 +111,7 @@ public class DumpOps
             Pair<NodeId, Node> pair = iter.next() ;
             NodeId nid = pair.car() ;
             Node n = pair.cdr();
-            String x = NodeFmtLib.str(n) ;
+            String x = NodeFmtLib.displayStr(n) ;
             System.out.printf("%016X %s\n", nid.getId(), x) ; 
         }
         dumpedNodeTables.add(nodeTable) ;

Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodecLib.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodecLib.java?rev=1616500&r1=1616499&r2=1616500&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodecLib.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/nodetable/NodecLib.java Thu Aug
 7 14:38:51 2014
@@ -36,15 +36,18 @@ import com.hp.hpl.jena.tdb.lib.NodeLib ;
 
 public class NodecLib
 {
+    // STATUS UNCLEAR.
+    // privateize the operations until checked.
+    
     // Better sharing with NodecSSE
     
     // Characters in IRIs that are illegal and cause SSE problems, but we wish to keep.
     final private static char MarkerChar = '_' ;
     final private static char[] invalidIRIChars = { MarkerChar , ' ' } ; 
     
-    public static String encode(Node node) { return encode(node, null) ; }
+    private /*public*/ static String encode(Node node) { return encode(node, null) ; }
 
-    public static String encode(Node node, PrefixMapping pmap)
+    private /*public*/ static String encode(Node node, PrefixMapping pmap)
     {
         if ( node.isBlank() )
             // Raw label.
@@ -61,9 +64,9 @@ public class NodecLib
         return NodeFmtLib.str(node) ;
     }
 
-    public static Node decode(String s)     { return decode(s, null) ; }
+    private /*public*/ static Node decode(String s)     { return decode(s, null) ; }
     
-    public static Node decode(String s, PrefixMapping pmap)
+    private /*public*/ static Node decode(String s, PrefixMapping pmap)
     {
         if ( s.startsWith("_:") )   
         {



Mime
View raw message