01: package net.sourceforge.jaxor.util;
02:
03: import net.sourceforge.jaxor.api.EntityListAdapter;
04: import net.sourceforge.jaxor.api.EntityInterface;
05:
06: import java.util.List;
07: import java.util.ArrayList;
08: import java.util.Iterator;
09:
10: /**
11: * Created By: Mike
12: * Date: Mar 2, 2004
13: * Time: 10:20:36 PM
14: *
15: * Last Checkin: $Author: mrettig $
16: * Date: $Date: 2004/03/03 04:42:10 $
17: * Revision: $Revision: 1.1 $
18: */
19: public class EntityListAdapterBase implements EntityListAdapter {
20: private final List _list;
21:
22: public EntityListAdapterBase() {
23: this (new ArrayList());
24: }
25:
26: public EntityListAdapterBase(List list) {
27: if (list == null)
28: _list = new ArrayList();
29: else
30: _list = list;
31: }
32:
33: public void deleteAll() {
34: for (Iterator iterator = _list.iterator(); iterator.hasNext();) {
35: EntityInterface abstractEntity = (EntityInterface) iterator
36: .next();
37: abstractEntity.registerDelete();
38: }
39: }
40:
41: public int size() {
42: return _list.size();
43: }
44:
45: public int hashCode() {
46: return _list.hashCode();
47: }
48:
49: public boolean equals(Object obj) {
50: if (obj instanceof EntityListAdapterBase)
51: return ((EntityListAdapterBase) obj)._list.equals(_list);
52: return false;
53: }
54:
55: public String toString() {
56: return _list.toString();
57: }
58:
59: /**
60: * A shallow copy of the list
61: **/
62: public List toList() {
63: return new ArrayList(_list);
64: }
65:
66: /**
67: * Returns the actual member list, it is not a copy. Changes will be reflected in the type safe list.
68: **/
69: public List getList() {
70: return _list;
71: }
72: }
|