|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.uima.internal.util.CharArrayString
public class CharArrayString
An unsafe String class based on a publicly accessible character array. This class aims to provide similar functionality as java.lang.String, but without the overhead of copying at creation time. Consequently, you should only use this class if you have complete control over the underlying memory (i.e., char array).
Constructor Summary | |
---|---|
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(java.lang.String string)
Create a new CharArrayString from a String. |
Method Summary | |
---|---|
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(java.lang.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(java.lang.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. |
java.lang.String |
toString()
Return a string representation. |
CharArrayString |
trim()
Trim this. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public CharArrayString(java.lang.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.Method Detail |
---|
public int length()
public int getStart()
public int getEnd()
public char[] getChars()
public CharArrayString trim()
public CharArrayString substring(int startPos, int endPos) throws java.lang.IndexOutOfBoundsException
startPos
- The start of the substring.endPos
- The end of the substring.
java.lang.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 java.lang.String toString()
toString
in class java.lang.Object
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 java.lang.IndexOutOfBoundsException
c
- The char we're looking for.offset
- An offset after which we start looking.
-1
if the char wasn't found.
java.lang.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 java.lang.IndexOutOfBoundsException
pos
- The position where to set the char.c
- The char to set.
java.lang.IndexOutOfBoundsException
- If pos
is out of bounds.public CharArrayString copy()
public int hashCode()
hashCode
in class java.lang.Object
public static final int hashCode(char[] charArray, int startPos, int endPos)
charArray
- startPos
- endPos
-
public static final int hashCode(java.lang.String s)
s
- The string to get the hash code for.
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
s
- The other string.
true
iff the two strings are equal.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |