Package net.windwards.options.err

Examples of net.windwards.options.err.InvalidOptionValue


        for (DateFormat format : this.dateFormats()) {
            try {
                return format.parse(value);
            } catch (ParseException ignore) { }
        }
        throw new InvalidOptionValue("Malformed data in --" + desc.longOptionName);
    }
View Full Code Here


            return desc.defaultValue;

        try {
            return new URL(value);
        } catch (MalformedURLException e) {
            throw new InvalidOptionValue("Malformed URL in --" + desc.longOptionName);
        }
    }
View Full Code Here

    public Object parse(OptionDescription desc, Class<?> type, String value) throws InvalidOptionValue {
        for(Object cand : type.getEnumConstants()) {
            if (cand.toString().equals(value))
                return cand;
        }
        throw new InvalidOptionValue("Unacceptable value for --" + desc.longOptionName);
    }
View Full Code Here

            valueObj = true;
        } else if (value.equalsIgnoreCase("no") ||
                value.equalsIgnoreCase("off")) {
            valueObj = false;
        } else {
            throw new InvalidOptionValue("Option --" +
                    desc.longOptionName + " expect yes|no|on|off");
        }
        return valueObj;
    }
View Full Code Here

public class ClassValueParser implements ValueParser {
    public Object parse(OptionDescription desc, Class<?> type, String value) throws InvalidOptionValue {
        try {
            return Class.forName(value);
        } catch (ClassNotFoundException e) {
            throw new InvalidOptionValue("No class " + value + " for --" +
                    desc.longOptionName);
        }

    }
View Full Code Here

        if (type == long.class || type == Long.class) {
            try {
                valueObj = new Long(value);
            } catch (NumberFormatException e) {
                throw new InvalidOptionValue(
                        "Option --" + desc.longOptionName +
                                " can't accept value " + value + ".");
            }
        } else if (type == int.class || type == Integer.class) {
            try {
                valueObj = new Integer(value);
            } catch (NumberFormatException e) {
                throw new InvalidOptionValue(
                        "Option --" + desc.longOptionName +
                                " can't accept value " + value + ".");
            }
        } else if (type == short.class || type == Short.class) {
            try {
                valueObj = new Short(value);
            } catch (NumberFormatException e) {
                throw new InvalidOptionValue(
                        "Option --" + desc.longOptionName +
                                " can't accept value " + value + ".");
            }
        } else if (type == float.class || type == Float.class) {
            try {
                valueObj = new Float(value);
            } catch (NumberFormatException e) {
                throw new InvalidOptionValue(
                        "Option --" + desc.longOptionName +
                                " can't accept value " + value + ".");
            }
        } else if (type == double.class || type == Double.class) {
            try {
                valueObj = new Double(value);
            } catch (NumberFormatException e) {
                throw new InvalidOptionValue(
                        "Option --" + desc.longOptionName +
                                " can't accept value " + value + ".");
            }
        }
        return valueObj;
View Full Code Here

TOP

Related Classes of net.windwards.options.err.InvalidOptionValue

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.