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;
07:
08: import org.openrdf.sail.rdbms.algebra.base.RdbmsQueryModelNodeBase;
09: import org.openrdf.sail.rdbms.algebra.base.RdbmsQueryModelVisitorBase;
10: import org.openrdf.sail.rdbms.algebra.base.SqlExpr;
11:
12: /**
13: * A particular column in an SQL expression.
14: *
15: * @author James Leigh
16: *
17: */
18: public class IdColumn extends RdbmsQueryModelNodeBase implements
19: SqlExpr {
20: private String alias;
21: private String column;
22:
23: public IdColumn(String alias) {
24: super ();
25: this .alias = alias;
26: this .column = "id";
27: }
28:
29: public IdColumn(ColumnVar var) {
30: super ();
31: this .alias = var.getAlias();
32: this .column = var.getColumn();
33: }
34:
35: public IdColumn(String alias, String column) {
36: super ();
37: this .alias = alias;
38: this .column = column;
39: }
40:
41: public String getAlias() {
42: return alias;
43: }
44:
45: public String getColumn() {
46: return column;
47: }
48:
49: @Override
50: public String getSignature() {
51: return super .getSignature() + " " + alias + "." + column;
52: }
53:
54: @Override
55: public <X extends Exception> void visit(
56: RdbmsQueryModelVisitorBase<X> visitor) throws X {
57: visitor.meet(this );
58: }
59:
60: @Override
61: public IdColumn clone() {
62: return (IdColumn) super .clone();
63: }
64:
65: @Override
66: public int hashCode() {
67: final int prime = 31;
68: int result = 1;
69: result = prime * result
70: + ((alias == null) ? 0 : alias.hashCode());
71: result = prime * result
72: + ((column == null) ? 0 : column.hashCode());
73: return result;
74: }
75:
76: @Override
77: public boolean equals(Object obj) {
78: if (this == obj)
79: return true;
80: if (obj == null)
81: return false;
82: if (getClass() != obj.getClass())
83: return false;
84: final IdColumn other = (IdColumn) obj;
85: if (alias == null) {
86: if (other.alias != null)
87: return false;
88: } else if (!alias.equals(other.alias))
89: return false;
90: if (column == null) {
91: if (other.column != null)
92: return false;
93: } else if (!column.equals(other.column))
94: return false;
95: return true;
96: }
97: }
|