| bak.pcj.list.AbstractIntList bak.pcj.adapter.ListToIntListAdapter
ListToIntListAdapter | public class ListToIntListAdapter extends AbstractIntList (Code) | | This class represents adaptions of Java Collections Framework
lists to primitive lists of int values.
The adapter is implemented as a wrapper around the list.
Thus, changes to the underlying list are reflected by this
list and vice versa.
Adapters from JCF collections to primitive collections will
fail if the JCF collection contains null values or
values of the wrong class. However, adapters are not fast
failing in the case that the underlying collection should
contain illegal values. To implement fast failure would require
every operation to check every element of the underlying
collection before doing anything. Instead validation methods
are provided. They can be called using the assertion facility
in the client code:
ListToIntListAdapter s;
...
assert s.validate();
or by letting the adapter throw an exception on illegal values:
ListToIntListAdapter s;
...
s.evalidate(); // Throws an exception on illegal values
Either way, validation must be invoked directly by the client
code.
author: Søren Bak version: 1.2 20-08-2003 23:17 since: 1.0 |
Field Summary | |
protected List | list The underlying list. |
Constructor Summary | |
public | ListToIntListAdapter(List list) Creates a new adaption of a list to a list of int
values.
Parameters: list - the underlying list. | public | ListToIntListAdapter(List list, boolean validate) Creates a new adaption of a list to a list of int
values. |
Method Summary | |
public void | add(int index, int v) | public void | evalidate() Validates the list underlying this adapter and throws
an exception if it is invalid. | public int | get(int index) | public IntListIterator | listIterator(int index) | public int | removeElementAt(int index) | public int | set(int index, int v) | public int | size() | public boolean | validate() Indicates whether the underlying list is valid for
this adapter. |
list | protected List list(Code) | | The underlying list.
|
ListToIntListAdapter | public ListToIntListAdapter(List list)(Code) | | Creates a new adaption of a list to a list of int
values.
Parameters: list - the underlying list. This list mustconsist of values of classInteger Integer. Otherwise aClassCastException ClassCastExceptionwill be thrown by some methods. throws: NullPointerException - if list is null. |
ListToIntListAdapter | public ListToIntListAdapter(List list, boolean validate)(Code) | | Creates a new adaption of a list to a list of int
values. The list to adapt is optionally validated.
Parameters: list - the underlying list. This collection mustconsist of values of classInteger Integer. Otherwise aClassCastException ClassCastExceptionwill be thrown by some methods. Parameters: validate - indicates whether list shouldbe checked for illegal values. throws: NullPointerException - if list is null. throws: IllegalStateException - if validate is true andlist contains a null valueor a value that is not of classInteger Integer. |
add | public void add(int index, int v)(Code) | | |
evalidate | public void evalidate()(Code) | | Validates the list underlying this adapter and throws
an exception if it is invalid. For the underlying list
to be valid, it can only contain
Integer Integer values and no null values.
throws: IllegalStateException - if the underlying list is invalid. |
get | public int get(int index)(Code) | | |
removeElementAt | public int removeElementAt(int index)(Code) | | |
set | public int set(int index, int v)(Code) | | |
validate | public boolean validate()(Code) | | Indicates whether the underlying list is valid for
this adapter. For the underlying list to be valid, it
can only contain
Integer Integer values and no null
values.
true if the underlying list isvalid; returns false otherwise. |
|
|