01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 2006-2007.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.query.impl;
07:
08: import java.util.Collections;
09: import java.util.Iterator;
10: import java.util.Map;
11:
12: import info.aduna.iteration.CloseableIteration;
13: import info.aduna.iteration.CloseableIteratorIteration;
14: import info.aduna.iteration.IterationWrapper;
15:
16: import org.openrdf.model.Statement;
17: import org.openrdf.query.GraphQueryResult;
18: import org.openrdf.query.QueryEvaluationException;
19:
20: /**
21: * An utility implementation of the {@link GraphQueryResult} interface.
22: *
23: * @author Arjohn Kampman
24: * @author jeen
25: */
26: public class GraphQueryResultImpl extends
27: IterationWrapper<Statement, QueryEvaluationException> implements
28: GraphQueryResult {
29:
30: /*-----------*
31: * Variables *
32: *-----------*/
33:
34: private Map<String, String> namespaces;
35:
36: /*--------------*
37: * Constructors *
38: *--------------*/
39:
40: public GraphQueryResultImpl(Map<String, String> namespaces,
41: Iterable<? extends Statement> statements) {
42: this (namespaces, statements.iterator());
43: }
44:
45: public GraphQueryResultImpl(Map<String, String> namespaces,
46: Iterator<? extends Statement> statementIter) {
47: this (
48: namespaces,
49: new CloseableIteratorIteration<Statement, QueryEvaluationException>(
50: statementIter));
51: }
52:
53: public GraphQueryResultImpl(
54: Map<String, String> namespaces,
55: CloseableIteration<? extends Statement, ? extends QueryEvaluationException> statementIter) {
56: super (statementIter);
57: this .namespaces = Collections.unmodifiableMap(namespaces);
58: }
59:
60: /*---------*
61: * Methods *
62: *---------*/
63:
64: public Map<String, String> getNamespaces() {
65: return namespaces;
66: }
67: }
|