Package com.thoughtworks.xstream.converters

Examples of com.thoughtworks.xstream.converters.ConversionException


            reader.moveDown();

            String nodeName = reader.getNodeName();
            if (nodeName.equals("gbean-info")) {
                if (gbeanInfo != null) {
                    throw new ConversionException("GBean info declared more than once in gbean " + abstractName);
                }
                gbeanInfo = (GBeanInfo) unmarshallingContext.convertAnother(reader, GBeanInfo.class);
            } else if (nodeName.equals("dependency")) {
                ReferencePatterns referencePatterns = (ReferencePatterns) unmarshallingContext.convertAnother(reader, ReferencePatterns.class);
                dependencies.add(referencePatterns);
            } else if (nodeName.equals("attribute")) {
                String attributeName = reader.getAttribute("name");

                reader.moveDown();
                String classAttribute = reader.getAttribute(mapper.attributeForImplementationClass());
                Class type;
                if (classAttribute == null) {
                    type = mapper.realClass(reader.getNodeName());
                } else {
                    type = mapper.realClass(classAttribute);
                }
                Object attributeValue = unmarshallingContext.convertAnother(reader, type);
                reader.moveUp();

                attributes.put(attributeName, attributeValue);
            } else if (nodeName.equals("reference")) {
                String referenceName = reader.getAttribute("name");
                ReferencePatterns referencePatterns = (ReferencePatterns) unmarshallingContext.convertAnother(reader, ReferencePatterns.class);
                references.put(referenceName, referencePatterns);
            } else {
                throw new ConversionException("Unknown nested node in GBean: " + nodeName);
            }

            reader.moveUp();
        }

        if (gbeanInfo == null) {
            throw new ConversionException("GBean info not declared in gbean " + abstractName);
        }

        GBeanData gbeanData = new GBeanData(abstractName, gbeanInfo);
        gbeanData.setDependencies(dependencies);
        for (Map.Entry<String, Object> entry : attributes.entrySet()) {
View Full Code Here


        try {
            toXML(xstream, obj, writer);
        } catch (final ObjectStreamException e) {
            throw e;
        } catch (final IOException e) {
            throw new ConversionException("Unexpected IO error from a StringWriter", e);
        }
        return writer.toString();
    }
View Full Code Here

        try {
            return fromXML(new StringReader(xml));
        } catch (final ObjectStreamException e) {
            throw e;
        } catch (final IOException e) {
            throw new ConversionException("Unexpected IO error from a StringReader", e);
        }
    }
View Full Code Here

        try {
            return fromXML(new StringReader(xml), permissions);
        } catch (final ObjectStreamException e) {
            throw e;
        } catch (final IOException e) {
            throw new ConversionException("Unexpected IO error from a StringReader", e);
        }
    }
View Full Code Here

        try {
            return fromXML(driver, new StringReader(xml));
        } catch (final ObjectStreamException e) {
            throw e;
        } catch (final IOException e) {
            throw new ConversionException("Unexpected IO error from a StringReader", e);
        }
    }
View Full Code Here

        try {
            return fromXML(driver, new StringReader(xml), permissions);
        } catch (final ObjectStreamException e) {
            throw e;
        } catch (final IOException e) {
            throw new ConversionException("Unexpected IO error from a StringReader", e);
        }
    }
View Full Code Here

                comparator);
            Object backingMap = null;
            try {
                backingMap = sortedMapField.get(possibleResult);
            } catch (final IllegalAccessException e) {
                throw new ConversionException("Cannot get backing map of TreeSet", e);
            }
            if (backingMap instanceof TreeMap) {
                treeMap = (TreeMap<?, ?>)backingMap;
                result = possibleResult;
            } else {
View Full Code Here

                comparatorField.set(result, comparator);
            } else {
                typedResult.putAll(sortedMap); // will use comparator for already sorted map
            }
        } catch (final IllegalAccessException e) {
            throw new ConversionException("Cannot set comparator of TreeMap", e);
        }
    }
View Full Code Here

        final Class<?> declaringClass = (Class<?>)javaClassConverter.fromString(declaringClassName);
        try {
            return declaringClass.getDeclaredField(mapper.realMember(declaringClass, methodName));
        } catch (final NoSuchFieldException e) {
            throw new ConversionException(e);
        }
    }
View Full Code Here

    @Override
    public Object fromString(final String str) {
        try {
            return new URI(str);
        } catch (final URISyntaxException e) {
            throw new ConversionException(e);
        }
    }
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.