|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.joda.primitives.collection.impl.AbstractPrimitiveCollectable<Byte> org.joda.primitives.collection.impl.AbstractByteCollection
public abstract class AbstractByteCollection
Abstract base class for collections of primitive byte
elements.
This class implements Collection
allowing
seamless integration with other APIs.
The iterator
and size
must be implemented by subclases.
To make the subclass modifiable, the add(byte)
and
iterator remove()
methods must also be implemented.
Subclasses may override other methods to increase efficiency.
Constructor Summary | |
---|---|
protected |
AbstractByteCollection()
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 |
addAll(byte[] values)
Adds an array of primitive values to this collection (optional operation). |
|
boolean |
addAll(byte startInclusive,
byte endInclusive)
Adds a range of primitive values to this collection (optional operation). |
|
boolean |
addAll(ByteCollection values)
Adds a collection of primitive values to this collection (optional operation). |
|
boolean |
addAll(Collection<? extends Byte> coll)
Adds a collection of Byte values to this collection (optional operation). |
|
protected void |
arrayCopy(int fromIndex,
byte[] dest,
int destIndex,
int size)
Copies data from this collection into the specified array. |
|
protected void |
checkAddModifiable()
Check whether add is suported and throw an exception. |
|
protected void |
checkRemoveModifiable()
Check whether remove is suported and throw an exception. |
|
void |
clear()
Clears the collection/map of all elements (optional operation). |
|
boolean |
contains(byte value)
Checks whether this collection contains a specified primitive value. |
|
boolean |
contains(Object value)
Checks whether this collection contains a specified Byte value. |
|
boolean |
containsAll(byte[] values)
Checks if this collection contains all of the values in the specified array. |
|
boolean |
containsAll(byte startInclusive,
byte endInclusive)
Checks if this collection contain all the values in the specified range. |
|
boolean |
containsAll(ByteCollection values)
Checks if this collection contains all of the values in the specified collection. |
|
boolean |
containsAll(Collection<?> coll)
Checks if the collection contains all of the primitive values. |
|
boolean |
containsAny(byte[] values)
Checks if this collection contains any of the values in the specified array. |
|
boolean |
containsAny(byte startInclusive,
byte endInclusive)
Checks if this collection contain some of the values in the specified range. |
|
boolean |
containsAny(ByteCollection values)
Checks if this collection contains any of the values in the specified collection. |
|
boolean |
containsAny(Collection<?> coll)
Checks if the collection contains any of the primitive values in the array. |
|
protected boolean |
isAddModifiable()
Are the add methods supported. |
|
boolean |
isModifiable()
Is the collection modifiable in any way. |
|
protected boolean |
isRemoveModifiable()
Are the remove methods supported. |
|
protected boolean |
isToPrimitivePossible(Object value)
Checks if the object can be converted to a primitive successfully. |
|
boolean |
remove(Object value)
Removes the first occurrance of the specified Byte value from
this collection (optional operation). |
|
boolean |
removeAll(byte value)
Removes all occurrences of the specified primitive value from this collection. |
|
boolean |
removeAll(byte[] values)
Removes all occurrences from this collection of each primitive in the specified array. |
|
boolean |
removeAll(byte startInclusive,
byte endInclusive)
Removes all occurrences of a range of primitive values from this collection. |
|
boolean |
removeAll(ByteCollection values)
Removes all occurrences from this collection of each primitive in the specified collection. |
|
boolean |
removeAll(Collection<?> coll)
Removes each of a collection of Byte values from this collection (optional operation). |
|
boolean |
removeFirst(byte value)
Removes the first occurrence of the specified primitive value from this collection |
|
boolean |
retainAll(byte[] values)
Retains each element of this collection that is present in the specified array removing all other values. |
|
boolean |
retainAll(byte startInclusive,
byte endInclusive)
Retains all occurences of a range of primitive values within this collection removing all values outside the range (optional operation). |
|
boolean |
retainAll(ByteCollection values)
Retains each element of this collection that is present in the specified collection removing all other values. |
|
boolean |
retainAll(Collection<?> coll)
Retains each of a collection of Byte values, removing other
values (optional operation). |
|
Object[] |
toArray()
Gets the collection as an array of Byte . |
|
|
toArray(T[] array)
Gets the collection as an array, using the array provided. |
|
byte[] |
toByteArray()
Gets the elements of this collection as an array. |
|
byte[] |
toByteArray(byte[] array,
int startIndex)
Copies the elements of this collection into an array at a specified position. |
|
protected Byte |
toObject(byte value)
Wraps an byte with an Object wrapper. |
|
protected byte |
toPrimitive(Object value)
Unwraps the Byte to retrieve the primitive byte . |
|
protected byte[] |
toPrimitiveArray(Collection<?> coll)
Unwraps a Collection to retrieve the primitive byte . |
|
String |
toString()
Gets a string representing this collection. |
Methods inherited from class org.joda.primitives.collection.impl.AbstractPrimitiveCollectable |
---|
clone, isEmpty, optimize |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.joda.primitives.collection.ByteCollection |
---|
iterator |
Methods inherited from interface org.joda.primitives.PrimitiveCollectable |
---|
clone, isEmpty, optimize, size |
Methods inherited from interface java.util.Collection |
---|
equals, hashCode, isEmpty, size |
Constructor Detail |
---|
protected AbstractByteCollection()
Method Detail |
---|
public boolean contains(byte value)
This implementation uses byteIterator()
.
contains
in interface ByteCollection
value
- the value to search for
true
if the value is foundpublic boolean containsAll(byte[] values)
true
is returned.
This implementation uses contains(byte)
.
containsAll
in interface ByteCollection
values
- the values to search for, null treated as empty array
true
if all of the values are foundpublic boolean containsAll(ByteCollection values)
true
is returned.
This implementation uses contains(byte)
.
containsAll
in interface ByteCollection
values
- the values to search for, null treated as empty collection
true
if all of the values are foundpublic boolean containsAll(byte startInclusive, byte endInclusive)
The range is defined to be inclusive of the start and end.
If the start is greater than the end then the result is true
as the range is equivalent to an empty collection.
This implementation uses contains(byte)
.
containsAll
in interface ByteCollection
startInclusive
- the inclusive range start valueendInclusive
- the inclusive range end value
true
if the collection contains the entire rangepublic boolean containsAny(byte[] values)
false
is returned.
This implementation uses contains(byte)
.
containsAny
in interface ByteCollection
values
- the values to search for, null treated as empty array
true
if at least one of the values is foundpublic boolean containsAny(ByteCollection values)
false
is returned.
This implementation uses contains(byte)
.
containsAny
in interface ByteCollection
values
- the values to search for, null treated as empty collection
true
if at least one of the values is foundpublic boolean containsAny(byte startInclusive, byte endInclusive)
The range is defined to be inclusive of the start and end.
If the start is greater than the end then the result is false
as the range is equivalent to an empty collection.
This implementation uses contains(byte)
.
containsAny
in interface ByteCollection
startInclusive
- the inclusive range start valueendInclusive
- the inclusive range end value
true
if the collection contains at least one of the rangepublic byte[] toByteArray()
This implementation uses arrayCopy
.
toByteArray
in interface ByteCollection
public byte[] toByteArray(byte[] array, int startIndex)
If the array specified is null a new array is created. If the array specified is large enough, it will be modified. If the array is not large enough, a new array will be created containing the values from the specified array before the startIndex plus those from this collection.
This implementation uses arrayCopy
.
toByteArray
in interface ByteCollection
array
- the array to add the elements to, null treated as empty arraystartIndex
- the position in the array to start setting elements
IndexOutOfBoundsException
- if the index is negativepublic void clear()
The collection/map will have a zero size after this method completes. This method is optional, throwing an UnsupportedOperationException if the collection/map cannot be cleared.
This implementation uses iterator()
.
clear
in interface Collection<Byte>
clear
in interface PrimitiveCollectable<Byte>
UnsupportedOperationException
- if method not supported by this collectionpublic boolean add(byte value)
This implementation throws UnsupportedOperationException.
add
in interface ByteCollection
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 addAll(byte[] values)
This implementation uses add(byte)
.
addAll
in interface ByteCollection
values
- the values to add to this collection, null treated as empty array
true
if this collection was modified by this method call
IllegalArgumentException
- if a value is rejected by this collection
UnsupportedOperationException
- if not supported by this collectionpublic boolean addAll(ByteCollection values)
This implementation uses add(byte)
.
addAll
in interface ByteCollection
values
- the values to add to this collection, null treated as empty collection
true
if this collection was modified by this method call
IllegalArgumentException
- if a value is rejected by this collection
UnsupportedOperationException
- if not supported by this collectionpublic boolean addAll(byte startInclusive, byte endInclusive)
The range is defined to be inclusive of the start and end. If the start is greater than the end then the range is equivalent to an empty collection.
This implementation uses add(byte)
.
addAll
in interface ByteCollection
startInclusive
- the inclusive range start valueendInclusive
- the inclusive range end value
true
if this collection was modified by this method call
IllegalArgumentException
- if a value is rejected by this set
UnsupportedOperationException
- if not supported by this setpublic boolean removeFirst(byte value)
This implementation uses iterator().remove()
.
removeFirst
in interface ByteCollection
value
- the value to remove
true
if this collection was modified by this method call
UnsupportedOperationException
- if not supported by this collectionpublic boolean removeAll(byte value)
This implementation uses iterator().remove()
.
removeAll
in interface ByteCollection
value
- the value to remove
true
if this collection was modified by this method call
UnsupportedOperationException
- if not supported by this collectionpublic boolean removeAll(byte[] values)
This implementation uses iterator().remove()
.
removeAll
in interface ByteCollection
values
- the values to remove from this collection, null treated as empty array
true
if this list was modified by this method call
UnsupportedOperationException
- if not supported by this collectionpublic boolean removeAll(ByteCollection values)
This implementation uses iterator().remove()
.
removeAll
in interface ByteCollection
values
- the values to remove from this collection, null treated as empty collection
true
if this list was modified by this method call
UnsupportedOperationException
- if not supported by this collectionpublic boolean removeAll(byte startInclusive, byte endInclusive)
The range is defined to be inclusive of the start and end. The elements removed are greater than or equal to the start and less than or equal to the end. Thus if the start is greater than the end then no elements are removed.
This method is optional, throwing an UnsupportedOperationException if the set cannot be changed.
This implementation uses iterator().remove()
.
removeAll
in interface ByteCollection
startInclusive
- the inclusive range start valueendInclusive
- the inclusive range end value
true
if this collection was modified by this method call
UnsupportedOperationException
- if not supported by this collectionpublic boolean retainAll(byte[] values)
This implementation uses iterator().remove()
.
retainAll
in interface ByteCollection
values
- the values to remove from this collection, null treated as empty array
true
if this list was modified by this method call
UnsupportedOperationException
- if not supported by this collectionpublic boolean retainAll(ByteCollection values)
This implementation uses iterator().remove()
.
retainAll
in interface ByteCollection
values
- the values to retain in this collection, null treated as empty collection
true
if this collection was modified by this method call
UnsupportedOperationException
- if not supported by this collectionpublic boolean retainAll(byte startInclusive, byte endInclusive)
The range is defined to be inclusive of the start and end. If the start is greater than the end then the range is equivalent to an empty collection.
This method is optional, throwing an UnsupportedOperationException if the set cannot be changed.
retainAll
in interface ByteCollection
startInclusive
- the inclusive range start valueendInclusive
- the inclusive range end value
true
if this collection was modified by this method call
UnsupportedOperationException
- if not supported by this collectionpublic boolean contains(Object value)
Byte
value.
This implementation uses contains(byte)
.
contains
in interface Collection<Byte>
value
- the value to search for
true
if the value is foundpublic boolean containsAll(Collection<?> coll)
This implementation uses containsAll(byte[])
.
containsAll
in interface Collection<Byte>
coll
- the collection of values to search for
true
if all the values are foundpublic boolean containsAny(Collection<?> coll)
false
is returned.
This implementation uses containsAny(byte[])
.
containsAny
in interface PrimitiveCollection<Byte>
coll
- the collection of values to search for
true
if at least one of the values is foundpublic Object[] toArray()
Byte
.
toArray
in interface Collection<Byte>
Byte
public <T> T[] toArray(T[] array)
toArray
in interface Collection<Byte>
array
- the array to populate
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.
This implementation uses add(byte)
.
add
in interface Collection<Byte>
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 addAll(Collection<? extends Byte> coll)
Byte
values to this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
This implementation uses addAll(byte[])
.
addAll
in interface Collection<Byte>
coll
- 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 boolean remove(Object value)
Byte
value from
this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be removed from.
This implementation uses removeFirst(byte)
.
remove
in interface Collection<Byte>
value
- the value to remove
true
if this collection was modified by this method call
UnsupportedOperationException
- if not supported by this collectionpublic boolean removeAll(Collection<?> coll)
Byte
values from this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
This implementation uses removeAll(byte[])
.
removeAll
in interface Collection<Byte>
coll
- the values to remove from this collection
true
if this list was modified by this method call
UnsupportedOperationException
- if not supported by this collectionpublic boolean retainAll(Collection<?> coll)
Byte
values, removing other
values (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
This implementation uses retainAll(byte[])
.
retainAll
in interface Collection<Byte>
coll
- the values to retain in this collection
true
if this list was modified by this method call
UnsupportedOperationException
- if not supported by this collectionpublic String toString()
The format used is as per Collection
.
toString
in class Object
protected void arrayCopy(int fromIndex, byte[] dest, int destIndex, int size)
fromIndex
- the index to start fromdest
- the destination arraydestIndex
- the destination start indexsize
- the number of items to copyprotected boolean isAddModifiable()
This implementation returns false.
protected boolean isRemoveModifiable()
This implementation returns false.
public boolean isModifiable()
isModifiable
in interface PrimitiveCollectable<Byte>
isModifiable
in class AbstractPrimitiveCollectable<Byte>
protected void checkAddModifiable()
protected void checkRemoveModifiable()
protected Byte toObject(byte value)
byte
with an Object wrapper.
value
- the primitive value
protected boolean isToPrimitivePossible(Object value)
This implementation only allows non-null Byte objects.
value
- the Object wrapper
protected byte toPrimitive(Object value)
Byte
to retrieve the primitive byte
.
This implementation only allows non-null Byte objects.
value
- the Object to convert to a primitive
NullPointerException
- if the value is null and this is unacceptable
ClassCastException
- if the object is of an unsuitable typeprotected byte[] toPrimitiveArray(Collection<?> coll)
Collection
to retrieve the primitive byte
.
This implementation only allows non-null Byte objects.
coll
- the Collection to convert to primitives
NullPointerException
- if the value is null and this is unacceptable
ClassCastException
- if any object is of an unsuitable type
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |