public final class LocalizableMessageBuilder extends Object implements Appendable, CharSequence, Serializable
Note that before you use this class you should consider whether it is appropriate. In general composing messages by appending message to each other may not produce a message that is formatted appropriately for all locales.
It is usually better to create messages by composition. In other words you should create a base message that contains one or more string argument specifiers (%s) and define other message objects to use as replacement variables. In this way language translators have a change to reformat the message for a particular locale if necessary.
LocalizableMessage,
Serialized Form| Constructor and Description |
|---|
LocalizableMessageBuilder()
Creates a new message builder whose content is initially empty.
|
LocalizableMessageBuilder(LocalizableMessage message)
Creates a new message builder whose content is initially equal to the
provided message.
|
LocalizableMessageBuilder(LocalizableMessageBuilder builder)
Creates a new message builder whose content is initially equal to the
provided message builder.
|
LocalizableMessageBuilder(Object object)
Creates a new message builder whose content is initially equal to the
String representation of the provided Object. |
| Modifier and Type | Method and Description |
|---|---|
LocalizableMessageBuilder |
append(char c)
Appends the provided character to this message builder.
|
LocalizableMessageBuilder |
append(CharSequence cs)
Appends the provided character sequence to this message builder.
|
LocalizableMessageBuilder |
append(CharSequence cs,
int start,
int end)
Appends a subsequence of the provided character sequence to this message
builder.
|
LocalizableMessageBuilder |
append(int value)
Appends the provided integer to this message builder.
|
LocalizableMessageBuilder |
append(LocalizableMessage message)
Appends the provided message to this message builder.
|
LocalizableMessageBuilder |
append(Object object)
Appends the
String representation of the provided Object
to this message builder. |
char |
charAt(int index)
Returns the
char value at the specified index of the
String representation of this message builder in the default
locale. |
char |
charAt(Locale locale,
int index)
Returns the
char value at the specified index of the
String representation of this message builder in the specified
locale. |
int |
length()
Returns the length of the
String representation of this message
builder in the default locale. |
int |
length(Locale locale)
Returns the length of the
String representation of this message
builder in the specified locale. |
CharSequence |
subSequence(int start,
int end)
Returns a new
CharSequence which is a subsequence of the
String representation of this message builder in the default
locale. |
CharSequence |
subSequence(Locale locale,
int start,
int end)
Returns a new
CharSequence which is a subsequence of the
String representation of this message builder in the specified
locale. |
LocalizableMessage |
toMessage()
Returns the
LocalizableMessage representation of this message
builder. |
String |
toString()
Returns the
String representation of this message builder in the
default locale. |
String |
toString(Locale locale)
Returns the
String representation of this message builder in the
specified locale. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitchars, codePointspublic LocalizableMessageBuilder()
public LocalizableMessageBuilder(LocalizableMessage message)
message - The initial content of the message builder.NullPointerException - If message was null.public LocalizableMessageBuilder(LocalizableMessageBuilder builder)
builder - The initial content of the message builder.NullPointerException - If builder was null.public LocalizableMessageBuilder(Object object)
String representation of the provided Object.object - The initial content of the message builder, may be
null.public LocalizableMessageBuilder append(char c)
append in interface Appendablec - The character to be appended.public LocalizableMessageBuilder append(CharSequence cs)
append in interface Appendablecs - The character sequence to be appended.NullPointerException - If cs was null.public LocalizableMessageBuilder append(CharSequence cs, int start, int end)
An invocation of this method of the form append(cs, start, end),
behaves in exactly the same way as the invocation
append(cs.subSequence(start, end))
append in interface Appendablecs - The character sequence to be appended.start - The index of the first character in the subsequence.end - The index of the character following the last character in the
subsequence.IndexOutOfBoundsException - If start or end are negative, start
is greater than end, or end is greater than
csq.length().NullPointerException - If cs was null.public LocalizableMessageBuilder append(int value)
value - The integer to be appended.public LocalizableMessageBuilder append(LocalizableMessage message)
message - The message to be appended.NullPointerException - If message was null.public LocalizableMessageBuilder append(Object object)
String representation of the provided Object
to this message builder.object - The object to be appended, may be null.public char charAt(int index)
char value at the specified index of the
String representation of this message builder in the default
locale.charAt in interface CharSequenceindex - The index of the char value to be returned.char value.IndexOutOfBoundsException - If the index argument is negative or not less than
length().public char charAt(Locale locale, int index)
char value at the specified index of the
String representation of this message builder in the specified
locale.locale - The locale.index - The index of the char value to be returned.char value.IndexOutOfBoundsException - If the index argument is negative or not less than
length().NullPointerException - If locale was null.public int length()
String representation of this message
builder in the default locale.length in interface CharSequenceString representation of this message
builder in the default locale.public int length(Locale locale)
String representation of this message
builder in the specified locale.locale - The locale.String representation of this message
builder in the specified locale.NullPointerException - If locale was null.public CharSequence subSequence(int start, int end)
CharSequence which is a subsequence of the
String representation of this message builder in the default
locale. The subsequence starts with the char value at the
specified index and ends with the char value at index
end - 1 . The length (in chars) of the returned sequence
is end - start, so if start == end then an empty sequence
is returned.subSequence in interface CharSequencestart - The start index, inclusive.end - The end index, exclusive.IndexOutOfBoundsException - If start or end are negative, if end
is greater than length(), or if start is
greater than end.public CharSequence subSequence(Locale locale, int start, int end)
CharSequence which is a subsequence of the
String representation of this message builder in the specified
locale. The subsequence starts with the char value at the
specified index and ends with the char value at index
end - 1 . The length (in chars) of the returned sequence
is end - start, so if start == end then an empty sequence
is returned.locale - The locale.start - The start index, inclusive.end - The end index, exclusive.IndexOutOfBoundsException - If start or end are negative, if end
is greater than length(), or if start is
greater than end.NullPointerException - If locale was null.public LocalizableMessage toMessage()
LocalizableMessage representation of this message
builder. Subsequent changes to this message builder will not modify the
returned LocalizableMessage.LocalizableMessage representation of this message
builder.public String toString()
String representation of this message builder in the
default locale.toString in interface CharSequencetoString in class ObjectString representation of this message builder.public String toString(Locale locale)
String representation of this message builder in the
specified locale.locale - The locale.String representation of this message builder.NullPointerException - If locale was null.Copyright © 2025 Open Identity Platform Community. All rights reserved.