Deprecated
As of 3.6, use Apache Commons Text ExtendedMessageFormat.
java.text.MessageFormat to allow pluggable/additional formatting
options for embedded format elements. Client code should specify a registry
of FormatFactory instances associated with String
format names. This registry will be consulted when the format elements are
parsed from the message pattern. In this way custom patterns can be specified,
and the formats supported by java.text.MessageFormat can be overridden
at the format and/or format style level (see MessageFormat). A "format element"
embedded in the message pattern is specified (()? signifies optionality):{argument-number(,format-name
(,format-style)?)?}
format-name and format-style values are trimmed of surrounding whitespace
in the manner of java.. If format-name denotes
FormatFactory formatFactoryInstance in registry, a Format
matching format-name and format-style is requested from
formatFactoryInstance. If this is successful, the Format
found is used for this format element.
NOTICE: The various subformat mutator methods are considered unnecessary; they exist on the parent
class to allow the type of customization which it is the job of this class to provide in
a configurable fashion. These methods have thus been disabled and will throw
UnsupportedOperationException if called.
Limitations inherited from java.:
Formats, including MessageFormat and thus
ExtendedMessageFormat, is not guaranteed.| Modifier and Type | Field and Description |
|---|---|
| private static final String | |
| private static final char | |
| private static final char | |
| private final Map | registry
Our registry of FormatFactory. |
| private static final long | |
| private static final char | |
| private static final char | |
| private String | toPattern
To pattern string. |
| Access | Constructor and Description |
|---|---|
| public | ExtendedMessageFormat(final String
the pattern to use, not null pattern)Create a new ExtendedMessageFormat for the default locale. |
| public | ExtendedMessageFormat(final String
the pattern to use, not null pattern, final Locale the locale to use, not null locale)Create a new ExtendedMessageFormat. |
| public | ExtendedMessageFormat(final String
the pattern to use, not null. pattern, final Locale the locale to use. locale, final Map<String, ? extends FormatFactory> the registry of format factories, may be null. registry)Create a new ExtendedMessageFormat. |
| public | ExtendedMessageFormat(final String
the pattern to use, not null pattern, final Map<String, ? extends FormatFactory> the registry of format factories, may be null registry)Create a new ExtendedMessageFormat for the default locale. |
| Modifier and Type | Method and Description |
|---|---|
| private StringBuilder | Returns: appendTopattern to parse pattern, final ParsePosition current parse position pos, final StringBuilder optional StringBuilder to append appendTo)Consume a quoted string, adding it to |
| public final void | applyPattern(final String
String pattern)Overrides java. Apply the specified pattern. |
| private boolean | Returns: true if some Object was found, false otherwise.to check coll)Learn whether the specified Collection contains non-null elements. |
| public boolean | equals(final Object obj)
Overrides java. Compares the specified object with this |
| private Format | |
| private void | getQuotedString(final String
pattern to parse pattern, final ParsePosition current parse position pos)Consume quoted string only |
| public int | hashCode()
Overrides java. Returns the hash code value for this |
| private String | Returns: full patternsource pattern, final ArrayList<String> The custom patterns to re-insert, if any customPatterns)Insert formats back into the pattern for toPattern() support. |
| private ParsePosition | Returns: posParsePosition pos)Convenience method to advance parse position by 1 |
| private String | Returns: Format description Stringstring to parse pattern, final ParsePosition current parse position pos)Parse the format component of a format element. |
| private int | Returns: argument indexpattern to parse pattern, final ParsePosition current parse position pos)Reads the argument index from the current format element |
| private void | seekNonWs(final String
String to read pattern, final ParsePosition current position pos)Consume whitespace from the current parse position. |
| public void | setFormat(final int
format element index formatElementIndex, final Format the new format newFormat)Overrides java. Throws UnsupportedOperationException - see class Javadoc for details. |
| public void | setFormatByArgumentIndex(final int
argument index argumentIndex, final Format the new format newFormat)Overrides java. Throws UnsupportedOperationException - see class Javadoc for details. |
| public void | setFormats(final Format[]
new formats newFormats)Overrides java. Throws UnsupportedOperationException - see class Javadoc for details. |
| public void | setFormatsByArgumentIndex(final Format[]
new formats newFormats)Overrides java. Throws UnsupportedOperationException - see class Javadoc for details. |
| public String | toPattern()
Overrides java. Returns a String pattern adhering to the |
| EMPTY_PATTERN | back to summary |
|---|---|
| private static final String EMPTY_PATTERN | |
| END_FE | back to summary |
|---|---|
| private static final char END_FE | |
| QUOTE | back to summary |
|---|---|
| private static final char QUOTE | |
| registry | back to summary |
|---|---|
| private final Map<String, ? extends FormatFactory> registry Our registry of FormatFactory. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| START_FE | back to summary |
|---|---|
| private static final char START_FE | |
| START_FMT | back to summary |
|---|---|
| private static final char START_FMT | |
| toPattern | back to summary |
|---|---|
| private String toPattern To pattern string. | |
| ExtendedMessageFormat | back to summary |
|---|---|
| public ExtendedMessageFormat(final String pattern) Create a new ExtendedMessageFormat for the default locale.
| |
| ExtendedMessageFormat | back to summary |
|---|---|
| public ExtendedMessageFormat(final String pattern, final Locale locale) Create a new ExtendedMessageFormat.
| |
| ExtendedMessageFormat | back to summary |
|---|---|
| public ExtendedMessageFormat(final String pattern, final Locale locale, final Map<String, ? extends FormatFactory> registry) Create a new ExtendedMessageFormat.
| |
| ExtendedMessageFormat | back to summary |
|---|---|
| public ExtendedMessageFormat(final String pattern, final Map<String, ? extends FormatFactory> registry) Create a new ExtendedMessageFormat for the default locale.
| |
| appendQuotedString | back to summary |
|---|---|
| private StringBuilder appendQuotedString(final String pattern, final ParsePosition pos, final StringBuilder appendTo) Consume a quoted string, adding it to
| |
| applyPattern | back to summary |
|---|---|
| public final void applyPattern(final String pattern) Overrides java. Apply the specified pattern. | |
| containsElements | back to summary |
|---|---|
| private boolean containsElements(final Collection<?> coll) Learn whether the specified Collection contains non-null elements.
| |
| equals | back to summary |
|---|---|
| public boolean equals(final Object obj) Overrides java. Doc from java. Compares the specified object with this
| |
| getFormat | back to summary |
|---|---|
| private Format getFormat(final String desc) Gets a custom format from a format description. | |
| getQuotedString | back to summary |
|---|---|
| private void getQuotedString(final String pattern, final ParsePosition pos) Consume quoted string only
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns the hash code value for this
| |
| insertFormats | back to summary |
|---|---|
| private String insertFormats(final String pattern, final ArrayList<String> customPatterns) Insert formats back into the pattern for toPattern() support. | |
| next | back to summary |
|---|---|
| private ParsePosition next(final ParsePosition pos) Convenience method to advance parse position by 1
| |
| parseFormatDescription | back to summary |
|---|---|
| private String parseFormatDescription(final String pattern, final ParsePosition pos) Parse the format component of a format element.
| |
| readArgumentIndex | back to summary |
|---|---|
| private int readArgumentIndex(final String pattern, final ParsePosition pos) Reads the argument index from the current format element
| |
| seekNonWs | back to summary |
|---|---|
| private void seekNonWs(final String pattern, final ParsePosition pos) Consume whitespace from the current parse position.
| |
| setFormat | back to summary |
|---|---|
| public void setFormat(final int formatElementIndex, final Format newFormat) Overrides java. Throws UnsupportedOperationException - see class Javadoc for details.
| |
| setFormatByArgumentIndex | back to summary |
|---|---|
| public void setFormatByArgumentIndex(final int argumentIndex, final Format newFormat) Overrides java. Throws UnsupportedOperationException - see class Javadoc for details.
| |
| setFormats | back to summary |
|---|---|
| public void setFormats(final Format[] newFormats) Overrides java. Throws UnsupportedOperationException - see class Javadoc for details.
| |
| setFormatsByArgumentIndex | back to summary |
|---|---|
| public void setFormatsByArgumentIndex(final Format[] newFormats) Overrides java. Throws UnsupportedOperationException - see class Javadoc for details.
| |
| toPattern | back to summary |
|---|---|
| public String toPattern() Overrides java. Doc from java. Returns a String pattern adhering to the
| |