Java Code Examples for jdk.nashorn.internal.runtime.QuotedStringTokenizer#hasMoreTokens()

The following examples show how to use jdk.nashorn.internal.runtime.QuotedStringTokenizer#hasMoreTokens() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Options.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
ParsedArg(final String argument) {
    final QuotedStringTokenizer st = new QuotedStringTokenizer(argument, "=");
    if (!st.hasMoreTokens()) {
        throw new IllegalArgumentException();
    }

    final String token = st.nextToken();
    this.template = getOptionTemplateByName(token);
    if (this.template == null) {
        throw new IllegalArgumentException(argument);
    }

    value = "";
    if (st.hasMoreTokens()) {
        while (st.hasMoreTokens()) {
            value += st.nextToken();
            if (st.hasMoreTokens()) {
                value += ':';
            }
        }
    } else if ("boolean".equals(this.template.getType())) {
        value = "true";
    }
}
 
Example 2
Source File: Options.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
ParsedArg(final String argument) {
    final QuotedStringTokenizer st = new QuotedStringTokenizer(argument, "=");
    if (!st.hasMoreTokens()) {
        throw new IllegalArgumentException();
    }

    final String token = st.nextToken();
    this.template = Options.getOptionTemplate(token);
    if (this.template == null) {
        throw new IllegalArgumentException(argument);
    }

    value = "";
    if (st.hasMoreTokens()) {
        while (st.hasMoreTokens()) {
            value += st.nextToken();
            if (st.hasMoreTokens()) {
                value += ':';
            }
        }
    } else if ("boolean".equals(this.template.getType())) {
        value = "true";
    }
}
 
Example 3
Source File: Options.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
ParsedArg(final String argument) {
    final QuotedStringTokenizer st = new QuotedStringTokenizer(argument, "=");
    if (!st.hasMoreTokens()) {
        throw new IllegalArgumentException();
    }

    final String token = st.nextToken();
    this.template = Options.getOptionTemplate(token);
    if (this.template == null) {
        throw new IllegalArgumentException(argument);
    }

    value = "";
    if (st.hasMoreTokens()) {
        while (st.hasMoreTokens()) {
            value += st.nextToken();
            if (st.hasMoreTokens()) {
                value += ':';
            }
        }
    } else if ("boolean".equals(this.template.getType())) {
        value = "true";
    }
}
 
Example 4
Source File: Options.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
ParsedArg(final String argument) {
    final QuotedStringTokenizer st = new QuotedStringTokenizer(argument, "=");
    if (!st.hasMoreTokens()) {
        throw new IllegalArgumentException();
    }

    final String token = st.nextToken();
    this.template = getOptionTemplateByName(token);
    if (this.template == null) {
        throw new IllegalArgumentException(argument);
    }

    value = "";
    if (st.hasMoreTokens()) {
        while (st.hasMoreTokens()) {
            value += st.nextToken();
            if (st.hasMoreTokens()) {
                value += ':';
            }
        }
    } else if ("boolean".equals(this.template.getType())) {
        value = "true";
    }
}
 
Example 5
Source File: Options.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
ParsedArg(final String argument) {
    final QuotedStringTokenizer st = new QuotedStringTokenizer(argument, "=");
    if (!st.hasMoreTokens()) {
        throw new IllegalArgumentException();
    }

    final String token = st.nextToken();
    this.template = getOptionTemplateByName(token);
    if (this.template == null) {
        throw new IllegalArgumentException(argument);
    }

    value = "";
    if (st.hasMoreTokens()) {
        while (st.hasMoreTokens()) {
            value += st.nextToken();
            if (st.hasMoreTokens()) {
                value += ':';
            }
        }
    } else if ("boolean".equals(this.template.getType())) {
        value = "true";
    }
}
 
Example 6
Source File: Options.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
ParsedArg(final String argument) {
    final QuotedStringTokenizer st = new QuotedStringTokenizer(argument, "=");
    if (!st.hasMoreTokens()) {
        throw new IllegalArgumentException();
    }

    final String token = st.nextToken();
    this.template = getOptionTemplateByName(token);
    if (this.template == null) {
        throw new IllegalArgumentException(argument);
    }

    value = "";
    if (st.hasMoreTokens()) {
        while (st.hasMoreTokens()) {
            value += st.nextToken();
            if (st.hasMoreTokens()) {
                value += ':';
            }
        }
    } else if ("boolean".equals(this.template.getType())) {
        value = "true";
    }
}
 
Example 7
Source File: Options.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
ParsedArg(final String argument) {
    final QuotedStringTokenizer st = new QuotedStringTokenizer(argument, "=");
    if (!st.hasMoreTokens()) {
        throw new IllegalArgumentException();
    }

    final String token = st.nextToken();
    this.template = getOptionTemplateByName(token);
    if (this.template == null) {
        throw new IllegalArgumentException(argument);
    }

    value = "";
    if (st.hasMoreTokens()) {
        while (st.hasMoreTokens()) {
            value += st.nextToken();
            if (st.hasMoreTokens()) {
                value += ':';
            }
        }
    } else if ("boolean".equals(this.template.getType())) {
        value = "true";
    }
}
 
Example 8
Source File: Options.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
ParsedArg(final String argument) {
    final QuotedStringTokenizer st = new QuotedStringTokenizer(argument, "=");
    if (!st.hasMoreTokens()) {
        throw new IllegalArgumentException();
    }

    final String token = st.nextToken();
    this.template = getOptionTemplateByName(token);
    if (this.template == null) {
        throw new IllegalArgumentException(argument);
    }

    value = "";
    if (st.hasMoreTokens()) {
        while (st.hasMoreTokens()) {
            value += st.nextToken();
            if (st.hasMoreTokens()) {
                value += ':';
            }
        }
    } else if ("boolean".equals(this.template.getType())) {
        value = "true";
    }
}
 
Example 9
Source File: Options.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
ParsedArg(final String argument) {
    final QuotedStringTokenizer st = new QuotedStringTokenizer(argument, "=");
    if (!st.hasMoreTokens()) {
        throw new IllegalArgumentException();
    }

    final String token = st.nextToken();
    this.template = Options.getOptionTemplate(token);
    if (this.template == null) {
        throw new IllegalArgumentException(argument);
    }

    value = "";
    if (st.hasMoreTokens()) {
        while (st.hasMoreTokens()) {
            value += st.nextToken();
            if (st.hasMoreTokens()) {
                value += ':';
            }
        }
    } else if ("boolean".equals(this.template.getType())) {
        value = "true";
    }
}
 
Example 10
Source File: Options.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
ParsedArg(final String argument) {
    final QuotedStringTokenizer st = new QuotedStringTokenizer(argument, "=");
    if (!st.hasMoreTokens()) {
        throw new IllegalArgumentException();
    }

    final String token = st.nextToken();
    this.template = Options.getOptionTemplate(token);
    if (this.template == null) {
        throw new IllegalArgumentException(argument);
    }

    value = "";
    if (st.hasMoreTokens()) {
        while (st.hasMoreTokens()) {
            value += st.nextToken();
            if (st.hasMoreTokens()) {
                value += ':';
            }
        }
    } else if ("boolean".equals(this.template.getType())) {
        value = "true";
    }
}
 
Example 11
Source File: OptionTemplate.java    From nashorn with GNU General Public License v2.0 4 votes vote down vote up
private void parse(final String origValue) {
    String value = origValue.trim();

    try {
        value = OptionTemplate.strip(value, '{', '}');
        final QuotedStringTokenizer keyValuePairs = new QuotedStringTokenizer(value, ",");

        while (keyValuePairs.hasMoreTokens()) {
            final String                keyValue = keyValuePairs.nextToken();
            final QuotedStringTokenizer st       = new QuotedStringTokenizer(keyValue, "=");
            final String                keyToken = st.nextToken();
            final String                arg      = st.nextToken();

            switch (keyToken) {
            case "is_undocumented":
                this.isUndocumented = Boolean.parseBoolean(arg);
                break;
            case "name":
                if (!arg.startsWith("-")) {
                    throw new IllegalArgumentException(arg);
                }
                this.name = arg;
                break;
            case "short_name":
                if (!arg.startsWith("-")) {
                    throw new IllegalArgumentException(arg);
                }
                this.shortName = arg;
                break;
            case "desc":
                this.description = arg;
                break;
            case "params":
                this.params = arg;
                break;
            case "type":
                this.type = arg.toLowerCase(Locale.ENGLISH);
                break;
            case "default":
                this.defaultValue = arg;
                break;
            case "dependency":
                this.dependency = arg;
                break;
            case "conflict":
                this.conflict = arg;
                break;
            case "value_next_arg":
                this.valueNextArg = Boolean.parseBoolean(arg);
                break;
            default:
                throw new IllegalArgumentException(keyToken);
            }
        }

        // default to boolean if no type is given
        if (this.type == null) {
            this.type = "boolean";
        }

        if (this.params == null && "boolean".equals(this.type)) {
            this.params = "[true|false]";
        }

    } catch (final Exception e) {
        throw new IllegalArgumentException(origValue);
    }

    if (name == null && shortName == null) {
        throw new IllegalArgumentException(origValue);
    }
}
 
Example 12
Source File: OptionTemplate.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
private void parse(final String origValue) {
    String value = origValue.trim();

    try {
        value = OptionTemplate.strip(value, '{', '}');
        final QuotedStringTokenizer keyValuePairs = new QuotedStringTokenizer(value, ",");

        while (keyValuePairs.hasMoreTokens()) {
            final String                keyValue = keyValuePairs.nextToken();
            final QuotedStringTokenizer st       = new QuotedStringTokenizer(keyValue, "=");
            final String                keyToken = st.nextToken();
            final String                arg      = st.nextToken();

            switch (keyToken) {
            case "is_undocumented":
                this.isUndocumented = Boolean.parseBoolean(arg);
                break;
            case "name":
                if (!arg.startsWith("-")) {
                    throw new IllegalArgumentException(arg);
                }
                this.name = arg;
                break;
            case "short_name":
                if (!arg.startsWith("-")) {
                    throw new IllegalArgumentException(arg);
                }
                this.shortName = arg;
                break;
            case "desc":
                this.description = arg;
                break;
            case "params":
                this.params = arg;
                break;
            case "type":
                this.type = arg.toLowerCase(Locale.ENGLISH);
                break;
            case "default":
                this.defaultValue = arg;
                break;
            case "dependency":
                this.dependency = arg;
                break;
            case "conflict":
                this.conflict = arg;
                break;
            case "value_next_arg":
                this.valueNextArg = Boolean.parseBoolean(arg);
                break;
            default:
                throw new IllegalArgumentException(keyToken);
            }
        }

        // default to boolean if no type is given
        if (this.type == null) {
            this.type = "boolean";
        }

        if (this.params == null && "boolean".equals(this.type)) {
            this.params = "[true|false]";
        }

    } catch (final Exception e) {
        throw new IllegalArgumentException(origValue);
    }

    if (name == null && shortName == null) {
        throw new IllegalArgumentException(origValue);
    }
}
 
Example 13
Source File: OptionTemplate.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private void parse(final String origValue) {
    String value = origValue.trim();

    try {
        value = OptionTemplate.strip(value, '{', '}');
        final QuotedStringTokenizer keyValuePairs = new QuotedStringTokenizer(value, ",");

        while (keyValuePairs.hasMoreTokens()) {
            final String                keyValue = keyValuePairs.nextToken();
            final QuotedStringTokenizer st       = new QuotedStringTokenizer(keyValue, "=");
            final String                keyToken = st.nextToken();
            final String                arg      = st.nextToken();

            switch (keyToken) {
            case "is_undocumented":
                this.isUndocumented = Boolean.parseBoolean(arg);
                break;
            case "name":
                if (!arg.startsWith("-")) {
                    throw new IllegalArgumentException(arg);
                }
                this.name = arg;
                break;
            case "short_name":
                if (!arg.startsWith("-")) {
                    throw new IllegalArgumentException(arg);
                }
                this.shortName = arg;
                break;
            case "desc":
                this.description = arg;
                break;
            case "params":
                this.params = arg;
                break;
            case "type":
                this.type = arg.toLowerCase(Locale.ENGLISH);
                break;
            case "default":
                this.defaultValue = arg;
                break;
            case "dependency":
                this.dependency = arg;
                break;
            case "conflict":
                this.conflict = arg;
                break;
            case "value_next_arg":
                this.valueNextArg = Boolean.parseBoolean(arg);
                break;
            default:
                throw new IllegalArgumentException(keyToken);
            }
        }

        // default to boolean if no type is given
        if (this.type == null) {
            this.type = "boolean";
        }

        if (this.params == null && "boolean".equals(this.type)) {
            this.params = "[true|false]";
        }

    } catch (final Exception e) {
        throw new IllegalArgumentException(origValue);
    }

    if (name == null && shortName == null) {
        throw new IllegalArgumentException(origValue);
    }
}
 
Example 14
Source File: OptionTemplate.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private void parse(final String origValue) {
    String value = origValue.trim();

    try {
        value = OptionTemplate.strip(value, '{', '}');
        final QuotedStringTokenizer keyValuePairs = new QuotedStringTokenizer(value, ",");

        while (keyValuePairs.hasMoreTokens()) {
            final String                keyValue = keyValuePairs.nextToken();
            final QuotedStringTokenizer st       = new QuotedStringTokenizer(keyValue, "=");
            final String                keyToken = st.nextToken();
            final String                arg      = st.nextToken();

            switch (keyToken) {
            case "is_undocumented":
                this.isUndocumented = Boolean.parseBoolean(arg);
                break;
            case "name":
                if (!arg.startsWith("-")) {
                    throw new IllegalArgumentException(arg);
                }
                this.name = arg;
                break;
            case "short_name":
                if (!arg.startsWith("-")) {
                    throw new IllegalArgumentException(arg);
                }
                this.shortName = arg;
                break;
            case "desc":
                this.description = arg;
                break;
            case "params":
                this.params = arg;
                break;
            case "type":
                this.type = arg.toLowerCase(Locale.ENGLISH);
                break;
            case "default":
                this.defaultValue = arg;
                break;
            case "dependency":
                this.dependency = arg;
                break;
            case "conflict":
                this.conflict = arg;
                break;
            case "value_next_arg":
                this.valueNextArg = Boolean.parseBoolean(arg);
                break;
            default:
                throw new IllegalArgumentException(keyToken);
            }
        }

        // default to boolean if no type is given
        if (this.type == null) {
            this.type = "boolean";
        }

        if (this.params == null && "boolean".equals(this.type)) {
            this.params = "[true|false]";
        }

    } catch (final Exception e) {
        throw new IllegalArgumentException(origValue);
    }

    if (name == null && shortName == null) {
        throw new IllegalArgumentException(origValue);
    }
}
 
Example 15
Source File: OptionTemplate.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private void parse(final String origValue) {
    String value = origValue.trim();

    try {
        value = OptionTemplate.strip(value, '{', '}');
        final QuotedStringTokenizer keyValuePairs = new QuotedStringTokenizer(value, ",");

        while (keyValuePairs.hasMoreTokens()) {
            final String                keyValue = keyValuePairs.nextToken();
            final QuotedStringTokenizer st       = new QuotedStringTokenizer(keyValue, "=");
            final String                keyToken = st.nextToken();
            final String                arg      = st.nextToken();

            switch (keyToken) {
            case "is_undocumented":
                this.isUndocumented = Boolean.parseBoolean(arg);
                break;
            case "name":
                if (!arg.startsWith("-")) {
                    throw new IllegalArgumentException(arg);
                }
                this.name = arg;
                break;
            case "short_name":
                if (!arg.startsWith("-")) {
                    throw new IllegalArgumentException(arg);
                }
                this.shortName = arg;
                break;
            case "desc":
                this.description = arg;
                break;
            case "params":
                this.params = arg;
                break;
            case "type":
                this.type = arg.toLowerCase(Locale.ENGLISH);
                break;
            case "default":
                this.defaultValue = arg;
                break;
            case "dependency":
                this.dependency = arg;
                break;
            case "conflict":
                this.conflict = arg;
                break;
            case "value_next_arg":
                this.valueNextArg = Boolean.parseBoolean(arg);
                break;
            default:
                throw new IllegalArgumentException(keyToken);
            }
        }

        // default to boolean if no type is given
        if (this.type == null) {
            this.type = "boolean";
        }

        if (this.params == null && "boolean".equals(this.type)) {
            this.params = "[true|false]";
        }

    } catch (final Exception e) {
        throw new IllegalArgumentException(origValue);
    }

    if (name == null && shortName == null) {
        throw new IllegalArgumentException(origValue);
    }
}
 
Example 16
Source File: OptionTemplate.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private void parse(final String origValue) {
    String value = origValue.trim();

    try {
        value = OptionTemplate.strip(value, '{', '}');
        final QuotedStringTokenizer keyValuePairs = new QuotedStringTokenizer(value, ",");

        while (keyValuePairs.hasMoreTokens()) {
            final String                keyValue = keyValuePairs.nextToken();
            final QuotedStringTokenizer st       = new QuotedStringTokenizer(keyValue, "=");
            final String                keyToken = st.nextToken();
            final String                arg      = st.nextToken();

            switch (keyToken) {
            case "is_undocumented":
                this.isUndocumented = Boolean.parseBoolean(arg);
                break;
            case "name":
                if (!arg.startsWith("-")) {
                    throw new IllegalArgumentException(arg);
                }
                this.name = arg;
                break;
            case "short_name":
                if (!arg.startsWith("-")) {
                    throw new IllegalArgumentException(arg);
                }
                this.shortName = arg;
                break;
            case "desc":
                this.description = arg;
                break;
            case "params":
                this.params = arg;
                break;
            case "type":
                this.type = arg.toLowerCase(Locale.ENGLISH);
                break;
            case "default":
                this.defaultValue = arg;
                break;
            case "dependency":
                this.dependency = arg;
                break;
            case "conflict":
                this.conflict = arg;
                break;
            case "value_next_arg":
                this.valueNextArg = Boolean.parseBoolean(arg);
                break;
            case "repeated":
                this.repeated = true;
                break;
            default:
                throw new IllegalArgumentException(keyToken);
            }
        }

        // default to boolean if no type is given
        if (this.type == null) {
            this.type = "boolean";
        }

        if (this.params == null && "boolean".equals(this.type)) {
            this.params = "[true|false]";
        }

    } catch (final Exception e) {
        throw new IllegalArgumentException(origValue);
    }

    if (name == null && shortName == null) {
        throw new IllegalArgumentException(origValue);
    }

    if (this.repeated && !"string".equals(this.type)) {
        throw new IllegalArgumentException("repeated option should be of type string: " + this.name);
    }
}
 
Example 17
Source File: OptionTemplate.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private void parse(final String origValue) {
    String value = origValue.trim();

    try {
        value = OptionTemplate.strip(value, '{', '}');
        final QuotedStringTokenizer keyValuePairs = new QuotedStringTokenizer(value, ",");

        while (keyValuePairs.hasMoreTokens()) {
            final String                keyValue = keyValuePairs.nextToken();
            final QuotedStringTokenizer st       = new QuotedStringTokenizer(keyValue, "=");
            final String                keyToken = st.nextToken();
            final String                arg      = st.nextToken();

            switch (keyToken) {
            case "is_undocumented":
                this.isUndocumented = Boolean.parseBoolean(arg);
                break;
            case "name":
                if (!arg.startsWith("-")) {
                    throw new IllegalArgumentException(arg);
                }
                this.name = arg;
                break;
            case "short_name":
                if (!arg.startsWith("-")) {
                    throw new IllegalArgumentException(arg);
                }
                this.shortName = arg;
                break;
            case "desc":
                this.description = arg;
                break;
            case "params":
                this.params = arg;
                break;
            case "type":
                this.type = arg.toLowerCase(Locale.ENGLISH);
                break;
            case "default":
                this.defaultValue = arg;
                break;
            case "dependency":
                this.dependency = arg;
                break;
            case "conflict":
                this.conflict = arg;
                break;
            case "value_next_arg":
                this.valueNextArg = Boolean.parseBoolean(arg);
                break;
            default:
                throw new IllegalArgumentException(keyToken);
            }
        }

        // default to boolean if no type is given
        if (this.type == null) {
            this.type = "boolean";
        }

        if (this.params == null && "boolean".equals(this.type)) {
            this.params = "[true|false]";
        }

    } catch (final Exception e) {
        throw new IllegalArgumentException(origValue);
    }

    if (name == null && shortName == null) {
        throw new IllegalArgumentException(origValue);
    }
}
 
Example 18
Source File: OptionTemplate.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private void parse(final String origValue) {
    String value = origValue.trim();

    try {
        value = OptionTemplate.strip(value, '{', '}');
        final QuotedStringTokenizer keyValuePairs = new QuotedStringTokenizer(value, ",");

        while (keyValuePairs.hasMoreTokens()) {
            final String                keyValue = keyValuePairs.nextToken();
            final QuotedStringTokenizer st       = new QuotedStringTokenizer(keyValue, "=");
            final String                keyToken = st.nextToken();
            final String                arg      = st.nextToken();

            switch (keyToken) {
            case "is_undocumented":
                this.isUndocumented = Boolean.parseBoolean(arg);
                break;
            case "name":
                if (!arg.startsWith("-")) {
                    throw new IllegalArgumentException(arg);
                }
                this.name = arg;
                break;
            case "short_name":
                if (!arg.startsWith("-")) {
                    throw new IllegalArgumentException(arg);
                }
                this.shortName = arg;
                break;
            case "desc":
                this.description = arg;
                break;
            case "params":
                this.params = arg;
                break;
            case "type":
                this.type = arg.toLowerCase(Locale.ENGLISH);
                break;
            case "default":
                this.defaultValue = arg;
                break;
            case "dependency":
                this.dependency = arg;
                break;
            case "conflict":
                this.conflict = arg;
                break;
            case "value_next_arg":
                this.valueNextArg = Boolean.parseBoolean(arg);
                break;
            default:
                throw new IllegalArgumentException(keyToken);
            }
        }

        // default to boolean if no type is given
        if (this.type == null) {
            this.type = "boolean";
        }

        if (this.params == null && "boolean".equals(this.type)) {
            this.params = "[true|false]";
        }

    } catch (final Exception e) {
        throw new IllegalArgumentException(origValue);
    }

    if (name == null && shortName == null) {
        throw new IllegalArgumentException(origValue);
    }
}
 
Example 19
Source File: OptionTemplate.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private void parse(final String origValue) {
    String value = origValue.trim();

    try {
        value = OptionTemplate.strip(value, '{', '}');
        final QuotedStringTokenizer keyValuePairs = new QuotedStringTokenizer(value, ",");

        while (keyValuePairs.hasMoreTokens()) {
            final String                keyValue = keyValuePairs.nextToken();
            final QuotedStringTokenizer st       = new QuotedStringTokenizer(keyValue, "=");
            final String                keyToken = st.nextToken();
            final String                arg      = st.nextToken();

            switch (keyToken) {
            case "is_undocumented":
                this.isUndocumented = Boolean.parseBoolean(arg);
                break;
            case "name":
                if (!arg.startsWith("-")) {
                    throw new IllegalArgumentException(arg);
                }
                this.name = arg;
                break;
            case "short_name":
                if (!arg.startsWith("-")) {
                    throw new IllegalArgumentException(arg);
                }
                this.shortName = arg;
                break;
            case "desc":
                this.description = arg;
                break;
            case "params":
                this.params = arg;
                break;
            case "type":
                this.type = arg.toLowerCase(Locale.ENGLISH);
                break;
            case "default":
                this.defaultValue = arg;
                break;
            case "dependency":
                this.dependency = arg;
                break;
            case "conflict":
                this.conflict = arg;
                break;
            case "value_next_arg":
                this.valueNextArg = Boolean.parseBoolean(arg);
                break;
            default:
                throw new IllegalArgumentException(keyToken);
            }
        }

        // default to boolean if no type is given
        if (this.type == null) {
            this.type = "boolean";
        }

        if (this.params == null && "boolean".equals(this.type)) {
            this.params = "[true|false]";
        }

    } catch (final Exception e) {
        throw new IllegalArgumentException(origValue);
    }

    if (name == null && shortName == null) {
        throw new IllegalArgumentException(origValue);
    }
}
 
Example 20
Source File: OptionTemplate.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private void parse(final String origValue) {
    String value = origValue.trim();

    try {
        value = OptionTemplate.strip(value, '{', '}');
        final QuotedStringTokenizer keyValuePairs = new QuotedStringTokenizer(value, ",");

        while (keyValuePairs.hasMoreTokens()) {
            final String                keyValue = keyValuePairs.nextToken();
            final QuotedStringTokenizer st       = new QuotedStringTokenizer(keyValue, "=");
            final String                keyToken = st.nextToken();
            final String                arg      = st.nextToken();

            switch (keyToken) {
            case "is_undocumented":
                this.isUndocumented = Boolean.parseBoolean(arg);
                break;
            case "name":
                if (!arg.startsWith("-")) {
                    throw new IllegalArgumentException(arg);
                }
                this.name = arg;
                break;
            case "short_name":
                if (!arg.startsWith("-")) {
                    throw new IllegalArgumentException(arg);
                }
                this.shortName = arg;
                break;
            case "desc":
                this.description = arg;
                break;
            case "params":
                this.params = arg;
                break;
            case "type":
                this.type = arg.toLowerCase(Locale.ENGLISH);
                break;
            case "default":
                this.defaultValue = arg;
                break;
            case "dependency":
                this.dependency = arg;
                break;
            case "conflict":
                this.conflict = arg;
                break;
            case "value_next_arg":
                this.valueNextArg = Boolean.parseBoolean(arg);
                break;
            default:
                throw new IllegalArgumentException(keyToken);
            }
        }

        // default to boolean if no type is given
        if (this.type == null) {
            this.type = "boolean";
        }

        if (this.params == null && "boolean".equals(this.type)) {
            this.params = "[true|false]";
        }

    } catch (final Exception e) {
        throw new IllegalArgumentException(origValue);
    }

    if (name == null && shortName == null) {
        throw new IllegalArgumentException(origValue);
    }
}