Package org.glassfish.api.admin.CommandModel

Examples of org.glassfish.api.admin.CommandModel.ParamModel


     * based on the --interactive option.
     */
    protected Collection<ParamModel> usageOptions() {
        Collection<ParamModel> opts = commandModel.getParameters();
        Set<ParamModel> uopts = new LinkedHashSet<ParamModel>();
        ParamModel p = new CommandModelData.ParamModelData("printprompt",
                boolean.class, true, Boolean.toString(programOpts.isInteractive()));
        for (ParamModel pm : opts) {
            if (pm.getName().equals("printprompt"))
                uopts.add(p);
            else
View Full Code Here


     * @param req   is option required?
     * @param def   default value for option
     */
    private static void addMetaOption(Set<ParamModel> opts, String name,
            char sname, Class type, boolean req, String def) {
        ParamModel opt = new ParamModelData(name, type, !req, def,
                                                Character.toString(sname));
        opts.add(opt);
    }
View Full Code Here

    @Override
    protected void prevalidate() throws CommandException {
        try {
            //Copy date from interactive part of
            if (reExecutedOperands != null && !reExecutedOperands.isEmpty()) {
                ParamModel operandModel = getOperandModel();
                if (operandModel != null && !operandModel.getParam().optional()) {
                    if (operands == null) {
                        operands = new ArrayList<String>(reExecutedOperands.size());
                    }
                    if (reExecutedOperands.size() > operands.size()) {
                        if (operandModel.getParam().multiple()) {
                            for (String str : reExecutedOperands) {
                                if (!operands.contains(str)) {
                                    operands.add(str);
                                }
                            }
View Full Code Here

    @Override
    protected void prevalidate() throws CommandException {
        try {
            //Copy date from interactive part of
            if (reExecutedOperands != null && !reExecutedOperands.isEmpty()) {
                ParamModel operandModel = getOperandModel();
                if (operandModel != null && !operandModel.getParam().optional()) {
                    if (operands == null) {
                        operands = new ArrayList<String>(reExecutedOperands.size());
                    }
                    if (reExecutedOperands.size() > operands.size()) {
                        if (operandModel.getParam().multiple()) {
                            for (String str : reExecutedOperands) {
                                if (!operands.contains(str)) {
                                    operands.add(str);
                                }
                            }
View Full Code Here

        }
        usageText.append(helpText);
        len += helpText.length();

        optText.setLength(0);
        ParamModel operandParam = getOperandModel();
        String opname = operandParam != null ?
        lc(operandParam.getName()) : null;
        if (!ok(opname))
            opname = "operand";

        int operandMin = 0;
        int operandMax = 0;
        if (operandParam != null) {
            operandMin = operandParam.getParam().optional() ? 0 : 1;
            operandMax = operandParam.getParam().multiple() ?
                                                        Integer.MAX_VALUE : 1;
        }
        if (operandMax > 0) {
            if (operandMin == 0) {
                optText.append("[").append(opname);
View Full Code Here

                        ProgramOptions.getValidOptions();
                StringBuilder sb = new StringBuilder();
                sb.append(programOpts.getCommandName());
                for (Map.Entry<String,List<String>> p : params.entrySet()) {
                    // find the corresponding ParamModel
                    ParamModel opt = null;
                    for (ParamModel vo : programOptions) {
                        if (vo.getName().equalsIgnoreCase(p.getKey())) {
                            opt = vo;
                            break;
                        }
                    }
                    if (opt == null) {
                        continue;
                    }

                    // format the option appropriately
                    sb.append(" --").append(p.getKey());
                    List<String> pl = p.getValue();
                    // XXX - won't handle multi-values
                    if (opt.getType() == Boolean.class ||
                        opt.getType() == boolean.class) {
                        if (!pl.get(0).equalsIgnoreCase("true")) {
                            sb.append("=false");
                        }
                    } else if (pl != null && pl.size() > 0) {
                        sb.append(" ").append(pl.get(0));
View Full Code Here

            throw new CommandValidationException(
                    strings.get("missingOptions", name));

        int operandMin = 0;
        int operandMax = 0;
        ParamModel operandParam = getOperandModel();
        if (operandParam != null) {
            operandMin = operandParam.getParam().optional() ? 0 : 1;
            operandMax = operandParam.getParam().multiple() ?
                                                        Integer.MAX_VALUE : 1;
        }

        if (operands.size() < operandMin && cons != null) {
            cons.printf("%s",
                strings.get("operandPrompt", operandParam.getName()));
            String val = cons.readLine();
            if (ok(val)) {
                operands = new ArrayList<String>();
                operands.add(val);
            }
        }
        if (operands.size() < operandMin)
            throw new CommandValidationException(
                    strings.get("notEnoughOperands", name,
                                operandParam.getType()));
        if (operands.size() > operandMax) {
            if (operandMax == 0)
                throw new CommandValidationException(
                    strings.get("noOperandsAllowed", name));
            else if (operandMax == 1)
View Full Code Here

        if (val == null) {
            val = env.getStringOption(name);
        }
        if (val == null) {
            // no value, find the default
            ParamModel opt = commandModel.getModelFor(name);
            // if no value was specified and there's a default value, return it
            if (opt != null) {
                String def = opt.getParam().defaultValue();
                if (ok(def)) {
                    val = def;
                }
            }
        }
View Full Code Here

                val.add(v);
            }
        }
        if (val.isEmpty()) {
            // no value, find the default
            ParamModel opt = commandModel.getModelFor(name);
            // if no value was specified and there's a default value, return it
            if (opt != null) {
                String def = opt.getParam().defaultValue();
                if (ok(def)) {
                    val.add(def);
                }
            }
        }
View Full Code Here

    @Override
    protected void prevalidate() throws CommandException {
        try {
            //Copy date from interactive part of
            if (reExecutedOperands != null && !reExecutedOperands.isEmpty()) {
                ParamModel operandModel = getOperandModel();
                if (operandModel != null && !operandModel.getParam().optional()) {
                    if (operands == null) {
                        operands = new ArrayList<String>(reExecutedOperands.size());
                    }
                    if (reExecutedOperands.size() > operands.size()) {
                        if (operandModel.getParam().multiple()) {
                            for (String str : reExecutedOperands) {
                                if (!operands.contains(str)) {
                                    operands.add(str);
                                }
                            }
View Full Code Here

TOP

Related Classes of org.glassfish.api.admin.CommandModel.ParamModel

Copyright © 2018 www.massapicom. 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.