|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object PIRL.Strings.String_Buffer
public class String_Buffer
A String_Buffer is a wrapper for the StringBuffer class.
The StringBuffer class is declared final so it can not be extended. The String_Buffer class implements all of the StringBuffer methods (by simply calling the corresponding method) plus numerous methods that provide extended and convenient capabilities along the usual lines of String manipulation. The wrapped methods all function identically to their StringBuffer counterparts, of course, except when a reference to this StringBuffer object is returned it is a reference to this String_Buffer object.
StringBuffer
Field Summary | |
---|---|
static String |
ID
|
static String |
NL
|
static char |
QUESTIONABLE_CHARACTER
|
Constructor Summary | |
---|---|
String_Buffer()
Constructs a String_Buffer with no characters in it and an initial capacity of 16 characters. |
|
String_Buffer(int length)
Constructs a String_Buffer with no characters in it and an initial capacity specified by the length argument. |
|
String_Buffer(String string)
Constructs a String_Buffer so that it represents the same sequence of characters as the string argument; in other words, the initial contents of the String_Buffer is a copy of the argument string. |
Method Summary | |
---|---|
String_Buffer |
append(boolean b)
|
String_Buffer |
append(byte b)
Append a byte as a character. |
String_Buffer |
append(byte[] bytes)
Append a byte array as characters. |
String_Buffer |
append(byte[] bytes,
int offset,
int length)
Append a set of bytes as characters. |
String_Buffer |
append(char c)
|
String_Buffer |
append(char[] s)
|
String_Buffer |
append(char[] s,
int offset,
int length)
|
String_Buffer |
append(double d)
|
String_Buffer |
append(float f)
|
String_Buffer |
append(int i)
|
String_Buffer |
append(long l)
|
String_Buffer |
append(Object o)
|
String_Buffer |
append(String s)
|
int |
capacity()
|
char |
charAt(int index)
|
String_Buffer |
clean(char character)
Clean all unescaped occurances of a character from a String. |
String_Buffer |
clear()
Empties the buffer of all characters. |
String_Buffer |
delete(int start,
int end)
|
String_Buffer |
deleteCharAt(int index)
|
void |
ensureCapacity(int minimumCapacity)
|
boolean |
equals_ignore_case(int index,
String pattern)
Tests if the pattern String is equal regardless of case to the substring of the same length starting at the index. |
boolean |
equals(int index,
String pattern)
Tests if the pattern String is equal to the substring of the same length starting at the index. |
boolean |
equalsIgnoreCase(int index,
String pattern)
|
String_Buffer |
escape_to_special()
Substitutes escape sequences with special characters. |
static String |
escape_to_special(String string)
Substitutes escape sequences with special characters. |
String_Buffer |
from_character_references()
Substitutes numeric character references with characters. |
static String |
from_character_references(String string)
Substitutes numeric character references with characters. |
void |
getChars(int srcBegin,
int srcEnd,
char[] dst,
int dstBegin)
|
int |
index_of(int index,
char character)
Gets the index of the next character matching the specified character, starting with the specified index. |
int |
index_of(int index,
String pattern)
Gets the index of the next occurance of the substring matching the pattern String, starting with the specified index. |
int |
indexOf(int index,
char character)
|
int |
indexOf(int index,
String pattern)
|
String_Buffer |
insert(int index,
boolean b)
|
String_Buffer |
insert(int index,
char c)
|
String_Buffer |
insert(int index,
char[] s)
|
String_Buffer |
insert(int index,
char[] s,
int offset,
int length)
|
String_Buffer |
insert(int index,
double d)
|
String_Buffer |
insert(int index,
float f)
|
String_Buffer |
insert(int index,
int i)
|
String_Buffer |
insert(int index,
long l)
|
String_Buffer |
insert(int index,
Object o)
|
String_Buffer |
insert(int index,
String s)
|
int |
length()
|
String_Buffer |
replace_span(int index,
String span,
String substitute)
Replaces all sequences of any and all characters from the span String with the substitute String, starting at the specified index. |
String_Buffer |
replace(int start,
int end,
String string)
|
String_Buffer |
replace(int index,
String old_string,
String new_string)
Replaces all occurances of the old_string with the new_string, starting at the specified index. |
String_Buffer |
replaceSpan(int index,
String span,
String substitute)
|
String_Buffer |
reverse()
|
void |
setCharAt(int index,
char c)
|
void |
setLength(int length)
|
int |
skip_back_over(int index,
String skip)
Skips back over any and all characters in the skip String, starting with the character at the specified index. |
int |
skip_back_until(int index,
String find)
Skips back until a character also in the find String is found, starting with the character at the specified index. |
int |
skip_over(int index,
String skip)
Skips over any and all characters in the skip String, starting with the character at the specified index. |
int |
skip_until(int index,
String find)
Skips until a character also in the find String is found, starting with the character at the specified index. |
int |
skipBackOver(int index,
String skip)
|
int |
skipBackUntil(int index,
String find)
|
int |
skipOver(int index,
String skip)
|
int |
skipUntil(int index,
String find)
|
String_Buffer |
special_to_escape()
Substitutes special characters with escape sequences. |
static String |
special_to_escape(String string)
Substitutes special characters with escape sequences. |
String |
substring(int index)
|
String |
substring(int start,
int end)
|
String_Buffer |
to_character_references()
Substitutes non-printable characters with numeric character references. |
static String |
to_character_references(String string)
Substitutes non-printable characters with numeric character references. |
String_Buffer |
to_printable_ASCII()
Substitute all non-ASCII and unprintable characters with a question mark. |
static String |
to_printable_ASCII(String string)
Substitute all non-ASCII and unprintable characters with a question mark. |
String |
toString()
|
String_Buffer |
trim_all(char character)
Trims a sequence of the same character from both ends of a string. |
String_Buffer |
trim_beginning()
Trims whitespace from the beginning of the String_Buffer. |
String_Buffer |
trim_end()
Trims whitespace from the end of the String_Buffer. |
String_Buffer |
trim()
Trims whitespace from both ends of the String_Buffer. |
String_Buffer |
trim(char character)
Trims a character from both ends of a string. |
String_Buffer |
trim(int start,
int end)
Trims whitespace from both ends of a substring of the String_Buffer, starting at the start index and ending before the end index. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String ID
public static final String NL
public static final char QUESTIONABLE_CHARACTER
Constructor Detail |
---|
public String_Buffer()
public String_Buffer(int length)
length
- The initial capacity.
NegativeArraySizeException
- If the length argument is less than 0.public String_Buffer(String string)
string
- The initial contents of the buffer.Method Detail |
---|
public String_Buffer append(boolean b)
StringBuffer.append(boolean)
public String_Buffer append(char c)
StringBuffer.append(char)
public String_Buffer append(byte b)
b
- The byte to be appended.public String_Buffer append(char[] s)
StringBuffer.append(char[])
public String_Buffer append(byte[] bytes)
Equivalent to append (bytes, 0, bytes.length);
bytes
- An array of bytes.public String_Buffer append(char[] s, int offset, int length)
StringBuffer.append(char[], int, int)
public String_Buffer append(byte[] bytes, int offset, int length) throws IndexOutOfBoundsException
A convenience method for append (new String (bytes, offset, length));
bytes
- An array of bytes.offset
- The byte array offset of the first byte to be appended.length
- The number of bytes to be appended.
IndexOutOfBoundsException
- If the offset and/or length index
bytes outside array bounds.public String_Buffer append(double d)
StringBuffer.append(double)
public String_Buffer append(float f)
StringBuffer.append(float)
public String_Buffer append(int i)
StringBuffer.append(int)
public String_Buffer append(long l)
StringBuffer.append(long)
public String_Buffer append(Object o)
StringBuffer.append(Object)
public String_Buffer append(String s)
StringBuffer.append(String)
public int capacity()
StringBuffer.capacity()
public char charAt(int index)
StringBuffer.charAt(int)
public String_Buffer delete(int start, int end)
StringBuffer.delete(int, int)
public String_Buffer deleteCharAt(int index)
StringBuffer.deleteCharAt(int)
public void ensureCapacity(int minimumCapacity)
StringBuffer.ensureCapacity(int)
public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
StringBuffer.getChars(int, int, char[], int)
public String_Buffer insert(int index, boolean b)
StringBuffer.insert(int, boolean)
public String_Buffer insert(int index, char c)
StringBuffer.insert(int, char)
public String_Buffer insert(int index, char[] s)
StringBuffer.insert(int, char[])
public String_Buffer insert(int index, char[] s, int offset, int length)
StringBuffer.insert(int, char[], int, int)
public String_Buffer insert(int index, double d)
StringBuffer.insert(int, double)
public String_Buffer insert(int index, float f)
StringBuffer.insert(int, float)
public String_Buffer insert(int index, int i)
StringBuffer.insert(int, int)
public String_Buffer insert(int index, long l)
StringBuffer.insert(int, long)
public String_Buffer insert(int index, Object o)
StringBuffer.insert(int, Object)
public String_Buffer insert(int index, String s)
StringBuffer.insert(int, String)
public int length()
StringBuffer.length()
public String_Buffer replace(int start, int end, String string)
StringBuffer.replace(int, int, String)
public String_Buffer reverse()
StringBuffer.reverse()
public void setCharAt(int index, char c)
StringBuffer.setCharAt(int, char)
public void setLength(int length)
StringBuffer.setLength(int)
public String substring(int index)
StringBuffer.substring(int)
public String substring(int start, int end)
StringBuffer.substring(int, int)
public String toString()
toString
in class Object
StringBuffer.toString()
public int skip_over(int index, String skip)
index
- The index of the first character to test.skip
- The set of characters to be skipped.
length
) index if all remaining characters from
the starting index are in the skip String.String.indexOf(int)
,
charAt(int)
public int skipOver(int index, String skip)
skip_over(int, String)
public int skip_back_over(int index, String skip)
index
- The index of the first character to test.skip
- The set of characters to be skipped.
String.indexOf(int)
,
charAt(int)
public int skipBackOver(int index, String skip)
skip_back_over(int, String)
public int skip_until(int index, String find)
index
- The index of the first character to test.find
- The set of potential characters to find.
String.indexOf(int)
,
charAt(int)
public int skipUntil(int index, String find)
skip_until(int, String)
public int skip_back_until(int index, String find)
index
- The index of the first character to test.find
- The set of potential characters to find.
String.indexOf(int)
,
charAt(int)
public int skipBackUntil(int index, String find)
skip_back_until(int, String)
public int index_of(int index, char character)
index
- The index of the first character to test.character
- The character to match.
String.indexOf(int, int)
public int indexOf(int index, char character)
index_of(int, char)
public int index_of(int index, String pattern)
index
- The starting index from which to search for the pattern String.pattern
- The pattern String to match.
String.indexOf(String, int)
public int indexOf(int index, String pattern)
index_of(int, String)
public boolean equals(int index, String pattern)
index
- The starting index from which to test for the pattern String.pattern
- The pattern String to match.
String.startsWith(String, int)
public boolean equals_ignore_case(int index, String pattern)
index
- The starting index from which to test for the pattern String.pattern
- The pattern String to match.
String.regionMatches(boolean, int, String, int, int)
public boolean equalsIgnoreCase(int index, String pattern)
equals_ignore_case(int, String)
public String_Buffer replace(int index, String old_string, String new_string)
Recursive replacements are avoided: If the new_string contains the old_string, the new old_string remains in its location within the new_string; the search for an old_string continues at the location after where the new_string has been inserted.
index
- The starting index from which to test for the old_string.old_string
- The substring to find.new_string
- The String to replace the old_string.
index_of(int, String)
,
StringBuffer.replace(int, int, String)
public String_Buffer replace_span(int index, String span, String substitute)
Each replacement occurs on the longest sequence of characters all from the span String set.
Recursive replacements are avoided: If the substitute contains any characters from the span the substitute remains unaffected; the search for another span continues at the location after where the substitute has been inserted.
index
- The starting index from which to test for span characters.span
- The set of potential characters for replacement.substitute
- The String to replace each span sequence.
skip_until(int, String)
,
skip_over(int, String)
,
StringBuffer.replace(int, int, String)
public String_Buffer replaceSpan(int index, String span, String substitute)
replace_span(int, String, String)
public String_Buffer trim(int start, int end)
start
- The index of the starting character of the substring.end
- The index of the end (last + 1) character of the substring.
StringBuffer.substring(int, int)
,
String.trim()
,
StringBuffer.replace(int, int, String)
public String_Buffer trim()
trim(int, int)
public String_Buffer trim_beginning()
Character.isWhitespace(char)
,
delete(int, int)
public String_Buffer trim_end()
Character.isWhitespace(char)
,
delete(int, int)
public String_Buffer trim(char character)
character
- The character to be trimmed off the ends.
public String_Buffer trim_all(char character)
character
- The character to be trimmed off the ends.
public String_Buffer clear()
public String_Buffer clean(char character)
Escaped characters, which are preceded by a backslash ('\') character, are always ignored. All other characters that match the character to be cleaned are removed from the String.
The backslash character can be cleaned from the String. Escaped backslash characters will result in a single backslash character. Thus a String might be first cleaned of a non-backslash character and then cleaned of backslash characters to remove any escape characters remaining from the previous cleaning.
character
- The char to be cleaned from the String.
escape_to_special()
public String_Buffer escape_to_special()
The following escape sequences, and their corresponding special characters, are recognized:
\b - Backspace (BS)
\t - Horizontal tab (HT)
\n - Newline (NL)
\f - Form feed (FF)
\r - Carriage return (CR)
\X - The character X
\0nnn - The character having the octal value nnn (0 <= nnn <= 177777)
The escape sequences will be substituted for their corresponding special characters, which will shorten the length of the String_Buffer. All backslash characters, except those that are themselves escaped, will be removed from the String_Buffer.
N.B.: If an octal valued escape sequence is immediately
followed by an octal digit (0-7) the latter will be mistaken for part
of the escape sequence unless the maximum 6 digit limit has been
reached. Because of this it may be preferable to encode non-printable
characters using standard character
references
.
special_to_escape()
public static String escape_to_special(String string)
string
- The String to be filtered. If null, null is returned.
escape_to_special()
public String_Buffer special_to_escape()
All control characters - less than ' ' (32) or greater than '~' (126) - will be substituted with escape sequences:
\b - for backspace (BS, 8)
\t - for horizontal tab (HT, 9)
\n - for newline (NL, 10)
\f - for form feed (FF, 12)
\r - for carriage return (CR, 13)
\0nnn - for all other special characters where nnn is the octal value of the character (1-6 digits).
The escape sequences will substitute for their corresponding special characters, which will increase the length of the String_Buffer.
N.B.: If an octal valued escape sequence is immediately
followed by an octal digit (0-7) the latter will be mistaken for part
of the escape sequence unless the maximum 6 digit limit has been
reached. Because of this it may be preferable to encode non-printable
characters using standard character
references
.
escape_to_special()
public static String special_to_escape(String string)
string
- The String to be filtered. If null, null is returned.
special_to_escape()
public String_Buffer from_character_references()
All numeric character references will be replaced with their single character value. A numeric character references has the form:
&#[X]N;
Where N is the text representation of the character value. If the 'X' (case insensitive) is present the value is in hexadecimal representation, otherwise it is decimal. N.B.: The semicolon terminating the numerical character reference must be present as well as the &# prefix that signals the presence of the reference.
to_character_references()
public static String from_character_references(String string)
string
- The String to be filtered. If null, null is returned.
from_character_references()
public String_Buffer to_character_references()
All non-printable characters - less than ' ' (32) or greater than '~' (126) - will be substituted with hexadecimal numeric character references. A hexadecimal numeric character references has the form:
&#XN;
Where N is the hexadecimal (uppercase) representation of the character value.
from_character_references()
,
special_to_escape()
public static String to_character_references(String string)
string
- The String to be filtered. If null, null is returned.
to_character_references()
public String_Buffer to_printable_ASCII()
All non-printable characters - less than ' ' (32) or greater than
'~' (126) - will be substituted with the question mark
('?') character.
public static String to_printable_ASCII(String string)
string
- The string to be filtered. If null, null is returned.
to_printable_ASCII()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |