public class StringCharList extends AbstractCharList implements Cloneable
This class implements List allowing
seamless integration with other APIs.
AbstractCharList.PListIterator| Modifier and Type | Field and Description |
|---|---|
protected String |
string
The String being wrapped
|
| Constructor and Description |
|---|
StringCharList()
Constructor that uses an empty string as the datasource.
|
StringCharList(CharList list)
Constructor that copies the specified list.
|
StringCharList(String str)
Constructor that uses the specified string as the datasource.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(char value)
Checks whether this collection contains a specified primitive value.
|
char |
getChar(int index)
Gets the character at the specified index.
|
int |
indexOf(char value)
Gets the first index of the specified primitive value.
|
int |
indexOf(char value,
int fromIndexInclusive)
Gets the first index of the specified primitive value from an index.
|
int |
lastIndexOf(char value)
Gets the last index of the specified primitive value.
|
int |
lastIndexOf(char value,
int fromIndexInclusive)
Gets the first index of the specified primitive value from an index.
|
int |
size()
Gets the size of the list, which is the string length.
|
CharList |
subList(int fromIndexInclusive,
int toIndexExclusive)
Gets a range view of part of this list.
|
char[] |
toCharArray()
Gets the elements of this collection as an array.
|
String |
toStringContents()
Gets the String underlying the list.
|
add, add, add, add, addAll, addAll, addAll, arrayCopy, checkIndex, checkIndexExists, checkRange, checkSetModifiable, clear, equals, first, firstChar, get, hashCode, indexOf, indexOf, isModifiable, isSetModifiable, iterator, last, lastChar, lastIndexOf, lastIndexOf, listIterator, listIterator, remove, removeChar, removeCharAt, removeRange, set, set, toCharArrayaddAll, 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, toCharArray, toObject, toPrimitive, toPrimitiveArray, toStringclone, isEmpty, optimizefinalize, getClass, notify, notifyAll, wait, wait, waitaddAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArrayaddAll, addAll, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, removeAll, removeAll, removeAll, removeAll, removeFirst, retainAll, retainAll, retainAll, toCharArraycontainsAnyclone, isEmpty, optimizepublic StringCharList()
public StringCharList(CharList list)
list - the list to copy, must not be nullIllegalArgumentException - if the list is nullpublic StringCharList(String str)
str - the string to wrap in a list, must not be nullIllegalArgumentException - if the string is nullpublic char getChar(int index)
public int size()
size in interface Collection<Character>size in interface List<Character>size in interface PrimitiveCollectable<Character>public boolean contains(char value)
This implementation uses String.indexOf(char).
contains in interface CharCollectioncontains in class AbstractCharListvalue - the value to search fortrue if the value is foundpublic int indexOf(char value)
This implementation uses String.indexOf(char).
indexOf in interface CharListindexOf in class AbstractCharListvalue - the value to search for-1 if not foundpublic int indexOf(char 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 String.indexOf(char, int).
indexOf in interface CharListindexOf in class AbstractCharListvalue - the value to search forfromIndexInclusive - the index to start searching from, inclusive-1 if not foundpublic int lastIndexOf(char value)
This implementation uses String.lastIndexOf(char).
lastIndexOf in interface CharListlastIndexOf in class AbstractCharListvalue - the value to search for-1 if not foundpublic int lastIndexOf(char 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 String.lastIndexOf(char, int).
lastIndexOf in interface CharListlastIndexOf in class AbstractCharListvalue - the value to search forfromIndexInclusive - the index to start searching from, inclusive-1 if not foundpublic String toStringContents()
toStringContents in interface CharListtoStringContents in class AbstractCharListpublic char[] toCharArray()
This implementation uses String.toCharArray().
toCharArray in interface CharCollectiontoCharArray in class AbstractCharCollectionpublic CharList subList(int fromIndexInclusive, int toIndexExclusive)
This method allows operations to work on a range within the greater list. StringCharList is unmodifiable, thus so is the view.
subList in interface List<Character>subList in interface CharListsubList in class AbstractCharListfromIndexInclusive - the index to start from, inclusivetoIndexExclusive - the index to end at, exclusiveIndexOutOfBoundsException - if either index is invalidCopyright © 2005-2012 Joda.org. All Rights Reserved.