| 1 | |
package org.apache.ojb.broker.core.proxy; |
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 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 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
public class ListProxyDefaultImpl extends CollectionProxyDefaultImpl implements List |
| 35 | |
{ |
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
public ListProxyDefaultImpl(PBKey aKey, Query aQuery) |
| 43 | |
{ |
| 44 | |
this(aKey, RemovalAwareCollection.class, aQuery); |
| 45 | |
} |
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
public ListProxyDefaultImpl(PBKey aKey, Class aCollClass, Query aQuery) |
| 54 | |
{ |
| 55 | |
super(aKey, aCollClass, aQuery); |
| 56 | |
} |
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
public boolean addAll(int index, Collection c) |
| 62 | |
{ |
| 63 | |
return getListData().addAll(index, c); |
| 64 | |
} |
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
public Object get(int index) |
| 70 | |
{ |
| 71 | |
return getListData().get(index); |
| 72 | |
} |
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
public Object set(int index, Object element) |
| 78 | |
{ |
| 79 | |
return getListData().set(index, element); |
| 80 | |
} |
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
|
| 85 | |
public void add(int index, Object element) |
| 86 | |
{ |
| 87 | |
getListData().add(index, element); |
| 88 | |
} |
| 89 | |
|
| 90 | |
|
| 91 | |
|
| 92 | |
|
| 93 | |
public Object remove(int index) |
| 94 | |
{ |
| 95 | |
return getListData().remove(index); |
| 96 | |
} |
| 97 | |
|
| 98 | |
|
| 99 | |
|
| 100 | |
|
| 101 | |
public int indexOf(Object o) |
| 102 | |
{ |
| 103 | |
return getListData().indexOf(o); |
| 104 | |
} |
| 105 | |
|
| 106 | |
|
| 107 | |
|
| 108 | |
|
| 109 | |
public int lastIndexOf(Object o) |
| 110 | |
{ |
| 111 | |
return getListData().lastIndexOf(o); |
| 112 | |
} |
| 113 | |
|
| 114 | |
|
| 115 | |
|
| 116 | |
|
| 117 | |
public ListIterator listIterator() |
| 118 | |
{ |
| 119 | |
return getListData().listIterator(); |
| 120 | |
} |
| 121 | |
|
| 122 | |
|
| 123 | |
|
| 124 | |
|
| 125 | |
public ListIterator listIterator(int index) |
| 126 | |
{ |
| 127 | |
return getListData().listIterator(index); |
| 128 | |
} |
| 129 | |
|
| 130 | |
|
| 131 | |
|
| 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 | |
|
| 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 | |
} |