KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > bsf > smartValueObject > container > SmartList


1 package org.bsf.smartValueObject.container;
2
3 import org.bsf.smartValueObject.container.AbstractSmartContainer;
4 import org.bsf.smartValueObject.Versionable;
5
6 import java.util.List JavaDoc;
7 import java.util.Iterator JavaDoc;
8 import java.util.Collection JavaDoc;
9 import java.util.ListIterator JavaDoc;
10
11 /**
12  * A smart wrapper class around <tt>java.util.List</tt>.
13  *
14  * @see org.bsf.smartValueObject.container.SmartContainer
15  * @see java.util.List
16  */

17 public class SmartList extends AbstractSmartContainer implements List JavaDoc {
18
19     private List JavaDoc list;
20
21     public SmartList(List JavaDoc list, Versionable v) {
22         super(v);
23         this.list = list;
24     }
25
26     protected boolean addToContainer(Object JavaDoc o) {
27         return list.add(o);
28     }
29
30     protected Object JavaDoc addToContainer(Object JavaDoc key, Object JavaDoc o) {
31         throw new UnsupportedOperationException JavaDoc();
32     }
33
34     protected Object JavaDoc getFromContainer(Object JavaDoc key) {
35         throw new UnsupportedOperationException JavaDoc();
36     }
37
38     protected boolean removeFromContainer(Object JavaDoc o) {
39         return list.remove(o);
40     }
41
42     protected Object JavaDoc removeKeyFromContainer(Object JavaDoc key) {
43         throw new UnsupportedOperationException JavaDoc();
44     }
45
46     protected boolean containerContains(Object JavaDoc o) {
47         return list.contains(o);
48     }
49
50     protected boolean containerContainsKey(Object JavaDoc key) {
51         throw new UnsupportedOperationException JavaDoc();
52     }
53
54     protected int containerSize() {
55         return list.size();
56     }
57
58     protected Iterator JavaDoc containerIterator() {
59         return list.iterator();
60     }
61
62     protected void containerClear() {
63         list.clear();
64     }
65
66     protected Object JavaDoc[] toObjectArray() {
67         return list.toArray();
68     }
69
70     public Object JavaDoc getContainer() {
71         return list;
72     }
73
74     //- List interface
75
public boolean remove(Object JavaDoc o) {
76         return removeObject(o);
77     }
78
79     public boolean containsAll(Collection JavaDoc c) {
80         return list.containsAll(c);
81     }
82
83     public boolean addAll(Collection JavaDoc c) {
84         return list.addAll(c);
85     }
86
87     public boolean addAll(int index, Collection JavaDoc c) {
88         return list.addAll(index, c);
89     }
90
91     public boolean removeAll(Collection JavaDoc c) {
92         return list.removeAll(c);
93     }
94
95     public boolean retainAll(Collection JavaDoc c) {
96         return list.retainAll(c);
97     }
98
99     public Object JavaDoc get(int index) {
100         return list.get(index);
101     }
102
103     public Object JavaDoc set(int index, Object JavaDoc element) {
104         return list.set(index, element);
105     }
106
107     public void add(int index, Object JavaDoc element) {
108         list.add(index, element);
109     }
110
111     public Object JavaDoc remove(int index) {
112         return list.remove(index);
113     }
114
115     public int indexOf(Object JavaDoc o) {
116         return list.indexOf(o);
117     }
118
119     public int lastIndexOf(Object JavaDoc o) {
120         return list.lastIndexOf(o);
121     }
122
123     public ListIterator JavaDoc listIterator() {
124         return list.listIterator();
125     }
126
127     public ListIterator JavaDoc listIterator(int index) {
128         return list.listIterator(index);
129     }
130
131     public List JavaDoc subList(int fromIndex, int toIndex) {
132         return list.subList(fromIndex, toIndex);
133     }
134 }
135
Popular Tags