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


001:        /*
002:         * The contents of this file are subject to the terms of the Common Development
003:         * and Distribution License (the License). You may not use this file except in
004:         * compliance with the License.
005:         * 
006:         * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007:         * or http://www.netbeans.org/cddl.txt.
008:         * 
009:         * When distributing Covered Code, include this CDDL Header Notice in each file
010:         * and include the License file at http://www.netbeans.org/cddl.txt.
011:         * If applicable, add the following below the CDDL Header, with the fields
012:         * enclosed by brackets [] replaced by your own identifying information:
013:         * "Portions Copyrighted [year] [name of copyright owner]"
014:         * 
015:         * The Original Software is NetBeans. The Initial Developer of the Original
016:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017:         * Microsystems, Inc. All Rights Reserved.
018:         */
019:
020:        /*
021:         *                 Sun Public License Notice
022:         *
023:         * The contents of this file are subject to the Sun Public License
024:         * Version 1.0 (the "License"). You may not use this file except in
025:         * compliance with the License. A copy of the License is available at
026:         * http://www.sun.com/
027:         *
028:         * The Original Code is NetBeans. The Initial Developer of the Original
029:         * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
030:         * Microsystems, Inc. All Rights Reserved.
031:         */
032:
033:        package org.netbeans.modules.sql.project.dbmodel;
034:
035:        import java.util.Collections;
036:        import java.util.List;
037:        import java.util.ArrayList;
038:
039:        //Internationalization
040:        import java.util.Locale;
041:        import java.text.MessageFormat;
042:        import java.util.ResourceBundle;
043:
044:        /**
045:         * Class to hold procedure metadata.
046:         *
047:         * @author Susan Chen
048:         * @author Jonathan Giron
049:         * @version 
050:         */
051:        public class Table {
052:            private String name = ""; // name of table
053:            private String javaName = ""; // java name of table
054:            private String catalog = ""; // catalog
055:            private String schema = ""; // schema
056:            private int numColumns = 0; // number of table columns
057:            private int numColumnsSelected = 0; // number of table columns selected
058:            private TableColumn[] columns; // array of table columns
059:            private String type = "TABLE"; // TABLE, SYSTEM TABLE, VIEW - from driver
060:
061:            private List indexList; // List of IndexColumn objects
062:            private List fkColumnList; // List of KeyColumn objects (PK cols)
063:            private List pkColumnList; // List of ForeignKeyColumn objects (FK cols)
064:            private boolean selected;
065:
066:            /**
067:             * Creates an instance of Table with the given attributes.
068:             *
069:             * @param tname Table name
070:             * @param tcatalog Catalog name
071:             * @param tschema Schema name
072:             * @param ttype Table type
073:             */
074:            public Table(String tname, String tcatalog, String tschema,
075:                    String ttype) {
076:                name = tname;
077:                catalog = tcatalog;
078:                schema = tschema;
079:                type = ttype;
080:
081:                indexList = Collections.EMPTY_LIST;
082:                fkColumnList = Collections.EMPTY_LIST;
083:                pkColumnList = Collections.EMPTY_LIST;
084:            }
085:
086:            /**
087:             * Creates an instance of Table with the given attributes.
088:             *
089:             * @param tname Table name
090:             * @param jname Table java name
091:             * @param tcatalog Catalog name
092:             * @param tschema Schema name
093:             * @param ttype Table type
094:             */
095:            public Table(String tname, String jname, String tcatalog,
096:                    String tschema, String ttype) {
097:                name = tname;
098:                javaName = jname;
099:                catalog = tcatalog;
100:                schema = tschema;
101:                type = ttype;
102:
103:                indexList = Collections.EMPTY_LIST;
104:                fkColumnList = Collections.EMPTY_LIST;
105:                pkColumnList = Collections.EMPTY_LIST;
106:            }
107:
108:            /**
109:             * Creates an instance of Table with the given attributes.
110:             *
111:             */
112:            public Table(Table nTable) {
113:                name = nTable.getName();
114:                javaName = nTable.getJavaName();
115:                catalog = nTable.getCatalog();
116:                schema = nTable.getSchema();
117:                numColumns = nTable.getNumColumns();
118:                numColumnsSelected = nTable.getNumColumnsSelected();
119:                cloneColumns(nTable.getColumns());
120:                type = nTable.getType();
121:                cloneIndexList(nTable.getIndexList());
122:                cloneForeignKeyColumnList(nTable.getForeignKeyColumnList());
123:                clonePrimaryKeyColumnList(nTable.getPrimaryKeyColumnList());
124:                selected = nTable.isSelected();
125:            }
126:
127:            /**
128:             * Get the table name.
129:             *
130:             * @return Table name
131:             */
132:            public String getName() {
133:                return name;
134:            }
135:
136:            /**
137:             * Get the table java name.
138:             *
139:             * @return Table java name
140:             */
141:            public String getJavaName() {
142:                return javaName;
143:            }
144:
145:            /**
146:             * Get the catalog name.
147:             *
148:             * @return Catalog name
149:             */
150:            public String getCatalog() {
151:                return catalog;
152:            }
153:
154:            /**
155:             * Get the schema name.
156:             *
157:             * @return Schema name
158:             */
159:            public String getSchema() {
160:                return schema;
161:            }
162:
163:            /**
164:             * Get the number of table columns.
165:             *
166:             * @return Number of table columns.
167:             */
168:            public int getNumColumns() {
169:                return numColumns;
170:            }
171:
172:            /**
173:             * Get the number of columns selected.
174:             *
175:             * @return Number of columns selected.
176:             */
177:            public int getNumColumnsSelected() {
178:                return numColumnsSelected;
179:            }
180:
181:            /**
182:             * Get the list of table columns.
183:             *
184:             * @return List of table columns
185:             */
186:            public TableColumn[] getColumns() {
187:                return columns;
188:            }
189:
190:            /**
191:             * Get the table type.
192:             *
193:             * @return Table type
194:             */
195:            public String getType() {
196:                return type;
197:            }
198:
199:            /**
200:             * Set the table name.
201:             *
202:             * @param newName Table name
203:             */
204:            public void setName(String newName) {
205:                name = newName;
206:            }
207:
208:            /**
209:             * Set the table java name.
210:             *
211:             * @param newName Table java name
212:             */
213:            public void setJavaName(String newJavaName) {
214:                javaName = newJavaName;
215:            }
216:
217:            /**
218:             * Set the catalog name.
219:             *
220:             * @param newCatalog Catalog name
221:             */
222:            public void setCatalog(String newCatalog) {
223:                catalog = newCatalog;
224:            }
225:
226:            /**
227:             * Set the schema name.
228:             *
229:             * @param newSchema Schema name
230:             */
231:            public void setSchema(String newSchema) {
232:                schema = newSchema;
233:            }
234:
235:            /**
236:             * Set the table columns.
237:             *
238:             * @param newColumns Table columns
239:             */
240:            public void setColumns(TableColumn[] newColumns) {
241:                columns = newColumns;
242:
243:                // update the number of columns and columns selected
244:                if (columns != null) {
245:                    numColumns = columns.length;
246:
247:                    int count = 0;
248:                    for (int i = 0; i < columns.length; i++) {
249:                        if (columns[i].getIsSelected()) {
250:                            count++;
251:                        }
252:                    }
253:                    numColumnsSelected = count;
254:                } else {
255:                    numColumns = 0;
256:                    numColumnsSelected = 0;
257:                }
258:            }
259:
260:            /**
261:             * Clone the table columns.
262:             *
263:             * @param newColumns Table columns
264:             */
265:            public void cloneColumns(TableColumn[] newColumns) {
266:                numColumns = 0;
267:                numColumnsSelected = 0;
268:
269:                int count = 0;
270:                if (newColumns != null) {
271:                    numColumns = newColumns.length;
272:                    if (numColumns > 0) {
273:                        columns = new TableColumn[numColumns];
274:                        for (int i = 0; i < numColumns; i++) {
275:                            columns[i] = new TableColumn(newColumns[i]);
276:                            if (columns[i].getIsSelected()) {
277:                                count++;
278:                            }
279:                        }
280:                    }
281:                    numColumnsSelected = count;
282:                }
283:            }
284:
285:            /**
286:             * Set the table type.
287:             *
288:             * @param newType Table type
289:             */
290:            public void setType(String newType) {
291:                type = newType;
292:            }
293:
294:            /**
295:             * Get the index list.
296:             *
297:             * @return Index list
298:             */
299:            public List getIndexList() {
300:                return indexList;
301:            }
302:
303:            /**
304:             * Set the index list.
305:             *
306:             * @param newList Index list
307:             */
308:            public void setIndexList(List newList) {
309:                if (newList != null && newList.size() != 0) {
310:                    try {
311:                        // Test to ensure that List contains nothing but Index objects.
312:                        IndexColumn[] dummy = (IndexColumn[]) newList
313:                                .toArray(new IndexColumn[newList.size()]);
314:                    } catch (ArrayStoreException e) {
315:                        throw new IllegalArgumentException(
316:                                "newList does not contain Index objects!");
317:                    }
318:
319:                    indexList = newList;
320:                }
321:            }
322:
323:            public void cloneIndexList(List newList) {
324:                indexList = Collections.EMPTY_LIST;
325:
326:                if (newList != null && newList.size() != 0) {
327:                    indexList = new ArrayList();
328:
329:                    try {
330:                        // Test to ensure that List contains nothing but Index objects.
331:                        IndexColumn[] dummy = (IndexColumn[]) newList
332:                                .toArray(new IndexColumn[newList.size()]);
333:                        for (int i = 0; i < newList.size(); i++) {
334:                            IndexColumn iCol = (IndexColumn) newList.get(i);
335:                            indexList.add(new IndexColumn(iCol));
336:                        }
337:                    } catch (ArrayStoreException e) {
338:                        throw new IllegalArgumentException(
339:                                "newList does not contain Index objects!");
340:                    }
341:                }
342:            }
343:
344:            //added by Neena
345:            //to set the selection state of the table 
346:
347:            public void setSelected(boolean selected) {
348:                this .selected = selected;
349:            }
350:
351:            //added by Neena
352:            // to get the selection state of the object
353:
354:            public boolean isSelected() {
355:                return selected;
356:            }
357:
358:            /**
359:             * Gets current List of KeyColumn objects, representing primary key columns
360:             * in this table.
361:             *
362:             * @return List (possibly empty) of KeyColumn instances
363:             */
364:            public List getPrimaryKeyColumnList() {
365:                return pkColumnList;
366:            }
367:
368:            /**
369:             * Sets List of primary key column objects to the given List.
370:             *
371:             * @param newList List containing new collection of KeyColumn objects
372:             * representing primary key columns within this table
373:             */
374:            public void setPrimaryKeyColumnList(List newList) {
375:                if (newList != null && newList.size() != 0) {
376:                    try {
377:                        // Test to ensure that List contains nothing but Index objects.
378:                        KeyColumn[] dummy = (KeyColumn[]) newList
379:                                .toArray(new KeyColumn[newList.size()]);
380:                    } catch (ArrayStoreException e) {
381:                        Locale locale = Locale.getDefault();
382:                        ResourceBundle cMessages = ResourceBundle.getBundle(
383:                                "com/stc/oracle/builder/Bundle", locale); // NO i18n
384:                        throw new IllegalArgumentException(cMessages
385:                                .getString("ERROR_KEY")
386:                                + "(ERROR_KEY)");// NO i18n
387:                    }
388:
389:                    pkColumnList = newList;
390:                }
391:            }
392:
393:            public void clonePrimaryKeyColumnList(List newList) {
394:                pkColumnList = Collections.EMPTY_LIST;
395:
396:                if (newList != null && newList.size() != 0) {
397:                    pkColumnList = new ArrayList();
398:
399:                    try {
400:                        // Test to ensure that List contains nothing but Index objects.
401:                        KeyColumn[] dummy = (KeyColumn[]) newList
402:                                .toArray(new KeyColumn[newList.size()]);
403:                        for (int i = 0; i < newList.size(); i++) {
404:                            KeyColumn tPK = (KeyColumn) newList.get(i);
405:                            pkColumnList.add(new KeyColumn(tPK.getName(), tPK
406:                                    .getColumnName(), tPK.getColumnSequence()));
407:                        }
408:                    } catch (ArrayStoreException e) {
409:                        Locale locale = Locale.getDefault();
410:                        ResourceBundle cMessages = ResourceBundle.getBundle(
411:                                "com/stc/oracle/builder/Bundle", locale); // NO i18n
412:                        throw new IllegalArgumentException(cMessages
413:                                .getString("ERROR_KEY")
414:                                + "(ERROR_KEY)");// NO i18n
415:                    }
416:                }
417:            }
418:
419:            /**
420:             * Gets current List of ForeignKeyColumn objects, representing foreign key
421:             * columns in this table.
422:             *
423:             * @return List (possibly empty) of ForeignKeyColumn instances
424:             */
425:            public List getForeignKeyColumnList() {
426:                return fkColumnList;
427:            }
428:
429:            /**
430:             * Sets List of foreign key column objects to the given List.
431:             *
432:             * @param newList List containing new collection of ForeignKeyColumn objects
433:             * representing foreign key columns within this table
434:             */
435:            public void setForeignKeyColumnList(List newList) {
436:                if (newList != null && newList.size() != 0) {
437:                    try {
438:                        // Test to ensure that List contains nothing but Index objects.
439:                        ForeignKeyColumn[] dummy = (ForeignKeyColumn[]) newList
440:                                .toArray(new ForeignKeyColumn[newList.size()]);
441:                    } catch (ArrayStoreException e) {
442:                        Locale locale = Locale.getDefault();
443:                        ResourceBundle cMessages = ResourceBundle.getBundle(
444:                                "com/stc/oracle/builder/Bundle", locale); // NO i18n
445:                        throw new IllegalArgumentException(cMessages
446:                                .getString("ERROR_FK_KEY")
447:                                + "(ERROR_FK_KEY)");// NO i18n
448:                    }
449:
450:                    fkColumnList = newList;
451:                }
452:            }
453:
454:            public void cloneForeignKeyColumnList(List newList) {
455:                fkColumnList = Collections.EMPTY_LIST;
456:
457:                if (newList != null && newList.size() != 0) {
458:                    fkColumnList = new ArrayList();
459:
460:                    try {
461:                        // Test to ensure that List contains nothing but Index objects.
462:                        ForeignKeyColumn[] dummy = (ForeignKeyColumn[]) newList
463:                                .toArray(new ForeignKeyColumn[newList.size()]);
464:                        for (int i = 0; i < newList.size(); i++) {
465:                            ForeignKeyColumn fkCol = (ForeignKeyColumn) newList
466:                                    .get(i);
467:                            fkColumnList.add(new ForeignKeyColumn(fkCol));
468:                        }
469:                    } catch (ArrayStoreException e) {
470:                        Locale locale = Locale.getDefault();
471:                        ResourceBundle cMessages = ResourceBundle.getBundle(
472:                                "com/stc/oracle/builder/Bundle", locale); // NO i18n
473:                        throw new IllegalArgumentException(cMessages
474:                                .getString("ERROR_FK_KEY")
475:                                + "(ERROR_FK_KEY)");// NO i18n
476:                    }
477:                }
478:            }
479:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.