Source Code Cross Referenced for Set.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas_ejb » container » jorm » 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 » J2EE » JOnAS 4.8.6 » org.objectweb.jonas_ejb.container.jorm 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999-2004 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * --------------------------------------------------------------------------
022:         * $Id: Set.java 10145 2007-04-05 06:50:20Z durieuxp $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas_ejb.container.jorm;
025:
026:        import org.objectweb.jorm.api.PClassMapping;
027:        import org.objectweb.jorm.api.PException;
028:
029:        import javax.ejb.EJBException;
030:        import javax.ejb.NoSuchObjectLocalException;
031:
032:        import java.lang.reflect.Array;
033:        import java.util.Iterator;
034:
035:        import org.objectweb.jonas_ejb.container.TraceEjb;
036:        import org.objectweb.util.monolog.api.BasicLevel;
037:
038:        /**
039:         * This class is a basic implementation of the java.util.Set based on the
040:         * generic class implementation (GenClassImpl) and the Collection
041:         * implementation. This class can be used to represent a relation between bean.
042:         *
043:         * @author S.Chassande-Barrioz : Initial developer
044:         * @author Helene Joanin : fix bugs in the toArray(...) methods
045:         */
046:        public class Set extends GenClassImpl implements  java.util.Set {
047:
048:            public Set() {
049:                super ();
050:            }
051:
052:            /**
053:             * Before adding the object into the set, it checks that the new element
054:             * does not exist.
055:             * @param o is the element to add
056:             * @return true is the element has been added, and false is the element
057:             * already exists in the set.
058:             */
059:            public boolean add(Object o) {
060:                return add(o, true);
061:            }
062:
063:            public boolean add(Object o, boolean callListener) {
064:                TraceEjb.genclass.log(BasicLevel.DEBUG, "");
065:                try {
066:                    if (!gcContains((PObject) o, null)) {
067:                        gcAdd((PObject) o, callListener);
068:                        return true;
069:                    } else {
070:                        return false;
071:                    }
072:                } catch (NoSuchObjectLocalException e) {
073:                    throw new IllegalArgumentException(e.getMessage());
074:                } catch (PException e) {
075:                    e.printStackTrace();
076:                    return false;
077:                }
078:            }
079:
080:            //------------------------------------//
081:
082:            public int size() {
083:                return size;
084:            }
085:
086:            public boolean isEmpty() {
087:                return size == 0;
088:            }
089:
090:            public boolean contains(Object o) {
091:                TraceEjb.genclass.log(BasicLevel.DEBUG, "");
092:                try {
093:                    return gcContains((PObject) o, null);
094:                } catch (PException e) {
095:                    e.printStackTrace();
096:                    throw new ArrayStoreException(e.getMessage());
097:                }
098:            }
099:
100:            public Iterator iterator() {
101:                try {
102:                    return gcIterator();
103:                } catch (PException e) {
104:                    e.printStackTrace();
105:                    throw new ArrayStoreException(e.getMessage());
106:                }
107:            }
108:
109:            /**
110:             * It returns an array of the elements.
111:             * @return array of the elements
112:             */
113:            public Object[] toArray() {
114:                return toArray(new Object[size]);
115:            }
116:
117:            /**
118:             * It returns an array of the elements.
119:             * It is built by an iteration over the existing elements.
120:             * @param objects the array into which the elements of this collection are to be stored
121:             * @return array of the elements
122:             */
123:            public Object[] toArray(Object[] objects) {
124:                try {
125:                    int i = 0;
126:                    for (Iterator it = gcIterator(); it.hasNext();) {
127:                        objects[i++] = it.next();
128:                    }
129:                } catch (PException e) {
130:                    e.printStackTrace();
131:                    throw new ArrayStoreException(e.getMessage());
132:                }
133:                return objects;
134:            }
135:
136:            public boolean remove(Object o) {
137:                try {
138:                    return gcRemove(o, true) != null;
139:                } catch (PException e) {
140:                    throw new EJBException(e);
141:                }
142:
143:            }
144:
145:            public boolean remove(Object o, boolean callListener) {
146:                TraceEjb.genclass.log(BasicLevel.DEBUG, "");
147:                try {
148:                    return gcRemove(o, callListener) != null;
149:                } catch (PException e) {
150:                    throw new EJBException(e);
151:                }
152:
153:            }
154:
155:            public boolean containsAll(java.util.Collection collection) {
156:                TraceEjb.genclass.log(BasicLevel.DEBUG, "");
157:                if (collection == null) {
158:                    return true;
159:                }
160:                try {
161:                    boolean res = true;
162:                    Object conn = gcm.getPMapper().getConnection();
163:                    for (Iterator it = collection.iterator(); it.hasNext()
164:                            && res;) {
165:                        res = gcContains((PObject) it.next(), conn);
166:                    }
167:                    gcm.getPMapper().closeConnection(conn);
168:                    return res;
169:                } catch (PException e) {
170:                    e.printStackTrace();
171:                    throw new ArrayStoreException(e.getMessage());
172:                }
173:            }
174:
175:            /**
176:             * It iterates over the collection parameter to add each element in the
177:             * collection.
178:             * @param collection the collection of elements to add
179:             */
180:            public boolean addAll(java.util.Collection collection) {
181:                TraceEjb.genclass.log(BasicLevel.DEBUG, "");
182:                if (collection == null) {
183:                    return true;
184:                }
185:                boolean res = true;
186:                for (Iterator it = collection.iterator(); it.hasNext();) {
187:                    res &= add((PObject) it.next());
188:                }
189:                return res;
190:            }
191:
192:            /**
193:             * It iterates over the collection parameter to remove each element in the
194:             * collection.
195:             * @param collection The collection of elements to remove
196:             */
197:            public boolean removeAll(java.util.Collection collection) {
198:                TraceEjb.genclass.log(BasicLevel.DEBUG, "");
199:                if (collection == null) {
200:                    return true;
201:                }
202:                try {
203:                    for (Iterator it = collection.iterator(); it.hasNext();) {
204:                        gcRemove((PObject) it.next(), true);
205:                    }
206:                } catch (PException e) {
207:                    throw new EJBException(e);
208:                }
209:                return true;
210:            }
211:
212:            /**
213:             * For each element of the current collection, it checks if it exist into
214:             * the collection parameter. If it does not found then it is removed from
215:             * the current collection.
216:             */
217:            public boolean retainAll(java.util.Collection collection) {
218:                TraceEjb.genclass.log(BasicLevel.DEBUG, "");
219:                if (collection == null) {
220:                    clear();
221:                    return true;
222:                }
223:                try {
224:                    for (Iterator it = iterator(); it.hasNext();) {
225:                        PObject o = (PObject) it.next();
226:                        if (!collection.contains(o)) {
227:                            gcRemove(o, true);
228:                        }
229:                    }
230:                } catch (PException e) {
231:                    throw new EJBException(e);
232:                }
233:                return true;
234:            }
235:
236:            /**
237:             * It removes all elements.
238:             */
239:            public void clear() {
240:                TraceEjb.genclass.log(BasicLevel.DEBUG, "");
241:                gcClear(false);
242:            }
243:
244:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.