Source Code Cross Referenced for PersistenceFileMetaData.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) 2006 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:        Contributors:
016:            ...
017:         **********************************************************************/package org.jpox.metadata;
018:
019:        import java.util.HashSet;
020:        import java.util.Iterator;
021:
022:        /**
023:         * Representation of a Meta-Data "persistence.xml" file. 
024:         * Contains a set of "persistence-unit" meta-data.
025:         *
026:         * @since 1.1 
027:         * @version $Revision: 1.4 $
028:         */
029:        public class PersistenceFileMetaData extends MetaData {
030:            /** Filename of the "persistence.xml" */
031:            protected String filename = null;
032:
033:            /** Persistence units defined in this file. */
034:            protected HashSet persistenceUnits = new HashSet();
035:
036:            /**
037:             * Constructor.
038:             * @param filename The file where this is stored (or null).
039:             */
040:            public PersistenceFileMetaData(String filename) {
041:                super (null);
042:
043:                this .filename = filename;
044:            }
045:
046:            // ------------------------------ Accessors --------------------------------
047:
048:            /**
049:             * Accessor for the filename
050:             * @return The filename of this MetaData file.
051:             */
052:            public String getFilename() {
053:                return filename;
054:            }
055:
056:            /**
057:             * Accessor for the number of persistence units.
058:             * @return no of persistence units.
059:             */
060:            public int getNoOfPersistenceUnits() {
061:                return persistenceUnits.size();
062:            }
063:
064:            /**
065:             * Accessor for the Meta-Data of a persistence unit with a given name.
066:             * @param name Name of the persistence unit
067:             * @return Meta-Data for the persistence unit
068:             */
069:            public PersistenceUnitMetaData getPersistenceUnit(String name) {
070:                Iterator iter = persistenceUnits.iterator();
071:                while (iter.hasNext()) {
072:                    PersistenceUnitMetaData p = (PersistenceUnitMetaData) iter
073:                            .next();
074:                    if (p.name.equals(name)) {
075:                        return p;
076:                    }
077:                }
078:                return null;
079:            }
080:
081:            /**
082:             * Accessor for the persistence units in this "persistence.xml" file.
083:             * @return The persistence units
084:             */
085:            public PersistenceUnitMetaData[] getPersistenceUnits() {
086:                if (persistenceUnits.size() == 0) {
087:                    return null;
088:                }
089:
090:                return (PersistenceUnitMetaData[]) persistenceUnits
091:                        .toArray(new PersistenceUnitMetaData[persistenceUnits
092:                                .size()]);
093:            }
094:
095:            // -------------------------------- Mutators -------------------------------
096:
097:            /**
098:             * Mutator for the filename for this MetaData file.
099:             * @param filename The filename of this MetaData file.
100:             */
101:            public void setFilename(String filename) {
102:                this .filename = filename;
103:            }
104:
105:            /**
106:             * Method to add a persistence unit
107:             * @param pumd The PersistenceUnitMetaData to add.
108:             **/
109:            public void addPersistenceUnit(PersistenceUnitMetaData pumd) {
110:                if (pumd == null) {
111:                    return;
112:                }
113:                Iterator iter = persistenceUnits.iterator();
114:                while (iter.hasNext()) {
115:                    PersistenceUnitMetaData p = (PersistenceUnitMetaData) iter
116:                            .next();
117:                    // Check if already exists
118:                    if (pumd.getName().equals(p.getName())) {
119:                        return;
120:                    }
121:                }
122:                persistenceUnits.add(pumd);
123:            }
124:
125:            // -------------------------------- Utilities ------------------------------
126:
127:            /**
128:             * Returns a string representation of the object.
129:             * @param indent The indent
130:             * @return a string representation of the object.
131:             */
132:            public String toString(String indent) {
133:                if (indent == null) {
134:                    indent = "";
135:                }
136:
137:                StringBuffer sb = new StringBuffer();
138:                sb.append("<persistence>\n");
139:
140:                // Add persistence units
141:                Iterator iter = persistenceUnits.iterator();
142:                while (iter.hasNext()) {
143:                    sb.append(((PersistenceUnitMetaData) iter.next()).toString(
144:                            indent, indent));
145:                }
146:
147:                sb.append("</persistence>");
148:                return sb.toString();
149:            }
150:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.