jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1135693 - in /incubator/jena/Jena2/ARQ/trunk: D.nt Q.rq src-dev/dev/RunARQ.java src/org/openjena/riot/system/ParserProfile.java src/org/openjena/riot/system/ParserProfileBase.java src/org/openjena/riot/tokens/Token.java
Date Tue, 14 Jun 2011 16:45:07 GMT
Author: andy
Date: Tue Jun 14 16:45:07 2011
New Revision: 1135693

URL: http://svn.apache.org/viewvc?rev=1135693&view=rev
Log:
Token to Node.ANY - JENA-71

Modified:
    incubator/jena/Jena2/ARQ/trunk/D.nt
    incubator/jena/Jena2/ARQ/trunk/Q.rq
    incubator/jena/Jena2/ARQ/trunk/src-dev/dev/RunARQ.java
    incubator/jena/Jena2/ARQ/trunk/src/org/openjena/riot/system/ParserProfile.java
    incubator/jena/Jena2/ARQ/trunk/src/org/openjena/riot/system/ParserProfileBase.java
    incubator/jena/Jena2/ARQ/trunk/src/org/openjena/riot/tokens/Token.java

Modified: incubator/jena/Jena2/ARQ/trunk/D.nt
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/D.nt?rev=1135693&r1=1135692&r2=1135693&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/D.nt (original)
+++ incubator/jena/Jena2/ARQ/trunk/D.nt Tue Jun 14 16:45:07 2011
@@ -0,0 +1 @@
+ANY <http://example/> "123" .

Modified: incubator/jena/Jena2/ARQ/trunk/Q.rq
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/Q.rq?rev=1135693&r1=1135692&r2=1135693&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/Q.rq (original)
+++ incubator/jena/Jena2/ARQ/trunk/Q.rq Tue Jun 14 16:45:07 2011
@@ -1,4 +1,5 @@
-SELECT (GROUP_CONCAT(?o ; SEPARATOR = ":" ) AS ?c)
+PREFIX : <http://example/>
+SELECT *
 {
-  ?s ?p ?o
-} GROUP BY ?o
\ No newline at end of file
+  <http://example/s> <http://example/p> 123 .
+}
\ No newline at end of file

Modified: incubator/jena/Jena2/ARQ/trunk/src-dev/dev/RunARQ.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src-dev/dev/RunARQ.java?rev=1135693&r1=1135692&r2=1135693&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src-dev/dev/RunARQ.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src-dev/dev/RunARQ.java Tue Jun 14 16:45:07 2011
@@ -8,6 +8,8 @@
 
 package dev;
 
+import java.io.PrintWriter ;
+import java.io.Writer ;
 import java.util.Iterator ;
 import java.util.NoSuchElementException ;
 import java.util.concurrent.ArrayBlockingQueue ;
@@ -23,10 +25,14 @@ import org.openjena.atlas.lib.Sink ;
 import org.openjena.atlas.lib.StrUtils ;
 import org.openjena.atlas.logging.Log ;
 import org.openjena.riot.ErrorHandlerFactory ;
+import org.openjena.riot.Lang ;
 import org.openjena.riot.RiotReader ;
 import org.openjena.riot.checker.CheckerIRI ;
 import org.openjena.riot.out.NodeFmtLib ;
+import org.openjena.riot.out.OutputLangUtils ;
 import org.openjena.riot.pipeline.normalize.CanonicalizeLiteral ;
+import org.openjena.riot.system.ParserProfile ;
+import org.openjena.riot.system.RiotLib ;
 import org.openjena.riot.tokens.Token ;
 import org.openjena.riot.tokens.Tokenizer ;
 import org.openjena.riot.tokens.TokenizerFactory ;
@@ -108,7 +114,8 @@ public class RunARQ
     }
 
     public static void exit(int code)
-    {System.out.flush() ;
+    {
+        System.out.flush() ;
         System.out.println("DONE") ;
         System.exit(code) ;
     }
@@ -118,6 +125,28 @@ public class RunARQ
     
     public static void main(String[] argv) throws Exception
     {
+        
+        ParserProfile p = RiotLib.profile(Lang.NTRIPLES, null) ;
+        {
+            Writer w = new PrintWriter(System.out) ; 
+            OutputLangUtils.output(w, Node.ANY, null, null) ;
+            w.write("\n") ;
+            w.flush();
+            
+            
+            Tokenizer tokenizer = TokenizerFactory.makeTokenizerString("ANY <123> KW.")
;
+            for ( ; tokenizer.hasNext() ; )
+            {
+                Token t = tokenizer.next() ;
+                System.out.println(t) ;
+                if ( t.isNode() )
+                    System.out.println("==> "+t.asNode()) ;
+                Node n = p.create(null, t) ;
+                System.out.println("--> "+n) ;
+            }
+            exit(0) ;
+        }
+
         Node node1 = Node_Blank.createAnon();
         String str = NodeFmtLib.serialize(node1);
         Tokenizer tokenizer = TokenizerFactory.makeTokenizerString(str);

Modified: incubator/jena/Jena2/ARQ/trunk/src/org/openjena/riot/system/ParserProfile.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/org/openjena/riot/system/ParserProfile.java?rev=1135693&r1=1135692&r2=1135693&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/org/openjena/riot/system/ParserProfile.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src/org/openjena/riot/system/ParserProfile.java Tue Jun
14 16:45:07 2011
@@ -33,6 +33,9 @@ public interface ParserProfile
     public Node createPlainLiteral(String lexical, long line, long col) ;
     public Node createBlankNode(Node scope, String label, long line, long col) ;
     
+    /** Make a node from a token - called after all else has been tried - return null for
no such node */
+    public Node createNodeFromToken(Node scope, Token token, long line, long col) ;
+    
     /** Make any node from a token as appropriate */
     public Node create(Node currentGraph, Token token) ;
     

Modified: incubator/jena/Jena2/ARQ/trunk/src/org/openjena/riot/system/ParserProfileBase.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/org/openjena/riot/system/ParserProfileBase.java?rev=1135693&r1=1135692&r2=1135693&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/org/openjena/riot/system/ParserProfileBase.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src/org/openjena/riot/system/ParserProfileBase.java Tue
Jun 14 16:45:07 2011
@@ -10,6 +10,7 @@ import org.openjena.riot.ErrorHandler ;
 import org.openjena.riot.RiotException ;
 import org.openjena.riot.lang.LabelToNode ;
 import org.openjena.riot.tokens.Token ;
+import org.openjena.riot.tokens.TokenType ;
 
 import com.hp.hpl.jena.datatypes.RDFDatatype ;
 import com.hp.hpl.jena.datatypes.xsd.XSDDatatype ;
@@ -119,6 +120,19 @@ public class ParserProfileBase implement
     {
         return Node.createLiteral(lexical) ;
     }
+    
+    /** Special token forms*/ 
+    //@Override
+    public Node createNodeFromToken(Node scope, Token token, long line, long col)
+    {
+        // OFF - Don't produce Node.ANY by default. 
+        if ( false && token.getType() == TokenType.KEYWORD )
+        {
+            if ( Token.ImageANY.equals(token.getImage()) )
+                return Node.ANY ;
+        }
+        return null ;
+    }
 
     //@Override
     public Node create(Node currentGraph, Token token)
@@ -177,10 +191,14 @@ public class ParserProfileBase implement
             case LONG_STRING1:
             case LONG_STRING2:
                 return createPlainLiteral(str, line, col) ;
-            // XXX Centralize exceptions
             default: 
+            {
+                Node x = createNodeFromToken(currentGraph, token, line, col) ;
+                if ( x != null )
+                    return x ;
                 errorHandler.fatal("Not a valid token for an RDF term: "+token, line , col)
;
                 return null ;
+            }
         }
     }
     

Modified: incubator/jena/Jena2/ARQ/trunk/src/org/openjena/riot/tokens/Token.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/org/openjena/riot/tokens/Token.java?rev=1135693&r1=1135692&r2=1135693&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/org/openjena/riot/tokens/Token.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src/org/openjena/riot/tokens/Token.java Tue Jun 14 16:45:07
2011
@@ -57,7 +57,7 @@ public final class Token
     private long line ;
     
     // Keywords recognized.
-    static final private String ImageANY = "ANY" ;
+    public static final String ImageANY = "ANY" ;
     
     public final TokenType getType() { return tokenType ; }
     public final String getImage()   { return tokenImage ; }
@@ -347,7 +347,7 @@ public final class Token
     {
         switch(tokenType)
         {
-            // Assumes that bnode labes have been sorted out already.
+            // Assumes that bnode labels have been sorted out already.
             case BNODE : return Node.createAnon(new AnonId(tokenImage)) ;
             case IRI :   return Node.createURI(tokenImage) ; 
             case PREFIXED_NAME :



Mime
View raw message