Package joptsimple

Examples of joptsimple.ValueConversionException


    private static class StringPairConverter implements ValueConverter<Pair<String, String>> {
        @Override
        public Pair<String, String> convert(String input) {
            int eqPos = input.indexOf('=');
            if (eqPos == -1) {
                throw new ValueConversionException("Parameter should be in the form key=value, which the " +
                        "following is not: '" + input + "'.");
            }
            String key = input.substring(0, eqPos).trim();
            String value = input.substring(eqPos + 1).trim();
            return Pair.newPair(key, value);
View Full Code Here


        @Override
        public T convert(String input) {
            try {
                return Enum.valueOf(enumClass, input.toUpperCase());
            } catch (IllegalArgumentException e) {
                throw new ValueConversionException("Unrecognized value for enum " + enumClass.getSimpleName()
                        + ": '" + input + "'.");
            }
        }
View Full Code Here

    public Date convert( String value ) {
        ParsePosition position = new ParsePosition( 0 );

        Date date = formatter.parse( value, position );
        if ( position.getIndex() != value.length() )
            throw new ValueConversionException( message( value ) );

        return date;
    }
View Full Code Here

    private void raiseValueConversionFailure( String value ) {
        ResourceBundle bundle = ResourceBundle.getBundle( "joptsimple.ExceptionMessages" );
        String template = bundle.getString( getClass().getName() + ".message" );
        String message = new MessageFormat( template ).format( new Object[] { value, pattern.pattern() } );
        throw new ValueConversionException( message );
    }
View Full Code Here

public class InetAddressConverter implements ValueConverter<InetAddress> {
    public InetAddress convert( String value ) {
        try {
            return InetAddress.getByName( value );
        } catch ( UnknownHostException e ) {
            throw new ValueConversionException( "Cannot convert value [" + value + " into an InetAddress", e );
        }
    }
View Full Code Here

        } else if (value.equals(LEVEL_TRACE)) {
            return Level.TRACE;
        } else if (value.equals(LEVEL_ALL)) {
            return Level.ALL;
        } else {
            throw new ValueConversionException("No valid log level: " + value);
        }

    }
View Full Code Here

    @SuppressWarnings("unchecked")
    public Class<? extends IExternalConverter> convert(String value) {
        try {
            return (Class<? extends IExternalConverter>) Class.forName(value);
        } catch (ClassNotFoundException e) {
            throw new ValueConversionException("Not a class name or not on class path: " + value);
        }
    }
View Full Code Here

TOP

Related Classes of joptsimple.ValueConversionException

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.