Package org.dellroad.stuff.text
Class MessageFmt.FormatArgumentSegment<T extends Format>
java.lang.Object
org.dellroad.stuff.text.MessageFmt.Segment
org.dellroad.stuff.text.MessageFmt.ArgumentSegment
org.dellroad.stuff.text.MessageFmt.FormatArgumentSegment<T>
- Type Parameters:
T
- type ofFormat
used to format the argument
- Direct Known Subclasses:
MessageFmt.DateFormatArgumentSegment
,MessageFmt.NumberFormatArgumentSegment
- Enclosing class:
- MessageFmt
public abstract static class MessageFmt.FormatArgumentSegment<T extends Format>
extends MessageFmt.ArgumentSegment
An
MessageFmt.ArgumentSegment
that formats its argument using a Format
of some kind.
Use FormatArgumentSegment.of()
to produce a concrete instance.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Format>
MessageFmt.FormatArgumentSegment<T>Map the given argumentFormat
into the correspondingMessageFmt.ArgumentSegment
.Methods inherited from class org.dellroad.stuff.text.MessageFmt.ArgumentSegment
equals, getArgumentNumber, getArgumentSuffix, hashCode, setArgumentNumber, toPattern, toString
Methods inherited from class org.dellroad.stuff.text.MessageFmt.Segment
visit
-
Constructor Details
-
FormatArgumentSegment
protected FormatArgumentSegment() -
FormatArgumentSegment
protected FormatArgumentSegment(int argumentNumber)
-
-
Method Details
-
of
public static <T extends Format> MessageFmt.FormatArgumentSegment<T> of(T format, int argumentNumber, Locale locale) Map the given argumentFormat
into the correspondingMessageFmt.ArgumentSegment
.The optional
locale
parameter allows for identification of certain formats when they equal the locale default. This also results in more conciseMessageFormat
format strings (seeMessageFmt.toPattern()
), but makes the result implicitly depend on theLocale
being used (because differentLocale
s have different defaults for integer, percent, currency, etc).- Type Parameters:
T
- format type- Parameters:
format
- format to be used for argumentargumentNumber
- argument numberlocale
- assumed locale, or null to not make any locale assumptions- Returns:
- an equivalent
MessageFmt.FormatArgumentSegment
- Throws:
IllegalArgumentException
- ifargumentNumber
is negativeIllegalArgumentException
- ifformat
is null or cannot be deciphered
-