当前位置: 首页>>代码示例>>Java>>正文


Java Arguments类代码示例

本文整理汇总了Java中org.cubeengine.dirigent.context.Arguments的典型用法代码示例。如果您正苦于以下问题:Java Arguments类的具体用法?Java Arguments怎么用?Java Arguments使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Arguments类属于org.cubeengine.dirigent.context包,在下文中一共展示了Arguments类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseDateFormatStyle

import org.cubeengine.dirigent.context.Arguments; //导入依赖的package包/类
/**
 * Parses the default style of the {@link DateFormat} from context labels.
 *
 * @param args The arguments of the macro.
 *
 * @return The id of the style.
 */
private int parseDateFormatStyle(Arguments args)
{
    if (args.has(SHORT_STYLE))
    {
        return DateFormat.SHORT;
    }
    else if (args.has(MEDIUM_STYLE))
    {
        return DateFormat.MEDIUM;
    }
    else if (args.has(LONG_STYLE))
    {
        return DateFormat.LONG;
    }
    else if (args.has(FULL_STYLE))
    {
        return DateFormat.FULL;
    }
    return DateFormat.DEFAULT;
}
 
开发者ID:CubeEngine,项目名称:Dirigent,代码行数:28,代码来源:DateTimeFormatter.java

示例2: parseFormatter

import org.cubeengine.dirigent.context.Arguments; //导入依赖的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);
}
 
开发者ID:CubeEngine,项目名称:Dirigent,代码行数:33,代码来源:NumberFormatter.java

示例3: loadFromContext

import org.cubeengine.dirigent.context.Arguments; //导入依赖的package包/类
/**
 * Loads the mode from the formatter context or returns the default mode if the context doesn't specify one.
 *
 * @param args The arguments of the macro.
 * @param defaultMode The default mode.
 *
 * @return the loaded mode.
 */
private static Mode loadFromContext(Arguments args, Mode defaultMode)
{
    if (args.has(INTEGER_MODE_FLAG))
    {
        return INTEGER;
    }
    if (args.has(CURRENCY_MODE_FLAG))
    {
        return CURRENCY;
    }
    if (args.has(PERCENT_MODE_FLAG))
    {
        return PERCENT;
    }
    return defaultMode;
}
 
开发者ID:CubeEngine,项目名称:Dirigent,代码行数:25,代码来源:NumberFormatter.java

示例4: checkFormat

import org.cubeengine.dirigent.context.Arguments; //导入依赖的package包/类
private void checkFormat(final String expected, final Object object, final Locale locale, final String flag)
{
    final Arguments arguments;
    if (flag == null)
    {
        arguments = Arguments.NONE;
    }
    else
    {
        arguments = toArgs(arg(flag));
    }

    final Component component = stringFormatter.format(object, createContext(locale), arguments);

    Assert.assertTrue(component instanceof Text);
    Assert.assertEquals(expected, ((Text)component).getText());
}
 
开发者ID:CubeEngine,项目名称:Dirigent,代码行数:18,代码来源:StringFormatterTest.java

示例5: checkFormat

import org.cubeengine.dirigent.context.Arguments; //导入依赖的package包/类
private void checkFormat(final String expected, final Locale locale, final String argument)
{
    final Arguments arguments;
    if (argument == null)
    {
        arguments = Arguments.NONE;
    }
    else
    {
        arguments = toArgs(arg(argument));
    }

    final Component component = staticTextFormatter.format(createContext(locale), arguments);

    Assert.assertTrue(component instanceof Text);
    Assert.assertEquals(expected, ((Text)component).getText());
}
 
开发者ID:CubeEngine,项目名称:Dirigent,代码行数:18,代码来源:StaticTextFormatterTest.java

示例6: createArguments

import org.cubeengine.dirigent.context.Arguments; //导入依赖的package包/类
private Arguments createArguments(final String defaultStyle, final String dateStyle, final String timeStyle,
                                  final String format)
{
    final List<Object> arguments = new ArrayList<Object>();

    if (defaultStyle != null)
    {
        arguments.add(arg(defaultStyle));
    }
    if (dateStyle != null)
    {
        arguments.add(arg(DateTimeFormatter.DATE_PARAM_NAME, dateStyle));
    }
    if (timeStyle != null)
    {
        arguments.add(arg(DateTimeFormatter.TIME_PARAM_NAME, timeStyle));
    }
    if (format != null)
    {
        arguments.add(arg(DateTimeFormatter.FORMAT_PARAM_NAME, format));
    }

    return toArgs(arguments.toArray());
}
 
开发者ID:CubeEngine,项目名称:Dirigent,代码行数:25,代码来源:AbstractDateTimeFormatterTest.java

示例7: toArgs

import org.cubeengine.dirigent.context.Arguments; //导入依赖的package包/类
public static Arguments toArgs(Object... args)
{
    List<String> values = new ArrayList<String>();
    Map<String, String> params = new HashMap<String, String>();
    for (final Object arg : args)
    {
        if (arg instanceof String)
        {
            values.add((String)arg);
        }
        else
        {
            String[] pair = (String[])arg;
            params.put(pair[0].toLowerCase(), pair[1]);
        }
    }
    return Arguments.create(values, params);
}
 
开发者ID:CubeEngine,项目名称:Dirigent,代码行数:19,代码来源:TestHelper.java

示例8: testFormatWithPrio

import org.cubeengine.dirigent.context.Arguments; //导入依赖的package包/类
@Test
public void testFormatWithPrio() {
    final TypeImpl typeImpl = new TypeImpl();
    Formatter<Object> formatter = new PrioFormatter();

    Component component = formatter.process(typeImpl, Contexts.EMPTY, Arguments.NONE);
    Assert.assertTrue(component instanceof TextComponent);
    Assert.assertEquals(typeImpl.getText(), ((TextComponent)component).getText());

    component = formatter.process(new Type2()
    {
        @Override
        public int getNumber()
        {
            return 34;
        }
    }, Contexts.EMPTY, Arguments.NONE);
    Assert.assertTrue(component instanceof TextComponent);
    Assert.assertEquals("34", ((TextComponent)component).getText());
}
 
开发者ID:CubeEngine,项目名称:Dirigent,代码行数:21,代码来源:ReflectedFormatterTest.java

示例9: parseArguments

import org.cubeengine.dirigent.context.Arguments; //导入依赖的package包/类
private static Arguments parseArguments(State s)
{
    List<String> values = null;
    Map<String, String> params = null;
    while (is(s, SECTION_SEP))
    {
        // skip SECTION_SEP
        ++s.offset;

        final String name = readUntil(s, PARAM_NAME_FOLLOW, false);
        if (is(s, VALUE_SEP))
        {
            // skip VALUE_SEP
            ++s.offset;
            if (name.isEmpty())
            {
                return null;
            }
            else
            {
                if (params == null)
                {
                    params = new HashMap<String, String>(1);
                }
                params.put(name.toLowerCase(), readUntil(s, SECTION_FOLLOW, false));
            }
        }
        else
        {
            if (values == null)
            {
                values = new ArrayList<String>(1);
            }
            values.add(name);
        }
    }
    return Arguments.create(values, params);
}
 
开发者ID:CubeEngine,项目名称:Dirigent,代码行数:39,代码来源:Parser.java

示例10: parseObjectToString

import org.cubeengine.dirigent.context.Arguments; //导入依赖的package包/类
/**
 * Parses the given object to a string depending on the context.
 *
 * @param object The object to parse.
 * @param locale The locale to use.
 *
 * @return The object as a string.
 */
protected String parseObjectToString(Object object, Locale locale, Arguments args)
{
    final String string = String.valueOf(object);
    if (args.has(LOWERCASE_FLAG))
    {
        return string.toLowerCase(locale);
    }
    if (args.has(UPPERCASE_FLAG))
    {
        return string.toUpperCase(locale);
    }
    return string;
}
 
开发者ID:CubeEngine,项目名称:Dirigent,代码行数:22,代码来源:StringFormatter.java

示例11: parseFormatter

import org.cubeengine.dirigent.context.Arguments; //导入依赖的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();
}
 
开发者ID:CubeEngine,项目名称:Dirigent,代码行数:36,代码来源:DateTimeFormatter.java

示例12: parseNumberToString

import org.cubeengine.dirigent.context.Arguments; //导入依赖的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);
}
 
开发者ID:CubeEngine,项目名称:Dirigent,代码行数:22,代码来源:NumberFormatter.java

示例13: format

import org.cubeengine.dirigent.context.Arguments; //导入依赖的package包/类
@Override
protected Component format(final Object input, Context context, Arguments args)
{
    final Class<?> inputClass = input.getClass();
    final List<Formatter> candidates = new ArrayList<Formatter>();
    for (Entry<Class<?>, Formatter> entry : formats.entrySet())
    {
        Class<?> formatterClass = entry.getKey();
        if (inputClass == formatterClass)
        {
            // exact match will be used directly
            return this.formats.get(formatterClass).format(input, context, args);
        }
        else if (formatterClass.isAssignableFrom(inputClass))
        {
            candidates.add(entry.getValue());
        }
    }
    if (candidates.isEmpty())
    {
        return null;
    }
    Collections.sort(candidates, new Comparator<ReflectedFormatter.Formatter>()
    {
        @Override
        public int compare(ReflectedFormatter.Formatter a, ReflectedFormatter.Formatter b)
        {
            // sort descending, so the highest priority value will be first.
            return b.prio - a.prio;
        }
    });
    return candidates.get(0).format(input, context, args);
}
 
开发者ID:CubeEngine,项目名称:Dirigent,代码行数:34,代码来源:ReflectedFormatter.java

示例14: applyPostProcessors

import org.cubeengine.dirigent.context.Arguments; //导入依赖的package包/类
/**
 * Executes all attached {@link PostProcessor}s to process the specified {@link Component}.
 *
 * @param in The component to process.
 * @param context The compose context.
 * @param args The macro arguments.
 *
 * @return The processed component.
 */
private Component applyPostProcessors(Component in, Context context, Arguments args)
{
    Component out = in;

    for (final PostProcessor postProcessor : postProcessors)
    {
        out = postProcessor.process(out, context, args);
    }

    return out;
}
 
开发者ID:CubeEngine,项目名称:Dirigent,代码行数:21,代码来源:AbstractDirigent.java

示例15: checkFormat

import org.cubeengine.dirigent.context.Arguments; //导入依赖的package包/类
private void checkFormat(final String expected, final Number number, final Locale locale)
{
    final Component component = currencyFormatter.format(number, createContext(locale), Arguments.NONE);

    Assert.assertTrue(component instanceof Text);
    Assert.assertEquals(expected, ((Text)component).getText());
}
 
开发者ID:CubeEngine,项目名称:Dirigent,代码行数:8,代码来源:CurrencyFormatterTest.java


注:本文中的org.cubeengine.dirigent.context.Arguments类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。