[Mulgara-svn] r601 - in branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql: . cst
pag at mulgara.org
pag at mulgara.org
Sun Dec 9 20:35:31 UTC 2007
Author: pag
Date: 2007-12-09 14:35:30 -0600 (Sun, 09 Dec 2007)
New Revision: 601
Added:
branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/SelectParser.java
branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/VariableAccumulator.java
branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/BlankNode.java
branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/IRIReference.java
Removed:
branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/IRIPredicate.java
Modified:
branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/SparqlInterpreter.java
branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/GraphElementVisitor.java
branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/GroupGraphPattern.java
branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/PredicateVisitor.java
branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/SelectQuery.java
Log:
Modifying classes to manage new grammar and lexer definitions. Not yet compiling
Added: branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/SelectParser.java
===================================================================
--- branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/SelectParser.java 2007-12-05 10:10:04 UTC (rev 600)
+++ branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/SelectParser.java 2007-12-09 20:35:30 UTC (rev 601)
@@ -0,0 +1,85 @@
+/**
+ * The contents of this file are subject to the Open Software License
+ * Version 3.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+package org.mulgara.sparql;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.mulgara.query.ConstraintExpression;
+import org.mulgara.query.ModelExpression;
+import org.mulgara.query.Order;
+import org.mulgara.sparql.cst.SelectQuery;
+
+/**
+ * A class for converting a CST SelectQuery into data useable for the AST.
+ *
+ * @created December 5, 2007
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class SelectParser {
+
+ /** The CST object representing a SelectQuery */
+ private SelectQuery select;
+
+ public SelectParser(SelectQuery select) {
+ this.select = select;
+ }
+
+ public List<Object> getVariables() {
+ List<String> vars = select.getVariables();
+ return (vars == null) ? allVariables() : buildVarList(vars);
+ }
+
+ public ConstraintExpression getConstraintExpression() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ModelExpression getModelExpression() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<Order> getOrderList() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Integer getLimit() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getOffset() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ private List<Object> allVariables() {
+ VariableAccumulator varAcc = new VariableAccumulator(select.getWhere());
+ return null;
+ }
+
+ /**
+ * Creates a list of {@link org.mulgara.query.Variable}s out of the variable names in the Select clause.
+ * @param varNames The string representations of each variable name.
+ * @return A list of all requested variables.
+ */
+ private List<Object> buildVarList(List<String> varNames) {
+ List<Object> varList = new ArrayList<Object>();
+ for (String varName: varNames) varList.add(new org.mulgara.query.Variable(varName));
+ return varList;
+ }
+
+}
Modified: branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/SparqlInterpreter.java
===================================================================
--- branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/SparqlInterpreter.java 2007-12-05 10:10:04 UTC (rev 600)
+++ branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/SparqlInterpreter.java 2007-12-09 20:35:30 UTC (rev 601)
@@ -19,17 +19,22 @@
import org.mulgara.parser.Interpreter;
import org.mulgara.parser.MulgaraLexerException;
import org.mulgara.parser.MulgaraParserException;
+import org.mulgara.query.ConstraintExpression;
+import org.mulgara.query.ConstraintHaving;
+import org.mulgara.query.ModelExpression;
+import org.mulgara.query.Order;
import org.mulgara.query.Query;
+import org.mulgara.query.UnconstrainedAnswer;
import org.mulgara.query.operation.Command;
import org.mulgara.sparql.compiler.ExpressionParser;
import org.mulgara.sparql.compiler.ExpressionScanner;
+import org.mulgara.sparql.cst.SparqlQuery;
import org.mulgara.sparql.cst.SelectQuery;
-import org.mulgara.sparql.cst.SparqlQuery;
import beaver.Parser;
/**
- * Interpreter for SPARQL queries.
+ * Interpreter for SPARQL query strings into {@link org.mulgara.query.operation.Command} objects.
*
* @created December 4, 2007
* @author Paul Gearon
@@ -39,6 +44,7 @@
public class SparqlInterpreter implements Interpreter {
/**
+ * Parses a string into a {@link org.mulgara.query.operation.Command} object (an AST object).
* @see org.mulgara.parser.Interpreter#parseCommand(java.lang.String)
*/
public Command parseCommand(String command) throws MulgaraParserException, MulgaraLexerException, IllegalArgumentException, IOException {
@@ -55,7 +61,8 @@
}
/**
- * Only handles a single query
+ * Parses a string containing multiple queries. SPARQL does not support multiple queries, so this only
+ * looks for a single command.
* @see org.mulgara.parser.Interpreter#parseCommands(java.lang.String)
*/
public List<Command> parseCommands(String command) throws MulgaraParserException, MulgaraLexerException, IOException, IllegalArgumentException {
@@ -65,7 +72,9 @@
}
/**
- * Parses a query. Throws an exception if the string results in some other type of command.
+ * Parses a query. This is the same as a command that can return a result. All commands in SPARQL
+ * can return a result, so this is the same as {@see #parseCommand(String)}.
+ * Throws an exception if the string results in some other type of command.
* @see org.mulgara.parser.Interpreter#parseQuery(java.lang.String)
*/
public Query parseQuery(String queryString) throws IOException, MulgaraLexerException, MulgaraParserException {
@@ -74,13 +83,54 @@
return (Query)cmd;
}
+ /**
+ * Callback from a {@link org.mulgara.sparql.cst.SelectQuery} to perform parsing on the object.
+ * @param select The SelectQuery to be parsed into a {@link org.mulgara.query.Query}
+ * @return A {@link org.mulgara.query.Query} as a {@link org.mulgara.query.operation.Command}.
+ */
public Command visit(SelectQuery select) {
- // TODO:
- return null;
+ SelectParser sel = new SelectParser(select);
+ List<Object> variableList = sel.getVariables();
+ ModelExpression modelExpression = sel.getModelExpression();
+ ConstraintExpression constraintExpression = sel.getConstraintExpression();
+ ConstraintHaving havingExpression = null;
+ List<Order> orderList = sel.getOrderList();
+ Integer limit = sel.getLimit(); // null indicates no limit
+ int offset = sel.getOffset();
+
+ // build a query using the information we've obtained from the parser
+ return new Query(variableList, modelExpression, constraintExpression,
+ havingExpression, orderList, limit, offset, new UnconstrainedAnswer());
}
-// TODO
-// public void visit(DescribeQuery describe) {
-//
-// }
+
+ // TODO
+ // /**
+ // * Callback from a {@link org.mulgara.sparql.cst.ConstructQuery} to perform parsing on the object.
+ // * @param construct The ConstructQuery to be parsed into a {@link org.mulgara.query.Query}
+ // * @return A {@link org.mulgara.query.Query} as a {@link org.mulgara.query.operation.Command}.
+ // */
+ // public void visit(ConstructQuery construct) {
+ //
+ // }
+
+ // TODO
+ // /**
+ // * Callback from a {@link org.mulgara.sparql.cst.AskQuery} to perform parsing on the object.
+ // * @param construct The AskQuery to be parsed into a {@link org.mulgara.query.Query}
+ // * @return A {@link org.mulgara.query.Query} as a {@link org.mulgara.query.operation.Command}.
+ // */
+ // public void visit(AskQuery ask) {
+ //
+ // }
+
+ // TODO
+ // /**
+ // * Callback from a {@link org.mulgara.sparql.cst.DescribeQuery} to perform parsing on the object.
+ // * @param construct The DescribeQuery to be parsed into a {@link org.mulgara.query.Query}
+ // * @return A {@link org.mulgara.query.Query} as a {@link org.mulgara.query.operation.Command}.
+ // */
+ // public void visit(DescribeQuery describe) {
+ //
+ // }
}
Added: branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/VariableAccumulator.java
===================================================================
--- branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/VariableAccumulator.java 2007-12-05 10:10:04 UTC (rev 600)
+++ branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/VariableAccumulator.java 2007-12-09 20:35:30 UTC (rev 601)
@@ -0,0 +1,297 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+
+package org.mulgara.sparql;
+
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.mulgara.sparql.cst.AndExpression;
+import org.mulgara.sparql.cst.BoundBuiltinCall;
+import org.mulgara.sparql.cst.Constraint;
+import org.mulgara.sparql.cst.DatatypeBuiltinCall;
+import org.mulgara.sparql.cst.DecimalExpression;
+import org.mulgara.sparql.cst.DivExpression;
+import org.mulgara.sparql.cst.DoubleExpression;
+import org.mulgara.sparql.cst.EqualsExpression;
+import org.mulgara.sparql.cst.FunctionCall;
+import org.mulgara.sparql.cst.GraphElementVisitor;
+import org.mulgara.sparql.cst.GraphGraphPatternElement;
+import org.mulgara.sparql.cst.GreaterThanEqualsExpression;
+import org.mulgara.sparql.cst.GreaterThanExpression;
+import org.mulgara.sparql.cst.GroupGraphPattern;
+import org.mulgara.sparql.cst.GroupOrUnionGraphPatternElement;
+import org.mulgara.sparql.cst.IntegerExpression;
+import org.mulgara.sparql.cst.IsBlankBuiltinCall;
+import org.mulgara.sparql.cst.IsIRIBuiltinCall;
+import org.mulgara.sparql.cst.IsLiteralBuiltinCall;
+import org.mulgara.sparql.cst.IsURIBuiltinCall;
+import org.mulgara.sparql.cst.LangBuiltinCall;
+import org.mulgara.sparql.cst.LangMatchesBuiltinCall;
+import org.mulgara.sparql.cst.LessThanEqualsExpression;
+import org.mulgara.sparql.cst.LessThanExpression;
+import org.mulgara.sparql.cst.MinusExpression;
+import org.mulgara.sparql.cst.MinusPrimaryExpression;
+import org.mulgara.sparql.cst.MultExpression;
+import org.mulgara.sparql.cst.NotEqualsExpression;
+import org.mulgara.sparql.cst.NotPrimaryExpression;
+import org.mulgara.sparql.cst.OptionalGraphPatternElement;
+import org.mulgara.sparql.cst.OrExpression;
+import org.mulgara.sparql.cst.PlusExpression;
+import org.mulgara.sparql.cst.PlusPrimaryExpression;
+import org.mulgara.sparql.cst.RegularExpression;
+import org.mulgara.sparql.cst.SameTermBuiltinCall;
+import org.mulgara.sparql.cst.StrBuiltinCall;
+import org.mulgara.sparql.cst.Triple;
+import org.mulgara.sparql.cst.VariableExpression;
+
+/**
+ * Traversese a query looking for all variables.
+ *
+ * @created Dec 5, 2007
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class VariableAccumulator implements GraphElementVisitor {
+
+ private GroupGraphPattern whereClause;
+
+ private Set<String> variables = new LinkedHashSet<String>();
+
+ public VariableAccumulator(GroupGraphPattern whereClause) {
+ this.whereClause = whereClause;
+ }
+
+ public void processForVariables() {
+ whereClause.accept(this);
+ }
+
+ public void visit(GroupGraphPattern element) {
+ List<Triple> triples = element.getInitialTripleBlock();
+ // TODO: triples only handle subjects of String - update grammar
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.OptionalGraphPatternElement)
+ */
+ public void visit(OptionalGraphPatternElement element) {
+ // TODO: variables may exist here
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.GroupOrUnionGraphPatternElement)
+ */
+ public void visit(GroupOrUnionGraphPatternElement element) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.GraphGraphPatternElement)
+ */
+ public void visit(GraphGraphPatternElement element) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.Constraint)
+ */
+ public void visit(Constraint constraint) {
+ // constraints are evaluated against existing variables
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.AndExpression)
+ */
+ public void visit(AndExpression expression) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.BoundBuiltinCall)
+ */
+ public void visit(BoundBuiltinCall call) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.DatatypeBuiltinCall)
+ */
+ public void visit(DatatypeBuiltinCall call) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.DecimalExpression)
+ */
+ public void visit(DecimalExpression expression) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.DivExpression)
+ */
+ public void visit(DivExpression expression) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.DoubleExpression)
+ */
+ public void visit(DoubleExpression expression) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.EqualsExpression)
+ */
+ public void visit(EqualsExpression expression) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.IntegerExpression)
+ */
+ public void visit(IntegerExpression expression) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.VariableExpression)
+ */
+ public void visit(VariableExpression expression) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.OrExpression)
+ */
+ public void visit(OrExpression expression) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.NotEqualsExpression)
+ */
+ public void visit(NotEqualsExpression expression) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.LessThanExpression)
+ */
+ public void visit(LessThanExpression expression) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.GreaterThanExpression)
+ */
+ public void visit(GreaterThanExpression expression) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.LessThanEqualsExpression)
+ */
+ public void visit(LessThanEqualsExpression expression) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.GreaterThanEqualsExpression)
+ */
+ public void visit(GreaterThanEqualsExpression expression) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.PlusExpression)
+ */
+ public void visit(PlusExpression expression) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.MinusExpression)
+ */
+ public void visit(MinusExpression expression) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.MultExpression)
+ */
+ public void visit(MultExpression expression) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.NotPrimaryExpression)
+ */
+ public void visit(NotPrimaryExpression expression) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.PlusPrimaryExpression)
+ */
+ public void visit(PlusPrimaryExpression expression) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.MinusPrimaryExpression)
+ */
+ public void visit(MinusPrimaryExpression expression) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.StrBuiltinCall)
+ */
+ public void visit(StrBuiltinCall builtin) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.LangBuiltinCall)
+ */
+ public void visit(LangBuiltinCall builtin) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.LangMatchesBuiltinCall)
+ */
+ public void visit(LangMatchesBuiltinCall builtin) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.SameTermBuiltinCall)
+ */
+ public void visit(SameTermBuiltinCall builtin) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.IsIRIBuiltinCall)
+ */
+ public void visit(IsIRIBuiltinCall builtin) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.IsURIBuiltinCall)
+ */
+ public void visit(IsURIBuiltinCall builtin) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.IsBlankBuiltinCall)
+ */
+ public void visit(IsBlankBuiltinCall builtin) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.IsLiteralBuiltinCall)
+ */
+ public void visit(IsLiteralBuiltinCall builtin) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.RegularExpression)
+ */
+ public void visit(RegularExpression builtin) {
+ }
+
+ /**
+ * @see org.mulgara.sparql.cst.GraphElementVisitor#visit(org.mulgara.sparql.cst.FunctionCall)
+ */
+ public void visit(FunctionCall call) {
+ }
+
+}
Added: branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/BlankNode.java
===================================================================
--- branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/BlankNode.java 2007-12-05 10:10:04 UTC (rev 600)
+++ branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/BlankNode.java 2007-12-09 20:35:30 UTC (rev 601)
@@ -0,0 +1,41 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+
+package org.mulgara.sparql.cst;
+
+import beaver.Symbol;
+
+/**
+ * A CST representation of a blank node. May be anonymous or labelled.
+ *
+ * @created Dec 7, 2007
+ * @author Paul Gearon
+ * @copyright © 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class BlankNode extends Symbol {
+
+ /**
+ * Create a blank node of no particular name.
+ */
+ public BlankNode() {
+ }
+
+ /**
+ * Creates a blank node with a label.
+ * @param label The label for a blank node
+ */
+ public BlankNode(String label) {
+ super(label);
+ }
+
+}
Modified: branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/GraphElementVisitor.java
===================================================================
--- branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/GraphElementVisitor.java 2007-12-05 10:10:04 UTC (rev 600)
+++ branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/GraphElementVisitor.java 2007-12-09 20:35:30 UTC (rev 601)
@@ -20,6 +20,7 @@
* @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
*/
public interface GraphElementVisitor {
+ void visit(GroupGraphPattern element);
void visit(Constraint constraint);
void visit(OptionalGraphPatternElement element);
void visit(GroupOrUnionGraphPatternElement element);
Modified: branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/GroupGraphPattern.java
===================================================================
--- branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/GroupGraphPattern.java 2007-12-05 10:10:04 UTC (rev 600)
+++ branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/GroupGraphPattern.java 2007-12-09 20:35:30 UTC (rev 601)
@@ -22,7 +22,7 @@
* @copyright © 2007 <a href="mailto:isidhu at fourthcodex.com">Inderbir Sidhu</a>
* @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
*/
-public class GroupGraphPattern extends Symbol {
+public class GroupGraphPattern extends Symbol implements GraphElementVisitable {
private List<Triple> beginningTriples;
private List<GraphElement> nonTriples;
@@ -66,4 +66,9 @@
}
return sb.toString();
}
+
+ public void accept(GraphElementVisitor visitor) {
+ visitor.visit(this);
+ }
+
}
Deleted: branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/IRIPredicate.java
===================================================================
--- branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/IRIPredicate.java 2007-12-05 10:10:04 UTC (rev 600)
+++ branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/IRIPredicate.java 2007-12-09 20:35:30 UTC (rev 601)
@@ -1,30 +0,0 @@
-/*
- * The contents of this file are subject to the Open Software License
- * Version 3.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.opensource.org/licenses/osl-3.0.txt
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- */
-
-package org.mulgara.sparql.cst;
-
-/**
- *
- * @created November 30, 2007
- * @author Inderbir Sidhu
- * @copyright © 2007 <a href="mailto:isidhu at fourthcodex.com">Inderbir Sidhu</a>
- * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
- */
-public class IRIPredicate extends Predicate {
- public IRIPredicate(String iriRef) {
- super(iriRef);
- }
-
- public void accept(PredicateVisitor visitor) {
- visitor.visit(this);
- }
-}
Copied: branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/IRIReference.java (from rev 598, branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/IRIPredicate.java)
===================================================================
--- branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/IRIPredicate.java 2007-12-04 21:40:59 UTC (rev 598)
+++ branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/IRIReference.java 2007-12-09 20:35:30 UTC (rev 601)
@@ -0,0 +1,30 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+
+package org.mulgara.sparql.cst;
+
+/**
+ *
+ * @created November 30, 2007
+ * @author Inderbir Sidhu
+ * @copyright © 2007 <a href="mailto:isidhu at fourthcodex.com">Inderbir Sidhu</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class IRIReference extends Predicate {
+ public IRIReference(String iriRef) {
+ super(iriRef);
+ }
+
+ public void accept(PredicateVisitor visitor) {
+ visitor.visit(this);
+ }
+}
Modified: branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/PredicateVisitor.java
===================================================================
--- branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/PredicateVisitor.java 2007-12-05 10:10:04 UTC (rev 600)
+++ branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/PredicateVisitor.java 2007-12-09 20:35:30 UTC (rev 601)
@@ -22,6 +22,6 @@
public interface PredicateVisitor {
void visit(ConstantPredicate p);
void visit(VariablePredicate p);
- void visit(IRIPredicate p);
+ void visit(IRIReference p);
void visit(URIPredicate p);
}
Modified: branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/SelectQuery.java
===================================================================
--- branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/SelectQuery.java 2007-12-05 10:10:04 UTC (rev 600)
+++ branches/mgr-61-sparql/src/jar/sparql/java/org/mulgara/sparql/cst/SelectQuery.java 2007-12-09 20:35:30 UTC (rev 601)
@@ -12,12 +12,16 @@
package org.mulgara.sparql.cst;
+import java.util.List;
+
import org.mulgara.query.operation.Command;
import org.mulgara.sparql.SparqlInterpreter;
import beaver.Symbol;
/**
+ * This object represents an entire SELECT query.
+ * {@linkplain http://www.w3.org/TR/rdf-sparql-query/#select}
*
* @created November 30, 2007
* @author Inderbir Sidhu
@@ -25,9 +29,9 @@
* @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
*/
public class SelectQuery extends Symbol implements SparqlQuery {
+
+ private List<String> variables;
- private Expr expr;
-
private From from;
private String distinct;
@@ -36,21 +40,29 @@
private SolutionModifier modifier;
- public SelectQuery(String distinct, From from, GroupGraphPattern where, SolutionModifier modifier) {
+ @SuppressWarnings("unchecked")
+ public SelectQuery(Symbol selectVars, String distinct, From from, GroupGraphPattern where, SolutionModifier modifier) {
+ Object vars = selectVars.value;
+ if (vars instanceof List) {
+ variables = (List<String>)vars;
+ } else if (vars instanceof String) {
+ assert "*".equals((String)vars) : "Non-variable in select clause is not *: " + vars;
+ variables = null;
+ } else throw new AssertionError("Unexpected object in variable list: " + vars.getClass());
this.from = from;
this.where = where;
this.distinct = distinct;
this.modifier = modifier;
}
+ public List<String> getVariables() {
+ return variables;
+ }
+
public String getDistinct() {
return distinct;
}
- public Expr getExpr() {
- return expr;
- }
-
public From getFrom() {
return from;
}
More information about the Mulgara-svn
mailing list