KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > broker > core > proxy > ListProxyDefaultImpl


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 JavaDoc;
19 import java.util.List JavaDoc;
20 import java.util.ListIterator JavaDoc;
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.2.1 2005/12/21 22:25:31 tomdz Exp $
33  */

34 public class ListProxyDefaultImpl extends CollectionProxyDefaultImpl implements List JavaDoc
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 JavaDoc 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 JavaDoc c)
62     {
63         return getListData().addAll(index, c);
64     }
65
66     /**
67      * @see java.util.List#get(int)
68      */

69     public Object JavaDoc 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 JavaDoc set(int index, Object JavaDoc 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 JavaDoc element)
86     {
87         getListData().add(index, element);
88     }
89
90     /**
91      * @see java.util.List#remove(int)
92      */

93     public Object JavaDoc 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 JavaDoc 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 JavaDoc o)
110     {
111         return getListData().lastIndexOf(o);
112     }
113
114     /**
115      * @see java.util.List#listIterator()
116      */

117     public ListIterator JavaDoc listIterator()
118     {
119         return getListData().listIterator();
120     }
121
122     /**
123      * @see java.util.List#listIterator(int)
124      */

125     public ListIterator JavaDoc listIterator(int index)
126     {
127         return getListData().listIterator(index);
128     }
129
130     /**
131      * @see java.util.List#subList(int, int)
132      */

133     public List JavaDoc subList(int fromIndex, int toIndex)
134     {
135         return getListData().subList(fromIndex, toIndex);
136     }
137
138     protected List JavaDoc getListData()
139     {
140         return (List JavaDoc) super.getData();
141     }
142
143     /**
144      * @see org.apache.ojb.broker.core.proxy.CollectionProxyDefaultImpl#loadData()
145      */

146     protected Collection JavaDoc loadData() throws PersistenceBrokerException
147     {
148         Collection JavaDoc result = super.loadData();
149
150         if (result instanceof List JavaDoc)
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 }
162
Popular Tags