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