|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--xbn.XBNObject | +--xbn.string.StringOrBuffer
Base class of "wrappers" for Strings and StringBuffers, to prevent duplication of functions used by both.
Source code: StringOrBuffer.java. Unit tests: xbn_junit.JUTStringOrBuffer.java.
Fields inherited from class xbn.XBNObject |
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP |
Constructor Summary | |
StringOrBuffer()
|
Method Summary | |
abstract void |
append(char c_toAppend)
Append a character onto the end (right). |
abstract void |
append(String s_toAppend)
Append a string onto the end (right). |
abstract void |
appendToLeft(char c_toAppend)
Append a character to the start. |
abstract void |
appendToLeft(String s_toAppend)
Append a string to the start. |
abstract char |
charAt(int i_dx)
Get the character located at the requested array index. |
abstract void |
delete(int i_idxLeft,
int i_idxAfterRight)
Delete a range of characters. |
void |
deleteAll()
Delete all characters. |
abstract void |
deleteCharAt(int i_dx)
Delete a character. |
abstract boolean |
endsWith(String s_toSearchFor)
Is the search string found at the end of the StringOrBuffer? |
abstract String |
getTrimmed()
Get the value of this StringOrBuffer, after trimming whitespace from the ends. |
int |
indexOf(char c_toSearchFor)
Get the array index of the right-most occurance of the search string. |
int |
indexOf(char c_toSearchFor,
int i_idxLeft)
Get the array index of the right-most occurance of the search string. |
int |
indexOf(char c_toSearchFor,
int i_idxLeft,
int i_idxAfterRight)
Get the array index of the right-most occurance of the search string. |
int |
indexOf(char c_toSearchFor,
int i_idxLeft,
int i_idxAfterRight,
boolean b_bounded)
Get the array index of the left-most occurance of the search string. |
int |
indexOf(String s_toSearchFor)
Get the array index of the right-most occurance of the search string. |
int |
indexOf(String s_toSearchFor,
int i_idxLeft)
Get the array index of the right-most occurance of the search string. |
int |
indexOf(String s_toSearchFor,
int i_idxLeft,
int i_idxAfterRight)
Get the array index of the right-most occurance of the search string. |
int |
indexOf(String s_toSearchFor,
int i_idxLeft,
int i_idxAfterRight,
boolean b_bounded)
Get the array index of the left-most occurance of the search string. |
abstract void |
insert(int i_dx,
char c_toInsert)
Insert a character. |
abstract void |
insert(int i_dx,
String s_toInsert)
Insert a string. |
boolean |
isEmpty()
Are there zero characters in this StringOrBuffer? |
abstract boolean |
isString()
Does this StringOrBuffer contain a String? |
boolean |
isStringAt(String s_toSearchFor,
int i_dx)
Is the search string found at the specific array index? |
boolean |
isStringBuffer()
Does this StringOrBuffer contain a StringBuffer? |
int |
lastIndexOf(char c_toSearchFor)
Get the array index of the right-most occurance of the search string. |
int |
lastIndexOf(char c_toSearchFor,
int i_idxAfterRight)
Get the array index of the right-most occurance of the search string. |
int |
lastIndexOf(char c_toSearchFor,
int i_idxAfterRight,
boolean b_bounded)
Get the array index of the right-most occurance of the search string. |
int |
lastIndexOf(char c_toSearchFor,
int i_idxLeft,
int i_idxAfterRight)
Get the array index of the right-most occurance of the search string. |
int |
lastIndexOf(char c_toSearchFor,
int i_idxLeft,
int i_idxAfterRight,
boolean b_bounded)
Get the array index of the right-most occurance of the search string. |
int |
lastIndexOf(String s_toSearchFor)
Get the array index of the right-most occurance of the search string. |
int |
lastIndexOf(String s_toSearchFor,
int i_idxAfterRight)
Get the array index of the right-most occurance of the search string. |
int |
lastIndexOf(String s_toSearchFor,
int i_idxAfterRight,
boolean b_bounded)
Get the array index of the right-most occurance of the search string. |
int |
lastIndexOf(String s_toSearchFor,
int i_idxLeft,
int i_idxAfterRight)
Get the array index of the right-most occurance of the search string. |
int |
lastIndexOf(String s_toSearchFor,
int i_idxLeft,
int i_idxAfterRight,
boolean b_bounded)
Get the array index of the right-most occurance of the search string. |
abstract int |
length()
How long is this StringOrBuffer? |
abstract void |
setLength(int i_newLength)
Set the length. |
abstract boolean |
startsWith(String s_toSearchFor)
Is the search string found at index 0? |
abstract String |
substring(int i_idxLeft)
Get a range of characters starting at the requested index. |
abstract String |
substring(int i_idxLeft,
int i_idxAfterRight)
Get a range of characters. |
abstract void |
trim()
Trim whitespace from the value of this StringOrBuffer. |
Methods inherited from class xbn.XBNObject |
getXMsgPrefix, sop, sopl, sopl, throwAX, throwAXIfBadStr, throwAXIfNull, throwAXSpoof |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public StringOrBuffer()
Method Detail |
public abstract boolean isString()
Does this StringOrBuffer contain a String?
public final boolean isStringBuffer()
Does this StringOrBuffer contain a StringBuffer?
!isString()
public abstract int length()
How long is this StringOrBuffer?
public final boolean isEmpty()
Are there zero characters in this StringOrBuffer?
(length() == 0)
public abstract boolean startsWith(String s_toSearchFor)
Is the search string found at index 0?
s_toSearchFor
- The string to search at index zero for. May not be null or zero characters in length.public abstract boolean endsWith(String s_toSearchFor)
Is the search string found at the end of the StringOrBuffer?
s_toSearchFor
- The string that should be searched for, at the end of the StringOrBuffer. May not be null or zero characters in length.public abstract String getTrimmed()
Get the value of this StringOrBuffer, after trimming whitespace from the ends. This does not alter the internally-held value.
public abstract void trim()
Trim whitespace from the value of this StringOrBuffer. Unlike the java.lang.String version of this function, this does not return anything, but rather just trims the internally-held value. See getTrimmed().
public abstract char charAt(int i_dx)
Get the character located at the requested array index.
i_dx
- The array index of the character you want. Must range 0..[length() - 1]
, inclusive.public abstract void append(String s_toAppend)
Append a string onto the end (right).
s_toAppend
- The string to append.public abstract void appendToLeft(String s_toAppend)
Append a string to the start.
s_toAppend
- The string to append.public abstract void insert(int i_dx, String s_toInsert)
Insert a string.
i_dx
- The array index at which s_toInsert should be inserted. Must range 0..[length() - 1]
, inclusive.s_toInsert
- The string to insert.public abstract void append(char c_toAppend)
Append a character onto the end (right).
s_toAppend
- The character to insert.public abstract void appendToLeft(char c_toAppend)
Append a character to the start.
c_toAppend
- The character to insert.public abstract void insert(int i_dx, char c_toInsert)
Insert a character.
i_dx
- The array index at which c_toInsert should be inserted. Must range 0..[length() - 1]
, inclusive.c_toInsert
- The character to insert.public abstract void deleteCharAt(int i_dx)
Delete a character.
i_dx
- The array index containing the character to delete. Must range 0..[length() - 1]
, inclusive.public abstract void delete(int i_idxLeft, int i_idxAfterRight)
Delete a range of characters.
i_idxLeft
- The array index of the left-most character to be deleted. Must range 0..[length() - 1]
, inclusive, and must be less than or equal to i_idxAfterRight.i_idxAfterRight
- The array index after the right-most to be retrieved. Must be between i_idxLeft and length, inclusive.public abstract void setLength(int i_newLength)
Set the length.
i_newLength
- The desired length. If less than length, then every character at and after (array index) i_newLength is deleted. If greater than length, then spaces are appended to the right hand side until the new length is achieved.public abstract String substring(int i_idxLeft)
Get a range of characters starting at the requested index.
This returns the same thing as substring(i_idxLeft, (length() - 1))
i_idxLeft
- The array index of the left-most character to be retrieved. Must range 0..[length() - 1]
, inclusive, and must be less than or equal to i_idxAfterRight.public abstract String substring(int i_idxLeft, int i_idxAfterRight)
Get a range of characters.
See substring.
i_idxLeft
- The array index of the left-most character to be retrieved. Must range 0..[length() - 1]
, inclusive, and must be less than or equal to i_idxAfterRight.i_idxAfterRight
- The array index after the right-most to be retrieved. Must be between i_idxLeft and length, inclusive.public final void deleteAll()
Delete all characters.
Equal to setLength(0)
public final int indexOf(String s_toSearchFor)
Get the array index of the right-most occurance of the search string.
indexOf(s_toSearchFor, 0)
public final int indexOf(String s_toSearchFor, int i_idxLeft)
Get the array index of the right-most occurance of the search string.
indexOf(s_toSearchFor, i_idxLeft, length())
public final int indexOf(String s_toSearchFor, int i_idxLeft, int i_idxAfterRight)
Get the array index of the right-most occurance of the search string.
indexOf(s_toSearchFor, i_idxLeft, i_idxAfterRight, true)
public final int indexOf(String s_toSearchFor, int i_idxLeft, int i_idxAfterRight, boolean b_bounded)
Get the array index of the left-most occurance of the search string.
s_toSearchFor
- The string to search for.. May not be null or zero characters in length.i_idxLeft
- The array index of the left-most (first) character to search. Must be between 0 and (length() - 1), inclusive.i_idxAfterRight
- The array index of the first character after the end of the search area. Must be between i_idxLeft and length, inclusive.b_bounded
- If true, then the search string must be fully contained between i_idxLeft (inclusive) and i_idxAfterRight (exclusive). If false, the search string must start between i_idxLeft and i_idxAfterRight, but the search string may exceed i_idxAfterRight (as long as it exists fully in the string as a whole).Assume the value of this StringOrBuffer is "abcdef"
and s_toSearchFor
is "bcde"
i_idxLeft |
i_idxAfterRight |
b_bounded |
RETURNED INT |
0 | 0 | true | -1 |
0 | length() |
true | 1 |
0 | 1 | true | -1 |
0 | 1 | false | 1 |
1 | 1 | true | -1 |
1 | 1 | false | 1 |
0 | 3 | true | -1 |
0 | 3 | false | 1 |
2 | length() |
true | -1 |
2 | length() |
false | -1 |
public final int lastIndexOf(String s_toSearchFor)
Get the array index of the right-most occurance of the search string.
lastIndexOf(s_toSearchFor, length())
public final int lastIndexOf(String s_toSearchFor, int i_idxAfterRight)
Get the array index of the right-most occurance of the search string.
lastIndexOf(s_toSearchFor, i_idxAfterRight, true)
public final int lastIndexOf(String s_toSearchFor, int i_idxAfterRight, boolean b_bounded)
Get the array index of the right-most occurance of the search string.
lastIndexOf(s_toSearchFor, 0, i_idxAfterRight, b_bounded)
public final int lastIndexOf(String s_toSearchFor, int i_idxLeft, int i_idxAfterRight)
Get the array index of the right-most occurance of the search string.
lastIndexOf(s_toSearchFor, i_idxLeft, i_idxAfterRight, true)
public final int lastIndexOf(String s_toSearchFor, int i_idxLeft, int i_idxAfterRight, boolean b_bounded)
Get the array index of the right-most occurance of the search string.
s_toSearchFor
- The string to search for. May not be null or zero characters in length.i_idxLeft
- The array index of the left-most (first) character to search. Must be between 0 and (length() - 1), inclusive.i_idxAfterRight
- The array index of the first character after the end of the search area. Must be between i_idxLeft and length, inclusive.b_bounded
- If true, then the search string must be fully contained between i_idxLeft (inclusive) and i_idxAfterRight (exclusive). If false, the search string must start between i_idxLeft and i_idxAfterRight, but the search string may exceed i_idxAfterRight (as long as it exists fully in the string as a whole). Note: The default behavior of java.lang.String.lastIndexOf(s,i)
is for the search to not be bounded (as if this were equal to false).Assume the value of this StringOrBuffer is "abcdef"
and s_toSearchFor
is "bcde"
i_idxLeft |
i_idxAfterRight |
b_bounded |
RETURNED INT |
0 | 0 | true | -1 |
0 | length() |
true | 1 |
0 | 1 | true | -1 |
0 | 1 | false | 1 |
1 | 1 | true | -1 |
1 | 1 | false | 1 |
0 | 3 | true | -1 |
0 | 3 | false | 1 |
2 | length() |
true | -1 |
2 | length() |
false | -1 |
public final int indexOf(char c_toSearchFor)
Get the array index of the right-most occurance of the search string.
indexOf((new Character(c_toSearchFor)).toString())
public final int indexOf(char c_toSearchFor, int i_idxLeft)
Get the array index of the right-most occurance of the search string.
indexOf((new Character(c_toSearchFor)).toString())
public final int indexOf(char c_toSearchFor, int i_idxLeft, int i_idxAfterRight)
Get the array index of the right-most occurance of the search string.
indexOf((new Character(c_toSearchFor)).toString(), i_idxLeft, i_idxAfterRight)
public final int indexOf(char c_toSearchFor, int i_idxLeft, int i_idxAfterRight, boolean b_bounded)
Get the array index of the left-most occurance of the search string.
lastIndexOf((new Character(c_toSearchFor)).toString(), i_idxLeft, i_idxAfterRight)
public final int lastIndexOf(char c_toSearchFor)
Get the array index of the right-most occurance of the search string.
lastIndexOf((new Character(c_toSearchFor)).toString())
public final int lastIndexOf(char c_toSearchFor, int i_idxAfterRight)
Get the array index of the right-most occurance of the search string.
lastIndexOf((new Character(c_toSearchFor)).toString(), i_idxAfterRight)
public final int lastIndexOf(char c_toSearchFor, int i_idxAfterRight, boolean b_bounded)
Get the array index of the right-most occurance of the search string.
lastIndexOf((new Character(c_toSearchFor)).toString(), i_idxAfterRight, b_bounded)
public final int lastIndexOf(char c_toSearchFor, int i_idxLeft, int i_idxAfterRight)
Get the array index of the right-most occurance of the search string.
lastIndexOf((new Character(c_toSearchFor)).toString(), i_idxLeft, i_idxAfterRight)
public final int lastIndexOf(char c_toSearchFor, int i_idxLeft, int i_idxAfterRight, boolean b_bounded)
Get the array index of the right-most occurance of the search string.
lastIndexOf((new Character(c_toSearchFor)).toString(), i_idxLeft, i_idxAfterRight)
public final boolean isStringAt(String s_toSearchFor, int i_dx)
Is the search string found at the specific array index?
s_toSearchFor
- What to search for. May not be null or zero characters in length.i_dx
- The array index at which s_toSearchFor should begin. Must be between zero and (length() - 1), inclusive.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1997-2003, Jeff Epstein, All Rights Reserved. See top of source code files for copyright notice.
http://sourceforge.net/projects/xbnjava