001: package org.apache.ojb.broker.core.proxy;
002:
003: /* Copyright 2003-2005 The Apache Software Foundation
004: *
005: * Licensed under the Apache License, Version 2.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: import java.util.Collection;
019: import java.util.List;
020: import java.util.ListIterator;
021:
022: import org.apache.ojb.broker.PBKey;
023: import org.apache.ojb.broker.PersistenceBrokerException;
024: import org.apache.ojb.broker.query.Query;
025: import org.apache.ojb.broker.util.collections.RemovalAwareCollection;
026:
027: /**
028: * A placeHolder for a whole list to support deferred loading of
029: * relationships. The complete relationship is loaded on request.
030: *
031: * @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a>
032: * @version $Id: ListProxyDefaultImpl.java,v 1.1.2.1 2005/12/21 22:25:31 tomdz Exp $
033: */
034: public class ListProxyDefaultImpl extends CollectionProxyDefaultImpl
035: implements List {
036:
037: /**
038: * Constructor for ListProxy.
039: * @param aKey
040: * @param aQuery
041: */
042: public ListProxyDefaultImpl(PBKey aKey, Query aQuery) {
043: this (aKey, RemovalAwareCollection.class, aQuery);
044: }
045:
046: /**
047: * Constructor for ListProxy.
048: * @param aKey
049: * @param aCollClass
050: * @param aQuery
051: */
052: public ListProxyDefaultImpl(PBKey aKey, Class aCollClass,
053: Query aQuery) {
054: super (aKey, aCollClass, aQuery);
055: }
056:
057: /**
058: * @see java.util.List#addAll(int, java.util.Collection)
059: */
060: public boolean addAll(int index, Collection c) {
061: return getListData().addAll(index, c);
062: }
063:
064: /**
065: * @see java.util.List#get(int)
066: */
067: public Object get(int index) {
068: return getListData().get(index);
069: }
070:
071: /**
072: * @see java.util.List#set(int, java.lang.Object)
073: */
074: public Object set(int index, Object element) {
075: return getListData().set(index, element);
076: }
077:
078: /**
079: * @see java.util.List#add(int, java.lang.Object)
080: */
081: public void add(int index, Object element) {
082: getListData().add(index, element);
083: }
084:
085: /**
086: * @see java.util.List#remove(int)
087: */
088: public Object remove(int index) {
089: return getListData().remove(index);
090: }
091:
092: /**
093: * @see java.util.List#indexOf(java.lang.Object)
094: */
095: public int indexOf(Object o) {
096: return getListData().indexOf(o);
097: }
098:
099: /**
100: * @see java.util.List#lastIndexOf(java.lang.Object)
101: */
102: public int lastIndexOf(Object o) {
103: return getListData().lastIndexOf(o);
104: }
105:
106: /**
107: * @see java.util.List#listIterator()
108: */
109: public ListIterator listIterator() {
110: return getListData().listIterator();
111: }
112:
113: /**
114: * @see java.util.List#listIterator(int)
115: */
116: public ListIterator listIterator(int index) {
117: return getListData().listIterator(index);
118: }
119:
120: /**
121: * @see java.util.List#subList(int, int)
122: */
123: public List subList(int fromIndex, int toIndex) {
124: return getListData().subList(fromIndex, toIndex);
125: }
126:
127: protected List getListData() {
128: return (List) super .getData();
129: }
130:
131: /**
132: * @see org.apache.ojb.broker.core.proxy.CollectionProxyDefaultImpl#loadData()
133: */
134: protected Collection loadData() throws PersistenceBrokerException {
135: Collection result = super .loadData();
136:
137: if (result instanceof List) {
138: return result;
139: } else {
140: throw new PersistenceBrokerException(
141: "loaded data does not implement java.util.List");
142: }
143:
144: }
145:
146: }
|