Package org.exolab.castor.mapping

Examples of org.exolab.castor.mapping.MappingException


     * @throws MappingException
     *             in case that the name is null or the Class can not be loaded
     */
    public void addClass(final String name, final boolean deep) throws MappingException {
        if (name == null) {
            throw new MappingException("Cannot introspect a null class.");
        }

        try {
            addClass(Class.forName(name), deep);
        } catch (ClassNotFoundException except) {
            throw new MappingException(except);
        }
    } // -- addClass
View Full Code Here


     * @throws MappingException
     *             in case that the name is null or the Class can not be loaded
     */
    public void addClass(final Class cls, final boolean deep) throws MappingException {
        if (cls == null) {
            throw new MappingException("Cannot introspect a null class.");
        }

        if (_mappings.get(cls) != null) {
            return;
        }

        if (cls.isArray()) {
            Class cType = cls.getComponentType();
            if (_mappings.get(cType) != null) {
                return;
            }
            if (Types.isSimpleType(cType)) {
                return;
            }
            // -- handle component type
            addClass(cType);
        }

        if (_forceIntrospection && (!Types.isConstructable(cls))) {
            throw new MappingException("mapping.classNotConstructable", cls.getName());
        }

        XMLClassDescriptor xmlClass;
        FieldDescriptor[] fields;
        ClassMapping classMap;
        FieldMapping fieldMap;

        boolean introspected = false;
        try {
            if (_forceIntrospection) {
                xmlClass = _internalContext.getIntrospector().generateClassDescriptor(cls);
                introspected = true;
            } else {
                xmlClass = (XMLClassDescriptor) _internalContext.getXMLClassDescriptorResolver().resolve(cls);
                introspected = _internalContext.getIntrospector().introspected(xmlClass);
            }
        } catch (Exception except) {
            throw new MappingException(except);
        }
        classMap = new ClassMapping();
        classMap.setName(cls.getName());
        classMap.setDescription("Default mapping for class " + cls.getName());

View Full Code Here

            marshal = new Marshaller(writer);
            marshal.setNamespaceMapping(null, "http://castor.exolab.org/");
            marshal.setNamespaceMapping("cst", "http://castor.exolab.org/");
            marshal.marshal(mapping);
        } catch (Exception except) {
            throw new MappingException(except);
        }
    } // -- write
View Full Code Here

                sb.append(IP_FORMAT.format(new Integer(st.nextToken())));
            }

            _hostAddress = sb.toString();
        } catch (Exception ex) {
            throw new MappingException(Messages.format(
                    "persist.keyGenSQL", getClass().getName(), ex.toString()), ex);
        }
    }
View Full Code Here

     */
    public void supportsSqlType(final int sqlType) throws MappingException {
        if ((sqlType != Types.CHAR)
                && (sqlType != Types.VARCHAR)
                && (sqlType != Types.LONGVARCHAR)) {
          throw new MappingException(Messages.format("mapping.keyGenSQLType",
                  getClass().getName(), new Integer(sqlType)));
        }
    }
View Full Code Here

    }
   
    public void initFromParameters(final Properties params) throws MappingException {
        _seqTable = params.getProperty(SEQ_TABLE);
        if (_seqTable == null) {
            throw new MappingException(Messages.format(
                    "mapping.KeyGenParamNotSet", SEQ_TABLE, getClass().getName()));
        }

        _seqKey = params.getProperty(SEQ_KEY);
        if (_seqKey == null) {
            throw new MappingException(Messages.format(
                    "mapping.KeyGenParamNotSet", SEQ_KEY, getClass().getName()));
        }

        _seqValue = params.getProperty(SEQ_VALUE);
        if (_seqValue == null) {
            throw new MappingException(Messages.format(
                    "mapping.KeyGenParamNotSet", SEQ_VALUE, getClass().getName()));
        }

        String grabSize = params.getProperty(GRAB_SIZE, "10");
        try {
            _grabSize = Integer.parseInt(grabSize);
        } catch (NumberFormatException except) {
            _grabSize = 0;
        }
        if (_grabSize <= 0) {
            throw new MappingException(Messages.format(
                    "mapping.wrongKeyGenParam", grabSize, GRAB_SIZE, getClass().getName()));
        }

        _sameConnection = "true".equals(params.getProperty(SAME_CONNECTION));
        _global = "true".equals(params.getProperty(GLOBAL));
View Full Code Here

    public void supportsSqlType(final int sqlType) throws MappingException {
        if ((sqlType != Types.INTEGER)
                && (sqlType != Types.BIGINT)
                && (sqlType != Types.NUMERIC)
                && (sqlType != Types.DECIMAL)) {
            throw new MappingException(Messages.format("mapping.keyGenSQLType",
                    getClass().getName(), new Integer(sqlType)));
        }
    }
View Full Code Here

        }

        if (!supported) {
            String msg = Messages.format("mapping.keyGenNotCompatible",
                    getClass().getName(), _factoryName);
            throw new MappingException(msg);
        }
    }
View Full Code Here

                && sqlType != Types.NUMERIC
                && sqlType != Types.DECIMAL
                && sqlType != Types.BIGINT) {
            String msg = Messages.format("mapping.keyGenSQLType",
                    getClass().getName(), new Integer(sqlType));
            throw new MappingException(msg);
        }
    }
View Full Code Here

        }

        if (!supported) {
            String msg = Messages.format("mapping.keyGenNotCompatible",
                    getClass().getName(), factoryName);
            throw new MappingException(msg);
        }
    }
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.