Examples of XMLInfoNature


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

        jsc.append(" target = (");
        jsc.append(localClassName);
        jsc.append(") object;");
        // -- check for null primitives
       
        XMLInfoNature xmlNature = new XMLInfoNature(member);
       
        if (xsType.isPrimitive() && !_config.usePrimitiveWrapper()) {
            if ((!xmlNature.isRequired()) && (!xsType.isEnumerated())
                    && (!xmlNature.isMultivalued())) {
                jsc
                        .add("// if null, use delete method for optional primitives ");
                jsc.add("if (value == null) {");
                jsc.indent();
                jsc.add("target.");
View Full Code Here

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

     */
    private void createResetMethod(final FieldInfo member,
            final String localClassName,
            final JSourceCode jsc) {
        // -- reset method (handle collections only)
        if (new XMLInfoNature(member).isMultivalued()) {
            CollectionInfo cInfo = (CollectionInfo) member;
            // FieldInfo content = cInfo.getContent();
            jsc.add("public void resetValue(Object object)"
                    + " throws IllegalStateException, IllegalArgumentException {");
            jsc.indent();
View Full Code Here

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

        // if (member.getDeclaringClassInfo() != null) {
        // isAbstract = member.getDeclaringClassInfo().isAbstract();
        // }

        // check whether class of member is declared as abstract
        XMLInfoNature xmlNature = new XMLInfoNature(member);
       
        if (xmlNature.getSchemaType() != null
                && xmlNature.getSchemaType().getJType() instanceof JClass) {
            JClass jClass = (JClass) xmlNature.getSchemaType().getJType();
            isAbstract = jClass.getModifiers().isAbstract();
        }

        if (!isAbstract && xsType.getJType() instanceof JClass) {
            JClass jClass = (JClass) xsType.getJType();
            isAbstract = jClass.getModifiers().isAbstract();
        }

        if (!isAbstract && xmlNature.getSchemaType() instanceof XSListType) {
            XSListType xsList = (XSListType) xmlNature.getSchemaType();
            if (xsList.getContentType().getJType() instanceof JClass) {
                JClass componentType = (JClass) xsList.getContentType().getJType();
                if (componentType.getModifiers().isAbstract()) {
                    isAbstract = componentType.getModifiers().isAbstract();
                }
View Full Code Here

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

     */
    private void createSetAsReferenceMethod(final CollectionInfo fieldInfo,
            final JClass jClass, final boolean useJava50) {
        JMethod method = new JMethod("set" + fieldInfo.getMethodSuffix()
                + fieldInfo.getReferenceSuffix());
        final JType collectionJType = new XMLInfoNature(fieldInfo).getSchemaType().getJType();
        JParameter parameter = new JParameter(
                collectionJType, fieldInfo.getParameterPrefix() + collectionJType.getLocalName());
        method.addParameter(parameter);

        // create Javadoc
View Full Code Here

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

                            final FieldMemberAndAccessorFactory contentMemberAndAccessorFactory) {
        super(contentType, name, elementName, useJava50,
                memberAndAccessorFactory, contentMemberAndAccessorFactory);
        // --override the schemaType
        if (hasNature(XMLInfoNature.class.getName())) {
            XMLInfoNature xmlNature = new XMLInfoNature(this);
            xmlNature.setSchemaType(XSCollectionFactory.createCollection(collectionType,
                    contentType, useJava50));
        }
    } // -- CollectionInfoJ2
View Full Code Here

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

       for (int i = 0; i < fInfos.length; i++) {
           fInfo = fInfos[i];
           cInfo = fInfo.getDeclaringClassInfo();
           JDOClassInfoNature cNature = new JDOClassInfoNature(cInfo);
           if (cNature.getPrimaryKeys() != null) {
               if (cNature.getPrimaryKeys().contains(new XMLInfoNature(fInfo).getNodeName())) {
                   continue;
               }
           }
           if (str.equals("")) {
               str = str + new XMLInfoNature(fInfo).getNodeName() + "FieldDescr";
           } else {
               str = str + "," new XMLInfoNature(fInfo).getNodeName() + "FieldDescr";
           }
       }
       return str;
   }
View Full Code Here

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

    * @return JSourceCode created in this method
    */
   private JSourceCode createEntityFieldInfoPart(final FieldInfo fInfo, final JSourceCode jsc) {
       JDOFieldInfoNature fNature = new JDOFieldInfoNature(fInfo);
       JDOClassInfoNature cNature = new JDOClassInfoNature(fInfo.getDeclaringClassInfo());
       XMLInfoNature xmlNature = new XMLInfoNature(fInfo);
      
       //-- set name
       String name = xmlNature.getNodeName();
       jsc.add("");
       jsc.add("//" + name + " field");
       jsc.add("String " + name + "FieldName = \"" + name + "\";");

       //-- initialize objects
       jsc.add("FieldDescriptorImpl " + name + "FieldDescr;");

       jsc.add("FieldMapping " + name + "FM = new FieldMapping();");

       //-- set typeInfo
       String type = null;
       XSType schemaType;
      
       schemaType = xmlNature.getSchemaType();
       JType javaType = schemaType.getJType();
       type = javaType.toString();
       String wrapperType = null;
       if (javaType instanceof JPrimitiveType) {
           wrapperType = ((JPrimitiveType) javaType).getWrapperName();
       } else {
           wrapperType = type;
       }

       // TODO IS THERE A NEED TO CHECK THIS?!
       if ((type != null) && (type.length() > 0)) {
           jsc.add("TypeInfo " + name
                   + "Type = new TypeInfo(" + wrapperType + ".class);");
       }

       jsc.add("// Set columns required (= not null)");
       jsc.add(name + "Type.setRequired("
               + Boolean.toString(xmlNature.isRequired()) + ");");

       jsc.add("");

       jsc.add("FieldHandler " + name + "Handler;");
       jsc.add("try {");

       //-- get/set methods
       jsc.indent();
       String className = fInfo.getDeclaringClassInfo().getJClass().getLocalName();
       // TODO IS THERE A NEED TO CHECK THIS?!
       if ((className != null) && (className.length() > 0)) {
           jsc.add("Method " + name + "GetMethod = "
                   + className + ".class.getMethod(\"get"
                   + toUpperCaseFirstLetter(name) + "\", null);");
           jsc.add("Method " + name + "SetMethod = "
                   + className + ".class.getMethod(\"set"
                   + toUpperCaseFirstLetter(name) + "\", new Class[]{");
       }

       // TODO IS THERE A NEED TO CHECK THIS?!
       if ((type != null) && (type.length() > 0)) {
           jsc.addIndented(type + ".class});");
       }

       jsc.add("");
       jsc.add(name + "Handler = new FieldHandlerImpl(" + name + "FieldName, ");
       jsc.append("null, null,");
       jsc.addIndented(name + "GetMethod, " + name + "SetMethod, " + name + "Type);");
       jsc.unindent();
       jsc.add("");

       //-- Catch of exceptions
       jsc.add("} catch (SecurityException e1) {");
       jsc.indent();
       jsc.add("throw new RuntimeException(e1.getMessage());");
       jsc.unindent();
       jsc.add("} catch (MappingException e1) {");
       jsc.indent();
       jsc.add("throw new RuntimeException(e1.getMessage());");
       jsc.unindent();
       jsc.add("} catch (NoSuchMethodException e1) {");
       jsc.indent();
       jsc.add("throw new RuntimeException(e1.getMessage());");
       jsc.unindent();
       jsc.add("}");

//       //-- JDOFieldDescriptorImpl constructor
//       jsc.add("// Instantiate " + name + " field descriptor");
//       jsc.add(name + "FieldDescr = new JDOFieldDescriptorImpl(");
//       jsc.append(name + "FieldName, " + name + "Type,");
//       jsc.indent();
//       jsc.add(name + "Handler, ");
//       jsc.append(Boolean.toString(fInfo.isTransient()) + ", ");
//       String sqlName = new JDOFieldInfoNature(fInfo).getColumnName();
//       jsc.append("new String[] { \"" + sqlName + "\" },");
//       jsc.add("new int[] {SQLTypeInfos");
//       jsc.indent();
//       jsc.add(".javaType2sqlTypeNum(");
//
//       // TODO IS THERE NEED TO CHECK THIS?!
//       if ((type != null) && (type.length() > 0)) {
//           jsc.append(wrapperType + ".class) },");
//       }
//
//       jsc.unindent();
//       jsc.add("null, new String[] {}, ");
//       jsc.append(Boolean.toString(fNature.isDirty()) + ", ");
//       jsc.append(Boolean.toString(fNature.isReadOnly()) + ");");
//       jsc.unindent();

       //-- invoke FieldDescriptorImpl constructor
       jsc.add("// Instantiate " + name + " field descriptor");
       jsc.add(name + "FieldDescr = new FieldDescriptorImpl(");
       jsc.append(name + "FieldName, " + name + "Type,");
       jsc.append(name + "Handler, ");
       jsc.append(Boolean.toString(fInfo.isTransient()) + ");");

       jsc.add(name + "FieldDescr.addNature(FieldDescriptorJDONature.class.getName());");

       jsc.add("FieldDescriptorJDONature " + name + "FieldJdoNature = new FieldDescriptorJDONature("
               + name + "FieldDescr);");

       String sqlName = new JDOFieldInfoNature(fInfo).getColumnName();
       jsc.add(name + "FieldJdoNature.setSQLName(new String[] { \"" + sqlName + "\" });");
       jsc.add(name + "FieldJdoNature.setSQLType(new int[] {SQLTypeInfos");
       jsc.append(".javaType2sqlTypeNum(");

       // TODO IS THERE NEED TO CHECK THIS?!
       if ((type != null) && (type.length() > 0)) {
           jsc.append(wrapperType + ".class) });");
       }

       // jsc.add("null, new String[] {}, ");
       jsc.add(name + "FieldJdoNature.setManyTable(null);");
       jsc.add(name + "FieldJdoNature.setManyKey(new String[] {});");
       jsc.add(name + "FieldJdoNature.setDirtyCheck(" + Boolean.toString(fNature.isDirty()) + ");");
       jsc.add(name + "FieldJdoNature.setReadOnly(" + Boolean.toString(fNature.isReadOnly()) + ");");

       jsc.add("");

       //-- parent class descriptor
       jsc.add(name + "FieldDescr.setContainingClassDescriptor(this);");
      
       boolean isPrimaryKey = false;
       if (cNature.getPrimaryKeys() != null) {
           isPrimaryKey = (cNature.getPrimaryKeys().contains(xmlNature.getNodeName()));
       }
      
       jsc.add(name + "FieldDescr.setIdentity("
               + Boolean.toString(isPrimaryKey) + ");");

       //-- fieldmapping
       jsc.add(name + "FM.setIdentity(" + Boolean.toString(isPrimaryKey) + ");");
       jsc.add(name + "FM.setDirect(false);");
       jsc.add(name + "FM.setName(\"" + name + "\");");
       jsc.add(name + "FM.setRequired(" + xmlNature.isRequired() + ");");
       jsc.add(name + "FM.setSetMethod(\"set"
               + toUpperCaseFirstLetter(name) + "\");");
       jsc.add(name + "FM.setGetMethod(\"get"
               + toUpperCaseFirstLetter(name) + "\");");

View Full Code Here

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

    */
   private JSourceCode createOneToOneFieldInfoPart(final FieldInfo fInfo, final JSourceCode jsc) {
//       JDOFieldInfoNature fNature = new JDOFieldInfoNature(fInfo);
       JDOClassInfoNature cNature = new JDOClassInfoNature(fInfo.getDeclaringClassInfo());
       JDOOneToOneNature oneNature = new JDOOneToOneNature(fInfo);
       XMLInfoNature xmlNature = new XMLInfoNature(fInfo);
      
       //-- set name
       String name = xmlNature.getNodeName();
       jsc.add("");
       jsc.add("//" + name + " field");
       jsc.add("String " + name + "FieldName = \"" + name + "\";");
      
       String sqlName = oneNature.getForeignKeys().get(0).toString();
       jsc.add("String " + name + "SqlName = \"" + sqlName + "\";");
      
       //-- initialize objects
       jsc.add("FieldDescriptorImpl " + name + "FieldDescr;");
       jsc.add("FieldMapping " + name + "FM = new FieldMapping();");

       //-- set typeInfo
       String type = null;
       XSType schemaType;
      
       schemaType = xmlNature.getSchemaType();
       JType javaType = schemaType.getJType();
       type = javaType.toString();
      
       String wrapperType = null;
       if (javaType instanceof JPrimitiveType) {
        wrapperType = ((JPrimitiveType) javaType).getWrapperName();
       } else {
           wrapperType = type;
       }


       // TODO IS THERE A NEED TO CHECK THIS?!
       if ((type != null) && (type.length() > 0)) {
           jsc.add("TypeInfo " + name
                   + "Type = new TypeInfo(" + type + ".class);");
       }

       jsc.add("// Set columns required (= not null)");
       jsc.add(name + "Type.setRequired("
               + Boolean.toString(xmlNature.isRequired()) + ");");

       jsc.add("");

       jsc.add("FieldHandler " + name + "Handler;");
       jsc.add("try {");

       //-- get/set methods
       jsc.indent();
       // TODO HOW ABOUT GETTING THE NAME FROM NATURE?
       String className = fInfo.getDeclaringClassInfo().getJClass().getLocalName();
       // TODO IS THERE A NEED TO CHECK THIS?!
       if ((className != null) && (className.length() > 0)) {
           jsc.add("Method " + name + "GetMethod = "
                   + className + ".class.getMethod(\"get"
                   + toUpperCaseFirstLetter(name) + "\", null);");
           jsc.add("Method " + name + "SetMethod = "
                   + className + ".class.getMethod(\"set"
                   + toUpperCaseFirstLetter(name) + "\", new Class[]{");
       }

       // TODO IS THERE A NEED TO CHECK THIS?!
       if ((type != null) && (type.length() > 0)) {
           jsc.addIndented(type + ".class});");
       }

       jsc.add("");
       jsc.add(name + "Handler = new FieldHandlerImpl(" + name + "FieldName, ");
       jsc.append("null, null,");
       jsc.addIndented(name + "GetMethod, " + name + "SetMethod, " + name + "Type);");
       jsc.unindent();
       jsc.add("");

       //-- Catch of exceptions
       jsc.add("} catch (SecurityException e1) {");
       jsc.indent();
       jsc.add("throw new RuntimeException(e1.getMessage());");
       jsc.unindent();
       jsc.add("} catch (MappingException e1) {");
       jsc.indent();
       jsc.add("throw new RuntimeException(e1.getMessage());");
       jsc.unindent();
       jsc.add("} catch (NoSuchMethodException e1) {");
       jsc.indent();
       jsc.add("throw new RuntimeException(e1.getMessage());");
       jsc.unindent();
       jsc.add("}");


//       //-- JDOFieldDescriptorImpl constructor
//       jsc.add("// Instantiate " + name + " field descriptor");
//       jsc.add(name + "FieldDescr = new JDOFieldDescriptorImpl(");
//       jsc.append(name + "FieldName, " + name + "Type,");
//       jsc.indent();
//       jsc.add(name + "Handler, ");
//       jsc.append(Boolean.toString(fInfo.isTransient()) + ", ");
//       jsc.append("new String[] { " + name + "SqlName },");
//       jsc.add("new int[] {SQLTypeInfos");
//       jsc.indent();
//       jsc.add(".javaType2sqlTypeNum(");
//
//       // TODO IS THERE NEED TO CHECK THIS?!
//       if ((type != null) && (type.length() > 0)) {
//           jsc.append(wrapperType + ".class) },");
//       }
//
//       jsc.unindent();
//       jsc.add("null, new String[] { " + name + "SqlName }, ");
//       jsc.append(Boolean.toString(oneNature.isDirty()) + ", ");
//       jsc.append(Boolean.toString(oneNature.isReadOnly()) + ");");
//       jsc.unindent();

       //-- invoke FieldDescriptorImpl constructor
       jsc.add("// Instantiate " + name + " field descriptor");
       jsc.add(name + "FieldDescr = new FieldDescriptorImpl(");
       jsc.append(name + "FieldName, " + name + "Type,");
       jsc.append(name + "Handler, ");
       jsc.append(Boolean.toString(fInfo.isTransient()) + ");");

       jsc.add(name + "FieldDescr.addNature(FieldDescriptorJDONature.class.getName());");

       jsc.add("FieldDescriptorJDONature " + name + "FieldJdoNature = new FieldDescriptorJDONature("
               + name + "FieldDescr);");

       jsc.add(name + "FieldJdoNature.setSQLName(new String[] { " + name + "SqlName });");
       jsc.add(name + "FieldJdoNature.setSQLType(new int[] {SQLTypeInfos");
       jsc.append(".javaType2sqlTypeNum(");

       // TODO IS THERE NEED TO CHECK THIS?!
       if ((type != null) && (type.length() > 0)) {
           jsc.append(wrapperType + ".class) });");
       }

//       jsc.add(name + "FieldJdoNature.setManyTable(null);");
       jsc.add(name + "FieldJdoNature.setManyKey(new String[] { " + name + "SqlName });");
       jsc.add(name + "FieldJdoNature.setDirtyCheck(" + Boolean.toString(oneNature.isDirty()) + ");");
       jsc.add(name + "FieldJdoNature.setReadOnly(" + Boolean.toString(oneNature.isReadOnly()) + ");");

       jsc.add("");

       //-- parent class descriptor
       jsc.add(name + "FieldDescr.setContainingClassDescriptor(this);");
       jsc.add(name + "FieldDescr.setClassDescriptor(new " + getLocalName(type)
               + "JDODescriptor());");
      
       boolean isPrimaryKey = false;
       if (cNature.getPrimaryKeys() != null) {
           isPrimaryKey = (cNature.getPrimaryKeys().contains(xmlNature.getNodeName()));
       }

       //-- fieldmapping
       jsc.add(name + "FM.setIdentity(" + Boolean.toString(isPrimaryKey) + ");");
       jsc.add(name + "FM.setDirect(false);");
       jsc.add(name + "FM.setName(\"" + name + "\");");
       jsc.add(name + "FM.setRequired(" + xmlNature.isRequired() + ");");
       jsc.add(name + "FM.setSetMethod(\"set"
               + toUpperCaseFirstLetter(name) + "\");");
       jsc.add(name + "FM.setGetMethod(\"get"
               + toUpperCaseFirstLetter(name) + "\");");

View Full Code Here

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

    public FieldInfo(final XSType type, final String name,
            final FieldMemberAndAccessorFactory memberAndAccessorFactory) {
        this._name    = name;
        this._memberAndAccessorFactory = memberAndAccessorFactory;
        this.addNature(XMLInfoNature.class.getName());
        XMLInfoNature xmlNature = new XMLInfoNature(this);
        xmlNature.setSchemaType(type);
    } //-- FieldInfo
View Full Code Here

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

    /**
     * Returns the name of the write method for this FieldInfo.
     * @return the name of the write method for this FieldInfo.
     */
    public final String getWriteMethodName() {
        if (new XMLInfoNature(this).isMultivalued()) {
            return METHOD_PREFIX_ADD + getMethodSuffix();
        }
        return METHOD_PREFIX_SET + getMethodSuffix();
    } //-- getWriteMethodName
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.