Source Code Cross Referenced for ElementMetaData.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 Erik Bengtson 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:        2004 Andy Jefferson - added toString(), MetaData docs, javadocs.
018:        2004 Andy Jefferson - added unique, indexed
019:            ...
020:         **********************************************************************/package org.jpox.metadata;
021:
022:        import org.jpox.ClassLoaderResolver;
023:
024:        /**
025:         * This element specifies the mapping for the element component of arrays and
026:         * collections.
027:         * 
028:         * If only one column is mapped, and no additional information is needed for the
029:         * column, then the column attribute can be used. Otherwise, the column
030:         * element(s) are used.
031:         * 
032:         * The serialized attribute specifies that the key values are to be serialized
033:         * into the named column.
034:         * 
035:         * The foreign-key attribute specifies the name of a foreign key to be
036:         * generated.
037:         *
038:         * <H3>MetaData Element</H3>
039:         * The MetaData element represented here is as follows
040:         * <PRE>
041:         * &lt;!ELEMENT element (extension*,embedded?,column*,foreign-key?,index?,unique?,extension*)&gt;
042:         * &lt;!ATTLIST element column CDATA #IMPLIED&gt;
043:         * &lt;!ATTLIST element delete-action (restrict|cascade|null|default|none) #IMPLIED&gt;
044:         * &lt;!ATTLIST element update-action CDATA #IMPLIED&gt;
045:         * &lt;!ATTLIST element indexed (true|false|unique) #IMPLIED&gt;
046:         * &lt;!ATTLIST element unique (true|false) #IMPLIED&gt;
047:         * &lt;!ATTLIST element mapped-by CDATA #IMPLIED&gt;
048:         * </PRE>
049:         *
050:         * @since 1.1
051:         * @version $Revision: 1.19 $
052:         */
053:        public class ElementMetaData extends AbstractElementMetaData {
054:            /**
055:             * Constructor to create a copy of the passed metadata using the provided parent.
056:             * @param parent The parent
057:             * @param emd The metadata to copy
058:             */
059:            public ElementMetaData(MetaData parent, ElementMetaData emd) {
060:                super (parent, emd);
061:            }
062:
063:            /**
064:             * Constructor.
065:             * @param parent Parent element
066:             * @param column The column tag
067:             * @param deleteAction attribute delete-action value
068:             * @param updateAction attribute update-action value
069:             * @param indexed Whether to index this
070:             * @param unique Whether to add a unique constraint
071:             * @param mappedBy Mapped by field
072:             */
073:            public ElementMetaData(MetaData parent, String column,
074:                    String deleteAction, String updateAction, String indexed,
075:                    String unique, String mappedBy) {
076:                super (parent, column, deleteAction, updateAction, indexed,
077:                        unique, mappedBy);
078:            }
079:
080:            /**
081:             * Populate the MetaData.
082:             * @param clr Class loader to use
083:             * @param primary the primary ClassLoader to use (or null)
084:             */
085:            public void populate(ClassLoaderResolver clr, ClassLoader primary) {
086:                if (embeddedMetaData == null
087:                        && ((AbstractMemberMetaData) parent).hasCollection()
088:                        && ((AbstractMemberMetaData) parent).getCollection()
089:                                .isEmbeddedElement()
090:                        && ((AbstractMemberMetaData) parent).getJoinMetaData() != null
091:                        && ((AbstractMemberMetaData) parent).getCollection()
092:                                .getElementClassMetaData() != null) {
093:                    // User has specified that the element is embedded in a join table but not how we embed it
094:                    // so add a dummy definition
095:                    embeddedMetaData = new EmbeddedMetaData(this , null, null,
096:                            null);
097:                }
098:                super .populate(clr, primary);
099:            }
100:
101:            // ------------------------------- Utilities -------------------------------
102:
103:            /**
104:             * Returns a string representation of the object using a prefix
105:             * This can be used as part of a facility to output a MetaData file. 
106:             * @param prefix prefix string
107:             * @param indent indent string
108:             * @return a string representation of the object.
109:             */
110:            public String toString(String prefix, String indent) {
111:                // Field needs outputting so generate metadata
112:                StringBuffer sb = new StringBuffer();
113:                sb.append(prefix).append("<element");
114:                if (mappedBy != null) {
115:                    sb.append(" mapped-by=\"" + mappedBy + "\"");
116:                }
117:                if (columnName != null) {
118:                    sb.append("\n");
119:                    sb.append(prefix).append(
120:                            "          column=\"" + columnName + "\"");
121:                }
122:                sb.append(">\n");
123:
124:                // Add columns
125:                for (int i = 0; i < columns.size(); i++) {
126:                    ColumnMetaData colmd = (ColumnMetaData) columns.get(i);
127:                    sb.append(colmd.toString(prefix + indent, indent));
128:                }
129:
130:                // Add index metadata
131:                if (indexMetaData != null) {
132:                    sb.append(indexMetaData.toString(prefix + indent, indent));
133:                }
134:
135:                // Add unique metadata
136:                if (uniqueMetaData != null) {
137:                    sb.append(uniqueMetaData.toString(prefix + indent, indent));
138:                }
139:
140:                // Add embedded metadata
141:                if (embeddedMetaData != null) {
142:                    sb.append(embeddedMetaData
143:                            .toString(prefix + indent, indent));
144:                }
145:
146:                // Add foreign-key metadata
147:                if (foreignKeyMetaData != null) {
148:                    sb.append(foreignKeyMetaData.toString(prefix + indent,
149:                            indent));
150:                }
151:
152:                // Add extensions
153:                sb.append(super .toString(prefix + indent, indent));
154:
155:                sb.append(prefix).append("</element>\n");
156:                return sb.toString();
157:            }
158:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.