org.clapper.util.text
Class XStringBufBase

java.lang.Object
  extended by org.clapper.util.text.XStringBufBase
All Implemented Interfaces:
java.lang.Appendable, java.lang.CharSequence
Direct Known Subclasses:
XStringBuffer, XStringBuilder

public abstract class XStringBufBase
extends java.lang.Object
implements java.lang.CharSequence, java.lang.Appendable

Abstract base class for XStringBuffer and XStringBuilder. This class exists to share common functionality, pushing appropriate details to the underlying implementation.

Version:
$Revision: 6735 $
Author:
Copyright © 2004-2007 Brian M. Clapper
See Also:
XStringBuffer, XStringBuilder, StringBuffer, StringBuilder

Field Summary
static char METACHAR_SEQUENCE_START
          The character that denotes the start of a metacharacter sequence.
 
Method Summary
 XStringBufBase append(boolean val)
          Append the string representation of a boolean value to the buffer.
 XStringBufBase append(char c)
          Append the specified character to the buffer.
 XStringBufBase append(char[] chars)
          Append the specified array of characters to the buffer.
 XStringBufBase append(char[] chars, int offset, int len)
          Append the specified characters in a character array to the buffer.
 XStringBufBase append(java.lang.CharSequence csq)
          Append the entire contents of the specified CharSequence to the buffer.
 XStringBufBase append(java.lang.CharSequence csq, int start, int end)
          Append a subsequence of the specified CharSequence to the buffer.
 XStringBufBase append(double val)
          Append the string representation of a double value to the buffer.
 XStringBufBase append(float val)
          Append the string representation of a float value to the buffer.
 XStringBufBase append(int val)
          Append the string representation of a int value to the buffer.
 XStringBufBase append(long val)
          Append the string representation of a long value to the buffer.
 XStringBufBase append(java.lang.Object obj)
          Append the string representation of an object to the buffer.
 XStringBufBase append(short val)
          Append the string representation of a short value to the buffer.
 XStringBufBase append(java.lang.String s)
          Append the specified string to the buffer.
 char charAt(int index)
          Return the character at a specified index in the buffer.
 void clear()
          Removes all characters from the buffer leaving it empty.
 void decodeMetacharacters()
          A version of decodeMetacharacters that processes the entire string buffer.
 void decodeMetacharacters(int start, int end)
          Replaces any metacharacter sequences in a portion of the string buffer (such as those produced by encodeMetacharacters() with their actual characters.
 XStringBufBase delete(int start, int end)
          Remove the characters in a substring of this XStringBuffer.
 boolean delete(java.lang.String substring)
          Delete the first occurrence of a given substring in the buffer.
protected abstract  void deleteCharacters(int start, int end)
          Remove the characters in a substring of this XStringBuffer.
 void encodeMetacharacters()
          A version of encodeMetacharacters that processes the entire string buffer.
 void encodeMetacharacters(int start, int end)
          Replaces certain characters in the string buffer with Java metacharacter ("backslash") sequences.
protected abstract  java.lang.Appendable getBufferAsAppendable()
          Get the underlying buffer (e.g., StringBuffer, StringBuilder) as an Appender object.
protected abstract  java.lang.CharSequence getBufferAsCharSequence()
          Get the underlying buffer (e.g., StringBuffer, StringBuilder) as a CharSequence object.
abstract  void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
          Copy the some or all of the contents of the buffer into a character array.
 int indexOf(int ch)
          Returns the index within this string of the first occurrence of the specified character.
 int indexOf(java.lang.String str)
          Returns the index within this string of the first occurrence of the specified substring in this sequence, starting at position 0.
 int indexOf(java.lang.String str, int start)
          Returns the index within this string of the first occurrence of the specified substring in this sequence, with the search starting at the specified position.
 XStringBufBase insert(int index, boolean val)
          Insert the string representation of a booleanvalue into the buffer at a specified position.
 XStringBufBase insert(int index, char ch)
          Insert a single character at a specified position in the buffer.
 XStringBufBase insert(int index, char[] chars)
          Insert the contents of a character array into the buffer at a specified position.
 XStringBufBase insert(int index, char[] chars, int offset, int len)
          Insert characters from a character array into the buffer at a specified position.
 XStringBufBase insert(int index, double val)
          Insert the string representation of a doublevalue into the buffer at a specified position.
 XStringBufBase insert(int index, float val)
          Insert the string representation of a floatvalue into the buffer at a specified position.
 XStringBufBase insert(int index, int val)
          Insert the string representation of a intvalue into the buffer at a specified position.
 XStringBufBase insert(int index, long val)
          Insert the string representation of a longvalue into the buffer at a specified position.
 XStringBufBase insert(int index, java.lang.Object obj)
          Insert the string representation of an arbitrary object into the buffer at a specified position.
 XStringBufBase insert(int index, short val)
          Insert the string representation of a shortvalue into the buffer at a specified position.
 XStringBufBase insert(int index, java.lang.String s)
          Insert the contents of a string into the buffer at a specified position.
protected abstract  void insertCharacter(int index, char ch)
          Insert a single character into the buffer at a specified position.
protected abstract  void insertCharacters(int index, char[] chars, int offset, int len)
          Insert characters from a character array into the buffer at a specified position.
 int length()
          Return the number of characters currently in the buffer.
protected abstract  java.lang.CharSequence newBufferAsCharSequence()
          Get a new instance of the underlying buffer type (e.g., StringBuffer, StringBuilder) as a CharSequence object.
 XStringBufBase replace(int start, int end, java.lang.String str)
          Replace the characters in a substring of this buffer with characters in the specified String.
 boolean replace(java.lang.String substring, char replacement)
          Replace the first occurrence of a given substring in the buffer with a given character
 boolean replace(java.lang.String substring, java.lang.String replacement)
          Replace the first occurrence of a given substring in the buffer with another substring.
 int replaceAll(char ch, char replacement)
          Replace the all occurrences of a given character in the buffer with another character.
 int replaceAll(char ch, java.lang.String replacement)
          Replace the all occurrences of a given character in the buffer with string.
 int replaceAll(java.lang.String substring, java.lang.String replacement)
          Replace the all occurrences of a given substring in the buffer with another substring.
protected abstract  void replaceString(int start, int end, java.lang.String str)
          Replace the characters in a substring of this buffer with characters in the specified String.
 void reset(java.lang.String str)
          Removes all existing characters from the buffer and loads the string into the buffer.
 java.lang.String[] split()
          Split the contents of a buffer on white space, and return the resulting strings.
 java.lang.String[] split(char delim)
          Split the contents of a buffer on a delimiter, and return the resulting strings.
 int split(char delim, java.util.Collection<java.lang.String> collection)
          Split the contents of a buffer on a delimiter, and store the resulting strings in a specified Collection.
 java.lang.String[] split(java.lang.String delimSet)
          Split the contents of a buffer on a delimiter, and return the resulting strings.
 int split(java.lang.String delimSet, java.util.Collection<java.lang.String> collection)
          Split the contents of a buffer on a delimiter, and store the resulting strings in a specified Collection.
 java.lang.CharSequence subSequence(int start, int end)
          Return a new CharSequence object (really, another XStringBuffer0 that contains a subsequence of characters currently contained in this buffer.
 java.lang.String substring(int index)
          Return a new String that contains a subsequence of characters currently contained in this buffer.
 java.lang.String substring(int start, int end)
          Return a new String that contains a subsequence of characters currently contained in this buffer.
 java.lang.String toString()
          Return the String representation of this buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

METACHAR_SEQUENCE_START

public static final char METACHAR_SEQUENCE_START
The character that denotes the start of a metacharacter sequence.

See Also:
Constant Field Values
Method Detail

getChars

public abstract void getChars(int srcBegin,
                              int srcEnd,
                              char[] dst,
                              int dstBegin)
                       throws java.lang.IndexOutOfBoundsException
Copy the some or all of the contents of the buffer into a character array. The first character to be copied is at index srcBegin; the last character to be copied is at index (srcEnd - 1). The total number of characters to be copied is (srcEnd - srcBegin). The characters are copied into the subarray of dst starting at index dstBegin and ending at index (dstBegin + (srcEnd - srcBegin) - 1).

Parameters:
srcBegin - Start copy from this offset in the string buffer
srcEnd - Stop copy from this offset in the string buffer
dst - Where to copy the characters.
dstBegin - Offset into dst
Throws:
java.lang.IndexOutOfBoundsException - invalid index

getBufferAsAppendable

protected abstract java.lang.Appendable getBufferAsAppendable()
Get the underlying buffer (e.g., StringBuffer, StringBuilder) as an Appender object.

Returns:
the Appender

getBufferAsCharSequence

protected abstract java.lang.CharSequence getBufferAsCharSequence()
Get the underlying buffer (e.g., StringBuffer, StringBuilder) as a CharSequence object.

Returns:
the Appendable

newBufferAsCharSequence

protected abstract java.lang.CharSequence newBufferAsCharSequence()
Get a new instance of the underlying buffer type (e.g., StringBuffer, StringBuilder) as a CharSequence object.

Returns:
the Appendable

deleteCharacters

protected abstract void deleteCharacters(int start,
                                         int end)
                                  throws java.lang.IndexOutOfBoundsException
Remove the characters in a substring of this XStringBuffer. The substring begins at the specified start and extends to the character at index end - 1, or to the end of the string, if no such character exists. If start is equal to end, no changes are made.

Parameters:
start - The beginning index, inclusive
end - The ending index, exclusive
Throws:
java.lang.IndexOutOfBoundsException - if start is negative, greater than length(), or greater than end

insertCharacter

protected abstract void insertCharacter(int index,
                                        char ch)
Insert a single character into the buffer at a specified position. Note that an insertion operation may push characters off the end of the buffer.

Parameters:
index - Where to start inserting in the string buffer
ch - The character to insert

insertCharacters

protected abstract void insertCharacters(int index,
                                         char[] chars,
                                         int offset,
                                         int len)
Insert characters from a character array into the buffer at a specified position. Note that an insertion operation may push characters off the end of the buffer.

Parameters:
index - Where to start inserting in the string buffer
chars - The character(s) to insert
offset - The starting position in the chars array
len - The number of characters to insert

replaceString

protected abstract void replaceString(int start,
                                      int end,
                                      java.lang.String str)
                               throws java.lang.IndexOutOfBoundsException
Replace the characters in a substring of this buffer with characters in the specified String. The substring begins at the specified start and extends to the character at index end - 1, or to the end of the XStringBuffer if no such character exists. First the characters in the substring are removed and then the specified String is inserted at start. (The XStringBuffer will be lengthened to accommodate the specified String if necessary.)

Parameters:
start - The beginning index, inclusive
end - The ending index, exclusive
str - The string that will replace the previous contents
Throws:
java.lang.IndexOutOfBoundsException - if start is negative, or greater than length(), or greater than end

append

public XStringBufBase append(boolean val)
Append the string representation of a boolean value to the buffer.

Parameters:
val - The boolean value.
Returns:
a reference to this object

append

public XStringBufBase append(char c)
Append the specified character to the buffer. If the buffer is already at its maximum length, the character is silently ignored.

Specified by:
append in interface java.lang.Appendable
Parameters:
c - The character to append.
Returns:
a reference to this object
Throws:
java.io.IOException - I/O error

append

public XStringBufBase append(char[] chars)
Append the specified array of characters to the buffer. This method appends only as much of the string as will fit without causing the buffer to exceed its maximum length.

Parameters:
chars - The characters to append.
Returns:
a reference to this object

append

public XStringBufBase append(char[] chars,
                             int offset,
                             int len)
Append the specified characters in a character array to the buffer. This method appends only as much of the string as will fit without causing the buffer to exceed its maximum length.

Parameters:
chars - The characters to append.
offset - The index of the first character to append
len - The maximum number of characters to append
Returns:
a reference to this object

append

public XStringBufBase append(double val)
Append the string representation of a double value to the buffer.

Parameters:
val - The double value.
Returns:
a reference to this object

append

public XStringBufBase append(float val)
Append the string representation of a float value to the buffer.

Parameters:
val - The float value.
Returns:
a reference to this object

append

public XStringBufBase append(int val)
Append the string representation of a int value to the buffer.

Parameters:
val - The int value.
Returns:
a reference to this object

append

public XStringBufBase append(long val)
Append the string representation of a long value to the buffer.

Parameters:
val - The long value.
Returns:
a reference to this object

append

public XStringBufBase append(java.lang.Object obj)
Append the string representation of an object to the buffer.

Parameters:
obj - The object whose string value is to be appended.
Returns:
a reference to this object

append

public XStringBufBase append(short val)
Append the string representation of a short value to the buffer.

Parameters:
val - The short value.
Returns:
a reference to this object

append

public XStringBufBase append(java.lang.String s)
Append the specified string to the buffer. This method appends only as much of the string as will fit without causing the buffer to exceed its maximum length.

Parameters:
s - The string to append.
Returns:
a reference to this object

append

public XStringBufBase append(java.lang.CharSequence csq)
Append the entire contents of the specified CharSequence to the buffer. This method appends only as much of the CharSequence as will fit without causing the buffer to exceed its maximum length.

Specified by:
append in interface java.lang.Appendable
Parameters:
csq - The CharSequence to append
Returns:
a reference to this object
See Also:
append(CharSequence,int,int)

append

public XStringBufBase append(java.lang.CharSequence csq,
                             int start,
                             int end)
Append a subsequence of the specified CharSequence to the buffer. This method appends only as much of the subsequence as will fit without causing the buffer to exceed its maximum length.

Specified by:
append in interface java.lang.Appendable
Parameters:
csq - The CharSequence to append
start - The starting index of the subsequence
end - One past the ending index of the subsequence
Returns:
a reference to this object
See Also:
append(CharSequence)

charAt

public char charAt(int index)
            throws java.lang.IndexOutOfBoundsException
Return the character at a specified index in the buffer. Indexes begin at 0. (i.e., The first character in the buffer has index 0.)

Specified by:
charAt in interface java.lang.CharSequence
Parameters:
index - The index of the character to return
Returns:
The character at the specified index.
Throws:
java.lang.IndexOutOfBoundsException - if index is negative or greater than or equal to length()

delete

public boolean delete(java.lang.String substring)
Delete the first occurrence of a given substring in the buffer. with another substring.

Parameters:
substring - The substring to find and replace
Returns:
true if the replacement succeeded, false otherwise.

clear

public void clear()
Removes all characters from the buffer leaving it empty.


delete

public XStringBufBase delete(int start,
                             int end)
                      throws java.lang.IndexOutOfBoundsException
Remove the characters in a substring of this XStringBuffer. The substring begins at the specified start and extends to the character at index end - 1, or to the end of the string, if no such character exists. If start is equal to end, no changes are made.

Parameters:
start - The beginning index, inclusive
end - The ending index, exclusive
Returns:
This object
Throws:
java.lang.IndexOutOfBoundsException - if start is negative, greater than length(), or greater than end

encodeMetacharacters

public void encodeMetacharacters(int start,
                                 int end)
                          throws java.lang.IndexOutOfBoundsException,
                                 java.io.IOException

Replaces certain characters in the string buffer with Java metacharacter ("backslash") sequences.

  • A horizontal tab is replaced with \t.
  • A line feed is replaced with \n.
  • A carriage return is replaced with \r.
  • A form feed is replaced with \f.
  • A backslash is replaced by two backslashes.
  • Nonprintable characters are replaced with a \uxxxx sequence.

This method uses the same definition of "non-printable" as TextUtil.isPrintable(char).

Parameters:
start - The beginning index, inclusive
end - The ending index, exclusive
Throws:
java.lang.StringIndexOutOfBoundsException - if start is negative, or greater than length(), or greater than end
java.io.IOException - I/O exception
java.lang.IndexOutOfBoundsException
See Also:
encodeMetacharacters(), decodeMetacharacters(int, int)

encodeMetacharacters

public void encodeMetacharacters()
A version of encodeMetacharacters that processes the entire string buffer. Calling this method is equivalent to:
 buf.encodeMetacharacters (0, buf.length())
 

See Also:
encodeMetacharacters(int, int), decodeMetacharacters()

decodeMetacharacters

public void decodeMetacharacters(int start,
                                 int end)
                          throws java.lang.StringIndexOutOfBoundsException
Replaces any metacharacter sequences in a portion of the string buffer (such as those produced by encodeMetacharacters() with their actual characters.

Parameters:
start - The beginning index, inclusive
end - The ending index, exclusive
Throws:
java.lang.StringIndexOutOfBoundsException - if start is negative, or greater than length(), or greater than end
See Also:
decodeMetacharacters(), encodeMetacharacters(int,int)

decodeMetacharacters

public void decodeMetacharacters()
A version of decodeMetacharacters that processes the entire string buffer. Calling this method is equivalent to:
 buf.decodeMetacharacters (0, buf.length())
 

See Also:
encodeMetacharacters(int, int), decodeMetacharacters()

indexOf

public int indexOf(int ch)
Returns the index within this string of the first occurrence of the specified character. If a character with value ch occurs in the character sequence represented by this object, then the index (in Unicode code units) of the first such occurrence is returned.

Parameters:
ch - the cahracter (Unicode code point)
Returns:
the index of the first occurrence of the character, or -1 if not found

indexOf

public int indexOf(java.lang.String str)
Returns the index within this string of the first occurrence of the specified substring in this sequence, starting at position 0.

Parameters:
str - the string to find
Returns:
the index of the first occurrence of the substring, or -1 if not found

indexOf

public int indexOf(java.lang.String str,
                   int start)
Returns the index within this string of the first occurrence of the specified substring in this sequence, with the search starting at the specified position.

Parameters:
str - the string to find
start - the index at which to start the search
Returns:
the index of the first occurrence of the substring, or -1 if not found

insert

public XStringBufBase insert(int index,
                             boolean val)
Insert the string representation of a booleanvalue into the buffer at a specified position. Note that an insertion operation may push characters off the end of the buffer.

Parameters:
index - Where to start inserting in the string buffer
val - The boolean value

insert

public XStringBufBase insert(int index,
                             char ch)
Insert a single character at a specified position in the buffer. Note that an insertion operation may push * characters off the end of the buffer.

Parameters:
index - Where to start inserting in the string buffer
ch - The character to insert.

insert

public XStringBufBase insert(int index,
                             char[] chars)
Insert the contents of a character array into the buffer at a specified position. Note that an insertion operation may push characters off the end of the buffer.

Parameters:
index - Where to start inserting in the string buffer
chars - The character array.

insert

public XStringBufBase insert(int index,
                             char[] chars,
                             int offset,
                             int len)
Insert characters from a character array into the buffer at a specified position. Note that an insertion operation may push characters off the end of the buffer.

Parameters:
index - Where to start inserting in the string buffer
chars - The character array.
offset - The index of the first character to insert
len - The maximum number of characters to insert

insert

public XStringBufBase insert(int index,
                             double val)
Insert the string representation of a doublevalue into the buffer at a specified position. Note that an insertion operation may push characters off the end of the buffer.

Parameters:
index - Where to start inserting in the string buffer
val - The double value

insert

public XStringBufBase insert(int index,
                             float val)
Insert the string representation of a floatvalue into the buffer at a specified position. Note that an insertion operation may push characters off the end of the buffer.

Parameters:
index - Where to start inserting in the string buffer
val - The float value

insert

public XStringBufBase insert(int index,
                             int val)
Insert the string representation of a intvalue into the buffer at a specified position. Note that an insertion operation may push characters off the end of the buffer.

Parameters:
index - Where to start inserting in the string buffer
val - The int value

insert

public XStringBufBase insert(int index,
                             long val)
Insert the string representation of a longvalue into the buffer at a specified position. Note that an insertion operation may push characters off the end of the buffer.

Parameters:
index - Where to start inserting in the string buffer
val - The long value

insert

public XStringBufBase insert(int index,
                             short val)
Insert the string representation of a shortvalue into the buffer at a specified position. Note that an insertion operation may push characters off the end of the buffer.

Parameters:
index - Where to start inserting in the string buffer
val - The short value

insert

public XStringBufBase insert(int index,
                             java.lang.Object obj)
Insert the string representation of an arbitrary object into the buffer at a specified position. Note that an insertion operation may push characters off the end of the buffer.

Parameters:
index - Where to start inserting in the string buffer
obj - The object whose string representation is to be inserted

insert

public XStringBufBase insert(int index,
                             java.lang.String s)
Insert the contents of a string into the buffer at a specified position. Note that an insertion operation may push characters off the end of the buffer.

Parameters:
index - Where to start inserting in the string buffer
s - The string to insert

length

public int length()
Return the number of characters currently in the buffer.

Specified by:
length in interface java.lang.CharSequence
Returns:
The number of characters in the buffer.

replace

public XStringBufBase replace(int start,
                              int end,
                              java.lang.String str)
                       throws java.lang.StringIndexOutOfBoundsException
Replace the characters in a substring of this buffer with characters in the specified String. The substring begins at the specified start and extends to the character at index end - 1, or to the end of the XStringBuffer if no such character exists. First the characters in the substring are removed and then the specified String is inserted at start. (The XStringBuffer will be lengthened to accommodate the specified String if necessary.)

Parameters:
start - The beginning index, inclusive
end - The ending index, exclusive
str - The string that will replace the previous contents
Returns:
This object
Throws:
java.lang.StringIndexOutOfBoundsException - if start is negative, or greater than length(), or greater than end

replace

public boolean replace(java.lang.String substring,
                       java.lang.String replacement)
Replace the first occurrence of a given substring in the buffer with another substring.

Parameters:
substring - The substring to find and replace
replacement - The replacement string
Returns:
true if the replacement succeeded, false otherwise.

replace

public boolean replace(java.lang.String substring,
                       char replacement)
Replace the first occurrence of a given substring in the buffer with a given character

Parameters:
substring - The substring to find and replace
replacement - The replacement char
Returns:
true if the replacement succeeded, false otherwise.

replaceAll

public int replaceAll(java.lang.String substring,
                      java.lang.String replacement)
Replace the all occurrences of a given substring in the buffer with another substring. This method avoids recursion; that is, it's safe even if the replacement string contains the source string.

Parameters:
substring - The substring to find and replace
replacement - The replacement string
Returns:
the number of replacements made

replaceAll

public int replaceAll(char ch,
                      char replacement)
Replace the all occurrences of a given character in the buffer with another character.

Parameters:
ch - The character to find and replace
replacement - The replacement character
Returns:
the number of replacements made

replaceAll

public int replaceAll(char ch,
                      java.lang.String replacement)
Replace the all occurrences of a given character in the buffer with string. This method avoids recursion; that is, it's safe even if the replacement string contains the character being replaced.

Parameters:
ch - The character to find and replace
replacement - The replacement string
Returns:
the number of replacements made

reset

public void reset(java.lang.String str)
Removes all existing characters from the buffer and loads the string into the buffer.

Parameters:
str - String object to be loaded into the cleared buffer.

split

public java.lang.String[] split()
Split the contents of a buffer on white space, and return the resulting strings. This method is a convenient front-end to TextUtil.split(String).

Returns:
an array of String objects
See Also:
split(String), TextUtil.split(String,char)

split

public java.lang.String[] split(char delim)
Split the contents of a buffer on a delimiter, and return the resulting strings. This method is a convenient front-end to TextUtil.split(String,char).

Parameters:
delim - the delimiter
Returns:
an array of String objects
See Also:
split(String), TextUtil.split(String,char)

split

public java.lang.String[] split(java.lang.String delimSet)
Split the contents of a buffer on a delimiter, and return the resulting strings. This method is a convenient front-end to TextUtil.split(String,String)

Parameters:
delimSet - the delimiter set
Returns:
an array of String objects
See Also:
split(char), TextUtil.split(String,String)

split

public int split(char delim,
                 java.util.Collection<java.lang.String> collection)
Split the contents of a buffer on a delimiter, and store the resulting strings in a specified Collection. This method is a convenient front-end for TextUtil.split(String,char,Collection).

Parameters:
delim - the delimiter
collection - where to store the resulting strings
Returns:
the number of strings added to the collection
See Also:
split(String,Collection), split(char), TextUtil.split(String,char), TextUtil.split(String,String,Collection)

split

public int split(java.lang.String delimSet,
                 java.util.Collection<java.lang.String> collection)
Split the contents of a buffer on a delimiter, and store the resulting strings in a specified Collection. This method is a convenient front-end for TextUtil.split(String,char,Collection).

Parameters:
delimSet - the set of delimiters
collection - where to store the resulting strings
Returns:
the number of strings added to the collection
See Also:
split(char,Collection), split(String), TextUtil.split(String,String), TextUtil.split(String,char,Collection)

substring

public java.lang.String substring(int index)
                           throws java.lang.StringIndexOutOfBoundsException
Return a new String that contains a subsequence of characters currently contained in this buffer. The substring begins at the specified index and extends to the end of the StringBuffer.

Parameters:
index - The beginning index, inclusive
Returns:
the substring
Throws:
java.lang.StringIndexOutOfBoundsException - index out of range

substring

public java.lang.String substring(int start,
                                  int end)
                           throws java.lang.StringIndexOutOfBoundsException
Return a new String that contains a subsequence of characters currently contained in this buffer. The substring begins at the specified start and extends to the character at index end - 1.

Parameters:
start - The beginning index, inclusive
end - The beginning index, exclusive
Returns:
the substring
Throws:
java.lang.StringIndexOutOfBoundsException - if start is negative, greater than length(), or greater than end
See Also:
subSequence(int, int)

subSequence

public java.lang.CharSequence subSequence(int start,
                                          int end)
                                   throws java.lang.IndexOutOfBoundsException
Return a new CharSequence object (really, another XStringBuffer0 that contains a subsequence of characters currently contained in this buffer. The substring begins at the specified start and extends to the character at index end - 1.

Specified by:
subSequence in interface java.lang.CharSequence
Parameters:
start - The beginning index, inclusive
end - The beginning index, exclusive
Returns:
the subsequence
Throws:
java.lang.IndexOutOfBoundsException - if start is negative, greater than length(), or greater than end

toString

public java.lang.String toString()
Return the String representation of this buffer.

Specified by:
toString in interface java.lang.CharSequence
Overrides:
toString in class java.lang.Object
Returns:
The string.


Copyright © 2004-2007 Brian M. Clapper. All Rights Reserved.