public class StringBufferCharList extends AbstractCharList
This class implements List
allowing
seamless integration with other APIs.
AbstractCharList.PListIterator
Modifier and Type | Field and Description |
---|---|
protected StringBuffer |
stringBuffer
The String being wrapped
|
Modifier | Constructor and Description |
---|---|
|
StringBufferCharList()
Constructor that uses an empty string as the datasource.
|
|
StringBufferCharList(CharList list)
Constructor that copies the specified list.
|
|
StringBufferCharList(String str)
Constructor that copies the specified string.
|
protected |
StringBufferCharList(StringBuffer buf)
Constructor that decorates the specified string buffer.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(char value)
Adds a primitive value to this collection.
|
boolean |
add(int index,
char value)
Adds a primitive value to this list at an index.
|
boolean |
addAll(char[] values)
Adds an array of primitive values to this list at an index.
|
boolean |
addAll(int index,
char[] values)
Adds an array of primitive values to this list at an index.
|
protected void |
arrayCopy(int fromIndex,
char[] dest,
int destIndex,
int size)
Copies data from this collection into the specified array.
|
static StringBufferCharList |
decorate(StringBuffer buf)
Decorates the specified string buffer with a StringBufferCharList.
|
char |
getChar(int index)
Gets the character at the specified index.
|
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 |
isSetModifiable()
Are the set methods supported.
|
char |
removeIndex(int index)
Removes a primitive value by index from the list.
|
boolean |
removeRange(int fromIndexInclusive,
int toIndexExclusive)
Removes a range of values from the list.
|
char |
set(int index,
char value)
Sets the primitive value at a specified index.
|
int |
size()
Gets the size of the list, which is the string length.
|
String |
toStringContents()
Gets the String underlying the list.
|
add, add, addAll, checkIndex, checkIndexExists, checkRange, checkSetModifiable, clear, contains, equals, first, firstChar, get, hashCode, indexOf, indexOf, indexOf, indexOf, iterator, last, lastChar, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOf, listIterator, listIterator, remove, removeChar, removeCharAt, set, subList, toCharArray
addAll, addAll, addAll, checkAddModifiable, checkRemoveModifiable, contains, containsAll, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, containsAny, isToPrimitivePossible, remove, removeAll, removeAll, removeAll, removeAll, removeAll, removeFirst, retainAll, retainAll, retainAll, retainAll, toArray, toArray, toCharArray, 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, toCharArray
containsAny
clone, isEmpty, optimize
protected final StringBuffer stringBuffer
public StringBufferCharList()
public StringBufferCharList(CharList list)
list
- the list to copy, must not be nullIllegalArgumentException
- if the list is nullpublic StringBufferCharList(String str)
str
- the string to copy, must not be nullIllegalArgumentException
- if the string is nullprotected StringBufferCharList(StringBuffer buf)
buf
- the string buffer to decorate, must not be nullIllegalArgumentException
- if the string is nullpublic static StringBufferCharList decorate(StringBuffer buf)
The specified buffer is used as the datasource, so changes to one will affect the other.
buf
- the string buffer to decorate, must not be nullIllegalArgumentException
- if the string is nullpublic char getChar(int index)
index
- the index to retrievepublic int size()
public boolean add(int index, char value)
add
in interface CharList
add
in class AbstractCharList
index
- the index to add atvalue
- the value to add to this collectiontrue
if this list was modified by this method callIndexOutOfBoundsException
- if the index is invalidpublic char removeIndex(int index)
index
- the index to remove fromIndexOutOfBoundsException
- if the index is invalidpublic char set(int index, char value)
This implementation throws UnsupportedOperationException.
set
in interface CharList
set
in class AbstractCharList
index
- the index to setvalue
- the value to storeIndexOutOfBoundsException
- if the index is invalidprotected boolean isAddModifiable()
isAddModifiable
in class AbstractCharCollection
protected boolean isRemoveModifiable()
isRemoveModifiable
in class AbstractCharCollection
protected boolean isSetModifiable()
isSetModifiable
in class AbstractCharList
public boolean isModifiable()
isModifiable
in interface PrimitiveCollectable<Character>
isModifiable
in class AbstractCharList
public boolean add(char value)
add
in interface CharCollection
add
in class AbstractCharList
value
- the value to add to this collectiontrue
if this collection was modified by this method callpublic boolean addAll(char[] values)
addAll
in interface CharCollection
addAll
in class AbstractCharList
values
- the values to add to this collection, null treated as empty arraytrue
if this list was modified by this method callIndexOutOfBoundsException
- if the index is invalidpublic boolean addAll(int index, char[] values)
addAll
in interface CharList
addAll
in class AbstractCharList
index
- the index to add atvalues
- the values to add to this collection, null treated as empty arraytrue
if this list was modified by this method callIndexOutOfBoundsException
- if the index is invalidpublic boolean removeRange(int fromIndexInclusive, int toIndexExclusive)
removeRange
in interface PrimitiveList<Character>
removeRange
in class AbstractCharList
fromIndexInclusive
- the start of the range to remove, inclusivetoIndexExclusive
- the end of the range to remove, exclusivetrue
if the collection was modifiedpublic String toStringContents()
toStringContents
in interface CharList
toStringContents
in class AbstractCharList
protected void arrayCopy(int fromIndex, char[] dest, int destIndex, int size)
arrayCopy
in class AbstractCharList
fromIndex
- the index to start fromdest
- the destination arraydestIndex
- the destination start indexsize
- the number of items to copyCopyright © 2005-2012 Joda.org. All Rights Reserved.