scala.StringBuilder

class StringBuilder

final class StringBuilder(initCapacity : Int, private initValue : String)

 extends (Int) => Char with Proxy


A mutable sequence of characters. This class provides an API compatible with java.lang.StringBuilder, but with no guarantee of synchronization.

author
- Stephane Micheloud
version
- 1.0


Companion: StringBuilder

Source: StringBuilder.scala(26)

 Constructors

def this(str : String)
def this
Constructs a string builder with no characters in it and an initial capacity of 16 characters
def this(capacity : Int)
Constructs a string builder with no characters in it and an initial capacity specified by the capacity argument [details]
param
capacity - the initial capacity.
throws
NegativeArraySizeException - if the capacity argument is less than 0.
def this(initCapacity : Int, initValue : String)

 Fields

capacity def capacity
Returns the current capacity [details]
The capacity is the amount of storage available for newly inserted characters, beyond which an allocation will occur.
return
- the current capacity
Int
length def length Int
self def self StringBuilder
toArray def toArray Array[Char]

 Methods

!= final def !=(arg0 : Object) Boolean AnyRef
!= final def !=(arg0 : Any) Boolean Any
== final def ==(arg0 : Any) Boolean Any
== final def ==(arg0 : Object) Boolean AnyRef
andThen def andThen[A](g : (R) => A)
(f andThen g)(x) == g(f(x))
(T1) => A Function1
append def append(x : Array[Char])

Appends the string representation of the Char array argument to this sequence.

[details]

The characters of the array argument are appended, in order, to the contents of this sequence. The length of this sequence increases by the length of the argument.

param
x - the characters to be appended.
return
- a reference to this object.
StringBuilder
append def append(x : Float) StringBuilder
append def append(x : Any)

Appends the string representation of the Any argument.

[details]

The argument is converted to a string as if by the method String.valueOf, and the characters of that string are then appended to this sequence.

param
x - an Any object.
return
- a reference to this object.
StringBuilder
append def append(x : Char) StringBuilder
append def append(sb : StringBuilder)
Appends the specified string builder to this sequence
StringBuilder
append def append(x : Int) StringBuilder
append def append(x : Boolean)

Appends the string representation of the Boolean argument to the sequence.

[details]

The argument is converted to a string as if by the method String.valueOf, and the characters of that string are then appended to this sequence.

param
x - a Boolean.
return
- a reference to this object.
StringBuilder
append def append(x : Seq[Char])

Appends the string representation of the Char sequence argument to this sequence.

[details]

The characters of the sequence argument are appended, in order, to the contents of this sequence. The length of this sequence increases by the length of the argument.

param
x - the characters to be appended.
return
- a reference to this object.
StringBuilder
append def append(x : Long) StringBuilder
append def append(x : Byte) StringBuilder
append def append(s : String)
Appends the specified string to this character sequence [details]
param
s - a string.
return
- a reference to this object.
StringBuilder
append def append(x : Short) StringBuilder
append def append(x : Double) StringBuilder
append def append(x : Array[Char], offset : Int, len : Int)

Appends the string representation of a subarray of the char array argument to this sequence.

[details]

Characters of the Char array x, starting at index offset, are appended, in order, to the contents of this sequence. The length of this sequence increases by the value of len.

param
offset - the index of the first Char to append.
len - the number of Chars to append.
x - the characters to be appended.
return
- a reference to this object.
StringBuilder
apply def apply(i : Int)
Same as charAt
Char
asInstanceOf final def asInstanceOf[T0] T0 Any
capacity_= def capacity_=(n : Int)
Same as ensureCapacity
Unit
charAt def charAt(index : Int)

Returns the Char value in this sequence at the specified index. The first Char value is at index 0, the next at index 1, and so on, as in array indexing.

[details]

The index argument must be greater than or equal to 0, and less than the length of this sequence.

param
index - the index of the desired Char value.
return
- the Char value at the specified index.
throws
IndexOutOfBoundsException - if index is negative or greater than or equal to length().
Char
clone protected def clone Object AnyRef
compose def compose[A](g : (A) => T1)
(f compose g)(x) == f(g(x))
(A) => R Function1
delete def delete(start : Int, end : Int)
Removes the characters in a substring of this sequence [details]
The substring begins at the specified start and extends to the character at index end - 1 or to the end of the sequence if no such character exists. If start is equal to end, no changes are made.
param
end - The ending index, exclusive.
start - The beginning index, inclusive.
return
- This object.
throws
StringIndexOutOfBoundsException - if start is negative, greater than length(), or greater than end.
StringBuilder
deleteCharAt def deleteCharAt(index : Int)

Removes the Char at the specified position in this sequence. This sequence is shortened by one Char.

[details]
param
index - Index of Char to remove
return
- This object.
throws
StringIndexOutOfBoundsException - if the index is negative or greater than or equal to length().
StringBuilder
ensureCapacity def ensureCapacity(n : Int)

Ensures that the capacity is at least equal to the specified minimum. If the current capacity is less than the argument, then a new internal array is allocated with greater capacity. The new capacity is the larger of:

[details]
  • The n argument.
  • Twice the old capacity, plus 2.

If the n argument is non-positive, this method takes no action and simply returns.

param
n - the minimum desired capacity.
Unit
eq final def eq(arg0 : Object) Boolean AnyRef
equals override def equals(that : Any) Boolean Proxy
finalize protected def finalize Unit AnyRef
getClass final def getClass Class[Any] AnyRef
hashCode override def hashCode Int Proxy
indexOf def indexOf(str : String, fromIndex : Int)

Returns the index within this string of the first occurrence of the specified substring, starting at the specified index. The integer returned is the smallest value k for which:

[details]
      k >= Math.min(fromIndex, str.length()) &&
                     this.toString().startsWith(str, k)

If no such value of k exists, then -1 is returned.

param
fromIndex - the index from which to start the search.
str - the substring for which to search.
return
- the index within this string of the first occurrence of the specified substring, starting at the specified index.
Int
indexOf def indexOf(str : String)

Returns the index within this string of the first occurrence of the specified substring. The integer returned is the smallest value k such that:

[details]
    this.toString().startsWith(str, k)

is true.

param
str - any string.
return
- if the string argument occurs as a substring within this object, then the index of the first character of the first such substring is returned; if it does not occur as a substring, -1 is returned.
throws
NullPointerException - if str is null.
Int
insert def insert(at : Int, x : Array[Char])
Inserts the string representation of the Char array argument into this sequence [details]
param
x - a character array.
at - the offset position.
return
- a reference to this object.
throws
StringIndexOutOfBoundsException - if the offset is invalid.
StringBuilder
insert def insert(at : Int, x : Double)

Inserts the string representation of the Double argument into this sequence.

[details]

The offset argument must be greater than or equal to 0, and less than or equal to the length of this sequence.

param
x - a Double value.
at - the offset position.
return
- a reference to this object.
StringBuilder
insert def insert(index : Int, str : Array[Char], offset : Int, len : Int)
Inserts the string representation of a subarray of the str array argument into this sequence [details]
The subarray begins at the specified offset and extends len chars. The characters of the subarray are inserted into this sequence at the position indicated by index. The length of this sequence increases by len Chars.
param
len - the number of Chars in the subarray to be inserted.
str - a Char array.
offset - the index of the first char in subarray to be inserted.
index - position at which to insert subarray.
return
- This object
throws
StringIndexOutOfBoundsException - if index is negative or greater than length(), or offset or len are negative, or (offset+len) is greater than str.length.
StringBuilder
insert def insert(at : Int, x : Short)

Inserts the string representation of the Short argument into this sequence.

[details]

The offset argument must be greater than or equal to 0, and less than or equal to the length of this sequence.

param
x - a Short value.
at - the offset position.
return
- a reference to this object.
StringBuilder
insert def insert(at : Int, x : String)
Inserts the string into this character sequence [details]
param
x - a string.
at - the offset position.
return
- a reference to this object.
throws
StringIndexOutOfBoundsException - if the offset is invalid.
StringBuilder
insert def insert(at : Int, x : Long)

Inserts the string representation of the Long argument into this sequence.

[details]

The offset argument must be greater than or equal to 0, and less than or equal to the length of this sequence.

param
x - a Long value.
at - the offset position.
return
- a reference to this object.
StringBuilder
insert def insert(at : Int, x : Byte)

Inserts the string representation of the Byte argument into this sequence.

[details]

The offset argument must be greater than or equal to 0, and less than or equal to the length of this sequence.

param
x - a Byte value.
at - the offset position.
return
- a reference to this object.
StringBuilder
insert def insert(at : Int, x : Seq[Char])
Inserts the string representation of the Char sequence argument into this sequence [details]
param
x - a character sequence.
at - the offset position.
return
- a reference to this object.
throws
StringIndexOutOfBoundsException - if the offset is invalid.
StringBuilder
insert def insert(at : Int, x : Float)

Inserts the string representation of the Float argument into this sequence.

[details]

The offset argument must be greater than or equal to 0, and less than or equal to the length of this sequence.

param
x - a Float value.
at - the offset position.
return
- a reference to this object.
StringBuilder
insert def insert(at : Int, x : Char)

Inserts the string representation of the Char argument into this sequence.

[details]

The offset argument must be greater than or equal to 0, and less than or equal to the length of this sequence.

param
x - a Char value.
at - the offset position.
return
- a reference to this object.
StringBuilder
insert def insert(at : Int, x : Any)

Inserts the string representation of the Any argument into this character sequence.

[details]

The second argument is converted to a string as if by the method String.valueOf, and the characters of that string are then inserted into this sequence at the indicated offset.

The offset argument must be greater than or equal to 0, and less than or equal to the length of this sequence.

param
x - an Any value.
offset - the offset.
return
- a reference to this object.
throws
StringIndexOutOfBoundsException - if the offset is invalid.
StringBuilder
insert def insert(at : Int, x : Int)

Inserts the string representation of the Int argument into this sequence.

[details]

The offset argument must be greater than or equal to 0, and less than or equal to the length of this sequence.

param
x - a Int value.
at - the offset position.
return
- a reference to this object.
StringBuilder
insert def insert(at : Int, x : Boolean)

Inserts the string representation of the Boolean argument into this sequence.

[details]

The offset argument must be greater than or equal to 0, and less than or equal to the length of this sequence.

param
x - a Boolean value.
at - the offset position.
return
- a reference to this object.
StringBuilder
isInstanceOf final def isInstanceOf[T0] Boolean Any
lastIndexOf def lastIndexOf(str : String, fromIndex : Int)

Returns the index within this string of the last occurrence of the specified substring. The integer returned is the largest value k such that:

[details]
      k <= Math.min(fromIndex, str.length()) &&
                     this.toString().startsWith(str, k)

If no such value of k exists, then -1 is returned.

param
fromIndex - the index to start the search from.
str - the substring to search for.
return
- the index within this sequence of the last occurrence of the specified substring.
Int
lastIndexOf def lastIndexOf(str : String)

Returns the index within this string of the rightmost occurrence of the specified substring. The rightmost empty string "" is considered to occur at the index value this.length(). The returned index is the largest value k such that

[details]
    this.toString().startsWith(str, k)

is true.

param
str - the substring to search for.
return
- if the string argument occurs one or more times as a substring within this object, then the index of the first character of the last such substring is returned. If it does not occur as a substring, -1 is returned.
throws
NullPointerException - if str is null.
Int
length_= def length_=(n : Int) Unit
ne final def ne(arg0 : Object) Boolean AnyRef
notify final def notify Unit AnyRef
notifyAll final def notifyAll Unit AnyRef
replace def replace(start : Int, end : Int, str : String)
Replaces the characters in a substring of this sequence with characters in the specified String [details]
The substring begins at the specified start and extends to the character at index end - 1 or to the end of the sequence if no such character exists. First the characters in the substring are removed and then the specified String is inserted at start.
param
end - The ending index, exclusive.
str - String that will replace previous contents.
start - The beginning index, inclusive.
return
- This object.
throws
StringIndexOutOfBoundsException - if start is negative, greater than length(), or greater than end.
Unit
reverse def reverse

Causes this character sequence to be replaced by the reverse of the sequence. If there are any surrogate pairs included in the sequence, these are treated as single characters for the reverse operation. Thus, the order of the high-low surrogates is never reversed.

[details]

Let n be the character length of this character sequence (not the length in Char values) just prior to execution of the reverse method. Then the character at index k in the new character sequence is equal to the character at index n-k-1 in the old character sequence.

return
- a reference to this object.
StringBuilder
setCharAt def setCharAt(index : Int, ch : Char)

The character at the specified index is set to ch. This sequence is altered to represent a new character sequence that is identical to the old character sequence, except that it contains the character ch at position index.

[details]

The index argument must be greater than or equal to 0, and less than the length of this sequence.

param
ch - the new character.
index - the index of the character to modify.
throws
IndexOutOfBoundsException - if index is negative or greater than or equal to length().
Unit
setLength def setLength(n : Int)
Sets the length of the character sequence [details]
param
newLength - the new length
throws
IndexOutOfBoundsException - if the n argument is negative.
Unit
substring def substring(start : Int)
Returns a new String that contains a subsequence of characters currently contained in this character sequence [details]
The substring begins at the specified index and extends to the end of this sequence.
param
start - The beginning index, inclusive.
return
- The new string.
throws
StringIndexOutOfBoundsException - if start is less than zero, or greater than the length of this object.
String
substring def substring(start : Int, end : Int)
Returns a new String that contains a subsequence of characters currently contained in this sequence [details]
The substring begins at the specified start and extends to the character at index end - 1.
param
end - The ending index, exclusive.
start - The beginning index, inclusive.
return
- The new string.
throws
StringIndexOutOfBoundsException - if start or end are negative or greater than length(), or start is greater than end.
String
synchronized final def synchronized[T0](arg0 : T0) T0 AnyRef
toString override def toString
Returns a string representing the data in this sequence [details]
A new String object is allocated and initialized to contain the character sequence currently represented by this object. This String is then returned. Subsequent changes to this sequence do not affect the contents of the String.
return
- a string representation of this sequence of characters.
String
update def update(i : Int, c : Char)
Same as setCharAt
Unit
wait final def wait(arg0 : Long, arg1 : Int) Unit AnyRef
wait final def wait(arg0 : Long) Unit AnyRef
wait final def wait Unit AnyRef
Copyright (c) 2008. All Rights Reserved.