jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1305317 [6/6] - in /incubator/jena/Jena2/ARQ/trunk: Grammar/ src/main/java/com/hp/hpl/jena/query/ src/main/java/com/hp/hpl/jena/sparql/algebra/ src/main/java/com/hp/hpl/jena/sparql/algebra/table/ src/main/java/com/hp/hpl/jena/sparql/core/ ...
Date Mon, 26 Mar 2012 11:46:10 GMT
Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/serializer/QuerySerializer.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/serializer/QuerySerializer.java?rev=1305317&r1=1305316&r2=1305317&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/serializer/QuerySerializer.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/serializer/QuerySerializer.java
Mon Mar 26 11:46:09 2012
@@ -262,36 +262,52 @@ public class QuerySerializer implements 
         if ( query.hasBindings() )
         {
             out.print("BINDINGS") ;
-            for ( Var v : query.getBindingVariables() )
+            outputDataBlock(out, query.getBindingsVariables(), query.getBindingsData(), query)
;
+        }
+    }
+
+    @Override
+    public void visitValues(Query query)
+    {
+        if ( query.hasValues() )
+        {
+            out.print("VALUES") ;
+            outputDataBlock(out, query.getValuesVariables(), query.getValuesData(),query)
;
+        }
+    }
+    
+    private static void outputDataBlock(IndentedWriter out, List<Var> variables, List<Binding>
values, Query query)
+    {
+        for ( Var v : variables )
+        {
+            out.print(" ") ;
+            out.print(v) ;
+        }
+        out.println();
+
+        out.print("{") ;
+        out.incIndent() ;
+        out.println() ;
+        for ( Binding valueRow : values )
+        {
+            // A value may be null for UNDEF
+            out.print("(") ;
+            for ( Var var : variables )
             {
                 out.print(" ") ;
-                out.print(v) ;
-            }
-            out.println();
-            
-            out.print("{") ;
-            out.incIndent() ;
-            out.println() ;
-            for ( Binding valueRow : query.getBindingValues() )
-            {
-                // A value may be null for UNDEF
-                out.print("(") ;
-                for ( Var var : query.getBindingVariables() )
-                {
-                    out.print(" ") ;
-                    Node value = valueRow.get(var) ; 
-                    if ( value == null )
-                        out.print("UNDEF") ;
-                    else
-                        out.print(FmtUtils.stringForNode(value, query)) ;
-                }
-                out.println(" )") ;
+                Node value = valueRow.get(var) ; 
+                if ( value == null )
+                    out.print("UNDEF") ;
+                else
+                    out.print(FmtUtils.stringForNode(value, query)) ;
             }
-            out.decIndent() ;
-            out.print("}") ;
-            out.println() ;
+            out.println(" )") ;
         }
+        out.decIndent() ;
+        out.print("}") ;
+        out.println() ;
     }
+    
 
     @Override
     public void finishVisit(Query query)



Mime
View raw message