Source Code Cross Referenced for DeleteFieldManager.java in  » Database-ORM » JPOX » org » jpox » store » fieldmanager » 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.store.fieldmanager 
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.store.fieldmanager;
018:
019:        import java.lang.reflect.Array;
020:        import java.util.Collection;
021:        import java.util.Iterator;
022:        import java.util.Map;
023:        import java.util.Set;
024:
025:        import org.jpox.StateManager;
026:        import org.jpox.api.ApiAdapter;
027:        import org.jpox.metadata.AbstractMemberMetaData;
028:
029:        /**
030:         * Field manager that deletes all "dependent" PC objects referenced from the source object.
031:         * Effectively provides "delete-dependent".
032:         * 
033:         * @version $Revision: 1.9 $
034:         **/
035:        public class DeleteFieldManager extends AbstractFieldManager {
036:            /** StateManager for the owning object. */
037:            private final StateManager sm;
038:
039:            /**
040:             * Constructor.
041:             * @param sm The state manager for the object.
042:             **/
043:            public DeleteFieldManager(StateManager sm) {
044:                this .sm = sm;
045:            }
046:
047:            /**
048:             * Utility method to process the passed persistable object.
049:             * @param pc The PC object
050:             */
051:            protected void processPersistable(Object pc) {
052:                // Delete it
053:                // TODO Are there particular object states that we dont want to do this for?
054:                sm.getObjectManager().deleteObjectInternal(pc);
055:            }
056:
057:            /**
058:             * Method to store an object field.
059:             * @param fieldNumber Number of the field (absolute)
060:             * @param value Value of the field
061:             */
062:            public void storeObjectField(int fieldNumber, Object value) {
063:                if (value != null) {
064:                    AbstractMemberMetaData fmd = sm.getClassMetaData()
065:                            .getMetaDataForManagedMemberAtAbsolutePosition(
066:                                    fieldNumber);
067:                    ApiAdapter api = sm.getObjectManager().getApiAdapter();
068:                    if (api.isPersistable(value)) {
069:                        // Process PC fields
070:                        if (fmd.isDependent()) {
071:                            processPersistable(value);
072:                        }
073:                    } else if (value instanceof  Collection) {
074:                        // Process all elements of the Collection that are PC
075:                        if (fmd.hasCollection()
076:                                && fmd.getCollection().isDependentElement()) {
077:                            // Process any elements that are PersistenceCapable
078:                            Collection coll = (Collection) value;
079:                            Iterator iter = coll.iterator();
080:                            while (iter.hasNext()) {
081:                                Object element = iter.next();
082:                                if (api.isPersistable(element)) {
083:                                    processPersistable(element);
084:                                }
085:                            }
086:                        }
087:                    } else if (value instanceof  Map) {
088:                        // Process all keys, values of the Map that are PC
089:                        Map map = (Map) value;
090:                        if (fmd.hasMap() && fmd.getMap().isDependentKey()) {
091:                            // Process any keys that are PersistenceCapable
092:                            Set keys = map.keySet();
093:                            Iterator iter = keys.iterator();
094:                            while (iter.hasNext()) {
095:                                Object mapKey = iter.next();
096:                                if (api.isPersistable(mapKey)) {
097:                                    processPersistable(mapKey);
098:                                }
099:                            }
100:                        }
101:                        if (fmd.hasMap() && fmd.getMap().isDependentValue()) {
102:                            // Process any values that are PersistenceCapable
103:                            Collection values = map.values();
104:                            Iterator iter = values.iterator();
105:                            while (iter.hasNext()) {
106:                                Object mapValue = iter.next();
107:                                if (api.isPersistable(mapValue)) {
108:                                    processPersistable(mapValue);
109:                                }
110:                            }
111:                        }
112:                    } else if (value instanceof  Object[]) {
113:                        // Process all array elements that are PC
114:                        if (fmd.hasArray()
115:                                && fmd.getArray().isDependentElement()) {
116:                            // Process any array elements that are PersistenceCapable
117:                            for (int i = 0; i < Array.getLength(value); i++) {
118:                                Object element = Array.get(value, i);
119:                                if (api.isPersistable(element)) {
120:                                    processPersistable(element);
121:                                }
122:                            }
123:                        }
124:                    } else {
125:                        // Primitive, or primitive array, or some unsupported container type
126:                    }
127:                }
128:            }
129:
130:            /**
131:             * Method to store a boolean field.
132:             * @param fieldNumber Number of the field (absolute)
133:             * @param value Value of the field
134:             */
135:            public void storeBooleanField(int fieldNumber, boolean value) {
136:                // Do nothing
137:            }
138:
139:            /**
140:             * Method to store a byte field.
141:             * @param fieldNumber Number of the field (absolute)
142:             * @param value Value of the field
143:             */
144:            public void storeByteField(int fieldNumber, byte value) {
145:                // Do nothing
146:            }
147:
148:            /**
149:             * Method to store a char field.
150:             * @param fieldNumber Number of the field (absolute)
151:             * @param value Value of the field
152:             */
153:            public void storeCharField(int fieldNumber, char value) {
154:                // Do nothing
155:            }
156:
157:            /**
158:             * Method to store a double field.
159:             * @param fieldNumber Number of the field (absolute)
160:             * @param value Value of the field
161:             */
162:            public void storeDoubleField(int fieldNumber, double value) {
163:                // Do nothing
164:            }
165:
166:            /**
167:             * Method to store a float field.
168:             * @param fieldNumber Number of the field (absolute)
169:             * @param value Value of the field
170:             */
171:            public void storeFloatField(int fieldNumber, float value) {
172:                // Do nothing
173:            }
174:
175:            /**
176:             * Method to store an int field.
177:             * @param fieldNumber Number of the field (absolute)
178:             * @param value Value of the field
179:             */
180:            public void storeIntField(int fieldNumber, int value) {
181:                // Do nothing
182:            }
183:
184:            /**
185:             * Method to store a long field.
186:             * @param fieldNumber Number of the field (absolute)
187:             * @param value Value of the field
188:             */
189:            public void storeLongField(int fieldNumber, long value) {
190:                // Do nothing
191:            }
192:
193:            /**
194:             * Method to store a short field.
195:             * @param fieldNumber Number of the field (absolute)
196:             * @param value Value of the field
197:             */
198:            public void storeShortField(int fieldNumber, short value) {
199:                // Do nothing
200:            }
201:
202:            /**
203:             * Method to store a string field.
204:             * @param fieldNumber Number of the field (absolute)
205:             * @param value Value of the field
206:             */
207:            public void storeStringField(int fieldNumber, String value) {
208:                // Do nothing
209:            }
210:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.