Package org.exolab.castor.builder.info.nature

Examples of org.exolab.castor.builder.info.nature.XMLInfoNature


                memberAndAccessorFactory, contentMemberAndAccessorFactory);
        final XSListType collection =
            XSCollectionFactory.createCollection(SourceGeneratorConstants.FIELD_INFO_ODMG,
                        contentType, useJava50);
        if (hasNature(XMLInfoNature.class.getName())) {
            XMLInfoNature xmlNature = new XMLInfoNature(this);
            xmlNature.setSchemaType(collection);
        }
    }
View Full Code Here


     * @param fieldInfo the fieldInfo to translate
     * @param jsc the JSourceCode in which to add the source to
     */
    public void generateInitializerCode(final FieldInfo fieldInfo, final JSourceCode jsc) {
        //set the default value
        XMLInfoNature xmlNature = new XMLInfoNature(fieldInfo);
       
        if (!xmlNature.getSchemaType().isPrimitive()) {
            String value = fieldInfo.getDefaultValue();
            boolean dateTime = xmlNature.getSchemaType().isDateTime();
            if (value == null) {
                value = fieldInfo.getFixedValue();
            }
            if (value != null) {
                StringBuilder buffer = new StringBuilder(50);
View Full Code Here

     *
     * @param fieldInfo the fieldInfo to translate
     * @param jClass the jclass the jField will be added to
     */
    public final void createJavaField(final FieldInfo fieldInfo,  final JClass jClass) {
        XMLInfoNature xmlNature = new XMLInfoNature(fieldInfo);
        XSType type = xmlNature.getSchemaType();
        JType jType = type.getJType();
        JField field = new JField(type.getJType(), fieldInfo.getName());

        if (xmlNature.getSchemaType().isDateTime()) {
            field.setDateTime(true);
        }

        if (fieldInfo.isStatic() || fieldInfo.isFinal()) {
            JModifiers modifiers = field.getModifiers();
            modifiers.setFinal(fieldInfo.isFinal());
            modifiers.setStatic(fieldInfo.isStatic());
        }

        if (!(fieldInfo.getVisibility().equals("private"))) {
            JModifiers modifiers = field.getModifiers();
            if (fieldInfo.getVisibility().equals("protected")) {
                modifiers.makeProtected();
            } else if (fieldInfo.getVisibility().equals("public")) {
                modifiers.makePublic();
            }
        }

        //-- set init String
        if (fieldInfo.getDefaultValue() != null) {
            field.setInitString(fieldInfo.getDefaultValue());
        }

        if (fieldInfo.getFixedValue() != null && !xmlNature.getSchemaType().isDateTime()) {
            field.setInitString(fieldInfo.getFixedValue());
        }

        //-- set Javadoc comment
        if (fieldInfo.getComment() != null) {
View Full Code Here

        JMethod method    = null;
        JSourceCode jsc   = null;

        String mname = fieldInfo.getMethodSuffix();

        XSType xsType = new XMLInfoNature(fieldInfo).getSchemaType();
        JType jType  = xsType.getJType();

        //-- create get method
        method = new JMethod(fieldInfo.getReadMethodName(), jType,
                             "the value of field '" + mname + "'.");
View Full Code Here

        JMethod method    = null;
        JSourceCode jsc   = null;

        String mname = fieldInfo.getMethodSuffix();

        XSType xsType = new XMLInfoNature(fieldInfo).getSchemaType();
        xsType.getJType();

        //-- create hasMethod
        method = new JMethod(fieldInfo.getHasMethodName(), JType.BOOLEAN,
                             "true if at least one " + mname + " has been added");
View Full Code Here

     private void createSetterMethod(final FieldInfo fieldInfo,
             final JClass jClass, final boolean useJava50) {
        JMethod method    = null;
        JSourceCode jsc   = null;

        XMLInfoNature xmlNature = new XMLInfoNature(fieldInfo);
       
        String mname  = fieldInfo.getMethodSuffix();
        XSType xsType = xmlNature.getSchemaType();
        JType jType   = xsType.getJType();

        //-- create set method
        /*
         * fieldInfo.getWriteMethodName() will either prefix the method
         * with 'add' (for multivalued fields) or 'set'!
         * @see FieldInfo#getWriteMethodeName()
         */
        method = new JMethod(fieldInfo.getWriteMethodName());
        jClass.addMethod(method);

        String paramName = fieldInfo.getName();

        //-- make parameter name pretty,
        //-- simply for aesthetic beauty
        if (paramName.indexOf('_') == 0) {
            String tempName = paramName.substring(1);
            if (_javaNaming.isValidJavaIdentifier(tempName)) {
                paramName = tempName;
            }
        }

        method.addParameter(new JParameter(jType, paramName));
//        if (useJava50) {
//            Java5HacksHelper.addOverrideAnnotations(method.getSignature()); // DAB Java 5.0 hack
//        }
        createSetterComment(fieldInfo, method.getJDocComment());
        jsc = method.getSourceCode();

        String fieldName = fieldInfo.getName();
        //-- bound properties
        if (fieldInfo.isBound()) {
            // save old value
            jsc.add("java.lang.Object old");
            jsc.append(mname);
            jsc.append(" = ");
            //-- 'this.' ensures this refers to the class member not the parameter
            jsc.append(xsType.createToJavaObjectCode("this." + fieldName));
            jsc.append(";");
        }

        //-- set new value
        jsc.add("this.");
        jsc.append(fieldName);
        jsc.append(" = ");
        jsc.append(paramName);
        jsc.append(";");

        if (fieldInfo.getFieldInfoReference() != null) {
            jsc.add("this.");
            jsc.append(fieldInfo.getFieldInfoReference().getName());
            jsc.append(" = ");

            JType referencedJType = new XMLInfoNature(fieldInfo.getFieldInfoReference()).getSchemaType().getJType();
            if (referencedJType.isPrimitive()) {
                jsc.append(paramName);
            } else if (jType.isPrimitive()) {
                JPrimitiveType primitive = (JPrimitiveType) jType;
                jsc.append("new ");
View Full Code Here

TOP

Related Classes of org.exolab.castor.builder.info.nature.XMLInfoNature

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.