| bak.pcj.list.AbstractLongList bak.pcj.adapter.ListToLongListAdapter
ListToLongListAdapter | public class ListToLongListAdapter extends AbstractLongList (Code) | | This class represents adaptions of Java Collections Framework
lists to primitive lists of long 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:
ListToLongListAdapter s;
...
assert s.validate();
or by letting the adapter throw an exception on illegal values:
ListToLongListAdapter 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 | ListToLongListAdapter(List list) Creates a new adaption of a list to a list of long
values.
Parameters: list - the underlying list. | public | ListToLongListAdapter(List list, boolean validate) Creates a new adaption of a list to a list of long
values. |
Method Summary | |
public void | add(int index, long v) | public void | evalidate() Validates the list underlying this adapter and throws
an exception if it is invalid. | public long | get(int index) | public LongListIterator | listIterator(int index) | public long | removeElementAt(int index) | public long | set(int index, long 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.
|
ListToLongListAdapter | public ListToLongListAdapter(List list)(Code) | | Creates a new adaption of a list to a list of long
values.
Parameters: list - the underlying list. This list mustconsist of values of classLong Long. Otherwise aClassCastException ClassCastExceptionwill be thrown by some methods. throws: NullPointerException - if list is null. |
ListToLongListAdapter | public ListToLongListAdapter(List list, boolean validate)(Code) | | Creates a new adaption of a list to a list of long
values. The list to adapt is optionally validated.
Parameters: list - the underlying list. This collection mustconsist of values of classLong Long. 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 classLong Long. |
add | public void add(int index, long 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
Long Long values and no null values.
throws: IllegalStateException - if the underlying list is invalid. |
get | public long get(int index)(Code) | | |
removeElementAt | public long removeElementAt(int index)(Code) | | |
set | public long set(int index, long 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
Long Long values and no null
values.
true if the underlying list isvalid; returns false otherwise. |
|
|