Package com.thoughtworks.xstream

Examples of com.thoughtworks.xstream.InitializationException


     * @param mapper to use
     * @since 1.4.5
     */
    protected JavaFieldConverter(final SingleValueConverter javaClassConverter, final Mapper mapper) {
        if (!javaClassConverter.canConvert(Class.class)) {
            throw new InitializationException("Java Class Converter cannot handle Class types");
        }
        this.javaClassConverter = javaClassConverter;
        this.mapper = mapper;
    }
View Full Code Here


     * @param javaClassConverter the converter to use
     * @since 1.4.5
     */
    protected JavaMethodConverter(final SingleValueConverter javaClassConverter) {
        if (!javaClassConverter.canConvert(Class.class)) {
            throw new InitializationException("Java Class Converter cannot handle Class types");
        }
        this.javaClassConverter = javaClassConverter;
    }
View Full Code Here

        addDefaultImplementation(Long.class, long.class);
    }

    public void addDefaultImplementation(final Class<?> defaultImplementation, final Class<?> ofType) {
        if (defaultImplementation != null && defaultImplementation.isInterface()) {
            throw new InitializationException("Default implementation is not a concrete class: "
                + defaultImplementation.getName());
        }
        typeToImpl.put(ofType, defaultImplementation);
        implToType.put(defaultImplementation, ofType);
    }
View Full Code Here

        while (declaredIn != Object.class && definedIn != null) {
            try {
                field = declaredIn.getDeclaredField(fieldName);
                break;
            } catch (final SecurityException e) {
                throw new InitializationException("Access denied for field with implicit collection", e);
            } catch (final NoSuchFieldException e) {
                declaredIn = declaredIn.getSuperclass();
            }
        }
        if (field == null) {
            throw new InitializationException("No field \"" + fieldName + "\" for implicit collection");
        } else if (Map.class.isAssignableFrom(field.getType())) {
            if (itemFieldName == null && keyFieldName == null) {
                itemType = Map.Entry.class;
            }
        } else if (!Collection.class.isAssignableFrom(field.getType())) {
            final Class<?> fieldType = field.getType();
            if (!fieldType.isArray()) {
                throw new InitializationException("Field \"" + fieldName + "\" declares no collection or array");
            } else {
                Class<?> componentType = fieldType.getComponentType();
                componentType = componentType.isPrimitive() ? Primitives.box(componentType) : componentType;
                if (itemType == null) {
                    itemType = componentType;
                } else {
                    itemType = itemType.isPrimitive() ? Primitives.box(itemType) : itemType;
                    if (!componentType.isAssignableFrom(itemType)) {
                        throw new InitializationException("Field \""
                            + fieldName
                            + "\" declares an array, but the array type is not compatible with "
                            + itemType.getName());

                    }
View Full Code Here

                final Converter converter = cacheConverter(annotation, converterAnnotation != null ? type : null);
                if (converter != null) {
                    if (converterAnnotation != null || converter.canConvert(type)) {
                        converterRegistry.registerConverter(converter, annotation.priority());
                    } else {
                        throw new InitializationException("Converter "
                            + annotation.value().getName()
                            + " cannot handle annotated class "
                            + type.getName());
                    }
                }
View Full Code Here

    private void processAliasAnnotation(final Class<?> type, final Set<Class<?>> types) {
        final XStreamAlias aliasAnnotation = type.getAnnotation(XStreamAlias.class);
        if (aliasAnnotation != null) {
            if (classAliasingMapper == null) {
                throw new InitializationException("No " + ClassAliasingMapper.class.getName() + " available");
            }
            classAliasingMapper.addClassAlias(aliasAnnotation.value(), type);
            if (aliasAnnotation.impl() != Void.class) {
                // Alias for Interface/Class with an impl
                defaultImplementationsMapper.addDefaultImplementation(aliasAnnotation.impl(), type);
View Full Code Here

    private void processAliasTypeAnnotation(final Class<?> type) {
        final XStreamAliasType aliasAnnotation = type.getAnnotation(XStreamAliasType.class);
        if (aliasAnnotation != null) {
            if (classAliasingMapper == null) {
                throw new InitializationException("No " + ClassAliasingMapper.class.getName() + " available");
            }
            classAliasingMapper.addTypeAlias(aliasAnnotation.value(), type);
        }
    }
View Full Code Here

    private void processFieldAliasAnnotation(final Field field) {
        final XStreamAlias aliasAnnotation = field.getAnnotation(XStreamAlias.class);
        if (aliasAnnotation != null) {
            if (fieldAliasingMapper == null) {
                throw new InitializationException("No " + FieldAliasingMapper.class.getName() + " available");
            }
            fieldAliasingMapper.addFieldAlias(aliasAnnotation.value(), field.getDeclaringClass(), field.getName());
        }
    }
View Full Code Here

    private void processAsAttributeAnnotation(final Field field) {
        final XStreamAsAttribute asAttributeAnnotation = field.getAnnotation(XStreamAsAttribute.class);
        if (asAttributeAnnotation != null) {
            if (attributeMapper == null) {
                throw new InitializationException("No " + AttributeMapper.class.getName() + " available");
            }
            attributeMapper.addAttributeFor(field);
        }
    }
View Full Code Here

    private void processImplicitAnnotation(final Field field) {
        final XStreamImplicit implicitAnnotation = field.getAnnotation(XStreamImplicit.class);
        if (implicitAnnotation != null) {
            if (implicitCollectionMapper == null) {
                throw new InitializationException("No " + ImplicitCollectionMapper.class.getName() + " available");
            }
            final String fieldName = field.getName();
            final String itemFieldName = implicitAnnotation.itemFieldName();
            final String keyFieldName = implicitAnnotation.keyFieldName();
            final boolean isMap = Map.class.isAssignableFrom(field.getType());
View Full Code Here

TOP

Related Classes of com.thoughtworks.xstream.InitializationException

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.