Package org.constretto.exception

Examples of org.constretto.exception.ConstrettoConversionException


    public InetAddress fromString(String value) throws ConstrettoConversionException {
        try {
            return InetAddress.getByName(value);
        } catch (UnknownHostException e) {
            throw new ConstrettoConversionException(value, InetAddress.class, e);
        }
    }
View Full Code Here


public class LocaleValueConverter implements ValueConverter<Locale> {
    public Locale fromString(String value) throws ConstrettoConversionException {
        try {
            return ConstrettoUtils.toLocale(value);
        } catch (IllegalArgumentException e) {
            throw new ConstrettoConversionException(value, Locale.class, e);
        }
    }
View Full Code Here

        add("false");
    }};

    public Boolean fromString(String value) throws ConstrettoConversionException {
        if (!validStrings.contains(value.toLowerCase())) {
            throw new ConstrettoConversionException(value, Boolean.class, "valid values are \"true\" and \"false\" ignoring case.");
        }
        return Boolean.valueOf(value);
    }
View Full Code Here

    public Float fromString(String value) throws ConstrettoConversionException {
        try {
            return Float.parseFloat(value);
        } catch (NumberFormatException e) {
            throw new ConstrettoConversionException(value, Float.class, e);
        }
    }
View Full Code Here

    public Byte fromString(String value) throws ConstrettoConversionException {
        try {
            return Byte.parseByte(value);
        } catch (NumberFormatException e) {
            throw new ConstrettoConversionException(value, Byte.class, e);
        }
    }
View Full Code Here

    public Double fromString(String value) throws ConstrettoConversionException {
        try {
            return Double.parseDouble(value);
        } catch (NumberFormatException e) {
            throw new ConstrettoConversionException(value, Double.class, e);
        }
    }
View Full Code Here

    public URL fromString(String value) throws ConstrettoConversionException {
        try {
            return new URL(value);
        } catch (MalformedURLException e) {
            throw new ConstrettoConversionException(value, URL.class, e.getMessage());
        }
    }
View Full Code Here

    public static <T extends Enum<T>> T convertEnum(Class<T> clazz, String value) {
        try {
            return Enum.valueOf(clazz, value);
        } catch (IllegalArgumentException e) {
            throw new ConstrettoConversionException(value, clazz, e);
        }
    }
View Full Code Here

            } else {
                properties.load(stream);
            }
            return properties;
        } catch (IOException e) {
            throw new ConstrettoConversionException(resourceName, Properties.class, e);
        }
    }
View Full Code Here

    public Integer fromString(String value) throws ConstrettoConversionException {
        try {
            return Integer.parseInt(value);
        } catch (NumberFormatException e) {
            throw new ConstrettoConversionException(value, Integer.class, e);
        }
    }
View Full Code Here

TOP

Related Classes of org.constretto.exception.ConstrettoConversionException

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.