01: /*
02:
03: This software is OSI Certified Open Source Software.
04: OSI Certified is a certification mark of the Open Source Initiative.
05:
06: The license (Mozilla version 1.0) can be read at the MMBase site.
07: See http://www.MMBase.org/license
08:
09: */
10:
11: package org.mmbase.bridge.util;
12:
13: import org.mmbase.bridge.*;
14: import java.util.*;
15:
16: /**
17: * As AbstractList, but implements some extra methods required by BridgeList
18: *
19: *
20: * @author Michiel Meeuwissen
21: * @version $Id: AbstractBridgeList.java,v 1.5 2007/02/24 21:57:50 nklasens Exp $
22: * @since MMBase-1.8
23: */
24:
25: abstract public class AbstractBridgeList<E extends Comparable<? super E>>
26: extends AbstractList<E> implements BridgeList<E> {
27:
28: private Map<Object, Object> properties = new HashMap<Object, Object>();
29:
30: // javadoc inherited
31: public Object getProperty(Object key) {
32: return properties.get(key);
33: }
34:
35: // javadoc inherited
36: public void setProperty(Object key, Object value) {
37: properties.put(key, value);
38: }
39:
40: // javadoc inherited
41: public void sort() {
42: Collections.sort(this );
43: }
44:
45: // javadoc inherited
46: public void sort(Comparator<? super E> comparator) {
47: Collections.sort(this , comparator);
48: }
49:
50: public abstract BridgeList<E> subList(int f, int t);
51:
52: protected class BasicIterator implements ListIterator<E> {
53: protected final ListIterator<E> iterator;
54:
55: protected BasicIterator() {
56: this .iterator = AbstractBridgeList.this .listIterator();
57: }
58:
59: public boolean hasNext() {
60: return iterator.hasNext();
61: }
62:
63: public boolean hasPrevious() {
64: return iterator.hasPrevious();
65: }
66:
67: public int nextIndex() {
68: return iterator.nextIndex();
69: }
70:
71: public int previousIndex() {
72: return iterator.previousIndex();
73: }
74:
75: public void remove() {
76: iterator.remove();
77: }
78:
79: // These have to be implemented with a check if o is of the right type.
80: public void set(E o) {
81: iterator.set(o);
82: }
83:
84: public void add(E o) {
85: iterator.add(o);
86: }
87:
88: public E next() {
89: return iterator.next();
90: }
91:
92: public E previous() {
93: return iterator.previous();
94: }
95:
96: }
97:
98: }
|