01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.query.algebra;
07:
08: /**
09: * The BOUND function, as defined in <a
10: * href="http://www.w3.org/TR/rdf-sparql-query/#func-bound">SPARQL Query
11: * Language for RDF</a>; checks if a variable is bound.
12: *
13: * @author Arjohn Kampman
14: */
15: public class Bound extends QueryModelNodeBase implements ValueExpr {
16:
17: /*-----------*
18: * Variables *
19: *-----------*/
20:
21: /**
22: * The operator's argument.
23: */
24: protected Var arg;
25:
26: /*--------------*
27: * Constructors *
28: *--------------*/
29:
30: public Bound() {
31: }
32:
33: public Bound(Var arg) {
34: setArg(arg);
35: }
36:
37: /*---------*
38: * Methods *
39: *---------*/
40:
41: /**
42: * Gets the argument of this unary value operator.
43: *
44: * @return The operator's argument.
45: */
46: public Var getArg() {
47: return arg;
48: }
49:
50: /**
51: * Sets the argument of this unary value operator.
52: *
53: * @param arg
54: * The (new) argument for this operator, must not be <tt>null</tt>.
55: */
56: public void setArg(Var arg) {
57: assert arg != null : "arg must not be null";
58: arg.setParentNode(this );
59: this .arg = arg;
60: }
61:
62: public <X extends Exception> void visit(QueryModelVisitor<X> visitor)
63: throws X {
64: visitor.meet(this );
65: }
66:
67: @Override
68: public <X extends Exception> void visitChildren(
69: QueryModelVisitor<X> visitor) throws X {
70: arg.visit(visitor);
71: }
72:
73: @Override
74: public void replaceChildNode(QueryModelNode current,
75: QueryModelNode replacement) {
76: if (arg == current) {
77: setArg((Var) replacement);
78: } else {
79: super .replaceChildNode(current, replacement);
80: }
81: }
82:
83: @Override
84: public Bound clone() {
85: Bound clone = (Bound) super.clone();
86: clone.setArg(getArg().clone());
87: return clone;
88: }
89: }
|