private String toJavaName(String name, boolean firstLetterIsUpperCase) {

    name = name.toLowerCase();

    StringBuffer res = new StringBuffer();

    boolean nextIsUpperCase = firstLetterIsUpperCase;

    for (int i = 0; i < name.length(); i++) {
      char c = name.charAt(i);

      if (nextIsUpperCase) {
        c = Character.toUpperCase(c);
      }

      if (Character.isLetter(c)) {
        res.append(c);
        nextIsUpperCase = false;
      } else {
        nextIsUpperCase = true;
      }
    }

    return res.toString();
  }
 public String resolveSuperClassType(DataObject dataObject) {
   StringBuffer type = new StringBuffer("");
   if (dataObject.getSuperClassName() != null && !"".equals(dataObject.getSuperClassName())) {
     type.append("extends ");
     type.append(dataObject.getSuperClassName());
   }
   return type.toString();
 }
  public String fitToSize(int size, String name, char padChar) {
    int n = size - name.length();

    StringBuffer buf = new StringBuffer();

    buf.append(name);

    for (int i = 0; i < n; i++) {
      buf.append(padChar);
    }

    return buf.toString();
  }
  public String resolveAnnotationType(Annotation annotation) {
    StringBuffer type = new StringBuffer();
    AnnotationDefinition annotationDefinition = annotation.getAnnotationDefinition();

    if (annotationDefinition == null) {
      logger.warn("Annotation definition for annotation: " + annotation + " is not defined.");
      return type.toString();
    }

    if (annotationDefinition.isMarker()) {
      return type.toString();
    }

    // finally we can process annotation members.
    Object memberValue;
    int memberCount = 0;
    for (AnnotationMemberDefinition memberDefinition :
        annotationDefinition.getAnnotationMembers()) {
      if ((memberValue = annotation.getValue(memberDefinition.getName())) != null) {
        // a value has been set for this member.
        if (memberCount == 0) type.append("(");
        if (memberCount > 0) type.append(", ");
        type.append(resolveMemberType(memberDefinition, memberValue));
        memberCount++;
      }
    }
    if (memberCount > 0) type.append(")");

    return type.toString();
  }
 public String resolveAttributeType(ObjectProperty attribute) {
   StringBuffer type = new StringBuffer("");
   if (attribute.isMultiple()) {
     if (attribute.getBag() != null && !"".equals(attribute.getBag())) {
       type.append(attribute.getBag());
     } else {
       type.append("java.util.List");
     }
     type.append("<");
   }
   type.append(attribute.getClassName());
   if (attribute.isMultiple()) {
     type.append(">");
   }
   return type.toString();
 }
 public String resolveImplementedInterfacesType(DataObject dataObject) {
   StringBuffer type = new StringBuffer("");
   type.append("implements java.io.Serializable");
   return type.toString();
 }
  public String resolveMemberType(AnnotationMemberDefinition memberDefinition, Object value) {
    StringBuffer type = new StringBuffer();

    type.append(memberDefinition.getName());
    type.append(" = ");

    if (memberDefinition.isEnum()) {
      type.append(memberDefinition.getClassName());
      type.append(".");
      type.append(value);
    } else if (memberDefinition.isString()) {
      type.append("\"");
      type.append(value);
      type.append("\"");
    } else if (memberDefinition.isPrimitiveType()) {
      // primitive types are wrapped by the java.lang.type.

      if (Character.class.getName().equals(memberDefinition.getClassName())) {
        type.append("'");
        type.append(value.toString());
        type.append("'");
      } else if (Long.class.getName().equals(memberDefinition.getClassName())) {
        type.append(value.toString());
        type.append("L");
      } else if (Float.class.getName().equals(memberDefinition.getClassName())) {
        type.append(value.toString());
        type.append("f");
      } else if (Double.class.getName().equals(memberDefinition.getClassName())) {
        type.append(value.toString());
        type.append("d");
      } else {
        type.append(value.toString());
      }
    }
    return type.toString();
  }