Build 1.0_r1(from source)

java.lang
Class AbstractStringBuilder

java.lang.Object
  extended by java.lang.AbstractStringBuilder
Direct Known Subclasses:
StringBuffer, StringBuilder

abstract class AbstractStringBuilder
extends Object

A modifiable sequence of characters for use in creating and modifying Strings. This class is intended as a base class for StringBuffer and StringBuilder.

Since:
1.5
See Also:
StringBuffer, StringBuilder

Field Summary
(package private) static int INITIAL_CAPACITY
           
 
Constructor Summary
AbstractStringBuilder()
           
AbstractStringBuilder(int capacity)
           
AbstractStringBuilder(String string)
           
 
Method Summary
(package private)  void append0(char ch)
           
(package private)  void append0(char[] chars)
           
(package private)  void append0(char[] chars, int start, int length)
           
(package private)  void append0(CharSequence s, int start, int end)
           
(package private)  void append0(String string)
           
(package private)  void appendNull()
           
 int capacity()
          Returns the number of characters this StringBuffer can hold without growing.
 char charAt(int index)
           Retrieves the character at the index.
 int codePointAt(int index)
           Retrieves the Unicode code point value at the index.
 int codePointBefore(int index)
           Retrieves the Unicode code point value that precedes the index.
 int codePointCount(int beginIndex, int endIndex)
           Calculates the number of Unicode code points between beginIndex and endIndex.
(package private)  void delete0(int start, int end)
           
(package private)  void deleteCharAt0(int location)
           
 void ensureCapacity(int min)
           Ensures that this object has a minimum capacity available before requiring the internal buffer to be enlarged.
 void getChars(int start, int end, char[] dest, int destStart)
           Copies the requested sequence of characters to be copied to the char[] passed.
(package private)  char[] getValue()
           
 int indexOf(String string)
          Searches in this StringBuffer for the first index of the specified character.
 int indexOf(String subString, int start)
          Searches in this StringBuffer for the index of the specified character.
(package private)  void insert0(int index, char ch)
           
(package private)  void insert0(int index, char[] chars)
           
(package private)  void insert0(int index, char[] chars, int start, int length)
           
(package private)  void insert0(int index, CharSequence s, int start, int end)
           
(package private)  void insert0(int index, String string)
           
 int lastIndexOf(String string)
          Searches in this StringBuffer for the last index of the specified character.
 int lastIndexOf(String subString, int start)
          Searches in this StringBuffer for the index of the specified character.
 int length()
           The current length of this object.
 int offsetByCodePoints(int index, int codePointOffset)
           Returns the index within this object that is offset from index by codePointOffset code points.
(package private)  void replace0(int start, int end, String string)
           
(package private)  void reverse0()
           
(package private)  void set(char[] val, int len)
           
 void setCharAt(int index, char ch)
           Sets the character at the index in this object.
 void setLength(int length)
           Sets the current length to a new value.
(package private)  char[] shareValue()
           
 CharSequence subSequence(int start, int end)
           Returns a CharSequence of the subsequence of this object from the start index to the start index.
 String substring(int start)
           Returns the String value of the subsequence of this object from the start index to the current end.
 String substring(int start, int end)
           Returns the String value of the subsequence of this object from the start index to the start index.
 String toString()
           Returns the current String representation of this object.
 void trimToSize()
           Trims off any extra capacity beyond the current length.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INITIAL_CAPACITY

static final int INITIAL_CAPACITY
See Also:
Constant Field Values
Constructor Detail

AbstractStringBuilder

AbstractStringBuilder()

AbstractStringBuilder

AbstractStringBuilder(int capacity)

AbstractStringBuilder

AbstractStringBuilder(String string)
Method Detail

getValue

final char[] getValue()

shareValue

final char[] shareValue()

set

final void set(char[] val,
               int len)
        throws InvalidObjectException
Throws:
InvalidObjectException

appendNull

final void appendNull()

append0

final void append0(char[] chars)

append0

final void append0(char[] chars,
                   int start,
                   int length)

append0

final void append0(char ch)

append0

final void append0(String string)

append0

final void append0(CharSequence s,
                   int start,
                   int end)

capacity

public int capacity()
Returns the number of characters this StringBuffer can hold without growing.

Returns:
the capacity of this StringBuffer
See Also:
ensureCapacity(int), length()

charAt

public char charAt(int index)

Retrieves the character at the index.

Parameters:
index - index of character in this object to retrieve.
Returns:
The char value.
Throws:
IndexOutOfBoundsException - if index is negative or greater than or equal to the current length().

delete0

final void delete0(int start,
                   int end)

deleteCharAt0

final void deleteCharAt0(int location)

ensureCapacity

public void ensureCapacity(int min)

Ensures that this object has a minimum capacity available before requiring the internal buffer to be enlarged. The general policy of this method is that if the minimumCapacity is larger than the current capacity(), then the capacity will be increased to the largest value of either the minimumCapacity or the current capacity multiplied by two plus two. Although this is the general policy, there is no guarantee that the capacity will change.

Parameters:
min - The new minimum capacity to set.

getChars

public void getChars(int start,
                     int end,
                     char[] dest,
                     int destStart)

Copies the requested sequence of characters to be copied to the char[] passed.

Parameters:
start - The inclusive start index of the characters to copy from this object.
end - The exclusive end index of the characters to copy from this object.
dest - The char[] to copy the characters to.
destStart - The inclusive start index of the dest parameter to begin copying to.
Throws:
IndexOutOfBoundsException - if the start is negative, the destStart is negative, the start is greater than end, the end is greater than the current length() or destStart + end - begin is greater than dest.length.

insert0

final void insert0(int index,
                   char[] chars)

insert0

final void insert0(int index,
                   char[] chars,
                   int start,
                   int length)

insert0

final void insert0(int index,
                   char ch)

insert0

final void insert0(int index,
                   String string)

insert0

final void insert0(int index,
                   CharSequence s,
                   int start,
                   int end)

length

public int length()

The current length of this object.

Returns:
the number of characters in this StringBuffer

replace0

final void replace0(int start,
                    int end,
                    String string)

reverse0

final void reverse0()

setCharAt

public void setCharAt(int index,
                      char ch)

Sets the character at the index in this object.

Parameters:
index - the zero-based index of the character to replace.
ch - the character to set.
Throws:
IndexOutOfBoundsException - if index is negative or greater than or equal to the current length().

setLength

public void setLength(int length)

Sets the current length to a new value. If the new length is larger than the current length, then the new characters at the end of this object will contain the char value of .

Parameters:
length - the new length of this StringBuffer
Throws:
IndexOutOfBoundsException - when length <>
See Also:
length()

substring

public String substring(int start)

Returns the String value of the subsequence of this object from the start index to the current end.

Parameters:
start - The inclusive start index to begin the subsequence.
Returns:
A String containing the subsequence.
Throws:
StringIndexOutOfBoundsException - if start is negative or greater than the current length().

substring

public String substring(int start,
                        int end)

Returns the String value of the subsequence of this object from the start index to the start index.

Parameters:
start - The inclusive start index to begin the subsequence.
end - The exclusive end index to end the subsequence.
Returns:
A String containing the subsequence.
Throws:
StringIndexOutOfBoundsException - if start is negative, greater than the current length() or greater than end.

toString

public String toString()

Returns the current String representation of this object.

Overrides:
toString in class Object
Returns:
a String containing the characters in this StringBuilder.

subSequence

public CharSequence subSequence(int start,
                                int end)

Returns a CharSequence of the subsequence of this object from the start index to the start index.

Parameters:
start - The inclusive start index to begin the subsequence.
end - The exclusive end index to end the subsequence.
Returns:
A CharSequence containing the subsequence.
Throws:
IndexOutOfBoundsException - if start is negative, greater than the current length() or greater than end.
Since:
1.4

indexOf

public int indexOf(String string)
Searches in this StringBuffer for the first index of the specified character. The search for the character starts at the beginning and moves towards the end.

Parameters:
string - the string to find
Returns:
the index in this StringBuffer of the specified character, -1 if the character isn't found
Since:
1.4
See Also:
lastIndexOf(String)

indexOf

public int indexOf(String subString,
                   int start)
Searches in this StringBuffer for the index of the specified character. The search for the character starts at the specified offset and moves towards the end.

Parameters:
subString - the string to find
start - the starting offset
Returns:
the index in this StringBuffer of the specified character, -1 if the character isn't found
Since:
1.4
See Also:
lastIndexOf(String,int)

lastIndexOf

public int lastIndexOf(String string)
Searches in this StringBuffer for the last index of the specified character. The search for the character starts at the end and moves towards the beginning.

Parameters:
string - the string to find
Returns:
the index in this StringBuffer of the specified character, -1 if the character isn't found
Throws:
NullPointerException - if the string parameter is null.
Since:
1.4
See Also:
String.lastIndexOf(java.lang.String)

lastIndexOf

public int lastIndexOf(String subString,
                       int start)
Searches in this StringBuffer for the index of the specified character. The search for the character starts at the specified offset and moves towards the beginning.

Parameters:
subString - the string to find
start - the starting offset
Returns:
the index in this StringBuffer of the specified character, -1 if the character isn't found
Throws:
NullPointerException - if the subString parameter is null.
Since:
1.4
See Also:
String.lastIndexOf(java.lang.String,int)

trimToSize

public void trimToSize()

Trims off any extra capacity beyond the current length. Note, this method is NOT guaranteed to change the capacity of this object.

Since:
1.5

codePointAt

public int codePointAt(int index)

Retrieves the Unicode code point value at the index.

Parameters:
index - The index to the char code unit within this object.
Returns:
The Unicode code point value.
Throws:
IndexOutOfBoundsException - if index is negative or greater than or equal to length().
Since:
1.5
See Also:
Character, Character.codePointAt(char[], int, int)

codePointBefore

public int codePointBefore(int index)

Retrieves the Unicode code point value that precedes the index.

Parameters:
index - The index to the char code unit within this object.
Returns:
The Unicode code point value.
Throws:
IndexOutOfBoundsException - if index is less than 1 or greater than length().
Since:
1.5
See Also:
Character, Character.codePointBefore(char[], int, int)

codePointCount

public int codePointCount(int beginIndex,
                          int endIndex)

Calculates the number of Unicode code points between beginIndex and endIndex.

Parameters:
beginIndex - The inclusive beginning index of the subsequence.
endIndex - The exclusive end index of the subsequence.
Returns:
The number of Unicode code points in the subsequence.
Throws:
IndexOutOfBoundsException - if beginIndex is negative or greater than endIndex or endIndex is greater than length().
Since:
1.5

offsetByCodePoints

public int offsetByCodePoints(int index,
                              int codePointOffset)

Returns the index within this object that is offset from index by codePointOffset code points.

Parameters:
index - The index within this object to calculate the offset from.
codePointOffset - The number of code points to count.
Returns:
The index within this object that is the offset.
Throws:
IndexOutOfBoundsException - if index is negative or greater than length() or if there aren't enough code points before or after index to match codePointOffset.
Since:
1.5

Build 1.0_r1(from source)

Please submit a feedback, bug or feature