public class CharArrayString extends Object
| Constructor and Description |
|---|
CharArrayString(char[] charArray)
Create a new CharArrayString from an array of characters.
|
CharArrayString(char[] charArray,
int startPos,
int length)
Create a new CharArrayString from an array of characters.
|
CharArrayString(String string)
Create a new CharArrayString from a String.
|
| Modifier and Type | Method and Description |
|---|---|
char |
charAt(int pos)
Return the character at a given position.
|
CharArrayString |
copy()
Copy this string.
|
boolean |
endsWith(char c)
Check if we end in a given character.
|
boolean |
endsWith(CharArrayString string)
Check of we end in a give string suffix.
|
boolean |
equals(Object o)
Check for equality with another CharArrayString.
|
char[] |
getChars()
Get the internal character array.
|
int |
getEnd()
Get the end position of the string in the internal array.
|
int |
getStart()
Get the start position of the string in the internal array.
|
int |
hashCode()
Get the hash code for this object.
|
static int |
hashCode(char[] charArray,
int startPos,
int endPos)
A static method to compute the hash code for a character range in an array.
|
static int |
hashCode(String s)
Compute a hash-code for a string.
|
int |
indexOf(char c)
Find the first occurence of a given char.
|
int |
indexOf(char c,
int offset)
Find an occurence of a given character after some position.
|
int |
lastIndexOf(char c)
Find the last occurence of a character.
|
int |
length()
Get the length of the string.
|
void |
setChar(int pos,
char c)
Set the char at a certain position.
|
CharArrayString |
substring(int startPos)
Return a substring starting at a given position.
|
CharArrayString |
substring(int startPos,
int endPos)
Returns a substring.
|
String |
toString()
Return a string representation.
|
CharArrayString |
trim()
Trim this.
|
public CharArrayString(String string)
string - The input string. The content of this string is copied.public CharArrayString(char[] charArray)
charArray - The input char array.public CharArrayString(char[] charArray,
int startPos,
int length)
charArray - The input char array.startPos - The start of the string.length - The length of the string.public int length()
public int getStart()
public int getEnd()
public char[] getChars()
public CharArrayString trim()
public CharArrayString substring(int startPos, int endPos) throws IndexOutOfBoundsException
startPos - The start of the substring.endPos - The end of the substring.IndexOutOfBoundsException - If the position parameters are not valid string positions.public CharArrayString substring(int startPos)
startPos - The start position of the substring.startPos.public int lastIndexOf(char c)
c - The char we're looking for.-1 if the character is not
contained in the string.public String toString()
public boolean endsWith(CharArrayString string)
string - The string suffix we're looking for.true iff string is a suffix of this.public boolean endsWith(char c)
c - The character.true iff we end in c.public char charAt(int pos)
pos - The position we're looking for.public int indexOf(char c,
int offset)
throws IndexOutOfBoundsException
c - The char we're looking for.offset - An offset after which we start looking.-1 if the char wasn't found.IndexOutOfBoundsException - If offset is less than 0.public int indexOf(char c)
c - The char we're looking for.-1 if the char couldn't be found.public void setChar(int pos,
char c)
throws IndexOutOfBoundsException
pos - The position where to set the char.c - The char to set.IndexOutOfBoundsException - If pos is out of bounds.public CharArrayString copy()
public int hashCode()
public static final int hashCode(char[] charArray,
int startPos,
int endPos)
charArray - -startPos - -endPos - -public static final int hashCode(String s)
s - The string to get the hash code for.Copyright © 2018. All rights reserved.