Package org.milyn.javabean

Examples of org.milyn.javabean.DataDecodeException


            data = data.trim();
            try {
                scope = ResultSetScope.valueOf(data);
            } catch (IllegalArgumentException e) {
                throw new DataDecodeException("Failed to decode ResultSetScope value '" + data + "'.  Allowed values are " + Arrays.asList(ResultSetScope.values()) + ".");
            }

            return scope;
        }
View Full Code Here


       
        final Number number;
        try {
            number = decimalFormat.parse(data.trim());
        } catch (final ParseException e) {
            throw new DataDecodeException("Failed to decode BigDecimal value '" + data
                    + "' using NumberFormat instance " + decimalFormat + ".", e);
        }
       
        return (BigDecimal) number;
    }
View Full Code Here

    List decoders = executionContext.getDeliveryConfig().getObjects("decoder:" + typeAlias);

        if (decoders == null || decoders.isEmpty()) {
            decoder = DataDecoder.Factory.create(typeAlias);
        } else if (!(decoders.get(0) instanceof DataDecoder)) {
            throw new DataDecodeException("Configured decoder '" + typeAlias + ":" + decoders.get(0).getClass().getName() + "' is not an instance of " + DataDecoder.class.getName());
        } else {
            decoder = (DataDecoder) decoders.get(0);
        }

        return decoder;
View Full Code Here

        if(format != null) {
            try {
                Number number = format.parse(data.trim());
                return number.floatValue();
            } catch (ParseException e) {
                throw new DataDecodeException("Failed to decode Float value '" + data + "' using NumberFormat instance " + format + ".", e);
            }
        } else {
            try {
                return Float.parseFloat(data.trim());
            } catch(NumberFormatException e) {
                throw new DataDecodeException("Failed to decode float value '" + data + "'.", e);
            }
        }
    }
View Full Code Here

    public Object decode(String data) throws DataDecodeException {
        try {
            return new URL(data.trim());
        } catch (MalformedURLException e) {
            throw new DataDecodeException("Failed to decode URL value '" + data + "'.", e);
        }
    }
View Full Code Here

                    return (short) (number.doubleValue() * 100);
                } else {
                    return number.shortValue();
                }
            } catch (ParseException e) {
                throw new DataDecodeException("Failed to decode Short value '" + data + "' using NumberFormat instance " + format + ".", e);
            }
        } else {
            try {
                return Short.parseShort(data.trim());
            } catch(NumberFormatException e) {
                throw new DataDecodeException("Failed to decode Short value '" + data + "'.", e);
            }
        }
    }
View Full Code Here

    public Object decode(String data) throws DataDecodeException {
        try {
            return ClassUtil.forName(data.trim(), ClassDecoder.class);
        } catch (ClassNotFoundException e) {
            throw new DataDecodeException("Failed to decode '" + data + "' as a Java Class.", e);
        }
    }
View Full Code Here

            // Must be sync'd - DateFormat is not synchronized.
            synchronized(decoder) {
                return decoder.parse(data.trim());
            }
        } catch (ParseException e) {
            throw new DataDecodeException("Error decoding Date data value '" + data + "' with decode format '" + format + "'.", e);
        }
    }
View Full Code Here

    }

    public String encode(Object date) throws DataDecodeException {
        AssertArgument.isNotNull(date, "date");
        if(!(date instanceof Date)) {
            throw new DataDecodeException("Cannot encode Object type '" + date.getClass().getName() + "'.  Must be type '" + Date.class.getName() + "'.");
        }
        // Must be sync'd - DateFormat is not synchronized.
        synchronized(decoder) {
            return decoder.format((Date) date);
        }
View Full Code Here

    public Object decode(String data) throws DataDecodeException {
        Matcher binaryMatcher = BINARY_PATTERN.matcher(data);
        if (binaryMatcher.matches()) {
            return data;
        } else {
            throw new DataDecodeException("Failed to decode binary sequence '" + data + "'.");
        }
    }
View Full Code Here

TOP

Related Classes of org.milyn.javabean.DataDecodeException

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.