Source Code Cross Referenced for UniqueMetaData.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) 2004 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:        /**
021:         * MetaData representing a unique constraint.
022:         *
023:         * @since 1.1
024:         * @version $Revision: 1.17 $
025:         */
026:        public class UniqueMetaData extends AbstractConstraintMetaData
027:                implements  ColumnMetaDataContainer {
028:            /**
029:             * Whether the unique is initially deferred.
030:             */
031:            final boolean deferred;
032:
033:            /**
034:             * Constructor to create a copy of the passed metadata using the provided parent.
035:             * @param umd The metadata to copy
036:             */
037:            public UniqueMetaData(UniqueMetaData umd) {
038:                super (null, umd.name, umd.table);
039:
040:                this .deferred = umd.deferred;
041:                // TODO Change these to copy rather than reference
042:                for (int i = 0; i < umd.members.size(); i++) {
043:                    addMember((AbstractMemberMetaData) umd.members.get(i));
044:                }
045:                for (int i = 0; i < umd.columns.size(); i++) {
046:                    addColumn((ColumnMetaData) umd.columns.get(i));
047:                }
048:            }
049:
050:            /**
051:             * Constructor.
052:             * @param name Name of unique constraint
053:             * @param table Name of the table
054:             * @param deferredValue Whether the unique is deferred initially
055:             */
056:            public UniqueMetaData(final String name, final String table,
057:                    final String deferredValue) {
058:                super (null, name, table); // Ignore parent
059:
060:                if (deferredValue != null
061:                        && deferredValue.equalsIgnoreCase("true")) {
062:                    this .deferred = true;
063:                } else {
064:                    this .deferred = false;
065:                }
066:            }
067:
068:            /**
069:             * Method to initialise the object, creating internal convenience arrays.
070:             * Initialise all sub-objects.
071:             */
072:            public void initialise() {
073:                if (isInitialised()) {
074:                    return;
075:                }
076:
077:                // Set up the fieldMetaData
078:                if (members.size() == 0) {
079:                    memberMetaData = null;
080:                } else {
081:                    memberMetaData = new AbstractMemberMetaData[members.size()];
082:                    for (int i = 0; i < memberMetaData.length; i++) {
083:                        memberMetaData[i] = (AbstractMemberMetaData) members
084:                                .get(i);
085:                        memberMetaData[i].initialise();
086:                    }
087:                }
088:
089:                // Set up the columnMetaData
090:                if (columns.size() == 0) {
091:                    columnMetaData = null;
092:                } else {
093:                    columnMetaData = new ColumnMetaData[columns.size()];
094:                    for (int i = 0; i < columnMetaData.length; i++) {
095:                        columnMetaData[i] = (ColumnMetaData) columns.get(i);
096:                        columnMetaData[i].initialise();
097:                    }
098:                }
099:
100:                // Clear out parsing data
101:                members.clear();
102:                members = null;
103:                columns.clear();
104:                columns = null;
105:
106:                setInitialised();
107:            }
108:
109:            // -------------------------------- Mutators -------------------------------
110:
111:            /**
112:             * Accessor for whether the unique constraint is deferred.
113:             * @return Returns whether the unique constraint is deferred
114:             */
115:            public final boolean isDeferred() {
116:                return deferred;
117:            }
118:
119:            // -------------------------------- Utilities ------------------------------
120:
121:            /**
122:             * Returns a string representation of the object.
123:             * This can be used as part of a facility to output a MetaData file. 
124:             * @param prefix prefix string
125:             * @param indent indent string
126:             * @return a string representation of the object.
127:             */
128:            public String toString(String prefix, String indent) {
129:                StringBuffer sb = new StringBuffer();
130:                sb.append(prefix).append("<unique");
131:                if (table != null) {
132:                    sb.append(" table=\"" + table + "\"");
133:                }
134:                if (deferred) {
135:                    sb.append(" deferred=\"true\"");
136:                }
137:                sb.append(name != null ? (" name=\"" + name + "\">\n") : ">\n");
138:
139:                // Add fields
140:                if (memberMetaData != null) {
141:                    for (int i = 0; i < memberMetaData.length; i++) {
142:                        sb.append(memberMetaData[i].toString(prefix + indent,
143:                                indent));
144:                    }
145:                }
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("</unique>\n");
159:                return sb.toString();
160:            }
161:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.