You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by rv...@apache.org on 2012/11/15 19:43:42 UTC

svn commit: r1409920 - /jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/AlgebraGenerator.java

Author: rvesse
Date: Thu Nov 15 18:43:41 2012
New Revision: 1409920

URL: http://svn.apache.org/viewvc?rev=1409920&view=rev
Log:
Adds a future extension point to AlgebraGenerator to allow generation from unknown element types to be added by extending the class and overriding a compileUnknownElement() method

Modified:
    jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/AlgebraGenerator.java

Modified: jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/AlgebraGenerator.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/AlgebraGenerator.java?rev=1409920&r1=1409919&r2=1409920&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/AlgebraGenerator.java (original)
+++ jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/AlgebraGenerator.java Thu Nov 15 18:43:41 2012
@@ -136,8 +136,23 @@ public class AlgebraGenerator 
         if ( elt == null )
             return OpNull.create() ;
 
-        broken("compile(Element)/Not a structural element: "+Utils.className(elt)) ;
-        return null ;
+        return compileUnknownElement(elt, "compile(Element)/Not a structural element: "+Utils.className(elt));
+    }
+    
+    /**
+     * Future extension point to allow the algebra generator to be more easily extended to understand new {@link Element} implementations
+     * that user defined language extensions may introduce.
+     * <p>
+     * This default implementation will throw an error
+     * </p>
+     * @param elt Element
+     * @param error Error message if unable to compile the given element type
+     * @return Algebra
+     */
+    protected Op compileUnknownElement(Element elt, String error)
+    {
+        broken(error) ;
+        return null;
     }
     
     //Produce the algebra for a single group.
@@ -386,8 +401,7 @@ public class AlgebraGenerator 
 //        }
         
         
-        broken("compile/Element not recognized: "+Utils.className(elt)) ;
-        return null ;
+        return compileUnknownElement(elt, "compile/Element not recognized: "+Utils.className(elt));
     }
 
     private Op compileElementUnion(ElementUnion el)



Re: svn commit: r1409920 - /jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/AlgebraGenerator.java

Posted by Rob Vesse <rv...@yarcdata.com>.
We have some ideas on introducing extensions to the language which would
appear as new Element in a similar fashion to sub-queries or FILTER calls
but which would require implementing new Element types.  Since
AlgebraGenerator had no means to handle these we would otherwise have to
write our own generator, making this change makes it a simple extension to
AlgebraGenerator if these ideas ever come to fruition


Rob

On 11/16/12 8:39 AM, "Andy Seaborne" <an...@apache.org> wrote:

>Hi Rob,
>
>(curiosity)
>Where there any particular syntax extensions you had in mind?
>
>	Andy
>


Re: svn commit: r1409920 - /jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/AlgebraGenerator.java

Posted by Andy Seaborne <an...@apache.org>.
Hi Rob,

(curiosity)
Where there any particular syntax extensions you had in mind?

	Andy