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 ProjectionElem extends QueryModelNodeBase {
09:
10: /*-----------*
11: * Variables *
12: *-----------*/
13:
14: private String sourceName;
15:
16: private String targetName;
17:
18: /*--------------*
19: * Constructors *
20: *--------------*/
21:
22: public ProjectionElem() {
23: }
24:
25: public ProjectionElem(String name) {
26: this (name, name);
27: }
28:
29: public ProjectionElem(String sourceName, String targetName) {
30: setSourceName(sourceName);
31: setTargetName(targetName);
32: }
33:
34: /*---------*
35: * Methods *
36: *---------*/
37:
38: public String getSourceName() {
39: return sourceName;
40: }
41:
42: public void setSourceName(String sourceName) {
43: assert sourceName != null : "sourceName must not be null";
44: this .sourceName = sourceName;
45: }
46:
47: public String getTargetName() {
48: return targetName;
49: }
50:
51: public void setTargetName(String targetName) {
52: assert targetName != null : "targetName must not be null";
53: this .targetName = targetName;
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 String getSignature() {
63: StringBuilder sb = new StringBuilder(32);
64: sb.append(super .getSignature());
65:
66: sb.append(" \"");
67: sb.append(sourceName);
68: sb.append("\"");
69:
70: if (!sourceName.equals(targetName)) {
71: sb.append(" AS \"").append(targetName).append("\"");
72: }
73:
74: return sb.toString();
75: }
76:
77: @Override
78: public ProjectionElem clone() {
79: return (ProjectionElem) super.clone();
80: }
81: }
|