public class NlsArgument extends Object
NlsMessage
. An argument is a place-holder for a dynamic parameter
filled into the message. It is resolved when the message is finally
localized
as String
for a specific
Locale
. The key
is used to lookup
the
argument value to fill in. If that value itself implements NlsObject
it will be also translated using the
same Locale
.NlsArgument
in an i18n message
is
specified as following:
'{' key [ ',' type [ ',' style ] ] [ '{' justification '}' ] '}'The literals are explained in this table.
literal | explanation |
---|---|
key | is the key of the parameter (may be numeric for legacy support) |
type | a type specifying how to format the value (see below). Should fit to the type of the
argument value to fill in.
|
style | a style according to type (see below). |
justification | a justification |
type
and style
:
type | style | Example | Comment |
---|---|---|---|
- | - | value as string | default string representation of the value |
number |
- | 123,456.78 | Numeric representation |
number |
percent |
12,345,678% | Number in percent |
number |
currency |
123,456.78 � | Number as currency |
number |
'#'##.## | #123456.78 | Any other style is treated as pattern for DecimalFormat |
date |
- | 31-Dec-1999 | Date default representation |
date |
short |
31/12/99 | Date short representation |
date |
medium |
31-Dec-1999 | Date medium representation |
date |
long |
31 December 1999 | Date long representation |
date |
full |
Friday, 31 December 1999 | Date full representation |
date |
iso8601 |
1999-12-31 | Date ISO-8601 representation |
date |
yyyy.MM.dd | 2010.01.01 | Any other style is treated as pattern for SimpleDateFormat |
time |
- | 23:59:59 | Time default representation |
time |
short |
23:59 | Time short representation |
time |
medium |
23:59:59 | Time medium representation |
time |
long |
23:59:59 GMT+01:00 | Time long representation |
time |
full |
23:59:59 o'clock GMT+01:00 | Time full representation |
time |
iso8601 |
23:59:59+01:00 | Time ISO-8601 representation |
time |
HH:mm:ss | 23:59:59 | Any other style is treated as pattern for SimpleDateFormat |
datetime |
- | 31-Dec-1999 23:59:59 | Date+time default representation |
datetime |
short |
31/12/99 23:59 | Date+time short representation |
datetime |
medium |
31-Dec-1999 23:59:59 | Date+time medium representation |
datetime |
long |
31 December 1999 23:59:59 GMT+01:00 | Date+time long representation |
datetime |
full |
Friday, 31 December 1999 23:59:59 o'clock GMT+01:00 | Date+time full representation |
datetime |
iso8601 |
1999-12-31T23:59:59+01:00 | Date+time ISO-8601 representation |
date |
yyyy.MM.dd-HH:mm:ss | 2010.01.01-23:59:59 | Any other style is treated as pattern for SimpleDateFormat |
type |
- | java.util.List | Type medium representation (omit java.lang ) |
type |
short |
List | Type short representation |
type |
medium |
java.util.List | Type medium representation (omit java.lang ) |
type |
long |
java.util.List<String> | Type long representation |
type |
full |
java.util.List<java.lang.String> | Type full representation |
choice |
(?==1)'error'(else)'errors' | error | A choice to distinguish singular/plural forms. |
choice |
(?>=5){key,choice,(?==true)'a'(else){key2}}(else)'c' | a | A choice that results to 'c' if the value is NOT greater or equal to 5. Otherwise it results to 'a' if the value
of the argument "key" is Boolean.TRUE . Otherwise it results to the value of the argument "key2". - This is a
wired example. It shows the power of the choice format as well as how things turn out unmaintainable if the power is
missused. |
Modifier and Type | Field and Description |
---|---|
private NlsFormatterPlugin<?> |
formatter |
private Justification |
justification |
private String |
key |
Constructor and Description |
---|
NlsArgument(String key,
NlsFormatterPlugin<?> formatter,
Justification justification)
The constructor.
|
Modifier and Type | Method and Description |
---|---|
NlsFormatterPlugin<?> |
getFormatter()
Is the formatter used to format the
argument . |
Justification |
getJustification()
This method gets the optional
Justification . |
String |
getKey()
This method gets the key of the argument to format.
|
String |
toString() |
private final String key
private final NlsFormatterPlugin<?> formatter
private final Justification justification
public NlsArgument(String key, NlsFormatterPlugin<?> formatter, Justification justification)
key
- is the key
.formatter
- is the formatter
.justification
- is the justification
.public String getKey()
public NlsFormatterPlugin<?> getFormatter()
argument
.public Justification getJustification()
Justification
.null
for none.Copyright © 2001–2016 mmm-Team. All rights reserved.