|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.mmm.util.component.base.AbstractComponent
net.sf.mmm.util.component.base.AbstractLoggableComponent
net.sf.mmm.util.nls.base.AbstractNlsFormatter<O>
net.sf.mmm.util.nls.base.AbstractNlsFormatterPlugin<Object>
net.sf.mmm.util.nls.impl.formatter.NlsFormatterChoice
public final class NlsFormatterChoice
This is the implementation of NlsFormatter
for choice-format.
Examples:
NlsMessage |
Example result |
|---|---|
| {deleteCount} {deleteCount,choice,(?==1)['files'](else)['file']} deleted. | 1 file deleted. |
| {flag,choice,(?==true){date}(else){time}} | 23:59:59 |
| Nested Class Summary | |
|---|---|
private static class |
NlsFormatterChoice.Choice
This inner class represents a single choice. |
private class |
NlsFormatterChoice.Condition
This inner class represents a single choice. |
| Field Summary | |
|---|---|
private List<NlsFormatterChoice.Choice> |
choices
The NlsFormatterChoice.Choices. |
static String |
CONDITION_ELSE
The value of a NlsFormatterChoice.Choice condition that matches always. |
static char |
CONDITION_END
The character used to indicate the end of a NlsFormatterChoice.Choice condition. |
static char |
CONDITION_START
The character used to indicate the start of a NlsFormatterChoice.Choice condition. |
static char |
CONDITION_VAR
The character used to indicate the variable object of a NlsFormatterChoice.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. |
| Constructor Summary | |
|---|---|
NlsFormatterChoice(CharSequenceScanner scanner,
NlsDependencies nlsDependencies)
The constructor. |
|
| Method Summary | |
|---|---|
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. |
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. |
| Methods inherited from class net.sf.mmm.util.nls.base.AbstractNlsFormatterPlugin |
|---|
toString |
| Methods inherited from class net.sf.mmm.util.nls.base.AbstractNlsFormatter |
|---|
format |
| Methods inherited from class net.sf.mmm.util.component.base.AbstractLoggableComponent |
|---|
doInitialize, getLogger, setLogger |
| Methods inherited from class net.sf.mmm.util.component.base.AbstractComponent |
|---|
doInitialized, getInitializationState, initialize |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface net.sf.mmm.util.nls.api.NlsFormatter |
|---|
format |
| Field Detail |
|---|
private static final String REQUIRED_FORMAT_COMPARATOR
private static final String REQUIRED_FORMAT_CONDITION
public static final char CONDITION_START
NlsFormatterChoice.Choice condition.
public static final char CONDITION_END
NlsFormatterChoice.Choice condition.
public static final char CONDITION_VAR
NlsFormatterChoice.Choice
condition.
public static final String CONDITION_ELSE
NlsFormatterChoice.Choice condition that matches always.
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
NlsFormatterChoice.Choices.
| Constructor Detail |
|---|
public NlsFormatterChoice(CharSequenceScanner scanner,
NlsDependencies nlsDependencies)
scanner - is the CharSequenceScanner pointing to the choice-
formatStyle.nlsDependencies - are the NlsDependencies to use.| Method Detail |
|---|
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
object 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()
type 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()
style of this formatter. See STYLE_* constants of
NlsFormatterManager e.g.
NlsFormatterManager.STYLE_LONG.
null for no style.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||