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


001:        /**********************************************************************
002:        Copyright (c) 2007 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;
018:
019:        import java.io.Serializable;
020:        import java.lang.reflect.Field;
021:        import java.util.Collection;
022:        import java.util.HashSet;
023:        import java.util.Iterator;
024:
025:        import org.jpox.exceptions.JPOXUserException;
026:        import org.jpox.util.ClassUtils;
027:        import org.jpox.util.Localiser;
028:
029:        /**
030:         * Group of fields for fetching, to be part of a FetchPlan.
031:         * @version $Revision: 1.2 $
032:         */
033:        public class FetchGroupImpl implements  FetchGroup, Serializable {
034:            /** Localisation utility for output messages */
035:            protected static final Localiser LOCALISER = Localiser
036:                    .getInstance("org.jpox.Localisation");
037:
038:            /** Name of the group. */
039:            private String name;
040:
041:            /** The class that this group is for. */
042:            private Class cls;
043:
044:            /** Whether the postLoad callback is to be called when this group is loaded. */
045:            private boolean postLoad = false;
046:
047:            /** Names of the fields of the class that are part of this group. */
048:            private Collection fieldNames = new HashSet();
049:
050:            /** FetchPlans listening to this group for changes. */
051:            private Collection planListeners = new HashSet();
052:
053:            /**
054:             * Constructor.
055:             * @param name Name of the group
056:             * @param cls The class
057:             */
058:            public FetchGroupImpl(String name, Class cls) {
059:                this .name = name;
060:                this .cls = cls;
061:            }
062:
063:            /**
064:             * Accessor for the group name.
065:             * @return Name of the group
066:             */
067:            public String getName() {
068:                return name;
069:            }
070:
071:            /**
072:             * Accessor for the class that this group is for.
073:             * @return the class
074:             */
075:            public Class getFetchGroupClass() {
076:                return cls;
077:            }
078:
079:            /**
080:             * Accessor for the class for this fetch group.
081:             * @return Name of the class for this group
082:             */
083:            public String getClassName() {
084:                return cls.getName();
085:            }
086:
087:            /**
088:             * Mutator for whether the postLoad callback should be called on loading this fetch group.
089:             * @param postLoad Whether the postLoad callback should be called.
090:             */
091:            public void setPostLoad(boolean postLoad) {
092:                this .postLoad = postLoad;
093:            }
094:
095:            /**
096:             * Accessor for whether to call postLoad when this group is loaded.
097:             * @return Whether to call postLoad
098:             */
099:            public boolean getPostLoad() {
100:                return postLoad;
101:            }
102:
103:            /**
104:             * Accessor for whether a particular field is in this group.
105:             * @param fieldName Name of the field
106:             * @return Whether it is present
107:             */
108:            public boolean hasField(String fieldName) {
109:                return fieldNames.contains(fieldName);
110:            }
111:
112:            /**
113:             * Accessor for the names of the fields in this fetch group.
114:             * @return Names of the fields in the group
115:             */
116:            public String[] getFieldNames() {
117:                return (String[]) fieldNames.toArray(new String[fieldNames
118:                        .size()]);
119:            }
120:
121:            /**
122:             * Method to add a field of the class to the fetch group.
123:             * @param fieldName Name of the field
124:             * @return This FetchGroup
125:             * @throws JPOXUserException if the field doesnt exist for this class
126:             */
127:            public FetchGroup add(String fieldName) {
128:                Field fld = ClassUtils.getFieldForClass(cls, fieldName);
129:                if (fld == null) {
130:                    throw new JPOXUserException(LOCALISER.msg("006004",
131:                            fieldName, cls.getName()));
132:                }
133:                this .fieldNames.add(fieldName);
134:                notifyListeners();
135:                return this ;
136:            }
137:
138:            /**
139:             * Method to remove a field of the class from the fetch group.
140:             * @param fieldName Name of the field
141:             * @return This FetchGroup
142:             */
143:            public FetchGroup remove(String fieldName) {
144:                this .fieldNames.remove(fieldName);
145:                notifyListeners();
146:                return this ;
147:            }
148:
149:            /**
150:             * Method to notify all FetchPlan listeners that this group has changed.
151:             */
152:            private void notifyListeners() {
153:                Iterator iter = planListeners.iterator();
154:                while (iter.hasNext()) {
155:                    ((FetchPlan) iter.next()).notifyFetchGroupChange(this );
156:                }
157:            }
158:
159:            /**
160:             * Method to register a listener for changes to this FetchGroup.
161:             * @param plan The FetchPlan that is listening
162:             */
163:            public void registerListener(FetchPlan plan) {
164:                planListeners.add(plan);
165:            }
166:
167:            /**
168:             * Method to deregister a listener for changes to this FetchGroup.
169:             * @param plan The FetchPlan that is no longer listening
170:             */
171:            public void deregisterListener(FetchPlan plan) {
172:                planListeners.remove(plan);
173:            }
174:
175:            /**
176:             * Method to disconnect this fetch group from all listeners since the group is removed from use.
177:             */
178:            public void disconnectFromListeners() {
179:                Iterator iter = planListeners.iterator();
180:                while (iter.hasNext()) {
181:                    ((FetchPlan) iter.next()).notifyFetchGroupRemove(this);
182:                }
183:                planListeners.clear();
184:            }
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.