public final class CharsWrapper
extends java.lang.Object
implements java.lang.CharSequence, java.lang.Cloneable, java.lang.Iterable<java.lang.Character>
| Modifier and Type | Class and Description |
|---|---|
static class |
CharsWrapper.Builder
Builder class for constructing CharsWrappers.
|
| Constructor and Description |
|---|
CharsWrapper(char... chars)
Creates a new CharsWrapper backed by the given char array.
|
CharsWrapper(char[] chars,
int offset,
int limit)
Creates a new CharsWrapper backed by the given char array.
|
CharsWrapper(java.lang.CharSequence csq)
Creates a new CharsWrapper containing the same characters as the specified CharSequence.
|
CharsWrapper(java.lang.CharSequence csq,
int begin,
int end)
Creates a new CharsWrapper containing the same characters as the specified CharSequence.
|
CharsWrapper(java.lang.String str)
Creates a new CharsWrapper containing the same characters as the specified String.
|
CharsWrapper(java.lang.String str,
int begin,
int end)
Creates a new CharsWrapper containing the same characters as the specified String.
|
| Modifier and Type | Method and Description |
|---|---|
char |
charAt(int index) |
CharsWrapper |
clone()
Creates and returns a copy of this CharsWrapper.
|
boolean |
contains(char c)
Checks if this CharsWrapper contains the specified character.
|
boolean |
contentEquals(char[] array)
Compares this CharsWrapper to an array of characters.
|
boolean |
contentEquals(java.lang.CharSequence cs)
Compares this CharsWrapper to a CharSequence.
|
boolean |
equals(java.lang.Object obj) |
boolean |
equalsIgnoreCase(java.lang.CharSequence cs)
Compares this CharsWrapper to a CharSequence, ignoring case considerations.
|
char |
get(int index) |
int |
hashCode()
Calculates the hash code of this CharsWrapper.
|
int |
indexOf(char c)
Returns the index within this CharsWrapper of the first occurrence of the specified
character.
|
int |
indexOfFirst(char... ch)
Returns the index within this CharsWrapper of the first occurrence of one of the specified
characters.
|
boolean |
isEmpty()
Checks if this CharsWrapper is empty, ie if its length is zero.
|
java.util.Iterator<java.lang.Character> |
iterator() |
int |
length() |
void |
replaceAll(char ch,
char replacement)
Replaces all occurences in this Wrapper of a character by another one.
|
void |
set(int index,
char ch)
Sets the value of a character.
|
boolean |
startsWith(java.lang.CharSequence cs)
Checks if this CharsWrapper starts with the same characters as the given CharSequence.
|
CharsWrapper |
subSequence(int start,
int end)
This method copies the data so the returned CharsWrapper doesn't share its array with this
CharsWrapper and is completely independant.
|
CharsWrapper |
subView(int start)
Creates a view of a part of this CharsWrapper.
|
CharsWrapper |
subView(int start,
int end)
Creates a view of a part of this CharsWrapper.
|
java.lang.String |
toString() |
CharsWrapper |
trimmedView()
Creates a trimmed view of this CharsWrapper, with any leading and trailing whitespace
removed.
|
public CharsWrapper(char... chars)
chars - the char array to usepublic CharsWrapper(char[] chars,
int offset,
int limit)
chars - the char array to useoffset - the index (in the array) of the first character to uselimit - the index +1 (in the array) of the last character to usepublic CharsWrapper(java.lang.String str)
str - the String to copypublic CharsWrapper(java.lang.String str,
int begin,
int end)
str - the String to copybegin - index of the first character to copy from strend - index after the last character to copy from strpublic CharsWrapper(java.lang.CharSequence csq)
csq - the sequence to copypublic CharsWrapper(java.lang.CharSequence csq,
int begin,
int end)
csq - the sequence to copybegin - index of the first character to copy from csqend - index after the last character to copy from csqpublic boolean isEmpty()
public int length()
length in interface java.lang.CharSequencepublic char charAt(int index)
charAt in interface java.lang.CharSequencepublic char get(int index)
index - the character's index (the first character is at index 0)public void set(int index,
char ch)
index - the character's index (the first character is at index 0)ch - the character value to setpublic void replaceAll(char ch,
char replacement)
ch - the character to replacereplacement - the replacement to usepublic boolean contains(char c)
c - the character to look forpublic int indexOf(char c)
c - the character to look forc, or -1 if not found.public int indexOfFirst(char... ch)
ch - the characters to look forch, or -1 if not
found.public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic boolean equalsIgnoreCase(java.lang.CharSequence cs)
cs - the CharSequence to compare with this CharsWrapperString.equalsIgnoreCase(String)public boolean contentEquals(java.lang.CharSequence cs)
cs - the CharSequence to compare with this CharsWrapperString.contentEquals(CharSequence)public boolean contentEquals(char[] array)
array - the array to compare with this CharsWrapperpublic boolean startsWith(java.lang.CharSequence cs)
cs - the sequence to compare to the beginning of this CharsWrapperpublic CharsWrapper subSequence(int start, int end)
This method copies the data so the returned CharsWrapper doesn't share its array with this CharsWrapper and is completely independant.
subSequence in interface java.lang.CharSequencepublic CharsWrapper subView(int start, int end)
start - the start index, inclusiveend - the end index, exclusivepublic CharsWrapper subView(int start)
start - the start index, inclusivepublic CharsWrapper trimmedView()
String.trim()public java.lang.String toString()
toString in interface java.lang.CharSequencetoString in class java.lang.Objectpublic int hashCode()
wrapper.toString().hashCode(). That is, if a String and a CharsWrapper contain
exactly the same characters then they will have the same hash code.hashCode in class java.lang.ObjectString.hashCode()public CharsWrapper clone()
clone in class java.lang.Objectpublic java.util.Iterator<java.lang.Character> iterator()
iterator in interface java.lang.Iterable<java.lang.Character>