Ejemplo n.º 1
0
  private String createStaticFieldDeclarationJavadoc(Class clss, Property field, int indent) {
    TextBuilder buf = new TextBuilder(LINE_SEP, this.context.getIndentationToken());
    buf.append(this.newline(indent));
    buf.append("/**"); // begin javadoc

    // add formatted doc from UML if exists
    // always put model definition first so it appears
    // on package summary line for class
    String docs = getWrappedDocmentations(field.getDocumentations(), indent);
    if (docs.trim().length() > 0) {
      buf.append(docs);
      buf.append(newline(indent));
      buf.append(" * <p></p>");
      buf.append(newline(indent));
      buf.append(" *");
    }

    buf.append(newline(indent));
    buf.append(
        " * Represents the logical <a href=\"http://docs.plasma-sdo.org/api/org/plasma/sdo/PlasmaProperty.html\">Property</a> <b>");
    buf.append(field.getName());
    buf.append(
        "</b> which is part of the <a href=\"http://docs.plasma-sdo.org/api/org/plasma/sdo/PlasmaType.html\">Type</a> <b>");
    buf.append(clss.getName());
    buf.append("</b>.");

    // data store mapping
    if (clss.getAlias() != null
        && clss.getAlias().getPhysicalName() != null
        && field.getAlias() != null
        && field.getAlias().getPhysicalName() != null) {
      buf.append(this.newline(indent));
      buf.append(" *");
      buf.append(this.newline(indent));
      buf.append(" * <p></p>");
      buf.append(this.newline(indent));
      buf.append(" * <b>Data Store Mapping:</b>");
      buf.append(this.newline(indent));
      buf.append(" * Corresponds to the physical data store element <b>");
      buf.append(clss.getAlias().getPhysicalName() + "." + field.getAlias().getPhysicalName());
      buf.append("</b>.");
    }

    buf.append(this.newline(indent));
    buf.append(" */"); // end javadoc	
    return buf.toString();
  }
Ejemplo n.º 2
0
  protected String createStaticFieldDeclarations(Package pkg, Class clss) {
    InterfaceProvisioning interfaceProvisioning =
        PlasmaConfig.getInstance().getSDOInterfaceProvisioning(pkg.getUri());
    if (interfaceProvisioning == null) interfaceProvisioning = this.globalInterfaceProvisioning;
    TextBuilder buf = new TextBuilder(LINE_SEP, this.context.getIndentationToken());

    // the namespace URI
    buf.appendln(
        1,
        "/** The <a href=\"http://plasma-sdo.org\">SDO</a> namespace URI associated with the <a href=\"http://docs.plasma-sdo.org/api/org/plasma/sdo/PlasmaType.html\">Type</a> for this class. */");
    buf.appendln(1, "public static final String NAMESPACE_URI = \"");
    buf.append(clss.getUri());
    buf.append("\";");
    buf.append(LINE_SEP);

    // the entity name
    buf.appendln(
        1,
        "/** The entity or <a href=\"http://docs.plasma-sdo.org/api/org/plasma/sdo/PlasmaType.html\">Type</a> logical name associated with this class. */");
    buf.appendln(1, "public static final String TYPE_NAME_");
    buf.append(toConstantName(clss.getName()));
    buf.append(" = \"");
    buf.append(clss.getName());
    buf.append("\";");

    buf.appendln(1, "");

    switch (interfaceProvisioning.getPropertyNameStyle()) {
      case ENUMS:
        switch (interfaceProvisioning.getEnumSource()) {
          case DERIVED:
            // the static enums
            buf.appendln(
                1,
                "/** The declared logical property names for this <a href=\"http://docs.plasma-sdo.org/api/org/plasma/sdo/PlasmaType.html\">Type</a>. */");
            buf.appendln(1, "public static enum PROPERTY {");
            int enumCount = 0;
            for (Property field : clss.getProperties()) {
              if (enumCount > 0) buf.append(",");
              buf.append(this.newline(2));
              String javadoc = createStaticFieldDeclarationJavadoc(clss, field, 2);
              buf.append(javadoc);
              buf.append(this.newline(2));
              buf.append(field.getName());
              enumCount++;
            }
            buf.appendln(1, "}");
            break;
          case EXTERNAL: // noop
            break;
          default:
            throw new TextProvisioningException(
                "unexpected enum source, " + interfaceProvisioning.getEnumSource());
        }
        break;
      case CONSTANTS:
        // static constants
        buf.appendln(1, "");
        for (Property field : clss.getProperties()) {
          String javadoc = createStaticFieldDeclarationJavadoc(clss, field, 1);
          buf.appendln(1, javadoc);

          buf.appendln(1, "public static final String ");
          buf.append(toConstantName(field.getName()));
          buf.append(" = \"");
          buf.append(field.getName());
          buf.append("\";");
        }
        buf.appendln(1, "");
        break;
      default:
    }

    return buf.toString();
  }