Top Description Inners Fields Constructors Methods
org.apache.commons.lang3.text

public Class StrBuilder

extends Object
implements CharSequence, Appendable, Serializable, Builder<String>
Class Inheritance
All Implemented Interfaces
org.apache.commons.lang3.builder.Builder, java.io.Serializable, java.lang.Appendable, java.lang.CharSequence
Annotations
@Deprecated
Imports
java.io.IOException, .Reader, .Serializable, .Writer, java.nio.CharBuffer, java.util.Arrays, .Iterator, .List, .Objects, org.apache.commons.lang3.ArrayUtils, .CharUtils, .ObjectUtils, .StringUtils, .Strings, org.apache.commons.lang3.builder.Builder

Deprecated

As of 3.6, use Apache Commons Text TextStringBuilder.

Builds a string from constituent parts providing a more flexible and powerful API than StringBuffer.

The main differences from StringBuffer/StringBuilder are:

The aim has been to provide an API that mimics very closely what StringBuffer provides, but with additional methods. It should be noted that some edge cases, with invalid indices or null input, have been altered - see individual methods. The biggest of these changes is that by default, null will not output the text 'null'. This can be controlled by a property, setNullText(String).

Prior to 3.0, this class implemented Cloneable but did not implement the clone method so could not be used. From 3.0 onwards it no longer implements the interface.

Since
2.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
StrBuilder.StrBuilderReader

Inner class to allow StrBuilder to operate as a reader.

pack-priv class
StrBuilder.StrBuilderTokenizer

References Deprecated StrTokenizer is deprecated or references (maybe indirectly) at least one deprecated element.
Inner class to allow StrBuilder to operate as a tokenizer.
pack-priv class
StrBuilder.StrBuilderWriter

Inner class to allow StrBuilder to operate as a writer.

Field Summary

Modifier and TypeField and Description
protected char[]
buffer

Internal data storage.

pack-priv static final int
CAPACITY

The extra capacity for new builders.

private String
newLine

The new line, null means use the system default from System#lineSeparator().

private String
nullText

The null text.

private static final long
serialVersionUID

Required for serialization support.

protected int
size

Current size of the buffer.

Constructor Summary

AccessConstructor and Description
public
StrBuilder()

Constructor that creates an empty builder initial capacity 32 characters.

public
StrBuilder(int
the initial capacity, zero or less will be converted to 32
initialCapacity
)

Constructor that creates an empty builder the specified initial capacity.

public
StrBuilder(final String
the string to copy, null treated as blank string
str
)

Constructor that creates a builder from the string, allocating 32 extra characters for growth.

Method Summary

Modifier and TypeMethod and Description
public StrBuilder

Returns:

this, to enable chaining
append
(final boolean
the value to append
value
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a boolean value to the string builder.

public StrBuilder

Returns:

this, to enable chaining
append
(final char
the value to append
ch
)

Implements java.lang.Appendable.append.

References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a char value to the string builder.

public StrBuilder

Returns:

this, to enable chaining
append
(final char[]
the char array to append
chars
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a char array to the string builder.

public StrBuilder

Returns:

this, to enable chaining
append
(final char[]
the char array to append
chars
,
final int
the start index, inclusive, must be valid
startIndex
,
final int
the length to append, must be valid
length
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a char array to the string builder.

public StrBuilder

Returns:

this, to enable chaining
append
(final CharBuffer
the char buffer to append
buf
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends the contents of a char buffer to this string builder.

public StrBuilder

Returns:

this, to enable chaining
append
(final CharBuffer
the char buffer to append
buf
,
final int
the start index, inclusive, must be valid
startIndex
,
final int
the length to append, must be valid
length
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends the contents of a char buffer to this string builder.

public StrBuilder

Returns:

this, to enable chaining
append
(final CharSequence
the CharSequence to append
seq
)

Implements java.lang.Appendable.append.

References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a CharSequence to this string builder.

public StrBuilder

Returns:

this, to enable chaining
append
(final CharSequence
the CharSequence to append
seq
,
final int
the start index, inclusive, must be valid
startIndex
,
final int
the length to append, must be valid
length
)

Implements java.lang.Appendable.append.

References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends part of a CharSequence to this string builder.

public StrBuilder

Returns:

this, to enable chaining
append
(final double
the value to append
value
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a double value to the string builder using String.valueOf.

public StrBuilder

Returns:

this, to enable chaining
append
(final float
the value to append
value
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a float value to the string builder using String.valueOf.

public StrBuilder

Returns:

this, to enable chaining
append
(final int
the value to append
value
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends an int value to the string builder using String.valueOf.

public StrBuilder

Returns:

this, to enable chaining
append
(final long
the value to append
value
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a long value to the string builder using String.valueOf.

public StrBuilder

Returns:

this, to enable chaining
append
(final Object
the object to append
obj
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends an object to this string builder.

public StrBuilder

Returns:

this, to enable chaining
append
(final StrBuilder
the string builder to append
str
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends another string builder to this string builder.

public StrBuilder

Returns:

this, to enable chaining
append
(final StrBuilder
the string to append
str
,
final int
the start index, inclusive, must be valid
startIndex
,
final int
the length to append, must be valid
length
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends part of a string builder to this string builder.

public StrBuilder

Returns:

this, to enable chaining
append
(final String
the string to append
str
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a string to this string builder.

public StrBuilder

Returns:

this, to enable chaining
append
(final String
the string to append
str
,
final int
the start index, inclusive, must be valid
startIndex
,
final int
the length to append, must be valid
length
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends part of a string to this string builder.

public StrBuilder

Returns:

this to enable chaining
append
(final String
the format string
format
,
final Object...
the objects to use in the format string
objs
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Calls String#format(String, Object...) and appends the result.

public StrBuilder

Returns:

this, to enable chaining
append
(final StringBuffer
the string buffer to append
str
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a string buffer to this string builder.

public StrBuilder

Returns:

this, to enable chaining
append
(final StringBuffer
the string to append
str
,
final int
the start index, inclusive, must be valid
startIndex
,
final int
the length to append, must be valid
length
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends part of a string buffer to this string builder.

public StrBuilder

Returns:

this, to enable chaining
append
(final StringBuilder
the StringBuilder to append
str
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a StringBuilder to this string builder.

public StrBuilder

Returns:

this, to enable chaining
append
(final StringBuilder
the StringBuilder to append
str
,
final int
the start index, inclusive, must be valid
startIndex
,
final int
the length to append, must be valid
length
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends part of a StringBuilder to this string builder.

public StrBuilder

Returns:

this, to enable chaining
appendAll
(final Iterable<?>
the iterable to append
iterable
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends each item in an iterable to the builder without any separators.

public StrBuilder

Returns:

this, to enable chaining
appendAll
(final Iterator<?>
the iterator to append
it
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends each item in an iterator to the builder without any separators.

public <
the element type
T
>
StrBuilder

Returns:

this, to enable chaining
appendAll
(final T...
the array to append
array
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends each item in an array to the builder without any separators.

public StrBuilder

Returns:

this, to enable chaining
appendFixedWidthPadLeft
(final int
the value to append
value
,
final int
the fixed field width, zero or negative has no effect
width
,
final char
the pad character to use
padChar
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends an object to the builder padding on the left to a fixed width.

public StrBuilder

Returns:

this, to enable chaining
appendFixedWidthPadLeft
(final Object
the object to append, null uses null text
obj
,
final int
the fixed field width, zero or negative has no effect
width
,
final char
the pad character to use
padChar
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends an object to the builder padding on the left to a fixed width.

public StrBuilder

Returns:

this, to enable chaining
appendFixedWidthPadRight
(final int
the value to append
value
,
final int
the fixed field width, zero or negative has no effect
width
,
final char
the pad character to use
padChar
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends an object to the builder padding on the right to a fixed length.

public StrBuilder

Returns:

this, to enable chaining
appendFixedWidthPadRight
(final Object
the object to append, null uses null text
obj
,
final int
the fixed field width, zero or negative has no effect
width
,
final char
the pad character to use
padChar
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends an object to the builder padding on the right to a fixed length.

public StrBuilder

Returns:

this, to enable chaining
appendln
(final boolean
the value to append
value
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a boolean value followed by a new line to the string builder.

public StrBuilder

Returns:

this, to enable chaining
appendln
(final char
the value to append
ch
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a char value followed by a new line to the string builder.

public StrBuilder

Returns:

this, to enable chaining
appendln
(final char[]
the char array to append
chars
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a char array followed by a new line to the string builder.

public StrBuilder

Returns:

this, to enable chaining
appendln
(final char[]
the char array to append
chars
,
final int
the start index, inclusive, must be valid
startIndex
,
final int
the length to append, must be valid
length
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a char array followed by a new line to the string builder.

public StrBuilder

Returns:

this, to enable chaining
appendln
(final double
the value to append
value
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a double value followed by a new line to the string builder using String.valueOf.

public StrBuilder

Returns:

this, to enable chaining
appendln
(final float
the value to append
value
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a float value followed by a new line to the string builder using String.valueOf.

public StrBuilder

Returns:

this, to enable chaining
appendln
(final int
the value to append
value
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends an int value followed by a new line to the string builder using String.valueOf.

public StrBuilder

Returns:

this, to enable chaining
appendln
(final long
the value to append
value
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a long value followed by a new line to the string builder using String.valueOf.

public StrBuilder

Returns:

this, to enable chaining
appendln
(final Object
the object to append
obj
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends an object followed by a new line to this string builder.

public StrBuilder

Returns:

this, to enable chaining
appendln
(final StrBuilder
the string builder to append
str
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends another string builder followed by a new line to this string builder.

public StrBuilder

Returns:

this, to enable chaining
appendln
(final StrBuilder
the string to append
str
,
final int
the start index, inclusive, must be valid
startIndex
,
final int
the length to append, must be valid
length
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends part of a string builder followed by a new line to this string builder.

public StrBuilder

Returns:

this, to enable chaining
appendln
(final String
the string to append
str
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a string followed by a new line to this string builder.

public StrBuilder

Returns:

this, to enable chaining
appendln
(final String
the string to append
str
,
final int
the start index, inclusive, must be valid
startIndex
,
final int
the length to append, must be valid
length
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends part of a string followed by a new line to this string builder.

public StrBuilder

Returns:

this to enable chaining
appendln
(final String
the format string
format
,
final Object...
the objects to use in the format string
objs
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Calls String#format(String, Object...) and appends the result.

public StrBuilder

Returns:

this, to enable chaining
appendln
(final StringBuffer
the string buffer to append
str
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a string buffer followed by a new line to this string builder.

public StrBuilder

Returns:

this, to enable chaining
appendln
(final StringBuffer
the string to append
str
,
final int
the start index, inclusive, must be valid
startIndex
,
final int
the length to append, must be valid
length
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends part of a string buffer followed by a new line to this string builder.

public StrBuilder

Returns:

this, to enable chaining
appendln
(final StringBuilder
the string builder to append
str
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a string builder followed by a new line to this string builder.

public StrBuilder

Returns:

this, to enable chaining
appendln
(final StringBuilder
the string builder to append
str
,
final int
the start index, inclusive, must be valid
startIndex
,
final int
the length to append, must be valid
length
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends part of a string builder followed by a new line to this string builder.

public StrBuilder

Returns:

this instance.
appendNewLine
()
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends this builder's new line string to this builder.

public StrBuilder

Returns:

this, to enable chaining
appendNull
()
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends the text representing null to this string builder.

public StrBuilder

Returns:

this, to enable chaining
appendPadding
(final int
the length to append, negative means no append
length
,
final char
the character to append
padChar
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends the pad character to the builder the specified number of times.

public StrBuilder

Returns:

this, to enable chaining
appendSeparator
(final char
the separator to use
separator
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a separator if the builder is currently non-empty.

public StrBuilder

Returns:

this, to enable chaining
appendSeparator
(final char
the separator if builder is not empty
standard
,
final char
the separator if builder is empty
defaultIfEmpty
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Append one of both separators to the builder If the builder is currently empty it will append the defaultIfEmpty-separator Otherwise it will append the standard-separator The separator is appended using append(char).

public StrBuilder

Returns:

this, to enable chaining
appendSeparator
(final char
the separator to use
separator
,
final int
the loop index
loopIndex
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a separator to the builder if the loop index is greater than zero.

public StrBuilder

Returns:

this, to enable chaining
appendSeparator
(final String
the separator to use, null means no separator
separator
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a separator if the builder is currently non-empty.

public StrBuilder

Returns:

this, to enable chaining
appendSeparator
(final String
the separator to use, null means no separator
separator
,
final int
the loop index
loopIndex
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends a separator to the builder if the loop index is greater than zero.

public StrBuilder

Returns:

this, to enable chaining
appendSeparator
(final String
the separator if builder is not empty, null means no separator
standard
,
final String
the separator if builder is empty, null means no separator
defaultIfEmpty
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends one of both separators to the StrBuilder.

public void
appendTo(final Appendable
the appendable to append data to
appendable
)

Appends current contents of this StrBuilder to the provided Appendable.

public StrBuilder

Returns:

this, to enable chaining
appendWithSeparators
(final Iterable<?>
the iterable to append
iterable
,
final String
the separator to use, null means no separator
separator
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends an iterable placing separators between each value, but not before the first or after the last.

public StrBuilder

Returns:

this, to enable chaining
appendWithSeparators
(final Iterator<?>
the iterator to append
it
,
final String
the separator to use, null means no separator
separator
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends an iterator placing separators between each value, but not before the first or after the last.

public StrBuilder

Returns:

this, to enable chaining
appendWithSeparators
(final Object[]
the array to append
array
,
final String
the separator to use, null means no separator
separator
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Appends an array placing separators between each value, but not before the first or after the last.

public Reader

Returns:

a reader that reads from this builder
asReader
()

Gets the contents of this builder as a Reader.

public StrTokenizer

Returns:

a tokenizer that is linked to this builder
asTokenizer
()
References Deprecated StrTokenizer is deprecated or references (maybe indirectly) at least one deprecated element.

Creates a tokenizer that can tokenize the contents of this builder.

public Writer

Returns:

a writer that populates this builder
asWriter
()

Gets this builder as a Writer that can be written to.

public String

Returns:

the builder as a String
build
()

Implements org.apache.commons.lang3.builder.Builder.build.

Implement the Builder interface.

public int

Returns:

the capacity
capacity
()

Gets the current size of the internal character array buffer.

public char

Returns:

the character at the index
charAt
(final int
the index to retrieve, must be valid
index
)

Implements java.lang.CharSequence.charAt.

Gets the character at the specified index.

public StrBuilder

Returns:

this, to enable chaining
clear
()
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Clears the string builder (convenience Collections API style method).

public boolean

Returns:

true if the builder contains the character
contains
(final char
the character to find
ch
)

Checks if the string builder contains the specified char.

public boolean

Returns:

true if the builder contains the string
contains
(final String
the string to find
str
)

Checks if the string builder contains the specified string.

public boolean

Returns:

true if the matcher finds a match in the builder
contains
(final StrMatcher
the matcher to use, null returns -1
matcher
)
References Deprecated StrMatcher is deprecated or references (maybe indirectly) at least one deprecated element.

Checks if the string builder contains a string matched using the specified matcher.

public StrBuilder

Returns:

this, to enable chaining
delete
(final int
the start index, inclusive, must be valid
startIndex
,
int
the end index, exclusive, must be valid except that if too large it is treated as end of string
endIndex
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Deletes the characters between the two specified indices.

public StrBuilder

Returns:

this, to enable chaining
deleteAll
(final char
the character to delete
ch
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Deletes the character wherever it occurs in the builder.

public StrBuilder

Returns:

this, to enable chaining
deleteAll
(final String
the string to delete, null causes no action
str
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Deletes the string wherever it occurs in the builder.

public StrBuilder

Returns:

this, to enable chaining
deleteAll
(final StrMatcher
the matcher to use to find the deletion, null causes no action
matcher
)
References Deprecated StrMatcher and StrBuilder are deprecated or reference (maybe indirectly) at least one deprecated element.

Deletes all parts of the builder that the matcher matches.

public StrBuilder

Returns:

this, to enable chaining
deleteCharAt
(final int
the index to delete
index
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Deletes the character at the specified index.

public StrBuilder

Returns:

this, to enable chaining
deleteFirst
(final char
the character to delete
ch
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Deletes the character wherever it occurs in the builder.

public StrBuilder

Returns:

this, to enable chaining
deleteFirst
(final String
the string to delete, null causes no action
str
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Deletes the string wherever it occurs in the builder.

public StrBuilder

Returns:

this, to enable chaining
deleteFirst
(final StrMatcher
the matcher to use to find the deletion, null causes no action
matcher
)
References Deprecated StrMatcher and StrBuilder are deprecated or reference (maybe indirectly) at least one deprecated element.

Deletes the first match within the builder using the specified matcher.

private void
deleteImpl(final int
the start index, must be valid
startIndex
,
final int
the end index (exclusive), must be valid
endIndex
,
final int
the length, must be valid
len
)

Internal method to delete a range without validation.

public boolean

Returns:

true if the builder ends with the string
endsWith
(final String
the string to search for, null returns false
str
)

Checks whether this builder ends with the specified string.

public StrBuilder

Returns:

this, to enable chaining
ensureCapacity
(final int
the capacity to ensure
capacity
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Checks the capacity and ensures that it is at least the size specified.

public boolean

Returns:

true if the builders contain the same characters in the same order
equals
(final Object
the object to check, null returns false
obj
)

Overrides java.lang.Object.equals.

Checks the contents of this builder against another to see if they contain the same character content.

public boolean

Returns:

true if the builders contain the same characters in the same order
equals
(final StrBuilder
the object to check, null returns false
other
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Checks the contents of this builder against another to see if they contain the same character content.

public boolean

Returns:

true if the builders contain the same characters in the same order
equalsIgnoreCase
(final StrBuilder
the object to check, null returns false
other
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Checks the contents of this builder against another to see if they contain the same character content ignoring case.

public char[]

Returns:

the input array, unless that was null or too small
getChars
(char[]
the destination array, null will cause an array to be created
destination
)

Copies the character array into the specified array.

public void
getChars(final int
first index to copy, inclusive, must be valid
startIndex
,
final int
last index, exclusive, must be valid
endIndex
,
final char[]
the destination array, must not be null or too small
destination
,
final int
the index to start copying in destination
destinationIndex
)

Overrides default java.lang.CharSequence.getChars.

Copies the character array into the specified array.

public String

Returns:

The new line text, null means use the system default from System#lineSeparator().
getNewLineText
()

Gets the text to be appended when a new line is added.

public String

Returns:

the null text, null means no append
getNullText
()

Gets the text to be appended when null is added.

public int

Returns:

a hash code
hashCode
()

Overrides java.lang.Object.hashCode.

Gets a suitable hash code for this builder.

public int

Returns:

the first index of the character, or -1 if not found
indexOf
(final char
the character to find
ch
)

Searches the string builder to find the first reference to the specified char.

public int

Returns:

the first index of the character, or -1 if not found
indexOf
(final char
the character to find
ch
,
int
the index to start at, invalid index rounded to edge
startIndex
)

Searches the string builder to find the first reference to the specified char.

public int

Returns:

the first index of the string, or -1 if not found
indexOf
(final String
the string to find, null returns -1
str
)

Searches the string builder to find the first reference to the specified string.

public int

Returns:

the first index of the string, or -1 if not found
indexOf
(final String
the string to find, null returns -1
str
,
final int
the index to start at, invalid index rounded to edge
startIndex
)

Searches the string builder to find the first reference to the specified string starting searching from the given index.

public int

Returns:

the first index matched, or -1 if not found
indexOf
(final StrMatcher
the matcher to use, null returns -1
matcher
)
References Deprecated StrMatcher is deprecated or references (maybe indirectly) at least one deprecated element.

Searches the string builder using the matcher to find the first match.

public int

Returns:

the first index matched, or -1 if not found
indexOf
(final StrMatcher
the matcher to use, null returns -1
matcher
,
int
the index to start at, invalid index rounded to edge
startIndex
)
References Deprecated StrMatcher is deprecated or references (maybe indirectly) at least one deprecated element.

Searches the string builder using the matcher to find the first match searching from the given index.

public StrBuilder

Returns:

this, to enable chaining
insert
(int
the index to add at, must be valid
index
,
final boolean
the value to insert
value
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Inserts the value into this builder.

public StrBuilder

Returns:

this, to enable chaining
insert
(final int
the index to add at, must be valid
index
,
final char
the value to insert
value
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Inserts the value into this builder.

public StrBuilder

Returns:

this, to enable chaining
insert
(final int
the index to add at, must be valid
index
,
final char[]
the char array to insert
chars
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Inserts the character array into this builder.

public StrBuilder

Returns:

this, to enable chaining
insert
(final int
the index to add at, must be valid
index
,
final char[]
the char array to insert
chars
,
final int
the offset into the character array to start at, must be valid
offset
,
final int
the length of the character array part to copy, must be positive
length
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Inserts part of the character array into this builder.

public StrBuilder

Returns:

this, to enable chaining
insert
(final int
the index to add at, must be valid
index
,
final double
the value to insert
value
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Inserts the value into this builder.

public StrBuilder

Returns:

this, to enable chaining
insert
(final int
the index to add at, must be valid
index
,
final float
the value to insert
value
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Inserts the value into this builder.

public StrBuilder

Returns:

this, to enable chaining
insert
(final int
the index to add at, must be valid
index
,
final int
the value to insert
value
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Inserts the value into this builder.

public StrBuilder

Returns:

this, to enable chaining
insert
(final int
the index to add at, must be valid
index
,
final long
the value to insert
value
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Inserts the value into this builder.

public StrBuilder

Returns:

this, to enable chaining
insert
(final int
the index to add at, must be valid
index
,
final Object
the object to insert
obj
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Inserts the string representation of an object into this builder.

public StrBuilder

Returns:

this, to enable chaining
insert
(final int
the index to add at, must be valid
index
,
String
the string to insert
str
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Inserts the string into this builder.

public boolean

Returns:

true if the size is 0.
isEmpty
()

Overrides default java.lang.CharSequence.isEmpty.

Checks is the string builder is empty (convenience Collections API style method).

public boolean

Returns:

true if the size is greater than 0.
isNotEmpty
()

Checks is the string builder is not empty (convenience Collections API style method).

public int

Returns:

the last index of the character, or -1 if not found
lastIndexOf
(final char
the character to find
ch
)

Searches the string builder to find the last reference to the specified char.

public int

Returns:

the last index of the character, or -1 if not found
lastIndexOf
(final char
the character to find
ch
,
int
the index to start at, invalid index rounded to edge
startIndex
)

Searches the string builder to find the last reference to the specified char.

public int

Returns:

the last index of the string, or -1 if not found
lastIndexOf
(final String
the string to find, null returns -1
str
)

Searches the string builder to find the last reference to the specified string.

public int

Returns:

the last index of the string, or -1 if not found
lastIndexOf
(final String
the string to find, null returns -1
str
,
final int
the index to start at, invalid index rounded to edge
startIndex
)

Searches the string builder to find the last reference to the specified string starting searching from the given index.

public int

Returns:

the last index matched, or -1 if not found
lastIndexOf
(final StrMatcher
the matcher to use, null returns -1
matcher
)
References Deprecated StrMatcher is deprecated or references (maybe indirectly) at least one deprecated element.

Searches the string builder using the matcher to find the last match.

public int

Returns:

the last index matched, or -1 if not found
lastIndexOf
(final StrMatcher
the matcher to use, null returns -1
matcher
,
int
the index to start at, invalid index rounded to edge
startIndex
)
References Deprecated StrMatcher is deprecated or references (maybe indirectly) at least one deprecated element.

Searches the string builder using the matcher to find the last match searching from the given index.

public String

Returns:

the new string
leftString
(final int
the number of characters to extract, negative returns empty string
length
)

Extracts the leftmost characters from the string builder without throwing an exception.

public int

Returns:

the length
length
()

Implements java.lang.CharSequence.length.

Gets the length of the string builder.

public String

Returns:

the new string
midString
(int
the index to start at, negative means zero
index
,
final int
the number of characters to extract, negative returns empty string
length
)

Extracts some characters from the middle of the string builder without throwing an exception.

public StrBuilder

Returns:

this, to enable chaining
minimizeCapacity
()
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Minimizes the capacity to the actual length of the string.

public int

Returns:

the number of characters read
readFrom
(final Readable
object to read from
readable
)

If possible, reads chars from the provided Readable directly into underlying character buffer without making extra copies.

public StrBuilder

Returns:

this, to enable chaining
replace
(final int
the start index, inclusive, must be valid
startIndex
,
int
the end index, exclusive, must be valid except that if too large it is treated as end of string
endIndex
,
final String
the string to replace with, null means delete range
replaceStr
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Replaces a portion of the string builder with another string.

public StrBuilder

Returns:

this, to enable chaining
replace
(final StrMatcher
the matcher to use to find the deletion, null causes no action
matcher
,
final String
the string to replace the match with, null is a delete
replaceStr
,
final int
the start index, inclusive, must be valid
startIndex
,
int
the end index, exclusive, must be valid except that if too large it is treated as end of string
endIndex
,
final int
the number of times to replace, -1 for replace all
replaceCount
)
References Deprecated StrMatcher and StrBuilder are deprecated or reference (maybe indirectly) at least one deprecated element.

Advanced search and replaces within the builder using a matcher.

public StrBuilder

Returns:

this, to enable chaining
replaceAll
(final char
the search character
search
,
final char
the replace character
replace
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Replaces the search character with the replace character throughout the builder.

public StrBuilder

Returns:

this, to enable chaining
replaceAll
(final String
the search string, null causes no action to occur
searchStr
,
final String
the replace string, null is equivalent to an empty string
replaceStr
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Replaces the search string with the replace string throughout the builder.

public StrBuilder

Returns:

this, to enable chaining
replaceAll
(final StrMatcher
the matcher to use to find the deletion, null causes no action
matcher
,
final String
the replace string, null is equivalent to an empty string
replaceStr
)
References Deprecated StrMatcher and StrBuilder are deprecated or reference (maybe indirectly) at least one deprecated element.

Replaces all matches within the builder with the replace string.

public StrBuilder

Returns:

this, to enable chaining
replaceFirst
(final char
the search character
search
,
final char
the replace character
replace
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Replaces the first instance of the search character with the replace character in the builder.

public StrBuilder

Returns:

this, to enable chaining
replaceFirst
(final String
the search string, null causes no action to occur
searchStr
,
final String
the replace string, null is equivalent to an empty string
replaceStr
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Replaces the first instance of the search string with the replace string.

public StrBuilder

Returns:

this, to enable chaining
replaceFirst
(final StrMatcher
the matcher to use to find the deletion, null causes no action
matcher
,
final String
the replace string, null is equivalent to an empty string
replaceStr
)
References Deprecated StrMatcher and StrBuilder are deprecated or reference (maybe indirectly) at least one deprecated element.

Replaces the first match within the builder with the replace string.

private void
replaceImpl(final int
the start index, must be valid
startIndex
,
final int
the end index (exclusive), must be valid
endIndex
,
final int
the length to remove (endIndex - startIndex), must be valid
removeLen
,
final String
the string to replace with, null means delete range
insertStr
,
final int
the length of the insert string, must be valid
insertLen
)

Internal method to delete a range without validation.

private StrBuilder

Returns:

this, to enable chaining
replaceImpl
(final StrMatcher
the matcher to use to find the deletion, null causes no action
matcher
,
final String
the string to replace the match with, null is a delete
replaceStr
,
final int
the start index, must be valid
from
,
int
the end index (exclusive), must be valid
to
,
int
the number of times to replace, -1 for replace all
replaceCount
)
References Deprecated StrMatcher and StrBuilder are deprecated or reference (maybe indirectly) at least one deprecated element.

Replaces within the builder using a matcher.

public StrBuilder

Returns:

this, to enable chaining
reverse
()
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Reverses the string builder placing each character in the opposite index.

public String

Returns:

the new string
rightString
(final int
the number of characters to extract, negative returns empty string
length
)

Extracts the rightmost characters from the string builder without throwing an exception.

public StrBuilder

Returns:

this, to enable chaining
setCharAt
(final int
the index to set
index
,
final char
the new character
ch
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Sets the character at the specified index.

public StrBuilder

Returns:

this, to enable chaining
setLength
(final int
the length to set to, must be zero or positive
length
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Updates the length of the builder by either dropping the last characters or adding filler of Unicode zero.

public StrBuilder

Returns:

this instance.
setNewLineText
(final String
the new line text, null means use the system default from System#lineSeparator().
newLine
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Sets the text to be appended when new line is called.

public StrBuilder

Returns:

this, to enable chaining
setNullText
(String
the null text, null means no append
nullText
)
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Sets the text to be appended when null is added.

public int

Returns:

the length
size
()

Gets the length of the string builder.

public boolean

Returns:

true if the builder starts with the string
startsWith
(final String
the string to search for, null returns false
str
)

Checks whether this builder starts with the specified string.

public CharSequence
subSequence(final int startIndex, final int endIndex)

Implements java.lang.CharSequence.subSequence.

Returns a CharSequence that is a subsequence of this sequence.

public String

Returns:

the new string
substring
(final int
the start index, inclusive, must be valid
start
)

Extracts a portion of this string builder as a string.

public String

Returns:

the new string
substring
(final int
the start index, inclusive, must be valid
startIndex
,
int
the end index, exclusive, must be valid except that if too large it is treated as end of string
endIndex
)

Extracts a portion of this string builder as a string.

public char[]

Returns:

a new array that represents the contents of the builder
toCharArray
()

Copies the builder's character array into a new character array.

public char[]

Returns:

a new array that holds part of the contents of the builder
toCharArray
(final int
the start index, inclusive, must be valid
startIndex
,
int
the end index, exclusive, must be valid except that if too large it is treated as end of string
endIndex
)

Copies part of the builder's character array into a new character array.

public String

Returns:

the builder as a String
toString
()

Overrides java.lang.Object.toString.

Implements java.lang.CharSequence.toString.

Gets a String version of the string builder, creating a new instance each time the method is called.

public StringBuffer

Returns:

the builder as a StringBuffer
toStringBuffer
()

Gets a StringBuffer version of the string builder, creating a new instance each time the method is called.

public StringBuilder

Returns:

the builder as a StringBuilder
toStringBuilder
()

Gets a StringBuilder version of the string builder, creating a new instance each time the method is called.

public StrBuilder

Returns:

this, to enable chaining
trim
()
References Deprecated StrBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

Trims the builder by removing characters less than or equal to a space from the beginning and end.

protected void
validateIndex(final int
the index, must be valid
index
)

Validates parameters defining a single index in the builder.

protected int

Returns:

the new string
validateRange
(final int
the start index, inclusive, must be valid
startIndex
,
int
the end index, exclusive, must be valid except that if too large it is treated as end of string
endIndex
)

Validates parameters defining a range of the builder.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait