jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1175838 - in /incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset: JSONInput.java JSONObjectResult.java JSONOutputASK.java JSONOutputResultSet.java JSONResults.java
Date Mon, 26 Sep 2011 12:42:08 GMT
Author: andy
Date: Mon Sep 26 12:42:08 2011
New Revision: 1175838

URL: http://svn.apache.org/viewvc?rev=1175838&view=rev
Log:
Finish rewrite of JSON results format:
1/ Follow draft spec.
2/ use Atlas JSON subsystem
3/ Delete unused class

Removed:
    incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/JSONObjectResult.java
Modified:
    incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/JSONInput.java
    incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/JSONOutputASK.java
    incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/JSONOutputResultSet.java
    incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/JSONResults.java

Modified: incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/JSONInput.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/JSONInput.java?rev=1175838&r1=1175837&r2=1175838&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/JSONInput.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/JSONInput.java Mon
Sep 26 12:42:08 2011
@@ -61,11 +61,10 @@ import com.hp.hpl.jena.sparql.util.graph
 
 /**
  * Code that reads a JSON Result Set and builds the ARQ structure for the same.
- * Originally from Elias Torres &lt;<a href="mailto:elias@torrez.us">elias@torrez.us</a>&gt;
- * Updated to not use org.json code : Andy Seaborne (2010)
  */
 public class JSONInput extends SPARQLResult
-{
+{
+    // This is like the XML reader but JSOn terms not XML tags.  
     public JSONInput(InputStream in)
     {
         this(in, null) ;
@@ -134,10 +133,6 @@ public class JSONInput extends SPARQLRes
 
         // Type
         boolean isResultSet = false;
-
-        // Result set
-        boolean ordered = false;
-        boolean distinct = false;
         boolean finished = false;
 
         Model model = null;
@@ -173,7 +168,6 @@ public class JSONInput extends SPARQLRes
         private void init() {
             processHead();
 
-            // Next should be a <result>, <boolean> element or </results>
             // Need to decide what sort of thing we are reading.
             if (json.hasKey(dfResults)) {
                 isResultSet = true;
@@ -188,7 +182,7 @@ public class JSONInput extends SPARQLRes
 
         public boolean hasNext() {
             if (!isResultSet)
-                throw new ResultSetException("Not an XML result set");
+                throw new ResultSetException("Not a JSON result set");
 
             if (finished)
                 return false;
@@ -226,10 +220,6 @@ public class JSONInput extends SPARQLRes
 
         public List<String> getResultVars() { return variables; }
 
-        public boolean isOrdered() { return ordered; }
-
-        public boolean isDistinct() { return distinct; }
-
         // No model - it was from a stream
         public Model getResourceModel() { return null ; }
         
@@ -264,8 +254,9 @@ public class JSONInput extends SPARQLRes
                         variables.add(vars.get(i).getAsString().value()) ;
                 }
 
-                if (head.hasKey(dfLink)) {
-                    // We're being lazy for now.
+                if (head.hasKey(dfLink))
+                {
+                    //No processing for link.
                 }
             } catch (JsonException e) {
                 throw new ResultSetException(e.getMessage(), e) ;
@@ -277,8 +268,6 @@ public class JSONInput extends SPARQLRes
         private void processResults() {
             try {
                 JsonObject results = json.get(dfResults).getAsObject() ;
-//                ordered = results.getAsBoolean(dfOrdered) ;
-//                distinct = results.getBoolean(dfDistinct) ;
             } catch (JsonException e) {
                 throw new ResultSetException(e.getMessage(), e) ;
             }

Modified: incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/JSONOutputASK.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/JSONOutputASK.java?rev=1175838&r1=1175837&r2=1175838&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/JSONOutputASK.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/JSONOutputASK.java
Mon Sep 26 12:42:08 2011
@@ -27,12 +27,7 @@ import java.io.OutputStream ;
 import org.openjena.atlas.io.IO ;
 import org.openjena.atlas.json.io.JSWriter ;
 
-/** JSON Output (ASK format)
- * 
- * @author Elias Torres (<a href="mailto:elias@torrez.us">elias@torrez.us</a>)
- * Rewritten to remove use of org.json: Andy Seaborne (2010)
- */
-
+/** JSON Output (ASK format) */
 
 public class JSONOutputASK
 {
@@ -48,7 +43,7 @@ public class JSONOutputASK
         JSWriter out = new JSWriter(outStream) ;
         
         out.startOutput() ;
-        
+
         out.startObject() ;
         out.key(dfHead) ;
         out.startObject() ;

Modified: incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/JSONOutputResultSet.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/JSONOutputResultSet.java?rev=1175838&r1=1175837&r2=1175838&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/JSONOutputResultSet.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/JSONOutputResultSet.java
Mon Sep 26 12:42:08 2011
@@ -18,7 +18,7 @@
 
 package com.hp.hpl.jena.sparql.resultset;
 
-import static com.hp.hpl.jena.sparql.resultset.JSONResults.* ;
+import static com.hp.hpl.jena.sparql.resultset.JSONResults.* ;
 
 import java.io.OutputStream ;
 import java.util.HashMap ;
@@ -34,17 +34,16 @@ import com.hp.hpl.jena.query.ResultSet ;
 import com.hp.hpl.jena.rdf.model.Literal ;
 import com.hp.hpl.jena.rdf.model.RDFNode ;
 import com.hp.hpl.jena.rdf.model.Resource ;
-import org.openjena.atlas.logging.Log ;
+import org.openjena.atlas.logging.Log ;
+
 /**
- * A JSON writer for SPARQL Result Sets
- * 
- * Format: <a href="http://www.w3.org/2001/sw/DataAccess/json-sparql/">Serializing
SPARQL Query Results in JSON</a> 
+ * A JSON writer for SPARQL Result Sets.  Uses jena' atlas JSON support. 
  * 
- * JSON: <a href="http://json.org">http://json.org/</a> */
+ * Format: <a href="http://www.w3.org/TR/sparql11-results-json/">SPARQL 1.1 Query Results
JSON Format</a> 
+ */ 
 
 public class JSONOutputResultSet implements ResultSetProcessor
 {
-    // XXX JSONOutputResultSet - Could improve the streaming - minor. 
     static boolean multiLineValues = false ;
     static boolean multiLineVarNames = false ;
     
@@ -68,8 +67,6 @@ public class JSONOutputResultSet impleme
         doHead(rs) ;
         out.println(quoteName(dfResults)+": {") ;
         out.incIndent() ;
-//        out.println(quoteName(dfDistinct)+": "+(rs.isDistinct()?"true":"false")+" ,") ;
-//        out.println(quoteName(dfOrdered)+": " +(rs.isOrdered() ?"true":"false")+" ,") ;
         out.println(quoteName(dfBindings)+": [") ;
         out.incIndent() ;
         firstSolution = true ;

Modified: incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/JSONResults.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/JSONResults.java?rev=1175838&r1=1175837&r2=1175838&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/JSONResults.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/JSONResults.java Mon
Sep 26 12:42:08 2011
@@ -18,32 +18,29 @@
 
 package com.hp.hpl.jena.sparql.resultset;
 
-
-/**
- * @author Elias Torres (<a href="mailto:elias@torrez.us">elias@torrez.us</a>)
- */
 public class JSONResults
 {
     public static final int INDENT = 2 ;
         
-    public static final String dfHead       = "head" ;
-    public static final String dfVars       = "vars" ;
-    public static final String dfLink       = "link" ;
-    public static final String dfResults    = "results" ;
-    public static final String dfBindings   = "bindings" ;
-    public static final String dfBoolean    = "boolean" ;
-    
+    public static final String dfHead           = "head" ;
+    public static final String dfVars           = "vars" ;
+    public static final String dfLink           = "link" ;
+    public static final String dfResults        = "results" ;
+    public static final String dfBindings       = "bindings" ;
+    public static final String dfBoolean        = "boolean" ;
+    
+    // Not part of SPARQl results formats any more. 
 //    public static final String dfOrdered    = "ordered" ;
 //    public static final String dfDistinct   = "distinct" ;
     
-    public static final String dfType       = "type" ;
-    public static final String dfValue      = "value" ;
-    public static final String dfDatatype   = "datatype" ;
-    public static final String dfLang       = "xml:lang" ;
+    public static final String dfType           = "type" ;
+    public static final String dfValue          = "value" ;
+    public static final String dfDatatype       = "datatype" ;
+    public static final String dfLang           = "xml:lang" ;
     
     public static final String dfBNode          = "bnode" ;
     public static final String dfURI            = "uri" ;
     public static final String dfLiteral        = "literal" ;
     public static final String dfTypedLiteral   = "typed-literal" ;  
-    public static final String dfUnbound    = "unbound" ;
+    public static final String dfUnbound        = "unbound" ;
 }



Mime
View raw message