Source Code Cross Referenced for PhysicalTable.java in  » IDE-Netbeans » etl.project » org » netbeans » modules » sql » framework » common » utils » 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 » IDE Netbeans » etl.project » org.netbeans.modules.sql.framework.common.utils 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        package org.netbeans.modules.sql.framework.common.utils;
042:
043:        import java.util.ArrayList;
044:        import java.util.Iterator;
045:        import java.util.List;
046:        import net.java.hulp.i18n.Logger;
047:        import org.netbeans.modules.etl.logger.Localizer;
048:        import org.netbeans.modules.etl.logger.LogUtil;
049:        import org.netbeans.modules.sql.framework.model.DBConnectionDefinition;
050:        import org.netbeans.modules.sql.framework.model.DBTable;
051:        import org.netbeans.modules.sql.framework.model.DatabaseModel;
052:
053:        /**
054:         * Class representing Physical table such that for any two instances t1 and t2 if
055:         * (t1.equals(t2)) then both instances represents the same physical table.
056:         *
057:         * @author Girish Patil
058:         * @version $Revision$
059:         */
060:        public class PhysicalTable {
061:
062:            private static boolean SKIP_CONNECTION_URL = false;
063:            //Preferably one of the two should be true to assert two tables are equal.
064:            private static boolean SKIP_DB_NAME = true;
065:            private static transient final Logger mLogger = LogUtil
066:                    .getLogger(PhysicalTable.class.getName());
067:            private static transient final Localizer mLoc = Localizer.get();
068:
069:            /**
070:             * Creates new instance of PhysicalTable for given DBTable.
071:             *
072:             * @param sqlTable
073:             * @return
074:             */
075:            public static PhysicalTable getPhysicalTable(DBTable sqlTable) {
076:                PhysicalTable pt = null;
077:                if (sqlTable != null) {
078:                    pt = new PhysicalTable();
079:                    pt.setCatalog(sqlTable.getCatalog());
080:                    pt.setName(sqlTable.getName());
081:                    pt.setSchema(sqlTable.getSchema());
082:
083:                    DatabaseModel dbModel = sqlTable.getParent();
084:                    if (dbModel != null) {
085:                        pt.setDbName(dbModel.getModelName());
086:                        DBConnectionDefinition dbConnDef = dbModel
087:                                .getConnectionDefinition();
088:                        if (dbConnDef != null) {
089:                            pt.setConnectionUrl(dbConnDef.getConnectionURL());
090:                        }
091:                    }
092:                }
093:
094:                return pt;
095:            }
096:
097:            /**
098:             * Returns list of PhysicalTable given given list of DBTable.
099:             *
100:             * @param sqlTable
101:             * @return
102:             */
103:            public static List<PhysicalTable> getPhysicalTableList(
104:                    List<DBTable> dbTableList) {
105:                List<PhysicalTable> ptList = null;
106:                PhysicalTable pt = null;
107:                DBTable sqlTable;
108:                if (dbTableList != null) {
109:                    ptList = new ArrayList<PhysicalTable>();
110:                    for (Iterator<DBTable> itr = dbTableList.iterator(); itr
111:                            .hasNext();) {
112:                        sqlTable = itr.next();
113:
114:                        pt = new PhysicalTable();
115:                        pt.setCatalog(sqlTable.getCatalog());
116:                        pt.setName(sqlTable.getName());
117:                        pt.setSchema(sqlTable.getSchema());
118:
119:                        DatabaseModel dbModel = sqlTable.getParent();
120:                        if (dbModel != null) {
121:                            pt.setDbName(dbModel.getModelName());
122:                            DBConnectionDefinition dbConnDef = dbModel
123:                                    .getConnectionDefinition();
124:                            if (dbConnDef != null) {
125:                                pt.setConnectionUrl(dbConnDef
126:                                        .getConnectionURL());
127:                            }
128:                        }
129:                        ptList.add(pt);
130:                    }
131:                }
132:
133:                return ptList;
134:            }
135:
136:            private String mCatalog;
137:            private String mConnectionUrl;
138:            private String mName;
139:            private String mDbName;
140:            private String mSchema;
141:
142:            @Override
143:            public boolean equals(Object other) {
144:                boolean eql = true;
145:                PhysicalTable otherTable = null;
146:                String blank = "";
147:
148:                if (!(other instanceof  PhysicalTable)) {
149:                    eql = false;
150:                    mLogger.infoNoloc(mLoc.t(
151:                            "PRSR101: Class cast request for:{0}", other));
152:                } else {
153:                    otherTable = (PhysicalTable) other;
154:                }
155:
156:                //Check Catalog
157:                if (eql) {
158:                    if ((this .mCatalog == null) || blank.equals(mCatalog)) {
159:                        if (!((otherTable.getCatalog() == null) || blank
160:                                .equals(otherTable.getCatalog()))) {
161:                            eql = false;
162:                        }
163:                    } else {
164:                        if (!this .mCatalog.equals(otherTable.getCatalog())) {
165:                            eql = false;
166:                        }
167:                    }
168:                }
169:
170:                //Check Schema
171:                if (eql) {
172:                    if ((this .mSchema == null) || blank.equals(mSchema)) {
173:                        if (!((otherTable.getSchema() == null) || blank
174:                                .equals(otherTable.getSchema()))) {
175:                            eql = false;
176:                        }
177:                    } else {
178:                        if (!this .mSchema.equals(otherTable.getSchema())) {
179:                            eql = false;
180:                        }
181:                    }
182:                }
183:
184:                //Check Name
185:                if (eql) {
186:                    if ((this .mName == null) || blank.equals(mName)) {
187:                        if (!((otherTable.getName() == null) || blank
188:                                .equals(otherTable.getName()))) {
189:                            eql = false;
190:                        }
191:                    } else {
192:                        if (!this .mName.equals(otherTable.getName())) {
193:                            eql = false;
194:                        }
195:                    }
196:                }
197:
198:                //Check DbName
199:                if (eql && (!SKIP_DB_NAME)) {
200:                    if ((this .mDbName == null) || blank.equals(mDbName)) {
201:                        if (!((otherTable.getDbName() == null) || blank
202:                                .equals(otherTable.getDbName()))) {
203:                            eql = false;
204:                        }
205:                    } else {
206:                        if (!this .mDbName.equals(otherTable.getDbName())) {
207:                            eql = false;
208:                        }
209:                    }
210:                }
211:
212:                //Check ConnectionUrl
213:                if (eql && (!SKIP_CONNECTION_URL)) {
214:                    if ((this .mConnectionUrl == null)
215:                            || blank.equals(mConnectionUrl)) {
216:                        if (!((otherTable.getConnectionUrl() == null) || blank
217:                                .equals(otherTable.getConnectionUrl()))) {
218:                            eql = false;
219:                        }
220:                    } else {
221:                        if (!this .mConnectionUrl.equals(otherTable
222:                                .getConnectionUrl())) {
223:                            eql = false;
224:                        }
225:                    }
226:                }
227:
228:                return eql;
229:            }
230:
231:            @Override
232:            public int hashCode() {
233:                int hash = 7;
234:                hash = 53
235:                        * hash
236:                        + (this .mCatalog != null ? this .mCatalog.hashCode() : 0);
237:                hash = 53
238:                        * hash
239:                        + (this .mConnectionUrl != null ? this .mConnectionUrl
240:                                .hashCode() : 0);
241:                hash = 53 * hash
242:                        + (this .mName != null ? this .mName.hashCode() : 0);
243:                hash = 53 * hash
244:                        + (this .mDbName != null ? this .mDbName.hashCode() : 0);
245:                hash = 53 * hash
246:                        + (this .mSchema != null ? this .mSchema.hashCode() : 0);
247:                return hash;
248:            }
249:
250:            /**
251:             * @return Returns the catalog.
252:             */
253:            public String getCatalog() {
254:                return mCatalog;
255:            }
256:
257:            /**
258:             * @return Returns the connectionUrl.
259:             */
260:            public String getConnectionUrl() {
261:                return mConnectionUrl;
262:            }
263:
264:            /**
265:             * @return Returns the name.
266:             */
267:            public String getName() {
268:                return mName;
269:            }
270:
271:            /**
272:             * @return Returns the dbName.
273:             */
274:            public String getDbName() {
275:                return mDbName;
276:            }
277:
278:            /**
279:             * @return Returns the schema.
280:             */
281:            public String getSchema() {
282:                return mSchema;
283:            }
284:
285:            /**
286:             * @param catalog The catalog to set.
287:             */
288:            public void setCatalog(String catalog) {
289:                this .mCatalog = catalog;
290:            }
291:
292:            /**
293:             * @param schema The schema to set.
294:             */
295:            public void setConnectionUrl(String cUrl) {
296:                this .mConnectionUrl = cUrl;
297:            }
298:
299:            /**
300:             * @param name The name to set.
301:             */
302:            public void setName(String name) {
303:                this .mName = name;
304:            }
305:
306:            /**
307:             * @param dbName The dbName to set.
308:             */
309:            public void setDbName(String dbName) {
310:                this .mDbName = dbName;
311:            }
312:
313:            /**
314:             * @param schema The schema to set.
315:             */
316:            public void setSchema(String schema) {
317:                this.mSchema = schema;
318:            }
319:        }
w___w_w_.__j___av__a_2s.__c___o___m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.