*
* type |
* style |
* Example |
* Comment |
*
*
* - |
* - |
* value as string |
* default string representation of the value |
*
*
* {@link NlsFormatterManager#TYPE_NUMBER number} |
* - |
* 123,456.78 |
* Numeric representation |
*
*
* {@link NlsFormatterManager#TYPE_NUMBER number} |
* {@link NlsFormatterManager#STYLE_PERCENT percent} |
* 12,345,678% |
* Number in percent |
*
*
* {@link NlsFormatterManager#TYPE_NUMBER number} |
* {@link NlsFormatterManager#STYLE_CURRENCY currency} |
* 123,456.78 ¤ |
* Number as currency |
*
*
* {@link NlsFormatterManager#TYPE_NUMBER number} |
* '#'##.## |
* #123456.78 |
* Any other style is treated as pattern for {@link java.text.DecimalFormat} |
*
*
* {@link NlsFormatterManager#TYPE_DATE date} |
* - |
* 31-Dec-1999 |
* Date default representation |
*
*
* {@link NlsFormatterManager#TYPE_DATE date} |
* {@link NlsFormatterManager#STYLE_SHORT short} |
* 31/12/99 |
* Date short representation |
*
*
* {@link NlsFormatterManager#TYPE_DATE date} |
* {@link NlsFormatterManager#STYLE_MEDIUM medium} |
* 31-Dec-1999 |
* Date medium representation |
*
*
* {@link NlsFormatterManager#TYPE_DATE date} |
* {@link NlsFormatterManager#STYLE_LONG long} |
* 31 December 1999 |
* Date long representation |
*
*
* {@link NlsFormatterManager#TYPE_DATE date} |
* {@link NlsFormatterManager#STYLE_FULL full} |
* Friday, 31 December 1999 |
* Date full representation |
*
*
* {@link NlsFormatterManager#TYPE_DATE date} |
* {@link NlsFormatterManager#STYLE_ISO_8601 iso8601} |
* 1999-12-31 |
* Date ISO-8601 representation |
*
*
* {@link NlsFormatterManager#TYPE_DATE date} |
* yyyy.MM.dd |
* 2010.01.01 |
* Any other style is treated as pattern for {@link java.text.SimpleDateFormat} |
*
*
* {@link NlsFormatterManager#TYPE_TIME time} |
* - |
* 23:59:59 |
* Time default representation |
*
*
* {@link NlsFormatterManager#TYPE_TIME time} |
* {@link NlsFormatterManager#STYLE_SHORT short} |
* 23:59 |
* Time short representation |
*
*
* {@link NlsFormatterManager#TYPE_TIME time} |
* {@link NlsFormatterManager#STYLE_MEDIUM medium} |
* 23:59:59 |
* Time medium representation |
*
*
* {@link NlsFormatterManager#TYPE_TIME time} |
* {@link NlsFormatterManager#STYLE_LONG long} |
* 23:59:59 GMT+01:00 |
* Time long representation |
*
*
* {@link NlsFormatterManager#TYPE_TIME time} |
* {@link NlsFormatterManager#STYLE_FULL full} |
* 23:59:59 o'clock GMT+01:00 |
* Time full representation |
*
*
* {@link NlsFormatterManager#TYPE_TIME time} |
* {@link NlsFormatterManager#STYLE_ISO_8601 iso8601} |
* 23:59:59+01:00 |
* Time ISO-8601 representation |
*
*
* {@link NlsFormatterManager#TYPE_TIME time} |
* HH:mm:ss |
* 23:59:59 |
* Any other style is treated as pattern for {@link java.text.SimpleDateFormat} |
*
* {@link NlsFormatterManager#TYPE_DATETIME datetime} |
* - |
* 31-Dec-1999 23:59:59 |
* Date+time default representation |
*
*
* {@link NlsFormatterManager#TYPE_DATETIME datetime} |
* {@link NlsFormatterManager#STYLE_SHORT short} |
* 31/12/99 23:59 |
* Date+time short representation |
*
*
* {@link NlsFormatterManager#TYPE_DATETIME datetime} |
* {@link NlsFormatterManager#STYLE_MEDIUM medium} |
* 31-Dec-1999 23:59:59 |
* Date+time medium representation |
*
*
* {@link NlsFormatterManager#TYPE_DATETIME datetime} |
* {@link NlsFormatterManager#STYLE_LONG long} |
* 31 December 1999 23:59:59 GMT+01:00 |
* Date+time long representation |
*
*
* {@link NlsFormatterManager#TYPE_DATETIME datetime} |
* {@link NlsFormatterManager#STYLE_FULL full} |
* Friday, 31 December 1999 23:59:59 o'clock GMT+01:00 |
* Date+time full representation |
*
*
* {@link NlsFormatterManager#TYPE_DATETIME datetime} |
* {@link NlsFormatterManager#STYLE_ISO_8601 iso8601} |
* 1999-12-31T23:59:59+01:00 |
* Date+time ISO-8601 representation |
*
*
* {@link NlsFormatterManager#TYPE_DATE date} |
* yyyy.MM.dd-HH:mm:ss |
* 2010.01.01-23:59:59 |
* Any other style is treated as pattern for {@link java.text.SimpleDateFormat} |
*
*
* {@link NlsFormatterManager#TYPE_TYPE type} |
* - |
* java.util.List |
* {@link java.lang.reflect.Type} medium representation (omit {@code java.lang}) |
*
*
* {@link NlsFormatterManager#TYPE_TYPE type} |
* {@link NlsFormatterManager#STYLE_SHORT short} |
* List |
* {@link java.lang.reflect.Type} short representation |
*
*
* {@link NlsFormatterManager#TYPE_TYPE type} |
* {@link NlsFormatterManager#STYLE_MEDIUM medium} |
* java.util.List |
* {@link java.lang.reflect.Type} medium representation (omit {@code java.lang}) |
*
*
* {@link NlsFormatterManager#TYPE_TYPE type} |
* {@link NlsFormatterManager#STYLE_LONG long} |
* java.util.List<String> |
* {@link java.lang.reflect.Type} long representation |
*
*
* {@link NlsFormatterManager#TYPE_TYPE type} |
* {@link NlsFormatterManager#STYLE_FULL full} |
* java.util.List<java.lang.String> |
* {@link java.lang.reflect.Type} full representation |
*
*
* {@link NlsFormatterManager#TYPE_CHOICE choice} |
* (?==1)'error'(else)'errors' |
* error |
* A choice to distinguish singular/plural forms. |
*
*
* {@link NlsFormatterManager#TYPE_CHOICE 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 {@link 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. |
*
*
*
* @author Joerg Hohwiller (hohwille at users.sourceforge.net)
* @since 2.0.0
*/
public class NlsArgument {
private final String key;
private final NlsFormatterPlugin formatter;
private final Justification justification;
/**
* The constructor.
*
* @param key is the {@link #getKey() key}.
* @param formatter is the {@link #getFormatter() formatter}.
* @param justification is the {@link #getJustification() justification}.
*/
public NlsArgument(String key, NlsFormatterPlugin formatter, Justification justification) {
super();
this.key = key;
this.formatter = formatter;
this.justification = justification;
}
/**
* This method gets the key of the argument to format.
*
* @return the key
*/
public String getKey() {
return this.key;
}
/**
* Is the formatter used to format the {@link #getKey() argument}.
*
* @return the formatter
*/
public NlsFormatterPlugin getFormatter() {
return this.formatter;
}
/**
* This method gets the optional {@link Justification}.
*
* @return the justification or {@code null} for none.
*/
public Justification getJustification() {
return this.justification;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(NlsArgumentParser.START_EXPRESSION);
sb.append(this.key);
if (!(this.formatter instanceof NlsFormatterDefault)) {
sb.append(NlsArgumentParser.FORMAT_SEPARATOR);
sb.append(this.formatter);
}
if (this.justification != null) {
sb.append(NlsArgumentParser.START_EXPRESSION);
sb.append(this.justification);
sb.append(NlsArgumentParser.END_EXPRESSION);
}
sb.append(NlsArgumentParser.END_EXPRESSION);
return sb.toString();
}
}