本文整理汇总了Java中org.cubeengine.dirigent.context.Context.get方法的典型用法代码示例。如果您正苦于以下问题:Java Context.get方法的具体用法?Java Context.get怎么用?Java Context.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.cubeengine.dirigent.context.Context
的用法示例。
在下文中一共展示了Context.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseFormatter
import org.cubeengine.dirigent.context.Context; //导入方法依赖的package包/类
/**
* Parses the {@link NumberFormat} to use from the context arguments.
*
* @param context The context.
* @param args The arguments of the macro.
*
* @return the {@link NumberFormat}.
*/
private NumberFormat parseFormatter(Context context, Arguments args)
{
final String format = args.get(FORMAT_PARAM_NAME);
final Locale locale = context.get(LOCALE);
if (format != null)
{
return new DecimalFormat(format, DecimalFormatSymbols.getInstance(locale));
}
final Mode mode = Mode.loadFromContext(args, this.defaultMode);
if (Mode.INTEGER.equals(mode))
{
return NumberFormat.getIntegerInstance(locale);
}
if (Mode.CURRENCY.equals(mode))
{
return NumberFormat.getCurrencyInstance(locale);
}
if (Mode.PERCENT.equals(mode))
{
return NumberFormat.getPercentInstance(locale);
}
return NumberFormat.getInstance(locale);
}
示例2: parseFormatter
import org.cubeengine.dirigent.context.Context; //导入方法依赖的package包/类
/**
* Parses the {@link DateFormat} to use from the context arguments.
*
* @param context The context.
* @param args The arguments of the macro.
*
* @return the {@link DateFormat}.
*/
private DateFormat parseFormatter(Context context, Arguments args)
{
final String format = args.get(FORMAT_PARAM_NAME);
final Locale locale = context.get(LOCALE);
if (format != null)
{
return new SimpleDateFormat(format, locale);
}
final int defaultFormatStyle = parseDateFormatStyle(args);
final int dateFormatStyle = parseDateFormatStyle(args.get(DATE_PARAM_NAME), defaultFormatStyle);
final int timeFormatStyle = parseDateFormatStyle(args.get(TIME_PARAM_NAME), defaultFormatStyle);
if (Mode.DATE_TIME.equals(mode))
{
return DateFormat.getDateTimeInstance(dateFormatStyle, timeFormatStyle, locale);
}
else if (Mode.DATE.equals(mode))
{
return DateFormat.getDateInstance(dateFormatStyle, locale);
}
else if (Mode.TIME.equals(mode))
{
return DateFormat.getTimeInstance(timeFormatStyle, locale);
}
return DateFormat.getInstance();
}
示例3: parseNumberToString
import org.cubeengine.dirigent.context.Context; //导入方法依赖的package包/类
/**
* Parses the given number to a string depending on the context.
*
* @param number The number to parse.
* @param context The context to use.
* @param args The arguments of the macro.
*
* @return The number as a string.
*/
protected String parseNumberToString(Number number, Context context, Arguments args)
{
final NumberFormat numberFormat = parseFormatter(context, args);
final Currency currency = context.get(Contexts.CURRENCY);
if (currency != null)
{
numberFormat.setCurrency(currency);
}
return numberFormat.format(number);
}
示例4: test
import org.cubeengine.dirigent.context.Context; //导入方法依赖的package包/类
@Format
public Component test(String string, Context context)
{
return new Text(string + context.get(Contexts.LOCALE));
}