public class FormattedStringBuilder extends Object implements CharSequence, Appendable
| Modifier and Type | Class and Description |
|---|---|
static interface |
FormattedStringBuilder.FieldWrapper |
| Modifier and Type | Field and Description |
|---|---|
static FormattedStringBuilder |
EMPTY
A constant, empty FormattedStringBuilder.
|
| Constructor and Description |
|---|
FormattedStringBuilder() |
FormattedStringBuilder(FormattedStringBuilder source) |
FormattedStringBuilder(int capacity) |
| Modifier and Type | Method and Description |
|---|---|
Appendable |
append(char c)
This method is provided for Java Appendable compatibility.
|
int |
append(char[] chars,
Object[] fields)
Appends the chars in the specified char array to the end of the string, and associates them with
the fields in the specified field array, which must have the same length as chars.
|
Appendable |
append(CharSequence csq)
This method is provided for Java Appendable compatibility.
|
Appendable |
append(CharSequence csq,
int start,
int end)
This method is provided for Java Appendable compatibility.
|
int |
append(CharSequence sequence,
Object field)
Appends the specified CharSequence to the end of the string.
|
int |
append(FormattedStringBuilder other)
Appends the contents of another
FormattedStringBuilder to the end of this instance. |
int |
appendChar16(char codeUnit,
Object field) |
int |
appendCodePoint(int codePoint,
Object field)
Appends the specified codePoint to the end of the string.
|
char |
charAt(int index) |
FormattedStringBuilder |
clear() |
int |
codePointAt(int index) |
int |
codePointBefore(int index) |
int |
codePointCount() |
boolean |
contentEquals(char[] chars,
Object[] fields) |
boolean |
contentEquals(FormattedStringBuilder other) |
void |
copyFrom(FormattedStringBuilder source) |
boolean |
equals(Object other) |
Object |
fieldAt(int index) |
int |
getFirstCodePoint() |
int |
getLastCodePoint() |
int |
hashCode() |
int |
insert(int index,
char[] chars,
Object[] fields)
Inserts the chars in the specified char array at the specified index in the string, and associates
them with the fields in the specified field array, which must have the same length as chars.
|
int |
insert(int index,
CharSequence sequence,
int start,
int end,
Object field)
Inserts the specified CharSequence at the specified index in the string, reading from the
CharSequence from start (inclusive) to end (exclusive).
|
int |
insert(int index,
CharSequence sequence,
Object field)
Inserts the specified CharSequence at the specified index in the string.
|
int |
insert(int index,
FormattedStringBuilder other)
Inserts the contents of another
FormattedStringBuilder into this instance at the given index. |
int |
insertChar16(int index,
char codeUnit,
Object field) |
int |
insertCodePoint(int index,
int codePoint,
Object field)
Inserts the specified codePoint at the specified index in the string.
|
int |
length() |
void |
setAppendableField(Object field)
Call this method before using any of the Appendable overrides.
|
void |
setAppendIndex(int index)
Sets the index at which append operations insert.
|
int |
splice(int startThis,
int endThis,
CharSequence sequence,
int startOther,
int endOther,
Object field)
Replaces the chars between startThis and endThis with the chars between startOther and endOther of
the given CharSequence.
|
String |
subString(int start,
int end)
Use this instead of subSequence if returning publicly.
|
char[] |
toCharArray() |
String |
toDebugString()
Returns a string that includes field information, for debugging purposes.
|
Object[] |
toFieldArray() |
String |
toString()
Returns the string represented by the characters in this string builder.
|
static Format.Field |
unwrapField(Object field) |
chars, codePoints, compare, isEmpty, subSequencepublic static final FormattedStringBuilder EMPTY
public FormattedStringBuilder()
public FormattedStringBuilder(int capacity)
public FormattedStringBuilder(FormattedStringBuilder source)
public static Format.Field unwrapField(Object field)
public void copyFrom(FormattedStringBuilder source)
public int length()
length in interface CharSequencepublic int codePointCount()
public char charAt(int index)
charAt in interface CharSequencepublic Object fieldAt(int index)
public int getFirstCodePoint()
public int getLastCodePoint()
public int codePointAt(int index)
public int codePointBefore(int index)
public FormattedStringBuilder clear()
public void setAppendIndex(int index)
index - The index at which append operations should insert.public int appendChar16(char codeUnit,
Object field)
public int insertChar16(int index,
char codeUnit,
Object field)
public int appendCodePoint(int codePoint,
Object field)
public int insertCodePoint(int index,
int codePoint,
Object field)
public int append(CharSequence sequence, Object field)
public int insert(int index,
CharSequence sequence,
Object field)
public int insert(int index,
CharSequence sequence,
int start,
int end,
Object field)
public int splice(int startThis,
int endThis,
CharSequence sequence,
int startOther,
int endOther,
Object field)
public int append(char[] chars,
Object[] fields)
public int insert(int index,
char[] chars,
Object[] fields)
public int append(FormattedStringBuilder other)
FormattedStringBuilder to the end of this instance.FormattedStringBuilder.public int insert(int index,
FormattedStringBuilder other)
FormattedStringBuilder into this instance at the given index.FormattedStringBuilder.public String subString(int start, int end)
public String toString()
For a string intended be used for debugging, use FormattedStringBuilder.toDebugString().
toString in interface CharSequencetoString in class Objectpublic String toDebugString()
For example, if the string is "-12.345", the debug string will be something like "<FormattedStringBuilder [-123.45] [-iii.ff]>"
public char[] toCharArray()
public Object[] toFieldArray()
public void setAppendableField(Object field)
field - The field used when inserting strings.public Appendable append(CharSequence csq)
FormattedStringBuilder.setAppendableField(java.lang.Object) first.append in interface Appendablepublic Appendable append(CharSequence csq, int start, int end)
FormattedStringBuilder.setAppendableField(java.lang.Object) first.append in interface Appendablepublic Appendable append(char c)
FormattedStringBuilder.setAppendableField(java.lang.Object) first.append in interface Appendablepublic boolean contentEquals(char[] chars,
Object[] fields)
FormattedStringBuilder.toCharArray(),
FormattedStringBuilder.toFieldArray()public boolean contentEquals(FormattedStringBuilder other)
other - The instance to compare.