Package com.thoughtworks.xstream.converters

Examples of com.thoughtworks.xstream.converters.ConversionException


    @Override
    public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
        final String attributeName = mapper().aliasForSystemAttribute("enum-type");
        if (attributeName == null) {
            throw new ConversionException("No EnumType specified for EnumMap");
        }
        final Class<?> type = mapper().realClass(reader.getAttribute(attributeName));
        @SuppressWarnings({"rawtypes", "unchecked"})
        final EnumMap<?, ?> map = new EnumMap(type);
        populateMap(reader, context, map);
View Full Code Here


    @Override
    public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
        final String attributeName = mapper.aliasForSystemAttribute("enum-type");
        if (attributeName == null) {
            throw new ConversionException("No EnumType specified for EnumSet");
        }
        @SuppressWarnings("rawtypes")
        final Class enumTypeForSet = mapper.realClass(reader.getAttribute(attributeName));
        @SuppressWarnings("unchecked")
        final EnumSet<?> set = create(enumTypeForSet, reader.getValue());
View Full Code Here

        if (str == null) {
            return null;
        }
        final T result = strings.get(str);
        if (result == null) {
            throw new ConversionException("Invalid string representation for enum type "
                + enumType.getName()
                + ": <"
                + str
                + ">");
        }
View Full Code Here

            } else {
                result.pushCallback(callback);
            }
            return result;
        } catch (final IOException e) {
            throw new ConversionException("Cannot create CustomObjectStream", e);
        }
    }
View Full Code Here

        type = mapper.defaultImplementationOf(type);
        if (converter == null) {
            converter = converterLookup.lookupConverterForType(type);
        } else {
            if (!converter.canConvert(type)) {
                final ConversionException e = new ConversionException("Explicit selected converter cannot handle type");
                e.add("item-type", type.getName());
                e.add("converter-type", converter.getClass().getName());
                throw e;
            }
        }
        return convert(parent, type, converter);
    }
View Full Code Here

            return result;
        } catch (final ConversionException conversionException) {
            addInformationTo(conversionException, type, converter, parent);
            throw conversionException;
        } catch (final RuntimeException e) {
            final ConversionException conversionException = new ConversionException(e);
            addInformationTo(conversionException, type, converter, parent);
            throw conversionException;
        }
    }
View Full Code Here

    public void convertAnother(final Object item, Converter converter) {
        if (converter == null) {
            converter = converterLookup.lookupConverterForType(item.getClass());
        } else {
            if (!converter.canConvert(item.getClass())) {
                final ConversionException e = new ConversionException("Explicit selected converter cannot handle item");
                e.add("item-type", item.getClass().getName());
                e.add("converter-type", converter.getClass().getName());
                throw e;
            }
        }
        convert(item, converter);
    }
View Full Code Here

        convert(item, converter);
    }

    protected void convert(final Object item, final Converter converter) {
        if (parentObjects.containsId(item)) {
            final ConversionException e = new CircularReferenceException("Recursive reference to parent object");
            e.add("item-type", item.getClass().getName());
            e.add("converter-type", converter.getClass().getName());
            throw e;
        }
        parentObjects.associateId(item, "");
        converter.marshal(item, writer, this);
        parentObjects.removeId(item);
View Full Code Here

                    }
                }
                return requiredState;
            case STATE_SET_VALUE:
                if ((mode & STRICT_MODE) != 0 && size == 2) {
                    throw new ConversionException("Single value cannot be root element");
                }
                if (valueToAdd == null) {
                    if (currentType == Mapper.Null.class) {
                        addValue("null", Type.NULL);
                    } else if ((mode & EXPLICIT_MODE) == 0 && !isArray) {
View Full Code Here

        for (final Converter converter : converters) {
            if (converter.canConvert(type)) {
                return converter;
            }
        }
        throw new ConversionException("No converter specified for " + type);
    }
View Full Code Here

TOP

Related Classes of com.thoughtworks.xstream.converters.ConversionException

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.