Package org.apache.sis.util

Examples of org.apache.sis.util.UnconvertibleObjectException


        if (candidate.getSourceClass() == sourceClass &&
            candidate.getTargetClass() == targetClass)
        {
            return (ObjectConverter<S,T>) candidate;
        }
        throw new UnconvertibleObjectException(Errors.format(Errors.Keys.CanNotConvertFromType_2, sourceClass, targetClass));
    }
View Full Code Here


            if (converter != null) {
                put(key, converter);
                return converter;
            }
        }
        throw new UnconvertibleObjectException(Errors.format(Errors.Keys.CanNotConvertFromType_2, sourceClass, targetClass));
    }
View Full Code Here

        try {
            return doConvert(source);
        } catch (UnconvertibleObjectException e) {
            throw e;
        } catch (Exception e) {
            throw new UnconvertibleObjectException(formatErrorMessage(source), e);
        }
    }
View Full Code Here

        @Override java.lang.Boolean doConvert(final String source) throws UnconvertibleObjectException {
            // "String in switch" in the JDK7 branch.
            final String lower = source.toLowerCase(java.util.Locale.US);
            if (lower.equals("true"|| lower.equals("yes") || lower.equals("on"|| lower.equals("1")) return java.lang.Boolean.TRUE;
            if (lower.equals("false") || lower.equals("no"|| lower.equals("off") || lower.equals("0")) return java.lang.Boolean.FALSE;
            throw new UnconvertibleObjectException(formatErrorMessage(source));
        }
View Full Code Here

        /** Converts the given string to the target type of this converter. */
        @Override T doConvert(String source) {
            final T code = Types.forCodeName(targetClass, source, false);
            if (code == null) {
                throw new UnconvertibleObjectException(formatErrorMessage(source));
            }
            return code;
        }
View Full Code Here

            return null;
        }
        try {
            return doConvert(source);
        } catch (Exception e) {
            throw new UnconvertibleObjectException(formatErrorMessage(source), e);
        }
    }
View Full Code Here

        final T target = Numbers.cast(source, targetClass);
        if (target.longValue() != source.longValue() ||
                Double.doubleToLongBits(target.doubleValue()) !=
                Double.doubleToLongBits(source.doubleValue()))
        {
            throw new UnconvertibleObjectException(formatErrorMessage(source));
        }
        return target;
    }
View Full Code Here

     * @return The parsed range (never {@code null}).
     * @throws ParseException If the given string can not be fully parsed.
     */
    public Range<?> parse(final String source) throws ParseException {
        final ParsePosition pos = new ParsePosition(0);
        UnconvertibleObjectException failure = null;
        try {
            final Range<?> range = tryParse(source, pos);
            if (range != null) {
                return range;
            }
View Full Code Here

            return value;
        }
        if (value instanceof Number && Number.class.isAssignableFrom(elementType)) {
            return Numbers.cast((Number) value, (Class<? extends Number>) elementType);
        }
        throw new UnconvertibleObjectException(Errors.format(
                Errors.Keys.IllegalClass_2, elementType, value.getClass()));
    }
View Full Code Here

     * to the storage map. The {@code original} key is used only for formatting an error message
     * in case of failure.
     */
    final V put(final K original, final SK key, final SV value) {
        if (key == null) {
            throw new UnconvertibleObjectException(Errors.format(
                    Errors.Keys.IllegalArgumentValue_2, "key", original));
        }
        return valueConverter.apply(storage.put(key, value));
    }
View Full Code Here

TOP

Related Classes of org.apache.sis.util.UnconvertibleObjectException

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.