Source Code Cross Referenced for TableName.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » impl » sql » compile » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » db derby 10.2 » org.apache.derby.impl.sql.compile 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derby.impl.sql.compile.TableName
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to you under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derby.impl.sql.compile;
023:
024:        import org.apache.derby.iapi.sql.dictionary.DataDictionary;
025:        import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
026:        import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
027:
028:        import org.apache.derby.iapi.error.StandardException;
029:
030:        import org.apache.derby.iapi.services.sanity.SanityManager;
031:
032:        import org.apache.derby.iapi.reference.Property;
033:        import org.apache.derby.iapi.reference.SQLState;
034:
035:        /**
036:         * A TableName represents a qualified name, externally represented as a schema name
037:         * and an object name separated by a dot. This class is mis-named: it is used to
038:         * represent the names of other object types in addition to tables.
039:         *
040:         * @author Jerry Brenner
041:         */
042:
043:        public class TableName extends QueryTreeNode {
044:            /* Both schemaName and tableName can be null, however, if 
045:             ** tableName is null then schemaName must also be null.
046:             */
047:            String tableName;
048:            String schemaName;
049:            private boolean hasSchema;
050:
051:            /**
052:             * Initializer for when you have both the table and schema names.
053:             *
054:             * @param schemaName	The name of the schema being referenced
055:             * @param tableName		The name of the table being referenced	 
056:             */
057:
058:            public void init(Object schemaName, Object tableName) {
059:                hasSchema = schemaName != null;
060:                this .schemaName = (String) schemaName;
061:                this .tableName = (String) tableName;
062:            }
063:
064:            /**
065:             * Initializer for when you have both the table and schema names.
066:             *
067:             * @param schemaName	The name of the schema being referenced
068:             * @param tableName		The name of the table being referenced	 
069:             * @param tokBeginOffset begin position of token for the table name 
070:             *					identifier from parser.  pass in -1 if unknown
071:             * @param tokEndOffset	end position of token for the table name 
072:             *					identifier from parser.  pass in -1 if unknown
073:             */
074:            public void init(Object schemaName, Object tableName,
075:                    Object tokBeginOffset, Object tokEndOffset) {
076:                init(schemaName, tableName);
077:                this .setBeginOffset(((Integer) tokBeginOffset).intValue());
078:                this .setEndOffset(((Integer) tokEndOffset).intValue());
079:            }
080:
081:            /**
082:             * Get the table name (without the schema name).
083:             *
084:             * @return Table name as a String
085:             */
086:
087:            public String getTableName() {
088:                return tableName;
089:            }
090:
091:            /**
092:             * Return true if this instance was initialized with not null schemaName.
093:             *
094:             * @return true if this instance was initialized with not null schemaName
095:             */
096:
097:            public boolean hasSchema() {
098:                return hasSchema;
099:            }
100:
101:            /**
102:             * Get the schema name.
103:             *
104:             * @return Schema name as a String
105:             */
106:
107:            public String getSchemaName() {
108:                return schemaName;
109:            }
110:
111:            /**
112:             * Set the schema name.
113:             *
114:             * @param schemaName	 Schema name as a String
115:             */
116:
117:            public void setSchemaName(String schemaName) {
118:                this .schemaName = schemaName;
119:            }
120:
121:            /**
122:             * Get the full table name (with the schema name, if explicitly
123:             * specified).
124:             *
125:             * @return Full table name as a String
126:             */
127:
128:            public String getFullTableName() {
129:                if (schemaName != null)
130:                    return schemaName + "." + tableName;
131:                else
132:                    return tableName;
133:            }
134:
135:            /**
136:             * Convert this object to a String.  See comments in QueryTreeNode.java
137:             * for how this should be done for tree printing.
138:             *
139:             * @return	This object as a String
140:             */
141:
142:            public String toString() {
143:                if (hasSchema)
144:                    return getFullTableName();
145:                else
146:                    return tableName;
147:            }
148:
149:            /**
150:             * 2 TableNames are equal if their both their schemaNames and tableNames are
151:             * equal, or if this node's full table name is null (which happens when a
152:             * SELECT * is expanded).  Also, only check table names if the schema
153:             * name(s) are null.
154:             *
155:             * @param otherTableName	The other TableName.
156:             *
157:             * @return boolean		Whether or not the 2 TableNames are equal.
158:             */
159:            public boolean equals(TableName otherTableName) {
160:                if (otherTableName == null)
161:                    return false;
162:
163:                String fullTableName = getFullTableName();
164:                if (fullTableName == null) {
165:                    return true;
166:                } else if ((schemaName == null)
167:                        || (otherTableName.getSchemaName() == null)) {
168:                    return tableName.equals(otherTableName.getTableName());
169:                } else {
170:                    return fullTableName.equals(otherTableName
171:                            .getFullTableName());
172:                }
173:            }
174:
175:            /**
176:             * 2 TableNames are equal if their both their schemaNames and tableNames are
177:             * equal, or if this node's full table name is null (which happens when a
178:             * SELECT * is expanded).  Also, only check table names if the schema
179:             * name(s) are null.
180:             *
181:             * @param otherSchemaName	The other TableName.
182:             * @param otherTableName	The other TableName.
183:             *
184:             * @return boolean		Whether or not the 2 TableNames are equal.
185:             */
186:            public boolean equals(String otherSchemaName, String otherTableName) {
187:                String fullTableName = getFullTableName();
188:                if (fullTableName == null) {
189:                    return true;
190:                } else if ((schemaName == null) || (otherSchemaName == null)) {
191:                    return tableName.equals(otherTableName);
192:                } else {
193:                    return fullTableName.equals(otherSchemaName + "."
194:                            + otherTableName);
195:                }
196:            }
197:
198:            ///////////////////////////////////////////////////////////////////////
199:            //
200:            //	BIND METHODS
201:            //
202:            ///////////////////////////////////////////////////////////////////////
203:
204:            /**
205:             *	Bind this TableName. This means filling in the schema name if it
206:             *	wasn't specified.
207:             *
208:             *	@param	dataDictionary	Data dictionary to bind against.
209:             *
210:             *	@exception StandardException		Thrown on error
211:             */
212:            public void bind(DataDictionary dataDictionary)
213:                    throws StandardException {
214:                schemaName = getSchemaDescriptor(schemaName).getSchemaName();
215:            }
216:
217:            ///////////////////////////////////////////////////////////////////////
218:            //
219:            //	OBJECT INTERFACE
220:            //
221:            ///////////////////////////////////////////////////////////////////////
222:
223:            /**
224:             *	Returns a hashcode for this tableName. This allows us to use TableNames
225:             *	as keys in hash lists.
226:             *
227:             *	@return	hashcode for this tablename
228:             */
229:            public int hashCode() {
230:                return getFullTableName().hashCode();
231:            }
232:
233:            /**
234:             *	Compares two TableNames. Needed for hashing logic to work.
235:             *
236:             *	@param	other	other tableName
237:             */
238:            public boolean equals(Object other) {
239:                if (!(other instanceof  TableName)) {
240:                    return false;
241:                }
242:
243:                TableName that = (TableName) other;
244:
245:                return this.getFullTableName().equals(that.getFullTableName());
246:            }
247:
248:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.