當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。