Examples of Argument


Examples of net.sourceforge.marathon.api.module.Argument

        List<Argument> arguments = function.getArguments();
        Assert.assertEquals(7, arguments.size());
        Assert.assertEquals("", function.getDocumentation());

        int constant = 0;
        Argument argument;

        argument = arguments.get(constant++);
        Assert.assertEquals("argNoDefault", argument.getName());

        argument = arguments.get(constant++);
        Assert.assertEquals("argString", argument.getName());
        Assert.assertEquals("string", argument.getDefault());
        // Assert.assertEquals(Type.STRING, argument.ge)

        argument = arguments.get(constant++);
        Assert.assertEquals("argInt", argument.getName());
        Assert.assertEquals("10", argument.getDefault());

        argument = arguments.get(constant++);
        Assert.assertEquals("argFloat", argument.getName());
        Assert.assertEquals("10.5", argument.getDefault());

        argument = arguments.get(constant++);
        Assert.assertEquals("argTuple", argument.getName());
        List<String> defaultList = argument.getDefaultList();
        Assert.assertNotNull(defaultList);
        Assert.assertEquals(2, defaultList.size());

        Assert.assertEquals("1", defaultList.get(0));
        Assert.assertEquals("2", defaultList.get(1));

        argument = arguments.get(constant++);
        Assert.assertEquals("argList", argument.getName());
        defaultList = argument.getDefaultList();
        Assert.assertNotNull(defaultList);
        Assert.assertEquals(2, defaultList.size());

        Assert.assertEquals("entry1", defaultList.get(0));
        Assert.assertEquals("entry2", defaultList.get(1));

        argument = arguments.get(constant++);
        Assert.assertEquals("argBool", argument.getName());
        Assert.assertNull(argument.getDefault());
    }
View Full Code Here

Examples of nexj.core.meta.Argument

               sArgName = sArgName.substring(0, sArgName.length() - 3);
            }

            try
            {
               m_event.addArgument(new Argument(sArgName));
            }
            catch (Throwable t)
            {
               error(m_methodDoc, "Could not add argument", t);
View Full Code Here

Examples of org.ajax4jsf.builder.model.Argument

*
*/
public class SimpleMutator extends JavaMethod {
 
  public SimpleMutator(String name, JavaField field) {
    super(name, new Argument(field.getName().substring(1), field.getType()));
    addModifier(JavaModifier.PUBLIC);
    setMethodBody(new SimpleMutatorMethodBody(this, field));
  }
View Full Code Here

Examples of org.apache.cocoon.components.flow.Interpreter.Argument

        }
        Object[] ids = parameters.getIds();
        list = new ArrayList();
        for (int i = 0; i < ids.length; i++) {
            String name = ids[i].toString();
            Argument arg = new Argument(name,
                                        org.mozilla.javascript.Context.toString(getProperty(parameters, name)));
            list.add(arg);
        }
        interpreter.handleContinuation(kontId, list, environment);
    }
View Full Code Here

Examples of org.apache.commons.cli2.Argument

    gBuilder.withOption(oBuilder.reset().withId(OPTION_QS).withShortName("qs").withLongName("querysilent").withDescription(
        "Silent Query the status of an NT service or Unix daemon").create());
    gBuilder.withOption(oBuilder.reset().withId(OPTION_QX).withShortName("qx").withLongName("queryposix").withDescription(
        "Query the status of a posix daemon. Return status as exit code").create());

    Argument pid = aBuilder.reset().withName(PID).withDescription("PID of process to reconnect to").withMinimum(1).withMaximum(1).withValidator(
        NumberValidator.getIntegerInstance()).create();

    gBuilder.withOption(oBuilder.reset().withId(OPTION_N).withShortName("n").withLongName("reconnect").withDescription(
        "recoNnect to existing application").withArgument(pid).create());

    Argument pid2 = aBuilder.reset().withName(PID).withDescription("PID of process to reconnect to").withMinimum(1).withMaximum(1).withValidator(
        NumberValidator.getIntegerInstance()).create();

    Argument defaultFile = aBuilder.reset().withName(DEFAULT_FILE).withDescription("Default Configuration File").withMinimum(0).withMaximum(1)
        .withValidator(VFSFileValidator.getExistingFileInstance().setBase(".")).create();
    /*
     * GroupBuilder childGbuilder = new GroupBuilder(); DefaultOptionBuilder
     * childoObuilder = new DefaultOptionBuilder("-", "--", true);
     *
 
View Full Code Here

Examples of org.apache.felix.gogo.commands.Argument

            for (Field field : type.getDeclaredFields()) {
                Option option = field.getAnnotation(Option.class);
                if (option != null) {
                    options.put(option, field);
                }
                Argument argument = field.getAnnotation(Argument.class);
                if (argument != null) {
                    if (Argument.DEFAULT.equals(argument.name())) {
                        final Argument delegate = argument;
                        final String name = field.getName();
                        argument = new Argument() {
                            public String name() {
                                return name;
                            }
                            public String description() {
                                return delegate.description();
                            }
                            public boolean required() {
                                return delegate.required();
                            }
                            public int index() {
                                return delegate.index();
                            }
                            public boolean multiValued() {
                                return delegate.multiValued();
                            }
                            public Class<? extends Annotation> annotationType() {
                                return delegate.annotationType();
                            }
                        };
                    }
                    arguments.put(argument, field);
                    int index = argument.index();
                    while (orderedArguments.size() <= index) {
                        orderedArguments.add(null);
                    }
                    if (orderedArguments.get(index) != null) {
                        throw new IllegalArgumentException("Duplicate argument index: " + index);
                    }
                    orderedArguments.set(index, argument);
                }
            }
        }
        // Check indexes are correct
        for (int i = 0; i < orderedArguments.size(); i++) {
            if (orderedArguments.get(i) == null) {
                throw new IllegalArgumentException("Missing argument for index: " + i);
            }
        }
        // Populate
        Map<Option, Object> optionValues = new HashMap<Option, Object>();
        Map<Argument, Object> argumentValues = new HashMap<Argument, Object>();
        boolean processOptions = true;
        int argIndex = 0;
        for (Iterator<Object> it = params.iterator(); it.hasNext();) {
            Object param = it.next();
            // Check for help
            if (HELP.name().equals(param) || Arrays.asList(HELP.aliases()).contains(param)) {
                printUsage(session, action, options, arguments, System.out);
                return false;
            }
            if (processOptions && param instanceof String && ((String) param).startsWith("-")) {
                boolean isKeyValuePair = ((String) param).indexOf('=') != -1;
                String name;
                Object value = null;
                if (isKeyValuePair) {
                    name = ((String) param).substring(0, ((String) param).indexOf('='));
                    value = ((String) param).substring(((String) param).indexOf('=') + 1);
                } else {
                    name = (String) param;
                }
                Option option = null;
                for (Option opt : options.keySet()) {
                    if (name.equals(opt.name()) || Arrays.asList(opt.aliases()).contains(name)) {
                        option = opt;
                        break;
                    }
                }
                if (option == null) {
                    Command command = action.getClass().getAnnotation(Command.class);
                    throw new CommandException(
                            Ansi.ansi()
                                    .fg(Ansi.Color.RED)
                                    .a("Error executing command ")
                                    .a(command.scope())
                                    .a(":")
                                    .a(Ansi.Attribute.INTENSITY_BOLD)
                                    .a(command.name())
                                    .a(Ansi.Attribute.INTENSITY_BOLD_OFF)
                                    .a(" undefined option ")
                                    .a(Ansi.Attribute.INTENSITY_BOLD)
                                    .a(param)
                                    .a(Ansi.Attribute.INTENSITY_BOLD_OFF)
                                    .fg(Ansi.Color.DEFAULT)
                                    .toString(),
                            "Undefined option: " + param
                    );
                }
                Field field = options.get(option);
                if (value == null && (field.getType() == boolean.class || field.getType() == Boolean.class)) {
                    value = Boolean.TRUE;
                }
                if (value == null && it.hasNext()) {
                    value = it.next();
                }
                if (value == null) {
                    Command command = action.getClass().getAnnotation(Command.class);
                    throw new CommandException(
                            Ansi.ansi()
                                    .fg(Ansi.Color.RED)
                                    .a("Error executing command ")
                                    .a(command.scope())
                                    .a(":")
                                    .a(Ansi.Attribute.INTENSITY_BOLD)
                                    .a(command.name())
                                    .a(Ansi.Attribute.INTENSITY_BOLD_OFF)
                                    .a(" missing value for option ")
                                    .a(Ansi.Attribute.INTENSITY_BOLD)
                                    .a(param)
                                    .a(Ansi.Attribute.INTENSITY_BOLD_OFF)
                                    .fg(Ansi.Color.DEFAULT)
                                    .toString(),
                            "Missing value for option: " + param
                    );
                }
                if (option.multiValued()) {
                    List<Object> l = (List<Object>) optionValues.get(option);
                    if (l == null) {
                        l = new ArrayList<Object>();
                        optionValues.put(option,  l);
                    }
                    l.add(value);
                } else {
                    optionValues.put(option, value);
                }
            } else {
                processOptions = false;
                if (argIndex >= orderedArguments.size()) {
                    Command command = action.getClass().getAnnotation(Command.class);
                    throw new CommandException(
                            Ansi.ansi()
                                    .fg(Ansi.Color.RED)
                                    .a("Error executing command ")
                                    .a(command.scope())
                                    .a(":")
                                    .a(Ansi.Attribute.INTENSITY_BOLD)
                                    .a(command.name())
                                    .a(Ansi.Attribute.INTENSITY_BOLD_OFF)
                                    .a(": too many arguments specified")
                                    .fg(Ansi.Color.DEFAULT)
                                    .toString(),
                            "Too many arguments specified"
                    );
                }
                Argument argument = orderedArguments.get(argIndex);
                if (!argument.multiValued()) {
                    argIndex++;
                }
                if (argument.multiValued()) {
                    List<Object> l = (List<Object>) argumentValues.get(argument);
                    if (l == null) {
                        l = new ArrayList<Object>();
                        argumentValues.put(argument, l);
                    }
                    l.add(param);
                } else {
                    argumentValues.put(argument, param);
                }
            }
        }
        // Check required arguments / options
        for (Option option : options.keySet()) {
            if (option.required() && optionValues.get(option) == null) {
                Command command = action.getClass().getAnnotation(Command.class);
                throw new CommandException(
                        Ansi.ansi()
                                .fg(Ansi.Color.RED)
                                .a("Error executing command ")
                                .a(command.scope())
                                .a(":")
                                .a(Ansi.Attribute.INTENSITY_BOLD)
                                .a(command.name())
                                .a(Ansi.Attribute.INTENSITY_BOLD_OFF)
                                .a(": option ")
                                .a(Ansi.Attribute.INTENSITY_BOLD)
                                .a(option.name())
                                .a(Ansi.Attribute.INTENSITY_BOLD_OFF)
                                .a(" is required")
                                .fg(Ansi.Color.DEFAULT)
                                .toString(),
                        "Option " + option.name() + " is required"
                );
            }
        }
        for (Argument argument : arguments.keySet()) {
            if (argument.required() && argumentValues.get(argument) == null) {
                Command command = action.getClass().getAnnotation(Command.class);
                throw new CommandException(
                        Ansi.ansi()
                                .fg(Ansi.Color.RED)
                                .a("Error executing command ")
                                .a(command.scope())
                                .a(":")
                                .a(Ansi.Attribute.INTENSITY_BOLD)
                                .a(command.name())
                                .a(Ansi.Attribute.INTENSITY_BOLD_OFF)
                                .a(": argument ")
                                .a(Ansi.Attribute.INTENSITY_BOLD)
                                .a(argument.name())
                                .a(Ansi.Attribute.INTENSITY_BOLD_OFF)
                                .a(" is required")
                                .fg(Ansi.Color.DEFAULT)
                                .toString(),
                        "Argument " + argument.name() + " is required"
                );
            }
        }
        // Convert and inject values
        for (Map.Entry<Option, Object> entry : optionValues.entrySet()) {
View Full Code Here

Examples of org.apache.imperius.spl.core.Argument

      if (arguments.size() != 0) {
        List paramValues = new ArrayList();
        Iterator it = arguments.iterator();
        // Iterate over the passed parameters
        while (it.hasNext()) {
          Argument arg = (Argument) it.next();
          //Add the values of the passed parameters to a list
          paramValues.add(arg.getValue());
        }

        // Convert list to an array
        Object[] arrayOfParameters = paramValues.toArray();
View Full Code Here

Examples of org.apache.jackrabbit.standalone.cli.Argument

        out.print(desc.getName() + " ");

        // Arguments
        Iterator iter = desc.getArguments().values().iterator();
        while (iter.hasNext()) {
            Argument arg = (Argument) iter.next();
            out.print("<" + arg.getLocalizedArgName() + "> ");
        }

        // Options
        iter = desc.getOptions().values().iterator();
        while (iter.hasNext()) {
            Option arg = (Option) iter.next();
            out.print("-" + arg.getName() + " <" + arg.getLocalizedArgName()
                    + "> ");
        }

        // flags
        iter = desc.getFlags().values().iterator();
        while (iter.hasNext()) {
            Flag arg = (Flag) iter.next();
            out.print("-" + arg.getName() + " ");
        }
        out.println();

        // Alias
        if (desc.getAlias().size() > 0) {
View Full Code Here

Examples of org.apache.jmeter.config.Argument

            HtmlParsingUtils.getDOM("<HTML></HTML>");
            HtmlParsingUtils.getDOM("");
        }

        public void testIsArgumentMatched() throws Exception {
            Argument arg = new Argument();
            Argument argp = new Argument();
            assertTrue(HtmlParsingUtils.isArgumentMatched(arg, argp));

            arg = new Argument("test", "abcd");
            argp = new Argument("test", "a.*d");
            assertTrue(HtmlParsingUtils.isArgumentMatched(arg, argp));

            arg = new Argument("test", "abcd");
            argp = new Argument("test", "a.*e");
            assertFalse(HtmlParsingUtils.isArgumentMatched(arg, argp));
        }
View Full Code Here

Examples of org.apache.jmeter.config.Argument

        assertEquals("file1", file.getPath());
        assertEquals("param1", file.getParamName());
        assertEquals("text/plain", file.getMimeType());
        Arguments args = muc.getArguments();
        assertEquals(3, args.getArgumentCount());
        Argument arg = args.getArgument(0);
        assertEquals("aa", arg.getName());
        assertEquals("bb", arg.getValue());
        arg = args.getArgument(1);
        assertEquals("xx", arg.getName());
        assertEquals("yy", arg.getValue());
        arg = args.getArgument(2);
        assertEquals("abc", arg.getName());
        assertEquals("xyz  \nxyz  ", arg.getValue());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.