Examples of FieldDescriptorImpl


Examples of org.exolab.castor.mapping.loader.FieldDescriptorImpl

     * @param choice
     * @return jdo field descriptor for id
     */
    private FieldDescriptor initId(final ClassChoice choice) {
        String idFieldName = "id";
        FieldDescriptorImpl idFieldDescr;
        FieldMapping idFM = new FieldMapping();
        TypeInfo idType = new TypeInfo(java.lang.Integer.class);
        // Set columns required (=not null)
        idType.setRequired(true);
       
        FieldHandler idHandler;
        try {
            idHandler = new FieldHandlerImpl(idFieldName, null, null,
                    Address.class.getMethod("getId", null), Address.class
                            .getMethod("setId", new Class[] { int.class }),
                    idType);
        } catch (SecurityException e1) {
            e1.printStackTrace();
            throw new RuntimeException(e1.getMessage());
        } catch (MappingException e1) {
            e1.printStackTrace();
            throw new RuntimeException(e1.getMessage());
        } catch (NoSuchMethodException e1) {
            e1.printStackTrace();
            throw new RuntimeException(e1.getMessage());
        }

        // Instantiate title field descriptor
        idFieldDescr = new FieldDescriptorImpl(idFieldName, idType, idHandler, false);
       
        idFieldDescr.addNature(FieldDescriptorJDONature.class.getName());
        FieldDescriptorJDONature idJdoNature = new FieldDescriptorJDONature(idFieldDescr);
       
        idJdoNature.setSQLName(new String[] { idFieldName });
        idJdoNature.setSQLType(new int[] { SQLTypeInfos.javaType2sqlTypeNum(java.lang.Integer.class) });
        idJdoNature.setManyKey(null);
        idJdoNature.setDirtyCheck(false);
        idJdoNature.setReadOnly(false);

        // Set parent class descriptor
        idFieldDescr.setContainingClassDescriptor(this);
        idFieldDescr.setClassDescriptor(this);
        idFieldDescr.setIdentity(true);
       
        idFM.setIdentity(true);
        idFM.setDirect(false);
        idFM.setName("id");
        idFM.setRequired(true);
View Full Code Here

Examples of org.exolab.castor.mapping.loader.FieldDescriptorImpl

        FieldHandler handler = fieldInfo.getFieldHandler();

        boolean isTransient = false;
        // isTransient = jpaNature.isTransient ();

        FieldDescriptorImpl descriptor = new FieldDescriptorImpl(name,
                typeInfo, handler, isTransient);

        /*
         * working!
         */
        descriptor.setContainingClassDescriptor(parent);
        descriptor.setFieldType(fieldInfo.getFieldType());
        // descriptor.setIdentity (jpaNature.isId ());
        /*
         * interim setters for not implemented getters!
         */
        descriptor.setIdentity(false);
        descriptor.setClassDescriptor(null);
        descriptor.setImmutable(false);
        descriptor.setMultivalued(false);
        descriptor.setRequired(false);

        /*
         * FieldDescriptorJDONature
         */
        descriptor.addNature(FieldDescriptorJDONature.class.getName());
        FieldDescriptorJDONature jdoNature = new FieldDescriptorJDONature(
                descriptor);

        /*
         * working!
 
View Full Code Here

Examples of org.exolab.castor.mapping.loader.FieldDescriptorImpl

            if (_factory != null) { sqlType = _factory.adjustSqlType(sqlType); }
            sqlTypeNum = new int[] {SQLTypeInfos.javaType2sqlTypeNum(sqlType)};
        }

        // create FieldDescriptor(Impl) instance, and apply JDO nature
        FieldDescriptorImpl fieldDescriptor =
            new FieldDescriptorImpl(fieldName, typeInfo, handler, fieldMap.getTransient());
        fieldDescriptor.addNature(FieldDescriptorJDONature.class.getName());
       
        fieldDescriptor.setRequired(fieldMap.getRequired());

        // If we're using an ExtendedFieldHandler we need to set the FieldDescriptor
        if (exfHandler != null) {
            ((FieldHandlerFriend) exfHandler).setFieldDescriptor(fieldDescriptor);
        }

        // if SQL mapping declares transient
        if (sql.getTransient()) {
            fieldDescriptor.setTransient(true);
        }
       
        FieldDescriptorJDONature fieldJdoNature =
            new FieldDescriptorJDONature(fieldDescriptor);
       
View Full Code Here

Examples of org.exolab.castor.mapping.loader.FieldDescriptorImpl

        mapping.setMapTo(mapTo);
        setMapping(mapping);

        //ssnr field
        String ssnrFieldName = "ssnr";
        FieldDescriptorImpl ssnrFieldDescr;
        FieldMapping ssnrFM = new FieldMapping();
        TypeInfo ssnrType = new TypeInfo(java.lang.Long.class);
        // Set columns required (= not null)
        ssnrType.setRequired(true);

        FieldHandler ssnrHandler;
        try {
            Method ssnrGetMethod = Father.class.getMethod("getSsnr", null);
            Method ssnrSetMethod = Father.class.getMethod("setSsnr", new Class[]{
                long.class});

            ssnrHandler = new FieldHandlerImpl(ssnrFieldName, null, null,
                ssnrGetMethod, ssnrSetMethod, ssnrType);

        } catch (SecurityException e1) {
            throw new RuntimeException(e1.getMessage());
        } catch (MappingException e1) {
            throw new RuntimeException(e1.getMessage());
        } catch (NoSuchMethodException e1) {
            throw new RuntimeException(e1.getMessage());
        }
        // Instantiate ssnr field descriptor
        ssnrFieldDescr = new FieldDescriptorImpl(ssnrFieldName, ssnrType,ssnrHandler, false);
        ssnrFieldDescr.addNature(FieldDescriptorJDONature.class.getName());
        FieldDescriptorJDONature ssnrFieldJdoNature = new FieldDescriptorJDONature(ssnrFieldDescr);
        ssnrFieldJdoNature.setSQLName(new String[] { "ssnr" });
        ssnrFieldJdoNature.setSQLType(new int[] {SQLTypeInfos.javaType2sqlTypeNum(java.lang.Long.class) });
        ssnrFieldJdoNature.setManyTable(null);
        ssnrFieldJdoNature.setManyKey(new String[] {});
        ssnrFieldJdoNature.setDirtyCheck(false);
        ssnrFieldJdoNature.setReadOnly(false);

        ssnrFieldDescr.setContainingClassDescriptor(this);
        ssnrFieldDescr.setIdentity(true);
        ssnrFM.setIdentity(true);
        ssnrFM.setDirect(false);
        ssnrFM.setName("ssnr");
        ssnrFM.setRequired(true);
        ssnrFM.setSetMethod("setSsnr");
        ssnrFM.setGetMethod("getSsnr");
        Sql ssnrSql = new Sql();
        ssnrSql.addName("ssnr");
        ssnrSql.setType("integer");
        ssnrFM.setSql(ssnrSql);
        ssnrFM.setType("long");
        choice.addFieldMapping(ssnrFM);

        //firstName field
        String firstNameFieldName = "firstName";
        FieldDescriptorImpl firstNameFieldDescr;
        FieldMapping firstNameFM = new FieldMapping();
        TypeInfo firstNameType = new TypeInfo(java.lang.String.class);
        // Set columns required (= not null)
        firstNameType.setRequired(true);

        FieldHandler firstNameHandler;
        try {
            Method firstNameGetMethod = Father.class.getMethod("getFirstName", null);
            Method firstNameSetMethod = Father.class.getMethod("setFirstName", new Class[]{
                java.lang.String.class});

            firstNameHandler = new FieldHandlerImpl(firstNameFieldName, null, null,
                firstNameGetMethod, firstNameSetMethod, firstNameType);

        } catch (SecurityException e1) {
            throw new RuntimeException(e1.getMessage());
        } catch (MappingException e1) {
            throw new RuntimeException(e1.getMessage());
        } catch (NoSuchMethodException e1) {
            throw new RuntimeException(e1.getMessage());
        }
        // Instantiate firstName field descriptor
        firstNameFieldDescr = new FieldDescriptorImpl(firstNameFieldName, firstNameType,firstNameHandler, false);
        firstNameFieldDescr.addNature(FieldDescriptorJDONature.class.getName());
        FieldDescriptorJDONature firstNameFieldJdoNature = new FieldDescriptorJDONature(firstNameFieldDescr);
        firstNameFieldJdoNature.setSQLName(new String[] { "firstName" });
        firstNameFieldJdoNature.setSQLType(new int[] {SQLTypeInfos.javaType2sqlTypeNum(java.lang.String.class) });
        firstNameFieldJdoNature.setManyTable(null);
        firstNameFieldJdoNature.setManyKey(new String[] {});
        firstNameFieldJdoNature.setDirtyCheck(false);
        firstNameFieldJdoNature.setReadOnly(false);

        firstNameFieldDescr.setContainingClassDescriptor(this);
        firstNameFieldDescr.setIdentity(false);
        firstNameFM.setIdentity(false);
        firstNameFM.setDirect(false);
        firstNameFM.setName("firstName");
        firstNameFM.setRequired(true);
        firstNameFM.setSetMethod("setFirstName");
        firstNameFM.setGetMethod("getFirstName");
        Sql firstNameSql = new Sql();
        firstNameSql.addName("firstName");
        firstNameSql.setType("varchar");
        firstNameFM.setSql(firstNameSql);
        firstNameFM.setType("java.lang.String");
        choice.addFieldMapping(firstNameFM);

        //lastName field
        String lastNameFieldName = "lastName";
        FieldDescriptorImpl lastNameFieldDescr;
        FieldMapping lastNameFM = new FieldMapping();
        TypeInfo lastNameType = new TypeInfo(java.lang.String.class);
        // Set columns required (= not null)
        lastNameType.setRequired(true);

        FieldHandler lastNameHandler;
        try {
            Method lastNameGetMethod = Father.class.getMethod("getLastName", null);
            Method lastNameSetMethod = Father.class.getMethod("setLastName", new Class[]{
                java.lang.String.class});

            lastNameHandler = new FieldHandlerImpl(lastNameFieldName, null, null,
                lastNameGetMethod, lastNameSetMethod, lastNameType);

        } catch (SecurityException e1) {
            throw new RuntimeException(e1.getMessage());
        } catch (MappingException e1) {
            throw new RuntimeException(e1.getMessage());
        } catch (NoSuchMethodException e1) {
            throw new RuntimeException(e1.getMessage());
        }
        // Instantiate lastName field descriptor
        lastNameFieldDescr = new FieldDescriptorImpl(lastNameFieldName, lastNameType,lastNameHandler, false);
        lastNameFieldDescr.addNature(FieldDescriptorJDONature.class.getName());
        FieldDescriptorJDONature lastNameFieldJdoNature = new FieldDescriptorJDONature(lastNameFieldDescr);
        lastNameFieldJdoNature.setSQLName(new String[] { "lastName" });
        lastNameFieldJdoNature.setSQLType(new int[] {SQLTypeInfos.javaType2sqlTypeNum(java.lang.String.class) });
        lastNameFieldJdoNature.setManyTable(null);
        lastNameFieldJdoNature.setManyKey(new String[] {});
        lastNameFieldJdoNature.setDirtyCheck(false);
        lastNameFieldJdoNature.setReadOnly(false);

        lastNameFieldDescr.setContainingClassDescriptor(this);
        lastNameFieldDescr.setIdentity(false);
        lastNameFM.setIdentity(false);
        lastNameFM.setDirect(false);
        lastNameFM.setName("lastName");
        lastNameFM.setRequired(true);
        lastNameFM.setSetMethod("setLastName");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.