Пример #1
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();
  }