001: /*
002: * Created: Apr 18, 2005
003: * By: updikca1
004: */
005: package org.python.core;
006:
007: import java.util.Collection;
008: import java.util.Iterator;
009: import java.util.List;
010: import java.util.ListIterator;
011:
012: /**
013: * @author updikca1
014: *
015: * To change the template for this generated type comment go to
016: * Window>Preferences>Java>Code Generation>Code and Comments
017: */
018: public abstract class PySequenceList extends PySequence implements List {
019:
020: protected PyObjectList list;
021:
022: public PySequenceList() {
023: list = new PyObjectList();
024: }
025:
026: protected PySequenceList(PyType type) {
027: super (type);
028: list = new PyObjectList();
029: }
030:
031: protected PySequenceList(PyType type, PyObject[] elements) {
032: super (type);
033: list = new PyObjectList(elements);
034: }
035:
036: /**
037: * Creates an instance directly backed by the array of PyObject elements.
038: * @param elements
039: */
040: public PySequenceList(PyObject[] elements) {
041: list = new PyObjectList(elements);
042: }
043:
044: public PySequenceList(PyType type, Collection c) {
045: super (type);
046: list = new PyObjectList(c);
047: }
048:
049: public void add(int index, Object element) {
050: list.add(index, element);
051: }
052:
053: public boolean add(Object o) {
054: return list.add(o);
055: }
056:
057: public boolean addAll(int index, Collection c) {
058: return list.addAll(index, c);
059: }
060:
061: public boolean addAll(Collection c) {
062: return list.addAll(c);
063: }
064:
065: public void clear() {
066: list.clear();
067: }
068:
069: public boolean contains(Object o) {
070: return list.contains(o);
071: }
072:
073: public boolean containsAll(Collection c) {
074: return list.containsAll(c);
075: }
076:
077: public Object get(int index) {
078: return list.get(index);
079: }
080:
081: public int indexOf(Object o) {
082: return list.indexOf(o);
083: }
084:
085: public boolean isEmpty() {
086: return list.isEmpty();
087: }
088:
089: public Iterator iterator() {
090: return list.iterator();
091: }
092:
093: public int lastIndexOf(Object o) {
094: return list.lastIndexOf(o);
095: }
096:
097: public ListIterator listIterator() {
098: return list.listIterator();
099: }
100:
101: public ListIterator listIterator(int index) {
102: return list.listIterator(index);
103: }
104:
105: public void pyadd(int index, PyObject element) {
106: list.pyadd(index, element);
107: }
108:
109: public PyObject pyget(int index) {
110: return list.pyget(index);
111: }
112:
113: public PyObject pyset(int index, PyObject element) {
114: return list.pyset(index, element);
115: }
116:
117: public Object remove(int index) {
118: return list.remove(index);
119: }
120:
121: public void remove(int start, int stop) {
122: list.remove(start, stop);
123: }
124:
125: public boolean remove(Object o) {
126: return list.remove(o);
127: }
128:
129: public boolean removeAll(Collection c) {
130: return list.removeAll(c);
131: }
132:
133: public boolean retainAll(Collection c) {
134: return list.retainAll(c);
135: }
136:
137: public Object set(int index, Object element) {
138: return list.set(index, element);
139: }
140:
141: public int size() {
142: return list.size();
143: }
144:
145: public List subList(int fromIndex, int toIndex) {
146: return list.subList(fromIndex, toIndex);
147: }
148:
149: public Object[] toArray() {
150: return list.toArray();
151: }
152:
153: public Object[] toArray(Object[] a) {
154: return list.toArray(a);
155: }
156:
157: public String toString() {
158: return list.toString();
159: }
160:
161: public boolean pyadd(PyObject o) {
162: return list.pyadd(o);
163: }
164:
165: public boolean equals(Object o) {
166: if (o instanceof PySequenceList) {
167: return list.equals(((PySequenceList) o).list);
168: } else if (o instanceof List) {
169: return o.equals(this );
170: } else
171: return false;
172: }
173:
174: public int hashCode() {
175: return list.hashCode();
176: }
177:
178: // /**
179: // * @param list The list to set.
180: // */
181: // public void setList(PyObjectList list) {
182: // this.list = list;
183: // }
184:
185: /**
186: * Get the backing array. The array should not be modified.
187: * To get a copy of the array, see {@link #toArray()}.
188: *
189: * @return backing array object
190: */
191: public PyObject[] getArray() {
192: return list.getArray();
193: }
194: }
|