KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > python > core > PySequenceList


1 /* JHU/APL PROPRIETARY
2  * Copyright 2005 The Johns Hopkins University/Applied Physics Laboratory.
3  * All rights reserved. This software is for internal JHU/APL use only and
4  * is not to be distributed outside of JHU/APL. For all other permissions,
5  * please contact the RMIS Development Team at JHU/APL.
6  *
7  * Created: Apr 18, 2005
8  * By: updikca1
9  */

10 package org.python.core;
11
12 import java.util.Collection JavaDoc;
13 import java.util.Iterator JavaDoc;
14 import java.util.List JavaDoc;
15 import java.util.ListIterator JavaDoc;
16 import java.util.Arrays JavaDoc;
17
18
19 /**
20  * @author updikca1
21  *
22  * To change the template for this generated type comment go to
23  * Window>Preferences>Java>Code Generation>Code and Comments
24  */

25 public abstract class PySequenceList extends PySequence implements List JavaDoc {
26
27     protected PyObjectList list;
28
29     public PySequenceList() {
30         list = new PyObjectList();
31     }
32
33     protected PySequenceList(PyType type) {
34         super(type);
35         list = new PyObjectList();
36     }
37
38     /**
39      * Creates an instance directly backed by the array of PyObject elements.
40      * @param elements
41      */

42     public PySequenceList(PyObject[] elements) {
43         list = new PyObjectList(elements);
44     }
45
46     public PySequenceList(Collection JavaDoc c) {
47         list = new PyObjectList(c);
48     }
49
50     public void add(int index, Object JavaDoc element) {
51         list.add(index, element);
52     }
53     public boolean add(Object JavaDoc o) {
54         return list.add(o);
55     }
56     public boolean addAll(int index, Collection JavaDoc c) {
57         return list.addAll(index, c);
58     }
59     public boolean addAll(Collection JavaDoc c) {
60         return list.addAll(c);
61     }
62     public void clear() {
63         list.clear();
64     }
65     public boolean contains(Object JavaDoc o) {
66         return list.contains(o);
67     }
68     public boolean containsAll(Collection JavaDoc c) {
69         return list.containsAll(c);
70     }
71     public Object JavaDoc get(int index) {
72         return list.get(index);
73     }
74     public int indexOf(Object JavaDoc o) {
75         return list.indexOf(o);
76     }
77     public boolean isEmpty() {
78         return list.isEmpty();
79     }
80     public Iterator JavaDoc iterator() {
81         return list.iterator();
82     }
83     public int lastIndexOf(Object JavaDoc o) {
84         return list.lastIndexOf(o);
85     }
86     public ListIterator JavaDoc listIterator() {
87         return list.listIterator();
88     }
89     public ListIterator JavaDoc listIterator(int index) {
90         return list.listIterator(index);
91     }
92     public void pyadd(int index, PyObject element) {
93         list.pyadd(index, element);
94     }
95     public PyObject pyget(int index) {
96         return list.pyget(index);
97     }
98     public PyObject pyset(int index, PyObject element) {
99         return list.pyset(index, element);
100     }
101     public Object JavaDoc remove(int index) {
102         return list.remove(index);
103     }
104     public void remove(int start, int stop) {
105         list.remove(start, stop);
106     }
107     public boolean remove(Object JavaDoc o) {
108         return list.remove(o);
109     }
110     public boolean removeAll(Collection JavaDoc c) {
111         return list.removeAll(c);
112     }
113     public boolean retainAll(Collection JavaDoc c) {
114         return list.retainAll(c);
115     }
116     public Object JavaDoc set(int index, Object JavaDoc element) {
117         return list.set(index, element);
118     }
119     public int size() {
120         return list.size();
121     }
122     public List JavaDoc subList(int fromIndex, int toIndex) {
123         return list.subList(fromIndex, toIndex);
124     }
125     public Object JavaDoc[] toArray() {
126         return list.toArray();
127     }
128     public Object JavaDoc[] toArray(Object JavaDoc[] a) {
129         return list.toArray(a);
130     }
131     public String JavaDoc toString() {
132         return list.toString();
133     }
134     public boolean pyadd(PyObject o) {
135         return list.pyadd(o);
136     }
137
138     public boolean equals(Object JavaDoc o) {
139         if(o instanceof PySequenceList) {
140             return list.equals(((PySequenceList)o).list);
141         } else if (o instanceof List JavaDoc) {
142             return o.equals(this);
143         } else return false;
144     }
145
146     public int hashCode() {
147         return list.hashCode();
148     }
149
150 // /**
151
// * @param list The list to set.
152
// */
153
// public void setList(PyObjectList list) {
154
// this.list = list;
155
// }
156

157         /**
158          * Get the backing array. The array should not be modified.
159          * To get a copy of the array, see {@link #toArray()}.
160          *
161          * @return backing array object
162          */

163     public PyObject[] getArray() {
164         return list.getArray();
165     }
166 }
167
Popular Tags