Package com.cybozu.vmbkp.util

Examples of com.cybozu.vmbkp.util.Option


        /* Initialize member variables. */
        initializeRestArgs();
        initializeOptionMap();
       
        int idx = 0;
        Option opt = null;
       
        while (idx < args.length) {
            if ((opt = parseOption(args, idx)) != null) {
                /* Parsed a option. */
                idx = opt.nextIdx;
View Full Code Here


     * @param optStr Option string.
     * @param argc The number of arguments for the option.
     */
    protected void registerOption(String optStr, int argc)
    {
        optionMap_.put(optStr, new Option(optStr, argc));
    }
View Full Code Here

    private Option parseOption(String[] args, int idx)
        throws Exception
    {
        assert(idx < args.length);

        Option opt = null;
        for (Map.Entry<String,Option> entry: optionMap_.entrySet()) {
            if (args[idx].equals(entry.getKey())) {

                opt = entry.getValue();
                idx ++;

                /* Get arguments of the option */
                for (int i = 0; i < opt.getArgc(); i ++) {
                    if (i < args.length == false) {
                        logger_.warning
                            (String.format
                             ("The option %s requires more arguments.",
                              opt.getOpt()));
                        throw new Exception();
                    }

                    opt.addArg(args[idx ++]);
                }
               
                opt.nextIdx = idx;
                break;
            }
View Full Code Here

     *
     * @return If the optStr option is specified
     */
    public boolean isOption(String optStr)
    {
        Option opt = getOption(optStr);
        return (opt != null && opt.isSpecified());
    }
View Full Code Here

     *
     * @return May return empty list, never null.
     */
    public List<String> getOptionArgs(String optStr)
    {
        Option opt = getOption(optStr);
        if (opt == null || opt.isValid() == false) {
            return new LinkedList<String>();
        } else {
            return opt.getArgs();
        }
    }
View Full Code Here

     */
    public String toStringAllOptions(String interval)
    {
        StringBuffer sb = new StringBuffer();
        for (Map.Entry<String,Option> entry: optionMap_.entrySet()) {
            Option opt = entry.getValue();
            if (opt.isSpecified()) {
                sb.append(opt.toString());
                if (interval != null) { sb.append(interval); }
            }
        }
        return sb.toString();
    }
View Full Code Here

     */
    public boolean isValid()
    {
        boolean isAllValid = true;
        for (Map.Entry<String,Option> entry: optionMap_.entrySet()) {
            Option opt = entry.getValue();
            if (opt.isSpecified() && opt.isValid() == false) {
                isAllValid = false;
                logger_.warning(opt.toString());
                break;
            }
        }
        return isAllValid;
    }
View Full Code Here

    private String getConfigPath(String optStr, String defaultPath)
    {
        String path = null;
       
        if (isOption(optStr)) {
            Option opt = super.getOption(optStr);
            if (opt.isValid()) {
                path = opt.getArgs().get(0);
            } else {
                logger_.warning("option invalid: " + opt.toString());
            }
        }

        if (path == null) {
            logger_.info(String.format
View Full Code Here

TOP

Related Classes of com.cybozu.vmbkp.util.Option

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.