Java Code Examples for jdk.nashorn.internal.runtime.QuotedStringTokenizer

The following examples show how to use jdk.nashorn.internal.runtime.QuotedStringTokenizer. These examples are extracted from open source projects. 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 Project: TencentKona-8   Source File: Options.java    License: 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 Project: jdk8u60   Source File: Options.java    License: 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 Project: openjdk-jdk8u   Source File: Options.java    License: 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 4
Source Project: openjdk-jdk8u-backup   Source File: Options.java    License: 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 Project: openjdk-jdk9   Source File: Options.java    License: 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 Project: hottub   Source File: Options.java    License: 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 Project: openjdk-8-source   Source File: Options.java    License: 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 8
Source Project: openjdk-8   Source File: Options.java    License: 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 9
Source Project: jdk8u_nashorn   Source File: Options.java    License: 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 10
Source Project: nashorn   Source File: Options.java    License: 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 Project: TencentKona-8   Source File: OptionTemplate.java    License: 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 Project: jdk8u60   Source File: OptionTemplate.java    License: 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 Project: openjdk-jdk8u   Source File: OptionTemplate.java    License: 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
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 Project: openjdk-jdk9   Source File: OptionTemplate.java    License: 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 16
Source Project: hottub   Source File: OptionTemplate.java    License: 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 17
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 Project: openjdk-8   Source File: OptionTemplate.java    License: 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 Project: jdk8u_nashorn   Source File: OptionTemplate.java    License: 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 Project: nashorn   Source File: OptionTemplate.java    License: 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);
    }
}