01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2007.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.query.parser;
07:
08: import java.util.Collections;
09: import java.util.Map;
10:
11: import org.openrdf.query.algebra.TupleExpr;
12:
13: /**
14: * A query forumalated in the OpenRDF query algebra that produces an RDF graph
15: * (a set of statements) as its result.
16: *
17: * @author Arjohn Kampman
18: */
19: public class ParsedGraphQuery extends ParsedQuery {
20:
21: /*-----------*
22: * Variables *
23: *-----------*/
24:
25: private Map<String, String> queryNamespaces;
26:
27: /*--------------*
28: * Constructors *
29: *--------------*/
30:
31: /**
32: * Creates a new graph query. To complete this query, a tuple expression
33: * needs to be supplied to it using {@link #setTupleExpr(TupleExpr)}.
34: */
35: public ParsedGraphQuery() {
36: super ();
37: }
38:
39: /**
40: * Creates a new graph query. To complete this query, a tuple expression
41: * needs to be supplied to it using {@link #setTupleExpr(TupleExpr)}.
42: *
43: * @param namespaces
44: * A mapping of namespace prefixes to namespace names representing the
45: * namespaces that are used in the query.
46: */
47: public ParsedGraphQuery(Map<String, String> namespaces) {
48: super ();
49: queryNamespaces = namespaces;
50: }
51:
52: /**
53: * Creates a new graph query for the supplied tuple expression.
54: *
55: * @param tupleExpr
56: * A tuple expression representing the query, formulated in Sail Query
57: * Model objects.
58: */
59: public ParsedGraphQuery(TupleExpr tupleExpr) {
60: super (tupleExpr);
61: }
62:
63: /**
64: * Creates a new graph query.
65: *
66: * @param tupleExpr
67: * A tuple expression representing the query, formulated in Sail Query
68: * Model objects.
69: * @param namespaces
70: * A mapping of namespace prefixes to namespace names representing the
71: * namespaces that are used in the query.
72: */
73: public ParsedGraphQuery(TupleExpr tupleExpr,
74: Map<String, String> namespaces) {
75: this (tupleExpr);
76: queryNamespaces = namespaces;
77: }
78:
79: /*---------*
80: * Methods *
81: *---------*/
82:
83: public Map<String, String> getQueryNamespaces() {
84: if (queryNamespaces != null) {
85: return queryNamespaces;
86: } else {
87: return Collections.emptyMap();
88: }
89: }
90: }
|