01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 2008.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.sail.rdbms.algebra.base;
07:
08: import org.openrdf.query.algebra.Var;
09: import org.openrdf.sail.rdbms.algebra.ColumnVar;
10:
11: /**
12: * A column in an SQL expression.
13: *
14: * @author James Leigh
15: *
16: */
17: public abstract class ValueColumnBase extends RdbmsQueryModelNodeBase
18: implements SqlExpr {
19: private String name;
20: private ColumnVar var;
21:
22: public ValueColumnBase(Var var) {
23: this .name = var.getName();
24: }
25:
26: public ValueColumnBase(ColumnVar var) {
27: this .name = var.getName();
28: setRdbmsVar(var);
29: }
30:
31: public String getVarName() {
32: return name;
33: }
34:
35: public ColumnVar getRdbmsVar() {
36: return var;
37: }
38:
39: public void setRdbmsVar(ColumnVar var) {
40: assert var != null;
41: this .var = var;
42: }
43:
44: public String getAlias() {
45: return var.getAlias();
46: }
47:
48: public String getColumn() {
49: return var.getColumn();
50: }
51:
52: @Override
53: public String getSignature() {
54: if (var != null)
55: return super .getSignature() + " " + var;
56: return super .getSignature() + " " + name;
57: }
58:
59: @Override
60: public ValueColumnBase clone() {
61: return (ValueColumnBase) super .clone();
62: }
63:
64: @Override
65: public int hashCode() {
66: final int prime = 31;
67: int result = 1;
68: result = prime * result
69: + ((name == null) ? 0 : name.hashCode());
70: return result;
71: }
72:
73: @Override
74: public boolean equals(Object obj) {
75: if (this == obj)
76: return true;
77: if (obj == null)
78: return false;
79: if (getClass() != obj.getClass())
80: return false;
81: final ValueColumnBase other = (ValueColumnBase) obj;
82: if (name == null) {
83: if (other.name != null)
84: return false;
85: } else if (!name.equals(other.name))
86: return false;
87: return true;
88: }
89:
90: }
|