Package org.exolab.castor.mapping

Examples of org.exolab.castor.mapping.MappingException


        try {
            Mapping mapping = new Mapping(classLoader);
            mapping.loadMapping(url);
            return mapping;
        } catch (java.io.IOException ioex) {
            throw new MappingException(ioex);
        }
    }
View Full Code Here


    public FieldHandlerImpl( Field field, TypeInfo typeInfo )
        throws MappingException
    {
        if ( field.getModifiers() != Modifier.PUBLIC &&
             field.getModifiers() != ( Modifier.PUBLIC | Modifier.VOLATILE ) )
            throw new MappingException( "mapping.fieldNotAccessible", field.getName(),
                                        field.getDeclaringClass().getName() );
        _handler = null;
        _field = field;
        _fieldType = Types.typeFromPrimitive( typeInfo.getFieldType() );
        _fieldName = field.getName() + "(" + field.getType().getName() + ")";
View Full Code Here

    public void setCreateMethod( Method method )
        throws MappingException
    {
        if ( ( method.getModifiers() & Modifier.PUBLIC ) == 0 ||
             ( method.getModifiers() & Modifier.STATIC ) != 0 )
            throw new MappingException( "mapping.accessorNotAccessible",
                                        method, method.getDeclaringClass().getName() );
        if ( method.getParameterTypes().length != 0 )
            throw new MappingException( "mapping.createMethodNoParam",
                                        method, method.getDeclaringClass().getName() );
        _createMethod = method;
    }
View Full Code Here

    protected final void addDescriptor(final ClassDescriptor descriptor)
    throws MappingException {
        String classname = descriptor.getJavaClass().getName();
        if (_descriptorsByClassname.containsKey(classname)) {
            if (!isAllowRedefinition()) {
                throw new MappingException("mapping.duplicateDescriptors", classname);
            }
            for (Iterator iterator = _descriptors.iterator(); iterator.hasNext(); ) {
                ClassDescriptor d = (ClassDescriptor) iterator.next();
                if (classname.equals(d.getJavaClass().getName())) {
                    iterator.remove();
View Full Code Here

            FieldHandlerDef def = (FieldHandlerDef) enumeration.nextElement();
           
            String name = def.getName();
           
            if (_fieldHandlers.containsKey(name)) {
                throw new MappingException(Messages.format("mapping.dupFieldHandler", name));
            }
           
           
            Class clazz = resolveType(def.getClazz());
            FieldHandler fieldHandler = null;
            try {
                if (!FieldHandler.class.isAssignableFrom(clazz)) {
                    throw new MappingException(Messages.format("mapping.classNotFieldHandler",
                            name, def.getClazz()));
                }
                fieldHandler = (FieldHandler) clazz.newInstance();
                _fieldHandlers.put(name, fieldHandler);
            } catch (InstantiationException e) {
                throw new MappingException(e);
            } catch (IllegalAccessException e) {
                throw new MappingException(e);
            }
           
            // Add configuration data, if there is any
            configureFieldHandler(def, fieldHandler);
           
View Full Code Here

       
        // If there is configuration data, make sure that the field handler class
        // supports it.
        if (params.size() > 0) {
            if (!ConfigurableFieldHandler.class.isAssignableFrom(fieldHandler.getClass())) {
                throw new MappingException(Messages.format("mapping.classNotConfigurableFieldHandler",
                        def.getName(), def.getClazz()));
            }
           
            // Pass the configuration data to the field handler.
            try {
                ((ConfigurableFieldHandler)fieldHandler).setConfiguration(params);
            } catch (ValidityException e) {
                throw new MappingException(Messages.format("mapping.invalidFieldHandlerConfig",
                        def.getName(), e.getMessage()), e);
            }
        }
    }
View Full Code Here

        ClassMapping mapping = (ClassMapping) clsMap.getExtends();
        Class type = resolveType(mapping.getName());
        ClassDescriptor result = getDescriptor(type.getName());

        if (result == null) {
            throw new MappingException(
                    "mapping.extendsMissing", mapping, javaClass.getName());
        }

        if (!result.getJavaClass().isAssignableFrom(javaClass)) {
            throw new MappingException("mapping.classDoesNotExtend",
                    javaClass.getName(), result.getJavaClass().getName());
        }

        return result;
    }
View Full Code Here

        ClassMapping mapping = (ClassMapping) clsMap.getDepends();
        Class type = resolveType(mapping.getName());
        ClassDescriptor result = getDescriptor(type.getName());

        if (result == null) {
            throw new MappingException(
                    "Depends not found: " + mapping + " " + javaClass.getName());
        }

        return result;
    }
View Full Code Here

                                                  final Class cls) throws MappingException {
        for (int i = 0; i < fields.length - 1; i++) {
            String fieldName = fields[i].getFieldName();
            for (int j = i + 1; j < fields.length; j++) {
                if (fieldName.equals(fields[j].getFieldName())) {
                    throw new MappingException("The field " + fieldName
                            + " appears twice in the descriptor for " + cls.getName());
                }
            }
        }
    }
View Full Code Here

    protected final Class resolveType(final String typeName)
    throws MappingException {
        try {
            return Types.typeFromName(getClassLoader(), typeName);
        } catch (ClassNotFoundException ex) {
            throw new MappingException("mapping.classNotFound", typeName);
        }
    }
View Full Code Here

TOP

Related Classes of org.exolab.castor.mapping.MappingException

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.