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.algebra;
07:
08: import java.util.Set;
09:
10: /**
11: * A generalized projection (allowing the bindings to be renamed) on a tuple
12: * expression.
13: */
14: public class Projection extends UnaryTupleOperator {
15:
16: /*-----------*
17: * Variables *
18: *-----------*/
19:
20: private ProjectionElemList projElemList = new ProjectionElemList();
21:
22: /*--------------*
23: * Constructors *
24: *--------------*/
25:
26: public Projection() {
27: }
28:
29: public Projection(TupleExpr arg) {
30: super (arg);
31: }
32:
33: public Projection(TupleExpr arg, ProjectionElemList elements) {
34: this (arg);
35: setProjectionElemList(elements);
36: }
37:
38: /*---------*
39: * Methods *
40: *---------*/
41:
42: public ProjectionElemList getProjectionElemList() {
43: return projElemList;
44: }
45:
46: public void setProjectionElemList(ProjectionElemList projElemList) {
47: this .projElemList = projElemList;
48: projElemList.setParentNode(this );
49: }
50:
51: @Override
52: public Set<String> getBindingNames() {
53: return projElemList.getTargetNames();
54: }
55:
56: public <X extends Exception> void visit(QueryModelVisitor<X> visitor)
57: throws X {
58: visitor.meet(this );
59: }
60:
61: @Override
62: public <X extends Exception> void visitChildren(
63: QueryModelVisitor<X> visitor) throws X {
64: projElemList.visit(visitor);
65: super .visitChildren(visitor);
66: }
67:
68: @Override
69: public void replaceChildNode(QueryModelNode current,
70: QueryModelNode replacement) {
71: if (projElemList == current) {
72: setProjectionElemList((ProjectionElemList) replacement);
73: } else {
74: super .replaceChildNode(current, replacement);
75: }
76: }
77:
78: @Override
79: public Projection clone() {
80: Projection clone = (Projection) super.clone();
81: clone.setProjectionElemList(getProjectionElemList().clone());
82: return clone;
83: }
84: }
|