Author: rvesse
Date: Mon Jul 29 17:05:48 2013
New Revision: 1508136

URL: http://svn.apache.org/r1508136
Log:
Fix a bug in Query.cloneQuery() that can occur when using extended syntaxes
cloneQuery() relies of serializing the query and then parsing it back in.  For 
serialization it called serialize() which will result in an empty string
if the syntax is not one of the standard syntaxes that ARQ supports which then 
causes a QueryParseException to be thrown when trying to parse the
serialized form back in.  The commit changes the code to call toString() so 
extended query syntaxes can override toString() on their Query objects to
provide a valid serialization which can then be parsed back in

Modified:
    jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/query/Query.java
    jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/query/QueryFactory.java

Modified: jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/query/Query.java
URL: 
http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/query/Query.java?rev=1508136&r1=1508135&r2=1508136&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/query/Query.java 
(original)
+++ jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/query/Query.java Mon Jul 
29 17:05:48 2013
@@ -740,23 +740,10 @@ public class Query extends Prologue impl
      * Makes a copy of this query.  Copies by parsing a query from the 
serialized form of this query
      * @return Copy of this query
      */
-    public Query cloneQuery()
-    {
-       //By default clone from serialized form of this query
-       return cloneQuery(false);
-    }
-    
-    /**
-     * Makes a copy of this query.  May specify whether is cloned by parsing 
from original raw query or by parsing from serialized form of this query
-     * @param useRawQuery Copy from raw query if present
-     * @return Copy of this query
-     */
-    public Query cloneQuery(boolean useRawQuery)
-    {
+    public Query cloneQuery() {
         // A little crude.
-        IndentedLineBuffer buff = new IndentedLineBuffer() ;
-        serialize(buff, getSyntax()) ;
-        String qs = buff.toString() ;
+        // Must use toString() rather than serialize() because we may not know 
how to serialize extended syntaxes
+        String qs = this.toString();
         return QueryFactory.create(qs, getSyntax()) ;
     }
     

Modified: 
jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/query/QueryFactory.java
URL: 
http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/query/QueryFactory.java?rev=1508136&r1=1508135&r2=1508136&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/query/QueryFactory.java 
(original)
+++ jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/query/QueryFactory.java 
Mon Jul 29 17:05:48 2013
@@ -105,23 +105,6 @@ public class QueryFactory
         return originalQuery.cloneQuery() ;
     }
     
-    /**
-     * Make a query from another one by deep copy (a clone).
-     * The returned query will be .equals to the original.
-     * The returned query can be mutated without changing the
-     * original (at which point it will stop being .equals)
-     * 
-     * @param originalQuery  The query to clone.
-     * @param useRawQuery Whether to clone from the raw query string the 
original query was created from (if it is available)
-     *   
-     */
-
-    static public Query create(Query originalQuery, boolean useRawQuery)
-    {
-        return originalQuery.cloneQuery(useRawQuery) ;
-    }
-    
-
     /** Parse a query from the given string by calling the parser.
      *
      * @param query            Existing, uninitialized query


Reply via email to