Source Code Cross Referenced for PrimaryKeyMetaData.java in  » Database-ORM » JPOX » org » jpox » metadata » 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 ORM » JPOX » org.jpox.metadata 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************
002:        Copyright (c) 2005 Andy Jefferson and others. All rights reserved. 
003:        Licensed under the Apache License, Version 2.0 (the "License");
004:        you may not use this file except in compliance with the License.
005:        You may obtain a copy of the License at
006:
007:            http://www.apache.org/licenses/LICENSE-2.0
008:
009:        Unless required by applicable law or agreed to in writing, software
010:        distributed under the License is distributed on an "AS IS" BASIS,
011:        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012:        See the License for the specific language governing permissions and
013:        limitations under the License. 
014:         
015:
016:        Contributors:
017:            ...
018:         **********************************************************************/package org.jpox.metadata;
019:
020:        import java.util.ArrayList;
021:        import java.util.List;
022:
023:        import org.jpox.util.StringUtils;
024:
025:        /**
026:         * Representation of a primary key constraint.
027:         * Can also be used for specifying surrogate keys, but JPOX doesn't support this.
028:         *
029:         * @since 1.1
030:         * @version $Revision$
031:         */
032:        public class PrimaryKeyMetaData extends MetaData implements 
033:                ColumnMetaDataContainer {
034:            /** PK constraint name. */
035:            protected String name = null;
036:
037:            /** Column name of PK. */
038:            protected String columnName = null;
039:
040:            /** MetaData for columns to be used in PK. */
041:            protected ColumnMetaData[] columnMetaData = null;
042:
043:            // -------------------------------------------------------------------------
044:            // Fields below here are used in the metadata parse process where the parser
045:            // dynamically adds fields/columns as it encounters them in the MetaData files.
046:            // They are typically cleared at the point of initialise() and not used thereafter.
047:
048:            /**
049:             * the columns elements to be included in the index. Suitable to be empty
050:             * when this metadata is contained within a field, element, key, value, or join elements
051:             */
052:            protected List columns = new ArrayList();
053:
054:            /**
055:             * Constructor.
056:             * @param parent The parent metadata object
057:             * @param name Name of the PK constraint
058:             * @param columnName Name of the column (optional)
059:             */
060:            public PrimaryKeyMetaData(MetaData parent, final String name,
061:                    final String columnName) {
062:                super (parent);
063:
064:                this .name = (StringUtils.isWhitespace(name) ? null : name);
065:                this .columnName = (StringUtils.isWhitespace(columnName) ? null
066:                        : columnName);
067:            }
068:
069:            /**
070:             * Initialisation method. This should be called AFTER using the populate
071:             * method if you are going to use populate. It creates the internal
072:             * convenience arrays etc needed for normal operation.
073:             */
074:            public void initialise() {
075:                // Set up the columnMetaData
076:                if (columns.size() == 0 && columnName != null) {
077:                    columnMetaData = new ColumnMetaData[1];
078:                    columnMetaData[0] = new ColumnMetaData(this , columnName);
079:                    columnMetaData[0].initialise();
080:                } else {
081:                    columnMetaData = new ColumnMetaData[columns.size()];
082:                    for (int i = 0; i < columnMetaData.length; i++) {
083:                        columnMetaData[i] = (ColumnMetaData) columns.get(i);
084:                        columnMetaData[i].initialise();
085:                    }
086:                }
087:
088:                // Clean out parsing data
089:                columns.clear();
090:                columns = null;
091:
092:                setInitialised();
093:            }
094:
095:            // --------------------------- Accessors/Mutators ---------------------------
096:
097:            /**
098:             * Accessor for PK constraint name.
099:             * @return Returns the constraint name
100:             */
101:            public String getName() {
102:                return name;
103:            }
104:
105:            /**
106:             * Mutator for the name of the PK constraint.
107:             * @param name The name to use
108:             */
109:            public void setName(String name) {
110:                this .name = name;
111:            }
112:
113:            /**
114:             * Add a new ColumnMetaData element
115:             * @param colmd The ColumnMetaData to add
116:             */
117:            public void addColumn(ColumnMetaData colmd) {
118:                columns.add(colmd);
119:                colmd.parent = this ;
120:            }
121:
122:            /**
123:             * Accessor for columnMetaData
124:             * @return Returns the columnMetaData.
125:             */
126:            public final ColumnMetaData[] getColumnMetaData() {
127:                return columnMetaData;
128:            }
129:
130:            //  ----------------------------- Utilities ---------------------------------
131:
132:            /**
133:             * Returns a string representation of the object using a prefix
134:             * @param prefix prefix string
135:             * @param indent indent string
136:             * @return a string representation of the object.
137:             */
138:            public String toString(String prefix, String indent) {
139:                StringBuffer sb = new StringBuffer();
140:                sb.append(prefix).append(
141:                        "<primary-key"
142:                                + (name != null ? (" name=\"" + name + "\"")
143:                                        : "")
144:                                + (columnName != null ? (" column=\""
145:                                        + columnName + "\"") : "") + ">\n");
146:
147:                // Add columns
148:                if (columnMetaData != null) {
149:                    for (int i = 0; i < columnMetaData.length; i++) {
150:                        sb.append(columnMetaData[i].toString(prefix + indent,
151:                                indent));
152:                    }
153:                }
154:
155:                // Add extensions
156:                sb.append(super .toString(prefix + indent, indent));
157:
158:                sb.append(prefix).append("</primary-key>\n");
159:
160:                return sb.toString();
161:            }
162:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.