Source Code Cross Referenced for DelegatingResultList.java in  » Database-ORM » openjpa » org » apache » openjpa » kernel » 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 » openjpa » org.apache.openjpa.kernel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements.  See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership.  The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License.  You may obtain a copy of the License at
009:         *
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied.  See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.    
018:         */
019:        package org.apache.openjpa.kernel;
020:
021:        import java.io.ObjectStreamException;
022:        import java.util.Collection;
023:        import java.util.Iterator;
024:        import java.util.List;
025:        import java.util.ListIterator;
026:
027:        import org.apache.openjpa.lib.rop.ResultList;
028:        import org.apache.openjpa.util.RuntimeExceptionTranslator;
029:
030:        /**
031:         * Delegating result list that can also perform exception translation
032:         * for use in facades.
033:         *
034:         * @since 0.4.0
035:         * @author Marc Prud'hommeaux
036:         * @nojavadoc
037:         */
038:        public class DelegatingResultList implements  ResultList {
039:
040:            private final ResultList _del;
041:            private final RuntimeExceptionTranslator _trans;
042:
043:            /**
044:             * Constructor; supply delegate.
045:             */
046:            public DelegatingResultList(ResultList list) {
047:                this (list, null);
048:            }
049:
050:            /**
051:             * Constructor; supply delegate and exception translator.
052:             */
053:            public DelegatingResultList(ResultList list,
054:                    RuntimeExceptionTranslator trans) {
055:                _del = list;
056:                _trans = trans;
057:            }
058:
059:            /**
060:             * Return the direct delegate.
061:             */
062:            public ResultList getDelegate() {
063:                return _del;
064:            }
065:
066:            /**
067:             * Return the native delegate.
068:             */
069:            public ResultList getInnermostDelegate() {
070:                return _del instanceof  DelegatingResultList ? ((DelegatingResultList) _del)
071:                        .getInnermostDelegate()
072:                        : _del;
073:            }
074:
075:            /**
076:             * Writes delegate, which may in turn write a normal list.
077:             */
078:            public Object writeReplace() throws ObjectStreamException {
079:                return _del;
080:            }
081:
082:            public int hashCode() {
083:                try {
084:                    return getInnermostDelegate().hashCode();
085:                } catch (RuntimeException re) {
086:                    throw translate(re);
087:                }
088:            }
089:
090:            public boolean equals(Object other) {
091:                if (other == this )
092:                    return true;
093:                if (other instanceof  DelegatingResultList)
094:                    other = ((DelegatingResultList) other)
095:                            .getInnermostDelegate();
096:                try {
097:                    return getInnermostDelegate().equals(other);
098:                } catch (RuntimeException re) {
099:                    throw translate(re);
100:                }
101:            }
102:
103:            /**
104:             * Translate the OpenJPA exception.
105:             */
106:            protected RuntimeException translate(RuntimeException re) {
107:                return (_trans == null) ? re : _trans.translate(re);
108:            }
109:
110:            public boolean isProviderOpen() {
111:                try {
112:                    return _del.isProviderOpen();
113:                } catch (RuntimeException re) {
114:                    throw translate(re);
115:                }
116:            }
117:
118:            public void close() {
119:                try {
120:                    _del.close();
121:                } catch (RuntimeException re) {
122:                    throw translate(re);
123:                }
124:            }
125:
126:            public boolean isClosed() {
127:                try {
128:                    return _del.isClosed();
129:                } catch (RuntimeException re) {
130:                    throw translate(re);
131:                }
132:            }
133:
134:            public int size() {
135:                try {
136:                    return _del.size();
137:                } catch (RuntimeException re) {
138:                    throw translate(re);
139:                }
140:            }
141:
142:            public boolean isEmpty() {
143:                try {
144:                    return _del.isEmpty();
145:                } catch (RuntimeException re) {
146:                    throw translate(re);
147:                }
148:            }
149:
150:            public boolean contains(Object o) {
151:                try {
152:                    return _del.contains(o);
153:                } catch (RuntimeException re) {
154:                    throw translate(re);
155:                }
156:            }
157:
158:            public Iterator iterator() {
159:                return listIterator();
160:            }
161:
162:            public Object[] toArray() {
163:                try {
164:                    return _del.toArray();
165:                } catch (RuntimeException re) {
166:                    throw translate(re);
167:                }
168:            }
169:
170:            public Object[] toArray(Object[] a) {
171:                try {
172:                    return _del.toArray(a);
173:                } catch (RuntimeException re) {
174:                    throw translate(re);
175:                }
176:            }
177:
178:            public boolean add(Object o) {
179:                try {
180:                    return _del.add(o);
181:                } catch (RuntimeException re) {
182:                    throw translate(re);
183:                }
184:            }
185:
186:            public boolean remove(Object o) {
187:                try {
188:                    return _del.remove(o);
189:                } catch (RuntimeException re) {
190:                    throw translate(re);
191:                }
192:            }
193:
194:            public boolean containsAll(Collection c) {
195:                try {
196:                    return _del.containsAll(c);
197:                } catch (RuntimeException re) {
198:                    throw translate(re);
199:                }
200:            }
201:
202:            public boolean addAll(Collection c) {
203:                try {
204:                    return _del.addAll(c);
205:                } catch (RuntimeException re) {
206:                    throw translate(re);
207:                }
208:            }
209:
210:            public boolean addAll(int index, Collection c) {
211:                try {
212:                    return _del.addAll(index, c);
213:                } catch (RuntimeException re) {
214:                    throw translate(re);
215:                }
216:            }
217:
218:            public boolean removeAll(Collection c) {
219:                try {
220:                    return _del.removeAll(c);
221:                } catch (RuntimeException re) {
222:                    throw translate(re);
223:                }
224:            }
225:
226:            public boolean retainAll(Collection c) {
227:                try {
228:                    return _del.retainAll(c);
229:                } catch (RuntimeException re) {
230:                    throw translate(re);
231:                }
232:            }
233:
234:            public void clear() {
235:                try {
236:                    _del.clear();
237:                } catch (RuntimeException re) {
238:                    throw translate(re);
239:                }
240:            }
241:
242:            public Object get(int index) {
243:                try {
244:                    return _del.get(index);
245:                } catch (RuntimeException re) {
246:                    throw translate(re);
247:                }
248:            }
249:
250:            public Object set(int index, Object element) {
251:                try {
252:                    return _del.set(index, element);
253:                } catch (RuntimeException re) {
254:                    throw translate(re);
255:                }
256:            }
257:
258:            public void add(int index, Object element) {
259:                try {
260:                    _del.add(index, element);
261:                } catch (RuntimeException re) {
262:                    throw translate(re);
263:                }
264:            }
265:
266:            public Object remove(int index) {
267:                try {
268:                    return _del.remove(index);
269:                } catch (RuntimeException re) {
270:                    throw translate(re);
271:                }
272:            }
273:
274:            public int indexOf(Object o) {
275:                try {
276:                    return _del.indexOf(o);
277:                } catch (RuntimeException re) {
278:                    throw translate(re);
279:                }
280:            }
281:
282:            public int lastIndexOf(Object o) {
283:                try {
284:                    return _del.lastIndexOf(o);
285:                } catch (RuntimeException re) {
286:                    throw translate(re);
287:                }
288:            }
289:
290:            public ListIterator listIterator() {
291:                try {
292:                    return new DelegatingListIterator(_del.listIterator());
293:                } catch (RuntimeException re) {
294:                    throw translate(re);
295:                }
296:            }
297:
298:            public ListIterator listIterator(int index) {
299:                try {
300:                    return new DelegatingListIterator(_del.listIterator(index));
301:                } catch (RuntimeException re) {
302:                    throw translate(re);
303:                }
304:            }
305:
306:            public List subList(int fromIndex, int toIndex) {
307:                try {
308:                    return _del.subList(fromIndex, toIndex);
309:                } catch (RuntimeException re) {
310:                    throw translate(re);
311:                }
312:            }
313:
314:            /**
315:             * Delegating iterator that also performs exception translation.
316:             */
317:            public class DelegatingListIterator implements  ListIterator {
318:
319:                private final ListIterator _del;
320:
321:                /**
322:                 * Constructor; supply delegate.
323:                 */
324:                public DelegatingListIterator(ListIterator it) {
325:                    _del = it;
326:                }
327:
328:                /**
329:                 * Return the direct delegate.
330:                 */
331:                public ListIterator getDelegate() {
332:                    return _del;
333:                }
334:
335:                /**
336:                 * Return the native delegate.
337:                 */
338:                public ListIterator getInnermostDelegate() {
339:                    return _del instanceof  DelegatingListIterator ? ((DelegatingListIterator) _del)
340:                            .getInnermostDelegate()
341:                            : _del;
342:                }
343:
344:                public int hashCode() {
345:                    try {
346:                        return getInnermostDelegate().hashCode();
347:                    } catch (RuntimeException re) {
348:                        throw translate(re);
349:                    }
350:                }
351:
352:                public boolean equals(Object other) {
353:                    if (other == this )
354:                        return true;
355:                    if (other instanceof  DelegatingListIterator)
356:                        other = ((DelegatingListIterator) other)
357:                                .getInnermostDelegate();
358:                    try {
359:                        return getInnermostDelegate().equals(other);
360:                    } catch (RuntimeException re) {
361:                        throw translate(re);
362:                    }
363:                }
364:
365:                public boolean hasNext() {
366:                    try {
367:                        return _del.hasNext();
368:                    } catch (RuntimeException re) {
369:                        throw translate(re);
370:                    }
371:                }
372:
373:                public Object next() {
374:                    try {
375:                        return _del.next();
376:                    } catch (RuntimeException re) {
377:                        throw translate(re);
378:                    }
379:                }
380:
381:                public boolean hasPrevious() {
382:                    try {
383:                        return _del.hasPrevious();
384:                    } catch (RuntimeException re) {
385:                        throw translate(re);
386:                    }
387:                }
388:
389:                public Object previous() {
390:                    try {
391:                        return _del.previous();
392:                    } catch (RuntimeException re) {
393:                        throw translate(re);
394:                    }
395:                }
396:
397:                public int nextIndex() {
398:                    try {
399:                        return _del.nextIndex();
400:                    } catch (RuntimeException re) {
401:                        throw translate(re);
402:                    }
403:                }
404:
405:                public int previousIndex() {
406:                    try {
407:                        return _del.previousIndex();
408:                    } catch (RuntimeException re) {
409:                        throw translate(re);
410:                    }
411:                }
412:
413:                public void remove() {
414:                    try {
415:                        _del.remove();
416:                    } catch (RuntimeException re) {
417:                        throw translate(re);
418:                    }
419:                }
420:
421:                public void set(Object o) {
422:                    try {
423:                        _del.set(o);
424:                    } catch (RuntimeException re) {
425:                        throw translate(re);
426:                    }
427:                }
428:
429:                public void add(Object o) {
430:                    try {
431:                        _del.add(o);
432:                    } catch (RuntimeException re) {
433:                        throw translate(re);
434:                    }
435:                }
436:            }
437:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.