|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<T>
uk.ac.ebi.jmzidml.model.utils.FacadeList<T>
public class FacadeList<T>
Created by IntelliJ IDEA. User: rwang Date: 26/01/11 Time: 10:16
Controls access to a standard java list which contains more than one instance type, providing the developer with a virtual list of a specified type. When this list is created, the developer must specify the class of interest. Methods called on this class will be applied to the original list but will only act on instances of the specified type. For example, an originalList could contain a mixture of CvParams and UserParams. To work with a list of CvParams, a developer creates an instance of this class passing in 'CvParam.class' as clazz in the constructor. If the size method is called the list be searched and only instances of CvParam are counted towards the size. Likewise, if get(3) (3 is the index) is called the 3rd instance of CvParam will be returned. Note, this CvParam might not be the third element in the originallist. TODO Implement CvParam and UserParam's toString, equals, hashcode. With equals objects are normally considered equals if contents match. TODO Check iterator working with foreach TODO check the checkIndex(), maybe not the best implementation TODO finish all the add methods with checking the null input values
Constructor Summary | |
---|---|
FacadeList(List originalList,
Class<T> clazz)
|
Method Summary | ||
---|---|---|
void |
add(int index,
T element)
Add a new element to the sublist This will add the new element to the immediate index after the element at (index -1) in the sublist |
|
boolean |
add(T t)
|
|
boolean |
addAll(int index,
Collection<? extends T> c)
|
|
boolean |
contains(Object o)
Check whether the sublist contains the element |
|
boolean |
equals(Object comparedToListObject)
|
|
T |
get(int index)
Get an element from the original list at index. |
|
int |
hashCode()
|
|
int |
indexOf(Object o)
Get the index of sublist using a given object |
|
boolean |
isEmpty()
Check whether the sublist is empty |
|
Iterator<T> |
iterator()
Get an iterator of the sublist |
|
int |
lastIndexOf(Object o)
Get the last index of sublist using a given object |
|
ListIterator<T> |
listIterator()
|
|
ListIterator<T> |
listIterator(int index)
|
|
T |
remove(int index)
Remove a element from the original list The index here is the index of the specified element int the original list |
|
boolean |
remove(Object o)
Remove an object from the sublist |
|
boolean |
removeAll(Collection<?> c)
|
|
boolean |
retainAll(Collection<?> c)
|
|
T |
set(int index,
T element)
Set an new element based on the index of the sublist |
|
int |
size()
Get the size of the sublist |
|
List<T> |
subList(int fromIndex,
int toIndex)
sublist returned is an unmodifiable list, structural change to the sublist is not allowed. |
|
Object[] |
toArray()
|
|
|
toArray(T[] a)
|
|
String |
toString()
This method is overridden to print out the list in concatenated string format |
Methods inherited from class java.util.AbstractCollection |
---|
addAll, clear, containsAll |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
addAll, clear, containsAll |
Constructor Detail |
---|
public FacadeList(List originalList, Class<T> clazz)
Method Detail |
---|
public boolean add(T t)
add
in interface Collection<T>
add
in interface List<T>
add
in class AbstractCollection<T>
public T remove(int index)
remove
in interface List<T>
index
- list index
public T get(int index)
get
in interface List<T>
index
- list index
public T set(int index, T element)
set
in interface List<T>
index
- index of the sublistelement
- new element
public int size()
size
in interface Collection<T>
size
in interface List<T>
size
in class AbstractCollection<T>
public boolean isEmpty()
isEmpty
in interface Collection<T>
isEmpty
in interface List<T>
isEmpty
in class AbstractCollection<T>
public boolean contains(Object o)
contains
in interface Collection<T>
contains
in interface List<T>
contains
in class AbstractCollection<T>
o
- input object
public Iterator<T> iterator()
iterator
in interface Iterable<T>
iterator
in interface Collection<T>
iterator
in interface List<T>
iterator
in class AbstractCollection<T>
public int indexOf(Object o)
indexOf
in interface List<T>
o
- input object
public int lastIndexOf(Object o)
lastIndexOf
in interface List<T>
o
- input object
public ListIterator<T> listIterator()
listIterator
in interface List<T>
public ListIterator<T> listIterator(int index)
listIterator
in interface List<T>
public List<T> subList(int fromIndex, int toIndex)
subList
in interface List<T>
fromIndex
- low endpoint (inclusive) of the sublisttoIndex
- high endpoint (exclusive) of the sublist
public Object[] toArray()
toArray
in interface Collection<T>
toArray
in interface List<T>
toArray
in class AbstractCollection<T>
public <T> T[] toArray(T[] a)
toArray
in interface Collection<T>
toArray
in interface List<T>
toArray
in class AbstractCollection<T>
public void add(int index, T element)
add
in interface List<T>
index
- index of the sublistelement
- the new elementpublic boolean remove(Object o)
remove
in interface Collection<T>
remove
in interface List<T>
remove
in class AbstractCollection<T>
o
- object to be removed
public boolean addAll(int index, Collection<? extends T> c)
addAll
in interface List<T>
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<T>
removeAll
in interface List<T>
removeAll
in class AbstractCollection<T>
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<T>
retainAll
in interface List<T>
retainAll
in class AbstractCollection<T>
public String toString()
toString
in class AbstractCollection<T>
public int hashCode()
hashCode
in interface Collection<T>
hashCode
in interface List<T>
hashCode
in class Object
public boolean equals(Object comparedToListObject)
equals
in interface Collection<T>
equals
in interface List<T>
equals
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |