KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > extractor > algebra > Attribute


1 /*
2  * This file belongs to the XQuark distribution.
3  * Copyright (C) 2003 Universite de Versailles Saint-Quentin.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307.
18  * You can also get it at http://www.gnu.org/licenses/lgpl.html
19  *
20  * For more information on this software, see http://www.xquark.org.
21  */

22
23 package org.xquark.extractor.algebra;
24
25 import java.util.List JavaDoc;
26 import java.util.Map JavaDoc;
27
28 import org.xquark.extractor.common.SqlWrapperException;
29 import org.xquark.extractor.sql.SqlExpression;
30 import org.xquark.jdbc.typing.DbType;
31
32 public class Attribute extends Expression
33 {
34     private static final String JavaDoc RCSRevision = "$Revision: 1.8 $";
35     private static final String JavaDoc RCSName = "$Name: $";
36
37
38     protected org.xquark.extractor.metadata.Attribute _attribute;
39
40     /**
41     @param attribute
42     @roseuid 3BD1863001C7
43      */

44     public Attribute(org.xquark.extractor.metadata.Attribute attribute)
45     {
46         setAttribute(attribute);
47     }
48
49     synchronized Object JavaDoc clone(Map JavaDoc clonedExprs) throws CloneNotSupportedException JavaDoc
50     {
51         //Trace.enter(this, "clone(HashMap clonedExpr)");
52

53         Object JavaDoc retVal = super.clone(clonedExprs);
54
55         clonedExprs.put(this, retVal);
56         //Trace.exit(this, "clone(HashMap clonedExpr)");
57
return retVal;
58     }
59
60     /**
61     Access method for the _attribute property.
62
63     @return the current value of the _attribute property
64      */

65     public org.xquark.extractor.metadata.Attribute getAttribute()
66     {
67         return _attribute;
68     }
69
70     /**
71     Sets the value of the _attribute property.
72
73     @param aAttribute the new value of the _attribute property
74      */

75     public void setAttribute(org.xquark.extractor.metadata.Attribute aAttribute)
76     {
77         _attribute = aAttribute;
78     }
79
80     public String JavaDoc getName () {
81         return _attribute.getName();
82     }
83
84     public String JavaDoc getAlias () {
85         return _attribute.getAlias();
86     }
87
88     public SqlType getType()
89     {
90         return _type;
91     }
92
93     public DbType getPrimitiveType()
94     {
95         return _attribute.getMappingInfo().getDBType();
96     }
97
98     public List JavaDoc getOperands()
99     {
100         return null;
101     }
102
103     public String JavaDoc getTableName()
104     {
105         return _attribute.getFather().getName();
106     }
107
108     public String JavaDoc getSchemaName()
109     {
110         return _attribute.getFather().getFather().getName();
111     }
112
113     public String JavaDoc getCatalogName()
114     {
115         return _attribute.getFather().getFather().getFather().getName();
116     }
117
118     public String JavaDoc getFullName()
119     {
120         return _attribute.getFullName();
121     }
122
123     public String JavaDoc pprint()
124     {
125         return getName();
126     }
127
128     public SqlExpression accept (GenSqlVisitor visitor) throws SqlWrapperException
129     {
130         return visitor.visit(this);
131     }
132
133     public void accept (AlgebraVisitor visitor) throws SqlWrapperException
134     {
135         visitor.visit(this);
136     }
137
138     /**
139      * The semantics chosen for equals of algebra nodes is "the same algebra operator
140      * hierarchy referring to the same database objects".
141      * @param o the expression to be compared with this.
142      */

143     public boolean deepEquals(Object JavaDoc o)
144     {
145         if (o instanceof Attribute)
146         {
147             Attribute att = (Attribute)o;
148             return _attribute.equals(att.getAttribute()); // NOTE: assuming metadata object are not duplicated...
149
}
150         return false;
151     }
152 }
153
Popular Tags