public final class NlsFormatterChoice extends AbstractNlsFormatterPlugin<Object>
NlsFormatter for
choice-format. NlsMessage |
Example result |
|---|---|
| {deleteCount} {deleteCount,choice,(?==1)'files'(else)'file'} deleted. | 1 file deleted. |
| {flag,choice,(?==true){date}(else){time}} | 23:59:59 |
| Modifier and Type | Class and Description |
|---|---|
static class |
NlsFormatterChoice.Choice
This inner class represents a single choice.
|
private static class |
NlsFormatterChoice.Condition
This inner class represents a single choice.
|
static class |
NlsFormatterChoice.Segment
This inner class represents a single segment of a
NlsFormatterChoice.Choice. |
| Modifier and Type | Field and Description |
|---|---|
private List<NlsFormatterChoice.Choice> |
choices
|
static String |
CONDITION_ELSE
The value of a Choice condition that matches always.
|
static char |
CONDITION_END
The character used to indicate the end of a Choice condition.
|
static char |
CONDITION_START
The character used to indicate the start of a Choice condition.
|
static char |
CONDITION_VAR
The character used to indicate the variable object of a Choice condition.
|
private static CharFilter |
FILTER_COMPARATOR
The
CharFilter for the comparator symbol . |
private static CharFilter |
FILTER_COMPARATOR_ARGUMENT
The
CharFilter for the comparator argument. |
private static Filter<Object> |
FILTER_ELSE
The
Filter for CONDITION_ELSE. |
private NlsDependencies |
nlsDependencies
The
NlsDependencies to use. |
private static String |
REQUIRED_FORMAT_COMPARATOR
The format of a comparator.
|
private static String |
REQUIRED_FORMAT_CONDITION
The format of a condition.
|
private static String |
REQUIRED_FORMAT_SEGMENTS
The format of the segments.
|
| Constructor and Description |
|---|
NlsFormatterChoice(CharSequenceScanner scanner,
NlsDependencies nlsDependencies)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
format(Object object,
Locale locale,
Map<String,Object> arguments,
NlsTemplateResolver resolver,
Appendable buffer)
This method formats the given
object according to the given locale. |
List<NlsFormatterChoice.Choice> |
getChoices() |
String |
getStyle()
This method gets the
style of this formatter. |
String |
getType()
This method gets the
type of
this formatter. |
private NlsFormatterChoice.Choice |
parseChoice(CharSequenceScanner scanner)
This method parses the
NlsFormatterChoice.Choice. |
private Object |
parseComparatorArgument(CharSequenceScanner scanner)
This method parses the
comparator argument. |
private Filter<Object> |
parseCondition(CharSequenceScanner scanner)
This method parses the
NlsFormatterChoice.Condition. |
String |
toString() |
formatcreateLogger, doInitialize, getLoggerdoInitialized, getInitializationState, initializeclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitformatprivate static final String REQUIRED_FORMAT_SEGMENTS
private static final String REQUIRED_FORMAT_COMPARATOR
private static final String REQUIRED_FORMAT_CONDITION
public static final char CONDITION_START
public static final char CONDITION_END
public static final char CONDITION_VAR
public static final String CONDITION_ELSE
private static final Filter<Object> FILTER_ELSE
Filter for CONDITION_ELSE.private static final CharFilter FILTER_COMPARATOR
CharFilter for the comparator symbol .private static final CharFilter FILTER_COMPARATOR_ARGUMENT
CharFilter for the comparator argument.private final NlsDependencies nlsDependencies
NlsDependencies to use.private final List<NlsFormatterChoice.Choice> choices
public NlsFormatterChoice(CharSequenceScanner scanner, NlsDependencies nlsDependencies)
scanner - is the CharSequenceScanner pointing to the choice- formatStyle.nlsDependencies - are the NlsDependencies to use.private NlsFormatterChoice.Choice parseChoice(CharSequenceScanner scanner)
NlsFormatterChoice.Choice.scanner - is the CharSequenceScanner.NlsFormatterChoice.Choice.private Filter<Object> parseCondition(CharSequenceScanner scanner)
NlsFormatterChoice.Condition.scanner - is the CharSequenceScanner.NlsFormatterChoice.Condition or FILTER_ELSE in case of CONDITION_ELSE.private Object parseComparatorArgument(CharSequenceScanner scanner)
comparator argument.scanner - is the CharSequenceScanner.public void format(Object object, Locale locale, Map<String,Object> arguments, NlsTemplateResolver resolver, Appendable buffer) throws IOException
NlsFormatterobject according to the given locale.object - is the object to format.locale - is the locale used for localized formatting.arguments - is the Map of arguments.resolver - is the NlsTemplateResolver.buffer - is where to append the formatted object.IOException - if the given Appendable caused such exception.public String getType()
NlsFormatterPlugintype of
this formatter. See TYPE_* constants of NlsFormatterManager e.g.
NlsFormatterManager.TYPE_NUMBER.null for the
default formatter. If type is
null then also style needs to be null.public String getStyle()
NlsFormatterPluginstyle of this formatter. See STYLE_* constants of
NlsFormatterManager e.g.
NlsFormatterManager.STYLE_LONG.null for no style.public List<NlsFormatterChoice.Choice> getChoices()
List of NlsFormatterChoice.Choices. Do not modify.public String toString()
toString in class AbstractNlsFormatterPlugin<Object>Copyright © 2001–2016 mmm-Team. All rights reserved.