Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ListProxyDefaultImpl |
|
| 1.2142857142857142;1.214 |
1 | package org.apache.ojb.broker.core.proxy; | |
2 | ||
3 | /* Copyright 2003-2005 The Apache Software Foundation | |
4 | * | |
5 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
6 | * you may not use this file except in compliance with the License. | |
7 | * You may obtain a copy of the License at | |
8 | * | |
9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
10 | * | |
11 | * Unless required by applicable law or agreed to in writing, software | |
12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | * See the License for the specific language governing permissions and | |
15 | * limitations under the License. | |
16 | */ | |
17 | ||
18 | import java.util.Collection; | |
19 | import java.util.List; | |
20 | import java.util.ListIterator; | |
21 | ||
22 | import org.apache.ojb.broker.PBKey; | |
23 | import org.apache.ojb.broker.PersistenceBrokerException; | |
24 | import org.apache.ojb.broker.query.Query; | |
25 | import org.apache.ojb.broker.util.collections.RemovalAwareCollection; | |
26 | ||
27 | /** | |
28 | * A placeHolder for a whole list to support deferred loading of | |
29 | * relationships. The complete relationship is loaded on request. | |
30 | * | |
31 | * @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a> | |
32 | * @version $Id: ListProxyDefaultImpl.java,v 1.1 2007-08-24 22:17:32 ewestfal Exp $ | |
33 | */ | |
34 | public class ListProxyDefaultImpl extends CollectionProxyDefaultImpl implements List | |
35 | { | |
36 | ||
37 | /** | |
38 | * Constructor for ListProxy. | |
39 | * @param aKey | |
40 | * @param aQuery | |
41 | */ | |
42 | public ListProxyDefaultImpl(PBKey aKey, Query aQuery) | |
43 | { | |
44 | this(aKey, RemovalAwareCollection.class, aQuery); | |
45 | } | |
46 | ||
47 | /** | |
48 | * Constructor for ListProxy. | |
49 | * @param aKey | |
50 | * @param aCollClass | |
51 | * @param aQuery | |
52 | */ | |
53 | public ListProxyDefaultImpl(PBKey aKey, Class aCollClass, Query aQuery) | |
54 | { | |
55 | super(aKey, aCollClass, aQuery); | |
56 | } | |
57 | ||
58 | /** | |
59 | * @see java.util.List#addAll(int, java.util.Collection) | |
60 | */ | |
61 | public boolean addAll(int index, Collection c) | |
62 | { | |
63 | return getListData().addAll(index, c); | |
64 | } | |
65 | ||
66 | /** | |
67 | * @see java.util.List#get(int) | |
68 | */ | |
69 | public Object get(int index) | |
70 | { | |
71 | return getListData().get(index); | |
72 | } | |
73 | ||
74 | /** | |
75 | * @see java.util.List#set(int, java.lang.Object) | |
76 | */ | |
77 | public Object set(int index, Object element) | |
78 | { | |
79 | return getListData().set(index, element); | |
80 | } | |
81 | ||
82 | /** | |
83 | * @see java.util.List#add(int, java.lang.Object) | |
84 | */ | |
85 | public void add(int index, Object element) | |
86 | { | |
87 | getListData().add(index, element); | |
88 | } | |
89 | ||
90 | /** | |
91 | * @see java.util.List#remove(int) | |
92 | */ | |
93 | public Object remove(int index) | |
94 | { | |
95 | return getListData().remove(index); | |
96 | } | |
97 | ||
98 | /** | |
99 | * @see java.util.List#indexOf(java.lang.Object) | |
100 | */ | |
101 | public int indexOf(Object o) | |
102 | { | |
103 | return getListData().indexOf(o); | |
104 | } | |
105 | ||
106 | /** | |
107 | * @see java.util.List#lastIndexOf(java.lang.Object) | |
108 | */ | |
109 | public int lastIndexOf(Object o) | |
110 | { | |
111 | return getListData().lastIndexOf(o); | |
112 | } | |
113 | ||
114 | /** | |
115 | * @see java.util.List#listIterator() | |
116 | */ | |
117 | public ListIterator listIterator() | |
118 | { | |
119 | return getListData().listIterator(); | |
120 | } | |
121 | ||
122 | /** | |
123 | * @see java.util.List#listIterator(int) | |
124 | */ | |
125 | public ListIterator listIterator(int index) | |
126 | { | |
127 | return getListData().listIterator(index); | |
128 | } | |
129 | ||
130 | /** | |
131 | * @see java.util.List#subList(int, int) | |
132 | */ | |
133 | public List subList(int fromIndex, int toIndex) | |
134 | { | |
135 | return getListData().subList(fromIndex, toIndex); | |
136 | } | |
137 | ||
138 | protected List getListData() | |
139 | { | |
140 | return (List) super.getData(); | |
141 | } | |
142 | ||
143 | /** | |
144 | * @see org.apache.ojb.broker.core.proxy.CollectionProxyDefaultImpl#loadData() | |
145 | */ | |
146 | protected Collection loadData() throws PersistenceBrokerException | |
147 | { | |
148 | Collection result = super.loadData(); | |
149 | ||
150 | if (result instanceof List) | |
151 | { | |
152 | return result; | |
153 | } | |
154 | else | |
155 | { | |
156 | throw new PersistenceBrokerException("loaded data does not implement java.util.List"); | |
157 | } | |
158 | ||
159 | } | |
160 | ||
161 | } |