public abstract class AbstractCharCollection extends AbstractPrimitiveCollectable<java.lang.Character> implements CharCollection
char 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(char) and
iterator remove() methods must also be implemented.
Subclasses may override other methods to increase efficiency.
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractCharCollection()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(char value)
Adds a primitive value to this collection (optional operation).
|
boolean |
add(java.lang.Character value)
Adds the
Character value to this collection (optional operation). |
boolean |
addAll(char[] values)
Adds an array of primitive values to this collection (optional operation).
|
boolean |
addAll(char startInclusive,
char endInclusive)
Adds a range of primitive values to this collection (optional operation).
|
boolean |
addAll(CharCollection values)
Adds a collection of primitive values to this collection (optional operation).
|
boolean |
addAll(java.util.Collection<? extends java.lang.Character> coll)
Adds a collection of
Character values to this collection (optional operation). |
protected void |
arrayCopy(int fromIndex,
char[] 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(char value)
Checks whether this collection contains a specified primitive value.
|
boolean |
contains(java.lang.Object value)
Checks whether this collection contains a specified
Character value. |
boolean |
containsAll(char[] values)
Checks if this collection contains all of the values in the specified array.
|
boolean |
containsAll(char startInclusive,
char endInclusive)
Checks if this collection contain all the values in the specified range.
|
boolean |
containsAll(CharCollection values)
Checks if this collection contains all of the values in the specified collection.
|
boolean |
containsAll(java.util.Collection<?> coll)
Checks if the collection contains all of the primitive values.
|
boolean |
containsAny(char[] values)
Checks if this collection contains any of the values in the specified array.
|
boolean |
containsAny(char startInclusive,
char endInclusive)
Checks if this collection contain some of the values in the specified range.
|
boolean |
containsAny(CharCollection values)
Checks if this collection contains any of the values in the specified collection.
|
boolean |
containsAny(java.util.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(java.lang.Object value)
Checks if the object can be converted to a primitive successfully.
|
boolean |
remove(java.lang.Object value)
Removes the first occurrance of the specified
Character value from
this collection (optional operation). |
boolean |
removeAll(char value)
Removes all occurrences of the specified primitive value from this collection.
|
boolean |
removeAll(char[] values)
Removes all occurrences from this collection of each primitive in the specified array.
|
boolean |
removeAll(char startInclusive,
char endInclusive)
Removes all occurrences of a range of primitive values from this collection.
|
boolean |
removeAll(CharCollection values)
Removes all occurrences from this collection of each primitive in the specified collection.
|
boolean |
removeAll(java.util.Collection<?> coll)
Removes each of a collection of
Character values from this collection (optional operation). |
boolean |
removeFirst(char value)
Removes the first occurrence of the specified primitive value from this collection
|
boolean |
retainAll(char[] values)
Retains each element of this collection that is present in the specified array
removing all other values.
|
boolean |
retainAll(char startInclusive,
char endInclusive)
Retains all occurences of a range of primitive values within this collection
removing all values outside the range (optional operation).
|
boolean |
retainAll(CharCollection values)
Retains each element of this collection that is present in the specified collection
removing all other values.
|
boolean |
retainAll(java.util.Collection<?> coll)
Retains each of a collection of
Character values, removing other
values (optional operation). |
java.lang.Object[] |
toArray()
Gets the collection as an array of
Character. |
<T> T[] |
toArray(T[] array)
Gets the collection as an array, using the array provided.
|
char[] |
toCharArray()
Gets the elements of this collection as an array.
|
char[] |
toCharArray(char[] array,
int startIndex)
Copies the elements of this collection into an array at a specified position.
|
protected java.lang.Character |
toObject(char value)
Wraps an
char with an Object wrapper. |
protected char |
toPrimitive(java.lang.Object value)
Unwraps the
Character to retrieve the primitive char. |
protected char[] |
toPrimitiveArray(java.util.Collection<?> coll)
Unwraps a
Collection to retrieve the primitive char. |
java.lang.String |
toString()
Gets a string representing this collection.
|
clone, isEmpty, optimizeequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waititeratorclone, isEmpty, optimize, sizepublic boolean contains(char value)
This implementation uses charIterator().
contains in interface CharCollectionvalue - the value to search fortrue if the value is foundpublic boolean containsAll(char[] values)
true is returned.
This implementation uses contains(char).
containsAll in interface CharCollectionvalues - the values to search for, null treated as empty arraytrue if all of the values are foundpublic boolean containsAll(CharCollection values)
true is returned.
This implementation uses contains(char).
containsAll in interface CharCollectionvalues - the values to search for, null treated as empty collectiontrue if all of the values are foundpublic boolean containsAll(char startInclusive,
char 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(char).
containsAll in interface CharCollectionstartInclusive - the inclusive range start valueendInclusive - the inclusive range end valuetrue if the collection contains the entire rangepublic boolean containsAny(char[] values)
false is returned.
This implementation uses contains(char).
containsAny in interface CharCollectionvalues - the values to search for, null treated as empty arraytrue if at least one of the values is foundpublic boolean containsAny(CharCollection values)
false is returned.
This implementation uses contains(char).
containsAny in interface CharCollectionvalues - the values to search for, null treated as empty collectiontrue if at least one of the values is foundpublic boolean containsAny(char startInclusive,
char 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(char).
containsAny in interface CharCollectionstartInclusive - the inclusive range start valueendInclusive - the inclusive range end valuetrue if the collection contains at least one of the rangepublic char[] toCharArray()
This implementation uses arrayCopy.
toCharArray in interface CharCollectionpublic char[] toCharArray(char[] 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.
toCharArray in interface CharCollectionarray - the array to add the elements to, null treated as empty arraystartIndex - the position in the array to start setting elementsjava.lang.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 java.util.Collection<java.lang.Character>clear in interface PrimitiveCollectable<java.lang.Character>java.lang.UnsupportedOperationException - if method not supported by this collectionpublic boolean add(char value)
This implementation throws UnsupportedOperationException.
add in interface CharCollectionvalue - the value to add to this collectiontrue if this collection was modified by this method calljava.lang.IllegalArgumentException - if value is rejected by this collectionjava.lang.UnsupportedOperationException - if not supported by this collectionpublic boolean addAll(char[] values)
This implementation uses add(char).
addAll in interface CharCollectionvalues - the values to add to this collection, null treated as empty arraytrue if this collection was modified by this method calljava.lang.IllegalArgumentException - if a value is rejected by this collectionjava.lang.UnsupportedOperationException - if not supported by this collectionpublic boolean addAll(CharCollection values)
This implementation uses add(char).
addAll in interface CharCollectionvalues - the values to add to this collection, null treated as empty collectiontrue if this collection was modified by this method calljava.lang.IllegalArgumentException - if a value is rejected by this collectionjava.lang.UnsupportedOperationException - if not supported by this collectionpublic boolean addAll(char startInclusive,
char 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(char).
addAll in interface CharCollectionstartInclusive - the inclusive range start valueendInclusive - the inclusive range end valuetrue if this collection was modified by this method calljava.lang.IllegalArgumentException - if a value is rejected by this setjava.lang.UnsupportedOperationException - if not supported by this setpublic boolean removeFirst(char value)
This implementation uses iterator().remove().
removeFirst in interface CharCollectionvalue - the value to removetrue if this collection was modified by this method calljava.lang.UnsupportedOperationException - if not supported by this collectionpublic boolean removeAll(char value)
This implementation uses iterator().remove().
removeAll in interface CharCollectionvalue - the value to removetrue if this collection was modified by this method calljava.lang.UnsupportedOperationException - if not supported by this collectionpublic boolean removeAll(char[] values)
This implementation uses iterator().remove().
removeAll in interface CharCollectionvalues - the values to remove from this collection, null treated as empty arraytrue if this list was modified by this method calljava.lang.UnsupportedOperationException - if not supported by this collectionpublic boolean removeAll(CharCollection values)
This implementation uses iterator().remove().
removeAll in interface CharCollectionvalues - the values to remove from this collection, null treated as empty collectiontrue if this list was modified by this method calljava.lang.UnsupportedOperationException - if not supported by this collectionpublic boolean removeAll(char startInclusive,
char 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 CharCollectionstartInclusive - the inclusive range start valueendInclusive - the inclusive range end valuetrue if this collection was modified by this method calljava.lang.UnsupportedOperationException - if not supported by this collectionpublic boolean retainAll(char[] values)
This implementation uses iterator().remove().
retainAll in interface CharCollectionvalues - the values to remove from this collection, null treated as empty arraytrue if this list was modified by this method calljava.lang.UnsupportedOperationException - if not supported by this collectionpublic boolean retainAll(CharCollection values)
This implementation uses iterator().remove().
retainAll in interface CharCollectionvalues - the values to retain in this collection, null treated as empty collectiontrue if this collection was modified by this method calljava.lang.UnsupportedOperationException - if not supported by this collectionpublic boolean retainAll(char startInclusive,
char 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 CharCollectionstartInclusive - the inclusive range start valueendInclusive - the inclusive range end valuetrue if this collection was modified by this method calljava.lang.UnsupportedOperationException - if not supported by this collectionpublic boolean contains(java.lang.Object value)
Character value.
This implementation uses contains(char).
contains in interface java.util.Collection<java.lang.Character>value - the value to search fortrue if the value is foundpublic boolean containsAll(java.util.Collection<?> coll)
This implementation uses containsAll(char[]).
containsAll in interface java.util.Collection<java.lang.Character>coll - the collection of values to search fortrue if all the values are foundpublic boolean containsAny(java.util.Collection<?> coll)
false is returned.
This implementation uses containsAny(char[]).
containsAny in interface PrimitiveCollection<java.lang.Character>coll - the collection of values to search fortrue if at least one of the values is foundpublic java.lang.Object[] toArray()
Character.toArray in interface java.util.Collection<java.lang.Character>Characterpublic <T> T[] toArray(T[] array)
toArray in interface java.util.Collection<java.lang.Character>T - the array typearray - the array to populateCharacterpublic boolean add(java.lang.Character value)
Character value to this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
This implementation uses add(char).
add in interface java.util.Collection<java.lang.Character>value - the value to add to this collectiontrue if this collection was modified by this method calljava.lang.IllegalArgumentException - if value is rejected by this collectionjava.lang.UnsupportedOperationException - if not supported by this collectionpublic boolean addAll(java.util.Collection<? extends java.lang.Character> coll)
Character values to this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
This implementation uses addAll(char[]).
addAll in interface java.util.Collection<java.lang.Character>coll - the values to add to this collectiontrue if this list was modified by this method calljava.lang.IndexOutOfBoundsException - if the index is invalidjava.lang.ClassCastException - if any object is not Characterjava.lang.IllegalArgumentException - if value is rejected by this collectionjava.lang.UnsupportedOperationException - if not supported by this collectionpublic boolean remove(java.lang.Object value)
Character value from
this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be removed from.
This implementation uses removeFirst(char).
remove in interface java.util.Collection<java.lang.Character>value - the value to removetrue if this collection was modified by this method calljava.lang.UnsupportedOperationException - if not supported by this collectionpublic boolean removeAll(java.util.Collection<?> coll)
Character values from this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
This implementation uses removeAll(char[]).
removeAll in interface java.util.Collection<java.lang.Character>coll - the values to remove from this collectiontrue if this list was modified by this method calljava.lang.UnsupportedOperationException - if not supported by this collectionpublic boolean retainAll(java.util.Collection<?> coll)
Character values, removing other
values (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
This implementation uses retainAll(char[]).
retainAll in interface java.util.Collection<java.lang.Character>coll - the values to retain in this collectiontrue if this list was modified by this method calljava.lang.UnsupportedOperationException - if not supported by this collectionpublic java.lang.String toString()
The format used is as per Collection.
toString in class java.lang.Objectprotected void arrayCopy(int fromIndex,
char[] 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<java.lang.Character>isModifiable in class AbstractPrimitiveCollectable<java.lang.Character>protected void checkAddModifiable()
protected void checkRemoveModifiable()
protected java.lang.Character toObject(char value)
char with an Object wrapper.value - the primitive valueprotected boolean isToPrimitivePossible(java.lang.Object value)
This implementation only allows non-null Char objects.
value - the Object wrapperprotected char toPrimitive(java.lang.Object value)
Character to retrieve the primitive char.
This implementation only allows non-null Char objects.
value - the Object to convert to a primitivejava.lang.NullPointerException - if the value is null and this is unacceptablejava.lang.ClassCastException - if the object is of an unsuitable typeprotected char[] toPrimitiveArray(java.util.Collection<?> coll)
Collection to retrieve the primitive char.
This implementation only allows non-null Char objects.
coll - the Collection to convert to primitivesjava.lang.NullPointerException - if the value is null and this is unacceptablejava.lang.ClassCastException - if any object is of an unsuitable typeCopyright © 2005–2018 Joda.org. All rights reserved.