Package com.volantis.mcs.build.javadoc

Examples of com.volantis.mcs.build.javadoc.FieldInfo


    if (queryFields.size() > 0) {
      out.println();
      boolean resolvedFieldAdded = false; // used for adding a comment line if necessary
      for (Iterator i = queryFields.iterator(); i.hasNext();) {
        // get the name of the new field
        FieldInfo newField = (FieldInfo) i.next();
        String fieldName = newField.getName();
        // find out it if it has already been resolved
        boolean alreadyExists = false;
        if (resolvedFields != null) {
          for (int index = 0; index < resolvedFields.size(); index++) {
            FieldInfo existingField = (FieldInfo) resolvedFields.get(index);
            if (existingField.getName().equalsIgnoreCase(fieldName)) {
              alreadyExists = true;
              break;
            }
          }
        }
View Full Code Here


    out.println ("      = new " + objectClassName + " (dstId);");

    // Initialise the non identity fields.
    out.println ();
    for (Iterator i = extraObjectFields.iterator (); i.hasNext ();) {
      FieldInfo field = (FieldInfo) i.next ();
      String fieldName = field.getName ();
      MethodInfo setter = objectClassInfo.getSetterMethod (fieldName, true);
      MethodInfo getter = objectClassInfo.getGetterMethod (fieldName, true);

      out.println ("    copy." + setter.getName () + " ("
                   + "original." + getter.getName () + " ());");
View Full Code Here

      return;
    }

    // Initialise the object with the fields from the identity.
    for (Iterator i = fields.iterator (); i.hasNext ();) {
      FieldInfo field = (FieldInfo) i.next ();
      if (!GenerateUtilities.isProjectField(field)) {
          String fieldName = field.getName ();
          MethodInfo setter = dstClassInfo.getSetterMethod (fieldName, true);
          MethodInfo getter = srcClassInfo.getGetterMethod (fieldName, true);

          //System.out.println ("Field name " + fieldName
          //+ " setter " + setter
View Full Code Here

      return;
    }

    // Initialise the object with the fields from the identity.
    for (Iterator i = fields.iterator (); i.hasNext ();) {
      FieldInfo field = (FieldInfo) i.next ();
      String fieldName = field.getName ();
      MethodInfo setter = classInfo.getSetterMethod (fieldName, true);

      //System.out.println ("Field name " + fieldName
      //+ " setter " + setter);
View Full Code Here

        separator = indent;
      } else {
        out.print (separator);
      }

      FieldInfo field = (FieldInfo) f.next ();
      String fieldName = field.getName ();

      if (!fieldName.equals (parameterName)) {
        throw new IllegalStateException ("Parameter " + parameterName
                                         + " not the same as " + fieldName);
      }
View Full Code Here

                                           List fields,
                                           ClassInfo classInfo,
                                           String instanceName) {

    for (Iterator i = fields.iterator (); i.hasNext ();) {
      FieldInfo field = (FieldInfo) i.next ();
      String fieldName = field.getName ();

      String separator;
      if (fieldName.length () > 12) {
        separator = "\n" + indent + "  ";
      } else {
        separator = " ";
      }

      MethodInfo getter = classInfo.getGetterMethod (fieldName, true);

      String typeName = field.getTypeName ();
      out.println (indent + typeName + " " + fieldName
                   + separator + "= " + instanceName
                   + "." + getter.getName () + " ();");
    }
  }
View Full Code Here

        String utilitiesName = objectClassName + "Utilities";

        List allObjectFields = repInfo.getAllObjectFields();
        boolean utilitiesNeeded = false;
        for (Iterator i = allObjectFields.iterator(); i.hasNext();) {
            FieldInfo field = (FieldInfo) i.next();

            if (field.getValues() != null || field.requiresChecking()) {
                utilitiesNeeded = true;
                break;
            }
        }

        if (!utilitiesNeeded) {
            return;
        }

        String utilitiesQualifiedName = utilitiesPackage + "." + utilitiesName;

        // Open a file.
        PrintStream out = openFileForClass(utilitiesQualifiedName, generatedDir);

        // Write the header.
        GenerateUtilities.writeHeader(out, "PropertyValueLookupUtilities" );

        // Write the package declaration.
        out.println();
        out.println("package " + utilitiesPackage + ";");

        // Write the imports.
        SortedSet imports = new TreeSet();
        imports.add("java.util.HashMap");
        imports.add("java.util.Map");

        //imports.add ("org.apache.log4j.Category");

        GenerateUtilities.writeImports(out, imports);

        out.println();
        out.println("public class " + utilitiesName + " {");

        // Create the log4j object.
        //GenerateUtilities.writeLogger (out, utilitiesPackage, accessorName);

        // Declare any variables needed for the mapping.
        for (Iterator i = allObjectFields.iterator(); i.hasNext();) {
            FieldInfo field = (FieldInfo) i.next();
            writeDeclareUtilityFields(out, field);
        }

        out.println();
        out.println("  static {");

        out.println("    Object internal;");
        out.println("    String external;");

        // Initialise the variables needed for the mapping.
        for (Iterator i = allObjectFields.iterator(); i.hasNext();) {
            FieldInfo field = (FieldInfo) i.next();
            writeInitialiseUtilityFields(out, field);
        }

        out.println("  }");

        // Expose the variables.
        for (Iterator i = allObjectFields.iterator(); i.hasNext();) {
            FieldInfo field = (FieldInfo) i.next();
            writeUtilityMethods(out, field);
        }

        out.println("}");
View Full Code Here

                if (!initializedIdentityAttributesList) {
                    initialization.append("    identityAttributesList = new ArrayList();\n");
                    initializedIdentityAttributesList = true;
                }
                for (int i = 0; i < identityAttributesList.size(); i++) {
                    FieldInfo fieldInfo = (FieldInfo)identityAttributesList.get(i);
                    initialization.append("    identityAttributesList.add(\"" + fieldInfo.getXMLAttributeName() + "\");\n");
                }
            }

            for (Iterator i = allObjectFields.iterator(); i.hasNext();) {
                FieldInfo field = (FieldInfo) i.next();

                String fieldName = field.getName();
                String titledFieldName =
                        GenerateUtilities.getTitledString(fieldName);

                String xmlAttrName = field.getXMLAttributeName();
                if (xmlAttrName != null && !xmlAttrName.equals(fieldName)) {
                    if (!initializedPropertyNametoXMLAttrName) {
                        initialization.append("    propertyNameToXMLAttributeName = new HashMap();\n");
                        initializedPropertyNametoXMLAttrName = true;
                    }
                    initialization.append("    propertyNameToXMLAttributeName.put(\"" + fieldName +
                            "\", \"" + xmlAttrName + "\");\n");
                }

                String controlType = field.getControlType();
                if (controlType!=null) {
                    if (!initializedPropertyToControlType) {
                        initialization.append("    propertyToControlType = new HashMap();\n");
                        initializedPropertyToControlType = true;
                    }
                    initialization.append("    propertyToControlType.put(\"" + fieldName +
                            "\", \"" + controlType + "\");\n");
                }

                int maxLength = field.getMaximumLength();
                if (maxLength > 0) {
                    if (!initializedPropertyToMaxLength) {
                        initialization.append("    propertyToMaxLength = new HashMap();\n");
                        initializedPropertyToMaxLength = true;
                    }
                    initialization.append("    propertyToMaxLength.put(\"" + fieldName +
                            "\", new Integer(" + maxLength + "));\n");
                }

                boolean required = repInfo.isFieldRequired(fieldName);
                if (required) {
                    if (!initializedPropertyToRequired) {
                        initialization.append("    propertyToRequired = new HashMap();\n");
                        initializedPropertyToRequired = true;
                    }
                    initialization.append("    propertyToRequired.put(\"" + fieldName +
                            "\", Boolean.TRUE);\n");
                }

                List values = field.getValues();

                if (values == null || values.size() == 0) {
                    continue;
                }

                if (!initializedPropertyToArray) {
                    initialization.append("    propertyToArray = new HashMap();\n");
                    initializedPropertyToArray = true;
                }

                initialization.append("    propertyToArray.put(\"" +
                        fieldName + "\", " +
                        utilitiesName + ".get" +
                        titledFieldName + "Array());\n");

                if (field.requiresXMLMapping()) {
                    if (!initializedPropertyToMap) {
                        initialization.append("    propertyToMap = new HashMap();\n");
                        initializedPropertyToMap = true;
                    }
View Full Code Here

    for (int i = 0; i < identityFieldCount; i += 1) {

      // Get the field name.
      String fieldName = tags [i].text ();

      FieldInfo identityField;

      // If it is inherited from the base class then ignore it.
      identityField = identityBaseClassInfo.getField (fieldName, true);
     
      if (identityField != null) {
        if (GenerateUtilities.isProjectField(identityField)) {
            projectIdentityField = identityField;
        }
        // Add it to the list of all the identity fields.
        allIdentityFields.add (identityField);
        continue;
      }

      // Get the details of the object's field.
      FieldInfo objectField = objectClassInfo.getField (fieldName, true);

      String comment = objectField.getComment ();
      comment = getConstructorParameterComment (objectClassDoc,
                                                fieldName,
                                                comment);

      // Create a field for the identity class.
      identityField = new FieldInfo (objectField, comment);

      // Add it to the class.
      identityClassInfo.addField (identityField);

      // Add it to the list of all the identity fields.
      allIdentityFields.add (identityField);

      // Get the details of the object's getter method.
      MethodInfo objectGetter = objectClassInfo.getGetterMethod (fieldName,
                                                                 true);
      MethodInfo identityGetter
        = new MethodInfo (objectGetter.getName (),
                          objectGetter.getReturnType (),
                          objectGetter.getComment ());

      // Add it to the class.
      identityClassInfo.addMethod (identityGetter);
    }

      // Create the list of parameters for the constructor.
    List constructorParameters = new ArrayList ();
    for (Iterator i = allIdentityFields.iterator (); i.hasNext ();) {
      FieldInfo field = (FieldInfo) i.next ();

      ParameterInfo parameter = new ParameterInfo (field.getClassInfo (),
                                                   field.getName (),
                                                   field.getType ());
      constructorParameters.add (parameter);
    }
   
    ConstructorInfo constructor = new ConstructorInfo (constructorParameters);
    identityClassInfo.addConstructor (constructor);

    // Get the list of extra identity fields.
    if (guardianInfo == null) {
      extraIdentityFields = new ArrayList (allIdentityFields);
    } else {
      ClassInfo guardianIdentityClassInfo
        = guardianInfo.getIdentityClassInfo ();

      extraIdentityFields = getExtraFields (allIdentityFields,
                                            guardianIdentityClassInfo);
    }

    // Create the set of the names of fields to ignore.
    Set ignore = new HashSet ();
    ignore.add ("identity");

    tags = objectClassDoc.tags ("mariner-object-ignore-field");
    for (int i = 0; i < tags.length; i += 1) {
      //System.out.println ("Field " + tags [i].text ()
      //+ " should be ignored");
      ignore.add (tags [i].text ());
    }

    // Initialise the list of object fields.
    allObjectFields = objectClassInfo.getAllInstanceFields ();
    for (Iterator i = allObjectFields.iterator (); i.hasNext ();) {
      FieldInfo field = (FieldInfo) i.next ();
      String fieldName = field.getName ();
      if (ignore.contains (fieldName)) {
        //System.out.println ("Ignoring " + fieldName);
        i.remove ();
      }
    }

    extraObjectFields = getExtraFields (allObjectFields, identityClassInfo);

    dependentsInfo = new ArrayList ();
    tags = objectClassDoc.tags ("mariner-object-dependent");
    for (int i = 0; i < tags.length; i += 1) {
      String dependentClassName = tags [i].text ();
      ClassDoc dependentClassDoc = rootDoc.classNamed (dependentClassName);
      if (dependentClassDoc == null) {
        throw new IllegalStateException ("Cannot find class named "
                                         + dependentClassName);
      }

      RepositoryObjectInfo dependentInfo = getInstance (rootDoc,
                                                        dependentClassDoc);
      dependentsInfo.add (dependentInfo);
    }

      tags = objectClassDoc.tags("mariner-separate-accessors");
      if (tags.length == 0) {
          hasSeparateAccessors = false;
      } else if (tags.length == 1) {
          hasSeparateAccessors = true;
      } else {
          throw new IllegalStateException ("Class can only have one"
                                           + " mariner-separate-accessors");
      }

    requiredFields = new HashSet ();
    tags = objectClassDoc.tags ("mariner-object-required-field");
    for (int i = 0; i < tags.length; i += 1) {
      String fieldName = tags [i].text ();
      requiredFields.add (fieldName);
    }

    // All the identity fields are also required.
    for (Iterator i = allIdentityFields.iterator (); i.hasNext ();) {
      FieldInfo field = (FieldInfo) i.next ();
      String fieldName = field.getName();
     
      requiredFields.add (fieldName);
    }

View Full Code Here

      return fields;
    }

    List extraFields = new ArrayList ();
    for (Iterator i = fields.iterator (); i.hasNext ();) {
      FieldInfo field = (FieldInfo) i.next ();
      if (classInfo.getField (field.getName (), true) == null) {
        extraFields.add (field);
      }
    }

    return extraFields;
View Full Code Here

TOP

Related Classes of com.volantis.mcs.build.javadoc.FieldInfo

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.