01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2006.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.query.algebra;
07:
08: public class ExtensionElem extends QueryModelNodeBase {
09:
10: /*-----------*
11: * Variables *
12: *-----------*/
13:
14: private ValueExpr expr;
15:
16: private String name;
17:
18: /*--------------*
19: * Constructors *
20: *--------------*/
21:
22: public ExtensionElem() {
23: }
24:
25: public ExtensionElem(ValueExpr expr, String name) {
26: setExpr(expr);
27: setName(name);
28: }
29:
30: /*---------*
31: * Methods *
32: *---------*/
33:
34: public ValueExpr getExpr() {
35: return expr;
36: }
37:
38: public void setExpr(ValueExpr expr) {
39: assert expr != null : "expr must not be null";
40: expr.setParentNode(this );
41: this .expr = expr;
42: }
43:
44: public String getName() {
45: return name;
46: }
47:
48: public void setName(String name) {
49: this .name = name;
50: }
51:
52: public <X extends Exception> void visit(QueryModelVisitor<X> visitor)
53: throws X {
54: visitor.meet(this );
55: }
56:
57: @Override
58: public <X extends Exception> void visitChildren(
59: QueryModelVisitor<X> visitor) throws X {
60: expr.visit(visitor);
61: }
62:
63: @Override
64: public void replaceChildNode(QueryModelNode current,
65: QueryModelNode replacement) {
66: if (expr == current) {
67: setExpr((ValueExpr) replacement);
68: } else {
69: super .replaceChildNode(current, replacement);
70: }
71: }
72:
73: @Override
74: public String getSignature() {
75: return super .getSignature() + " (" + name + ")";
76: }
77:
78: @Override
79: public ExtensionElem clone() {
80: ExtensionElem clone = (ExtensionElem) super.clone();
81: clone.setExpr(getExpr().clone());
82: return clone;
83: }
84: }
|