|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.geotools.feature.collection.AbstractResourceCollection org.geotools.feature.collection.AbstractResourceList
Starter for resource based list implementations.
Same deal as ResouceCollections - iterators that need to be closed. This implementation is set up for random access happy content, like an array list.
Read-only:
get(int index)
size()
For read/write:
set(index, element)
- for fixed length
add(index, element) and remove(index)
for dynamic length
AbstractList
Field Summary | |
protected int |
modCount
The number of times this list has been modified. |
Fields inherited from class org.geotools.feature.collection.AbstractResourceCollection |
open |
Constructor Summary | |
protected |
AbstractResourceList()
|
Method Summary | |
void |
add(int index,
java.lang.Object element)
Inserts the specified element at the specified position in this list (optional operation). |
boolean |
add(java.lang.Object item)
Appends element. |
boolean |
addAll(int index,
java.util.Collection c)
Inserts all of the elements in the specified collection into this list at the specified position (optional operation). |
void |
clear()
Removes all of the elements from this collection (optional operation). |
protected void |
closeIterator(java.util.Iterator close)
Please override to cleanup after your own iterators, and any used resources. |
boolean |
equals(java.lang.Object o)
Compares the specified object with this list for equality. |
abstract java.lang.Object |
get(int index)
item at the specified index. |
int |
hashCode()
Returns the hash code value for this list. |
int |
indexOf(java.lang.Object o)
Returns the index in this list of the first occurence of the specified element, or -1 if the list does not contain this element. |
int |
lastIndexOf(java.lang.Object o)
Returns the index in this list of the last occurence of the specified element, or -1 if the list does not contain this element. |
java.util.ListIterator |
listIterator()
Returns listIterator(0). |
java.util.ListIterator |
listIterator(int index)
Returns a list iterator of the elements in this list from index on. |
protected java.util.Iterator |
openIterator()
Returns a quick iterator that uses get and size methods. |
java.util.ListIterator |
openIterator(int index)
|
java.lang.Object |
remove(int index)
Removes the element at the specified position in this list (optional operation). |
void |
removeRange(int fromIndex,
int toIndex)
Removes from this list all of the elements whose index is between fromIndex upto toIndex |
java.lang.Object |
set(int index,
java.lang.Object item)
Replaces item in position index (optional operation). |
java.util.List |
subList(int fromIndex,
int toIndex)
view of the portion of this list between fromIndex up to toIndex. |
Methods inherited from class org.geotools.feature.collection.AbstractResourceCollection |
addAll, close, contains, containsAll, isEmpty, iterator, purge, remove, removeAll, retainAll, size, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
addAll, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
Methods inherited from interface org.geotools.data.collection.ResourceCollection |
close, iterator, purge |
Field Detail |
protected transient int modCount
Constructor Detail |
protected AbstractResourceList()
Method Detail |
public boolean add(java.lang.Object item)
This implementation calls add(size(), o).
Note that this implementation throws an UnsupportedOperationException unless add(int, Object) is overridden.
add
in interface java.util.List
add
in class AbstractResourceCollection
item
- element whose presence in this collection is to be ensured.
java.lang.UnsupportedOperationException
- if the add method is not supported by
this Set.
java.lang.ClassCastException
- if the class of the specified element prevents it from being
added to this set.
java.lang.IllegalArgumentException
- some aspect of this element prevents it from being added
to this collection.public abstract java.lang.Object get(int index)
get
in interface java.util.List
index
- index of item
java.lang.IndexOutOfBoundsException
- if index is not between 0 and sizepublic java.lang.Object set(int index, java.lang.Object item)
This implementation always throws an UnsupportedOperationException.
set
in interface java.util.List
index
- index of element to replace.
java.lang.UnsupportedOperationException
- if the set method is not supported by
this List.
java.lang.ClassCastException
- if the class of the specified element prevents it from being
added to this list.
java.lang.IllegalArgumentException
- if some aspect of the specified element prevents it from
being added to this list.
java.lang.IndexOutOfBoundsException
- if the specified index is out of range (index < 0 || index >= size()).public void add(int index, java.lang.Object element)
This implementation always throws an UnsupportedOperationException.
add
in interface java.util.List
index
- index at which the specified element is to be inserted.element
- element to be inserted.
java.lang.UnsupportedOperationException
- if the add method is not supported by
this list.
java.lang.ClassCastException
- if the class of the specified element prevents it from being
added to this list.
java.lang.IllegalArgumentException
- if some aspect of the specified element prevents it from
being added to this list.
java.lang.IndexOutOfBoundsException
- index is out of range (index <
0 || index > size()).public java.lang.Object remove(int index)
This implementation always throws an UnsupportedOperationException.
remove
in interface java.util.List
index
- the index of the element to remove.
java.lang.UnsupportedOperationException
- if the remove method is not supported by
this list.
java.lang.IndexOutOfBoundsException
- if the specified index is out of range (index < 0 || index >= size()).public int indexOf(java.lang.Object o)
This implementation first gets a list iterator (with listIterator()). Then, it iterates over the list until the specified element is found or the end of the list is reached.
indexOf
in interface java.util.List
o
- element to search for.
public int lastIndexOf(java.lang.Object o)
This implementation first gets a list iterator that points to the end of the list (with listIterator(size())). Then, it iterates backwards over the list until the specified element is found, or the beginning of the list is reached.
lastIndexOf
in interface java.util.List
o
- element to search for.
public void clear()
This implementation calls removeRange(0, size()).
Note that this implementation throws an UnsupportedOperationException unless remove(int index) or removeRange(int fromIndex, int toIndex) is overridden.
clear
in interface java.util.List
clear
in class AbstractResourceCollection
java.lang.UnsupportedOperationException
- if the clear method is not supported by
this Collection.public boolean addAll(int index, java.util.Collection c)
Note that this implementation throws an UnsupportedOperationException unless add(int, Object) is overridden.
addAll
in interface java.util.List
index
- index at which to insert the first element from the specified collection.c
- elements to be inserted into this List.
java.lang.UnsupportedOperationException
- if the addAll method is not supported by
this list.
java.lang.ClassCastException
- if the class of an element of the specified collection
prevents it from being added to this List.
java.lang.IllegalArgumentException
- some aspect an element of the specified collection
prevents it from being added to this List.
java.lang.IndexOutOfBoundsException
- index out of range (index < 0
|| index > size()).
java.lang.NullPointerException
- if the specified collection is null.public java.util.ListIterator listIterator()
listIterator
in interface java.util.List
listIterator(int)
public java.util.ListIterator listIterator(int index)
listIterator
in interface java.util.List
index
-
java.lang.IndexOutOfBoundsException
- if the specified index is out of rangemodCount
public java.util.ListIterator openIterator(int index)
protected java.util.Iterator openIterator()
As with all resource collections it is assumed that the iterator will be closed after use.
openIterator
in class AbstractResourceCollection
modCount
protected void closeIterator(java.util.Iterator close)
AbstractResourceCollection
As an example if the iterator was working off a File then the inputstream should be closed.
Subclass must call super.close( close ) to allow the list of open iterators to be adjusted.
closeIterator
in class AbstractResourceCollection
close
- Iterator, will not be null
public java.util.List subList(int fromIndex, int toIndex)
subList
in interface java.util.List
fromIndex
- toIndex
-
java.lang.IndexOutOfBoundsException
java.lang.IllegalArgumentException
- endpoint indices out of orderpublic boolean equals(java.lang.Object o)
This implementation first checks if the specified object is this list. If so, it returns true; if not, it checks if the specified object is a list. If not, it returns false; if so, it iterates over both lists, comparing corresponding pairs of elements. If any comparison returns false, this method returns false. If either iterator runs out of elements before the other it returns false (as the lists are of unequal length); otherwise it returns true when the iterations complete.
equals
in interface java.util.List
o
- the object to be compared for equality with this list.
public int hashCode()
This implementation uses exactly the code that is used to define the list hash function in the documentation for the List.hashCode method.
hashCode
in interface java.util.List
public void removeRange(int fromIndex, int toIndex)
removeRange
in interface ResourceList
fromIndex
- index of first element to be removed.toIndex
- index after last element to be removed.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |