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, toCharArray
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, toCharArray, toObject, toPrimitive, toPrimitiveArray, toString
clone, isEmpty, optimize
finalize, getClass, notify, notifyAll, wait, wait, wait
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
addAll, addAll, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, removeAll, removeAll, removeAll, removeAll, removeFirst, retainAll, retainAll, retainAll, toCharArray
containsAny
clone, isEmpty, optimize
public 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 CharCollection
contains
in class AbstractCharList
value
- the value to search fortrue
if the value is foundpublic int indexOf(char value)
This implementation uses String.indexOf(char)
.
indexOf
in interface CharList
indexOf
in class AbstractCharList
value
- 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 CharList
indexOf
in class AbstractCharList
value
- 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 CharList
lastIndexOf
in class AbstractCharList
value
- 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 CharList
lastIndexOf
in class AbstractCharList
value
- the value to search forfromIndexInclusive
- the index to start searching from, inclusive-1
if not foundpublic String toStringContents()
toStringContents
in interface CharList
toStringContents
in class AbstractCharList
public char[] toCharArray()
This implementation uses String.toCharArray()
.
toCharArray
in interface CharCollection
toCharArray
in class AbstractCharCollection
public 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 CharList
subList
in class AbstractCharList
fromIndexInclusive
- the index to start from, inclusivetoIndexExclusive
- the index to end at, exclusiveIndexOutOfBoundsException
- if either index is invalidCopyright © 2005-2012 Joda.org. All Rights Reserved.