001: /*
002: * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2007.
003: *
004: * Licensed under the Aduna BSD-style license.
005: */
006: package org.openrdf.query.parser;
007:
008: import org.openrdf.query.Dataset;
009: import org.openrdf.query.algebra.TupleExpr;
010:
011: /**
012: * Abstract super class of all query types that a query parser can generate.
013: *
014: * @author Arjohn Kampman
015: */
016: public abstract class ParsedQuery {
017:
018: /*-----------*
019: * Variables *
020: *-----------*/
021:
022: /**
023: * A tuple expression representing the actual query, formulated in OpenRDF
024: * Query Algebra objects.
025: */
026: private TupleExpr tupleExpr;
027:
028: /**
029: * The dataset that was specified in the query, if any.
030: */
031: private Dataset dataset;
032:
033: /*--------------*
034: * Constructors *
035: *--------------*/
036:
037: /**
038: * Creates a new query object. To complete this query, a tuple expression
039: * needs to be supplied to it using {@link #setTupleExpr(TupleExpr)}.
040: */
041: public ParsedQuery() {
042: }
043:
044: /**
045: * Creates a new query object.
046: *
047: * @param tupleExpr
048: * The tuple expression underlying this query.
049: */
050: public ParsedQuery(TupleExpr tupleExpr) {
051: setTupleExpr(tupleExpr);
052: }
053:
054: /**
055: * Creates a new query object.
056: *
057: * @param tupleExpr
058: * The tuple expression underlying this query.
059: */
060: public ParsedQuery(TupleExpr tupleExpr, Dataset dataset) {
061: this (tupleExpr);
062: setDataset(dataset);
063: }
064:
065: /*---------*
066: * Methods *
067: *---------*/
068:
069: /**
070: * Gets the tuple expression underlying this query.
071: */
072: public void setTupleExpr(TupleExpr tupleExpr) {
073: assert tupleExpr != null : "tupleExpr must not be null";
074: this .tupleExpr = tupleExpr;
075: }
076:
077: /**
078: * Gets the tuple expression underlying this query.
079: */
080: public TupleExpr getTupleExpr() {
081: return tupleExpr;
082: }
083:
084: public Dataset getDataset() {
085: return dataset;
086: }
087:
088: public void setDataset(Dataset dataset) {
089: this .dataset = dataset;
090: }
091:
092: /**
093: * Returns a string representation of the query that can be used for
094: * debugging.
095: */
096: @Override
097: public String toString() {
098: return tupleExpr.toString();
099: }
100: }
|