Source Code Cross Referenced for FetchGroupMetaData.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 - changed to extend MetaData
018:        2004 Andy Jefferson - added toString()
019:            ...
020:         **********************************************************************/package org.jpox.metadata;
021:
022:        import java.util.ArrayList;
023:        import java.util.List;
024:
025:        /**
026:         * A fetch group defines a particular loaded state for an object graph. 
027:         * It specifies fields/properties to be loaded for all of the instances in the graph when
028:         * this fetch group is active.
029:         * 
030:         * @since 1.1
031:         * @version $Revision: 1.12 $
032:         */
033:        public class FetchGroupMetaData extends MetaData {
034:            /**
035:             * The post-load attribute on the fetch-group element indicates whether the
036:             * jdoPost-Load callback will be made when the fetch group is loaded. It
037:             * defaults to false, for all fetch groups except the default fetch group,
038:             * on which it defaults to true.
039:             */
040:            Boolean postLoad;
041:
042:            /**
043:             * The name attribute on a field element contained within a fetch-group
044:             * element is the name of field in the enclosing class or a dot-separated
045:             * expression identifying a field reachable from the class by navigating a
046:             * reference, collection or map. For maps of persistencecapable classes
047:             * "#key" or "#value" may be appended to the name of the map field to
048:             * navigate the key or value respectively (e.g. to include a field of the
049:             * key class or value class in the fetch group).
050:             * 
051:             * For collection and arrays of persistence-capable classes, "#element" may
052:             * be appended to the name of the field to navigate the element. This is
053:             * optional; if omitted for collections and arrays, #element is assumed.
054:             */
055:            final String name;
056:
057:            /**
058:             * A contained fetch-group element indicates that the named group is to be
059:             * included in the group being defined. Nested fetch group elements are
060:             * limited to only the name attribute.
061:             */
062:            protected FetchGroupMetaData[] fetchGroupMetaData;
063:
064:            /** members declared to be in this fetch group. */
065:            protected AbstractMemberMetaData[] memberMetaData;
066:
067:            // -------------------------------------------------------------------------
068:            // Fields below here are used in the parsing process, up to the call to
069:            // initialise(). Thereafter they are typically cleared out and shouldn't be used.
070:
071:            /**
072:             * A contained fetch-group element indicates that the named group is to be
073:             * included in the group being defined. Nested fetch group elements are
074:             * limited to only the name attribute.
075:             */
076:            protected List fetchGroups = new ArrayList();
077:
078:            /** members (fields/properties) declared to be in this fetch group. */
079:            protected List members = new ArrayList();
080:
081:            /**
082:             * Constructor.
083:             * @param parent The parent MetaData
084:             * @param postLoad Whether to use at post load
085:             * @param name Name of fetch group
086:             */
087:            public FetchGroupMetaData(MetaData parent, String postLoad,
088:                    String name) {
089:                super (parent);
090:
091:                // "postLoad"
092:                if (postLoad != null) {
093:                    if (postLoad.equalsIgnoreCase("true")) {
094:                        this .postLoad = Boolean.TRUE;
095:                    } else if (postLoad.equalsIgnoreCase("false")) {
096:                        this .postLoad = Boolean.FALSE;
097:                    }
098:                }
099:                if (this .postLoad == null) {
100:                    this .postLoad = Boolean.FALSE;
101:                }
102:
103:                // "name"
104:                this .name = name;
105:            }
106:
107:            /**
108:             * Initialisation method. This should be called AFTER using the populate
109:             * method if you are going to use populate. It creates the internal
110:             * convenience arrays etc needed for normal operation.
111:             */
112:            public void initialise() {
113:                if (members.isEmpty()) {
114:                    memberMetaData = new AbstractMemberMetaData[0];
115:                } else {
116:                    memberMetaData = new AbstractMemberMetaData[members.size()];
117:                    for (int i = 0; i < memberMetaData.length; i++) {
118:                        memberMetaData[i] = (AbstractMemberMetaData) members
119:                                .get(i);
120:                    }
121:                }
122:
123:                if (fetchGroups.isEmpty()) {
124:                    fetchGroupMetaData = new FetchGroupMetaData[0];
125:                } else {
126:                    fetchGroupMetaData = new FetchGroupMetaData[fetchGroups
127:                            .size()];
128:                    for (int i = 0; i < fetchGroupMetaData.length; i++) {
129:                        fetchGroupMetaData[i] = (FetchGroupMetaData) fetchGroups
130:                                .get(i);
131:                    }
132:                }
133:                for (int i = 0; i < fetchGroupMetaData.length; i++) {
134:                    fetchGroupMetaData[i].initialise();
135:                }
136:
137:                super .initialise();
138:
139:                // Clear out parsing data
140:                fetchGroups.clear();
141:                fetchGroups = null;
142:                members.clear();
143:                members = null;
144:            }
145:
146:            /**
147:             * Accessor for name
148:             * @return Returns the name.
149:             */
150:            public final String getName() {
151:                return name;
152:            }
153:
154:            /**
155:             * Accessor for postLoad
156:             * @return Returns the postLoad.
157:             */
158:            public final Boolean getPostLoad() {
159:                return postLoad;
160:            }
161:
162:            /**
163:             * Accessor for fetchGroupMetaData
164:             * @return Returns the fetchGroupMetaData.
165:             */
166:            public final FetchGroupMetaData[] getFetchGroupMetaData() {
167:                return fetchGroupMetaData;
168:            }
169:
170:            /**
171:             * Accessor for metadata for the members of this group.
172:             * @return Returns the metadata for members
173:             */
174:            public final AbstractMemberMetaData[] getMemberMetaData() {
175:                return memberMetaData;
176:            }
177:
178:            // ------------------------------ Mutators ---------------------------------
179:
180:            /**
181:             * Add a new FetchGroupMetaData
182:             * @param fgmd the fetch group
183:             */
184:            public void addFetchGroup(FetchGroupMetaData fgmd) {
185:                fetchGroups.add(fgmd);
186:            }
187:
188:            /**
189:             * Add a new field/property.
190:             * @param mmd the field/property metadata
191:             */
192:            public void addMember(AbstractMemberMetaData mmd) {
193:                members.add(mmd);
194:            }
195:
196:            // ----------------------------- Utilities ------------------------------------
197:
198:            /**
199:             * Returns a string representation of the object.
200:             * This can be used as part of a facility to output a MetaData file. 
201:             * @param prefix prefix string
202:             * @param indent indent string
203:             * @return a string representation of the object.
204:             */
205:            public String toString(String prefix, String indent) {
206:                StringBuffer sb = new StringBuffer();
207:                sb.append(prefix)
208:                        .append("<fetch-group name=\"" + name + "\"\n");
209:
210:                // Add fetch-groups
211:                if (fetchGroupMetaData != null) {
212:                    for (int i = 0; i < fetchGroupMetaData.length; i++) {
213:                        sb.append(fetchGroupMetaData[i].toString(prefix
214:                                + indent, indent));
215:                    }
216:                }
217:
218:                // Add fields
219:                if (memberMetaData != null) {
220:                    for (int i = 0; i < memberMetaData.length; i++) {
221:                        sb.append(memberMetaData[i].toString(prefix + indent,
222:                                indent));
223:                    }
224:                }
225:
226:                sb.append(prefix + "</fetch-group>\n");
227:                return sb.toString();
228:            }
229:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.