|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.joda.primitives.collection.impl.AbstractPrimitiveCollectable<Byte>
org.joda.primitives.collection.impl.AbstractByteCollection
org.joda.primitives.list.impl.AbstractByteList
public abstract class AbstractByteList
Abstract base class for lists of primitive byte
elements.
This class implements Collection
allowing
seamless integration with other APIs.
The get(int)
and size()
methods must be
implemented by subclases.
To make the subclass modifiable, the add(int, byte)
,
removeIndex(int)
and set(int, byte) must also be implemented.
Subclasses may override other methods to increase efficiency.
Nested Class Summary | |
---|---|
protected static class |
AbstractByteList.PListIterator
List iterator. |
Constructor Summary | |
---|---|
protected |
AbstractByteList()
Constructor. |
Method Summary | |
---|---|
boolean |
add(byte value)
Adds a primitive value to this collection (optional operation). |
boolean |
add(Byte value)
Adds the Byte value to this collection (optional operation). |
boolean |
add(int index,
byte value)
Adds a primitive value to this list at an index (optional operation). |
void |
add(int index,
Byte value)
Adds the Byte value to this list at an index (optional operation). |
boolean |
addAll(byte[] values)
Adds an array of primitive values to this list at an index (optional operation). |
boolean |
addAll(int index,
byte[] values)
Adds an array of primitive values to this list at an index (optional operation). |
boolean |
addAll(int index,
Collection<? extends Byte> coll)
Adds an array of Byte values to this list at an index (optional operation). |
protected void |
arrayCopy(int fromIndex,
byte[] dest,
int destIndex,
int size)
Copies data from this collection into the specified array. |
protected void |
checkIndex(int index)
Checks whether an index is valid or not. |
protected void |
checkIndexExists(int index)
Checks whether an index is valid or not. |
protected void |
checkRange(int fromIndexInclusive,
int toIndexExclusive)
Checks whether a range is valid or not. |
protected void |
checkSetModifiable()
Check whether add is suported and throw an exception. |
void |
clear()
Clears the listof all elements (optional operation). |
boolean |
contains(byte value)
Checks whether this collection contains a specified primitive value. |
boolean |
equals(Object obj)
Compares this list to another as per the contract of List . |
Byte |
first()
Gets the first Byte value. |
byte |
firstByte()
Gets the first primitive value. |
Byte |
get(int index)
Gets the Byte value at the specified index. |
int |
hashCode()
Gets the hashCode of this list as per the contract of List . |
int |
indexOf(byte value)
Gets the first index of the specified primitive value. |
int |
indexOf(byte value,
int fromIndexInclusive)
Gets the first index of the specified primitive value from an index. |
int |
indexOf(Object value)
Gets the first index of the specified Byte value. |
int |
indexOf(Object value,
int fromIndexInclusive)
Gets the first index of the specified Byte value from an index. |
boolean |
isModifiable()
Is the collection modifiable in any way. |
protected boolean |
isSetModifiable()
Are the set methods supported. |
ByteListIterator |
iterator()
Gets an iterator over this list. |
Byte |
last()
Gets the last Byte value. |
byte |
lastByte()
Gets the last primitive value. |
int |
lastIndexOf(byte value)
Gets the last index of the specified primitive value. |
int |
lastIndexOf(byte value,
int fromIndexInclusive)
Gets the first index of the specified primitive value from an index. |
int |
lastIndexOf(Object value)
Gets the last index of the specified Byte value. |
int |
lastIndexOf(Object value,
int fromIndexInclusive)
Gets the first index of the specified Byte value from an index. |
ByteListIterator |
listIterator()
Gets a list iterator over this list. |
ByteListIterator |
listIterator(int index)
Gets a list iterator over this list from a start index. |
Byte |
remove(int index)
Deprecated. This method should only be used when working with List and not when working with ByteList - use removeByteAt(int) |
boolean |
removeByte(byte value)
Removes the first occurrence of a primitive value from the list (optional operation). |
byte |
removeByteAt(int index)
Removes a primitive value by index from the list (optional operation). |
boolean |
removeRange(int fromIndexInclusive,
int toIndexExclusive)
Removes a range of values from the list (optional operation). |
byte |
set(int index,
byte value)
Sets the primitive value at a specified index. |
Byte |
set(int index,
Byte value)
Sets the Byte value at a specified index. |
ByteList |
subList(int fromIndexInclusive,
int toIndexExclusive)
Gets a range view of part of this list. |
byte[] |
toByteArray(int fromIndexInclusive,
int toIndexExclusive)
Gets a range of elements as an array. |
Methods inherited from class org.joda.primitives.collection.impl.AbstractByteCollection |
---|
addAll, addAll, addAll, checkAddModifiable, checkRemoveModifiable, contains, containsAll, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, containsAny, isAddModifiable, isRemoveModifiable, isToPrimitivePossible, remove, removeAll, removeAll, removeAll, removeAll, removeAll, removeFirst, retainAll, retainAll, retainAll, retainAll, toArray, toArray, toByteArray, toByteArray, toObject, toPrimitive, toPrimitiveArray, toString |
Methods inherited from class org.joda.primitives.collection.impl.AbstractPrimitiveCollectable |
---|
clone, isEmpty, optimize |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.joda.primitives.list.ByteList |
---|
getByte |
Methods inherited from interface org.joda.primitives.collection.PrimitiveCollection |
---|
containsAny |
Methods inherited from interface org.joda.primitives.PrimitiveCollectable |
---|
clone, isEmpty, optimize, size |
Methods inherited from interface java.util.List |
---|
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, size, toArray, toArray |
Methods inherited from interface org.joda.primitives.collection.ByteCollection |
---|
addAll, addAll, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, removeAll, removeAll, removeAll, removeAll, removeFirst, retainAll, retainAll, retainAll, toByteArray, toByteArray |
Methods inherited from interface org.joda.primitives.collection.PrimitiveCollection |
---|
containsAny |
Methods inherited from interface org.joda.primitives.PrimitiveCollectable |
---|
clone, isEmpty, optimize, size |
Constructor Detail |
---|
protected AbstractByteList()
Method Detail |
---|
public ByteListIterator iterator()
iterator
in interface Iterable<Byte>
iterator
in interface Collection<Byte>
iterator
in interface List<Byte>
iterator
in interface ByteCollection
iterator
in interface ByteIterable
iterator
in interface ByteList
public ByteListIterator listIterator()
This implementation uses byteListIterator(int)
.
listIterator
in interface List<Byte>
listIterator
in interface ByteList
public ByteListIterator listIterator(int index)
listIterator
in interface List<Byte>
listIterator
in interface ByteList
index
- the index to start from
IndexOutOfBoundsException
- if the index is invalidpublic byte firstByte()
firstByte
in interface ByteList
IndexOutOfBoundsException
- if the size is zeropublic byte lastByte()
lastByte
in interface ByteList
size() - 1
IndexOutOfBoundsException
- if the size is zeropublic boolean contains(byte value)
This implementation uses getByte(int)
.
contains
in interface ByteCollection
contains
in class AbstractByteCollection
value
- the value to search for
true
if the value is foundpublic int indexOf(byte value)
This implementation uses indexof(byte, int)
.
indexOf
in interface ByteList
value
- the value to search for
-1
if not foundpublic int indexOf(byte value, int fromIndexInclusive)
This method follows the conventions of String
in that a
negative index is treated as zero, and an index greater than the list
size will simply return -1
.
This implementation uses get(int)
.
indexOf
in interface ByteList
value
- the value to search forfromIndexInclusive
- the index to start searching from, inclusive
-1
if not foundpublic int lastIndexOf(byte value)
This implementation uses lastIndexof(byte, int)
.
lastIndexOf
in interface ByteList
value
- the value to search for
-1
if not foundpublic int lastIndexOf(byte value, int fromIndexInclusive)
This method follows the conventions of String
in that an
index greater than the list size will start searching at the list size,
and a negative index simply returns -1
.
This implementation uses get(int)
.
lastIndexOf
in interface ByteList
value
- the value to search forfromIndexInclusive
- the index to start searching from, inclusive
-1
if not foundpublic byte[] toByteArray(int fromIndexInclusive, int toIndexExclusive)
toByteArray
in interface ByteList
fromIndexInclusive
- the index to start from, inclusivetoIndexExclusive
- the index to end at, exclusive
IndexOutOfBoundsException
- if either index is invalidpublic ByteList subList(int fromIndexInclusive, int toIndexExclusive)
This method allows operations to work on a range within the greater list. Changes made to the either object will affect the other.
subList
in interface List<Byte>
subList
in interface ByteList
fromIndexInclusive
- the index to start from, inclusivetoIndexExclusive
- the index to end at, exclusive
IndexOutOfBoundsException
- if either index is invalidpublic void clear()
This implementation uses removeRange(int, int)
.
clear
in interface Collection<Byte>
clear
in interface List<Byte>
clear
in interface PrimitiveCollectable<Byte>
clear
in class AbstractByteCollection
UnsupportedOperationException
- if method not supported by this collectionpublic boolean add(byte value)
This implementation uses add(int, byte)
.
add
in interface ByteCollection
add
in class AbstractByteCollection
value
- the value to add to this collection
true
if this collection was modified by this method call
IllegalArgumentException
- if value is rejected by this collection
UnsupportedOperationException
- if not supported by this collectionpublic boolean add(int index, byte value)
This implementation throws UnsupportedOperationException.
add
in interface ByteList
index
- the index to add atvalue
- the value to add to this collection
true
if this list was modified by this method call
IndexOutOfBoundsException
- if the index is invalid
IllegalArgumentException
- if value is rejected by this collection
UnsupportedOperationException
- if not supported by this collectionpublic boolean addAll(byte[] values)
This implementation uses addAll(int, byte)
.
addAll
in interface ByteCollection
addAll
in class AbstractByteCollection
values
- the values to add to this collection, null treated as empty array
true
if this list was modified by this method call
IndexOutOfBoundsException
- if the index is invalid
IllegalArgumentException
- if value is rejected by this collection
UnsupportedOperationException
- if not supported by this collectionpublic boolean addAll(int index, byte[] values)
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
addAll
in interface ByteList
index
- the index to add atvalues
- the values to add to this collection, null treated as empty array
true
if this list was modified by this method call
IndexOutOfBoundsException
- if the index is invalid
IllegalArgumentException
- if value is rejected by this collection
UnsupportedOperationException
- if not supported by this collectionpublic byte removeByteAt(int index)
This implementation throws UnsupportedOperationException.
removeByteAt
in interface ByteList
index
- the index to remove from
IndexOutOfBoundsException
- if the index is invalid
UnsupportedOperationException
- if not supported by this collectionpublic boolean removeByte(byte value)
This implementation uses get(int)
and removeByteAt(int)
.
value
- the value to remove
UnsupportedOperationException
- if not supported by this collectionpublic boolean removeRange(int fromIndexInclusive, int toIndexExclusive)
This implementation uses removeByteAt(int)
.
removeRange
in interface PrimitiveList<Byte>
fromIndexInclusive
- the start of the range to remove, inclusivetoIndexExclusive
- the end of the range to remove, exclusive
true
if the collection was modified
IndexOutOfBoundsException
- if the index is invalid
UnsupportedOperationException
- if remove is not supportedpublic byte set(int index, byte value)
This implementation throws UnsupportedOperationException.
set
in interface ByteList
index
- the index to setvalue
- the value to store
IndexOutOfBoundsException
- if the index is invalid
IllegalArgumentException
- if value is rejected by this collection
UnsupportedOperationException
- if not supported by this collectionpublic Byte get(int index)
Byte
value at the specified index.
get
in interface List<Byte>
index
- the index to get from
IndexOutOfBoundsException
- if the index is invalidpublic Byte first()
Byte
value.
first
in interface PrimitiveList<Byte>
public Byte last()
Byte
value.
last
in interface PrimitiveList<Byte>
size() - 1
or null if the size is zeropublic int indexOf(Object value)
Byte
value.
indexOf
in interface List<Byte>
value
- the value to search for
-1
if not found
NullPointerException
- if the value if null
ClassCastException
- if the object is not Byte
public int indexOf(Object value, int fromIndexInclusive)
Byte
value from an index.
This method follows the conventions of String
in that a
negative index is treated as zero, and an index greater than the list
size will simply return -1
.
value
- the value to search forfromIndexInclusive
- the index to start searching from, inclusive
-1
if not found
NullPointerException
- if the value if null
ClassCastException
- if the object is not Byte
public int lastIndexOf(Object value)
Byte
value.
lastIndexOf
in interface List<Byte>
value
- the value to search for
-1
if not found
NullPointerException
- if the value if null
ClassCastException
- if the object is not Byte
public int lastIndexOf(Object value, int fromIndexInclusive)
Byte
value from an index.
This method follows the conventions of String
in that an
index greater than the list size will start searching at the list size,
and a negative index simply returns -1
.
value
- the value to search forfromIndexInclusive
- the index to start searching from, inclusive
-1
if not found
NullPointerException
- if the value if null
ClassCastException
- if the object is not Byte
public boolean add(Byte value)
Byte
value to this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
add
in interface Collection<Byte>
add
in interface List<Byte>
add
in class AbstractByteCollection
value
- the value to add to this collection
true
if this collection was modified by this method call
IllegalArgumentException
- if value is rejected by this collection
UnsupportedOperationException
- if not supported by this collectionpublic void add(int index, Byte value)
Byte
value to this list at an index (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
add
in interface List<Byte>
index
- the index to add atvalue
- the value to add to this collection
IndexOutOfBoundsException
- if the index is invalid
ClassCastException
- if the object is not Byte
IllegalArgumentException
- if value is rejected by this collection
UnsupportedOperationException
- if not supported by this collectionpublic boolean addAll(int index, Collection<? extends Byte> coll)
Byte
values to this list at an index (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
addAll
in interface List<Byte>
index
- the index to add atcoll
- the values to add to this collection
true
if this list was modified by this method call
IndexOutOfBoundsException
- if the index is invalid
ClassCastException
- if any object is not Byte
IllegalArgumentException
- if value is rejected by this collection
UnsupportedOperationException
- if not supported by this collectionpublic Byte remove(int index)
removeByteAt(int)
This implementation uses removeByteAt(int)
.
remove
in interface List<Byte>
remove
in interface ByteList
index
- the index to remove from
IndexOutOfBoundsException
- if the index is invalid
UnsupportedOperationException
- if not supported by this collectionpublic Byte set(int index, Byte value)
Byte
value at a specified index.
This implementation uses set(int, byte)
.
set
in interface List<Byte>
index
- the index to setvalue
- the value to store
IndexOutOfBoundsException
- if the index is invalid
IllegalArgumentException
- if value is rejected by this collection
UnsupportedOperationException
- if not supported by this collectionpublic boolean equals(Object obj)
List
.
equals
in interface Collection<Byte>
equals
in interface List<Byte>
equals
in class Object
obj
- the object to compare to
true
if the lists are equalpublic int hashCode()
List
.
hashCode
in interface Collection<Byte>
hashCode
in interface List<Byte>
hashCode
in class Object
protected void arrayCopy(int fromIndex, byte[] dest, int destIndex, int size)
arrayCopy
in class AbstractByteCollection
fromIndex
- the index to start fromdest
- the destination arraydestIndex
- the destination start indexsize
- the number of items to copyprotected boolean isSetModifiable()
This implementation returns false.
public boolean isModifiable()
isModifiable
in interface PrimitiveCollectable<Byte>
isModifiable
in class AbstractByteCollection
protected void checkSetModifiable()
protected void checkIndexExists(int index)
index
- the index to check
IndexOutOfBoundsException
- if either index is invalidprotected void checkIndex(int index)
index
- the index to check
IndexOutOfBoundsException
- if either index is invalidprotected void checkRange(int fromIndexInclusive, int toIndexExclusive)
fromIndexInclusive
- the index to start from, inclusivetoIndexExclusive
- the index to end at, exclusive
IndexOutOfBoundsException
- if either index is invalid
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |