Exemplo n.º 1
0
  private void writeMethodSpecification(List memberSpecifications) {
    if (memberSpecifications != null) {
      for (int index = 0; index < memberSpecifications.size(); index++) {
        MemberSpecification memberSpecification =
            (MemberSpecification) memberSpecifications.get(index);

        writer.print("    ");

        // Write out the required annotation, if any.
        if (memberSpecification.annotationType != null) {
          writer.print(ConfigurationConstants.ANNOTATION_KEYWORD);
          writer.println(ClassUtil.externalType(memberSpecification.annotationType));
          writer.print("    ");
        }

        // Write out the method access flags.
        writer.print(
            ClassUtil.externalMethodAccessFlags(
                memberSpecification.requiredUnsetAccessFlags,
                ConfigurationConstants.NEGATOR_KEYWORD));

        writer.print(
            ClassUtil.externalMethodAccessFlags(memberSpecification.requiredSetAccessFlags));

        // Write out the method name and descriptor.
        String name = memberSpecification.name;
        String descriptor = memberSpecification.descriptor;

        writer.print(
            descriptor == null
                ? name == null
                    ? ConfigurationConstants.ANY_METHOD_KEYWORD
                    : ConfigurationConstants.ANY_TYPE_KEYWORD
                        + ' '
                        + name
                        + ConfigurationConstants.OPEN_ARGUMENTS_KEYWORD
                        + ConfigurationConstants.ANY_ARGUMENTS_KEYWORD
                        + ConfigurationConstants.CLOSE_ARGUMENTS_KEYWORD
                : ClassUtil.externalFullMethodDescription(
                    ClassConstants.METHOD_NAME_INIT,
                    0,
                    name == null ? ConfigurationConstants.ANY_CLASS_MEMBER_KEYWORD : name,
                    descriptor));

        writer.println(ConfigurationConstants.SEPARATOR_KEYWORD);
      }
    }
  }
  /** Sets the ClassMemberSpecification to be represented in this dialog. */
  public void setClassMemberSpecification(ClassMemberSpecification classMemberSpecification) {
    String name = classMemberSpecification.name;
    String descriptor = classMemberSpecification.descriptor;

    // Set the access radio buttons.
    setClassMemberSpecificationRadioButtons(
        classMemberSpecification, ClassConstants.INTERNAL_ACC_PUBLIC, publicRadioButtons);
    setClassMemberSpecificationRadioButtons(
        classMemberSpecification, ClassConstants.INTERNAL_ACC_PRIVATE, privateRadioButtons);
    setClassMemberSpecificationRadioButtons(
        classMemberSpecification, ClassConstants.INTERNAL_ACC_PROTECTED, protectedRadioButtons);
    setClassMemberSpecificationRadioButtons(
        classMemberSpecification, ClassConstants.INTERNAL_ACC_STATIC, staticRadioButtons);
    setClassMemberSpecificationRadioButtons(
        classMemberSpecification, ClassConstants.INTERNAL_ACC_FINAL, finalRadioButtons);
    setClassMemberSpecificationRadioButtons(
        classMemberSpecification, ClassConstants.INTERNAL_ACC_VOLATILE, volatileRadioButtons);
    setClassMemberSpecificationRadioButtons(
        classMemberSpecification, ClassConstants.INTERNAL_ACC_TRANSIENT, transientRadioButtons);
    setClassMemberSpecificationRadioButtons(
        classMemberSpecification,
        ClassConstants.INTERNAL_ACC_SYNCHRONIZED,
        synchronizedRadioButtons);
    setClassMemberSpecificationRadioButtons(
        classMemberSpecification, ClassConstants.INTERNAL_ACC_NATIVE, nativeRadioButtons);
    setClassMemberSpecificationRadioButtons(
        classMemberSpecification, ClassConstants.INTERNAL_ACC_ABSTRACT, abstractRadioButtons);
    setClassMemberSpecificationRadioButtons(
        classMemberSpecification, ClassConstants.INTERNAL_ACC_STRICT, strictRadioButtons);

    // Set the class name text fields.
    nameTextField.setText(name == null ? "" : name);

    if (isField) {
      typeTextField.setText(descriptor == null ? "" : ClassUtil.externalType(descriptor));
    } else {
      typeTextField.setText(
          descriptor == null ? "" : ClassUtil.externalMethodReturnType(descriptor));
      argumentsTextField.setText(
          descriptor == null ? "" : ClassUtil.externalMethodArguments(descriptor));
    }
  }
Exemplo n.º 3
0
  private void writeOption(String optionName, ClassSpecification classSpecification) {
    writer.println();

    // Write out the comments for this option.
    writeComments(classSpecification.comments);

    writer.print(optionName);
    writer.print(' ');

    // Write out the required annotation, if any.
    if (classSpecification.annotationType != null) {
      writer.print(ConfigurationConstants.ANNOTATION_KEYWORD);
      writer.print(ClassUtil.externalType(classSpecification.annotationType));
      writer.print(' ');
    }

    // Write out the class access flags.
    writer.print(
        ClassUtil.externalClassAccessFlags(
            classSpecification.requiredUnsetAccessFlags, ConfigurationConstants.NEGATOR_KEYWORD));

    writer.print(ClassUtil.externalClassAccessFlags(classSpecification.requiredSetAccessFlags));

    // Write out the class keyword, if we didn't write the interface
    // keyword earlier.
    if (((classSpecification.requiredSetAccessFlags | classSpecification.requiredUnsetAccessFlags)
            & (ClassConstants.ACC_INTERFACE | ClassConstants.ACC_ENUM))
        == 0) {
      writer.print(ConfigurationConstants.CLASS_KEYWORD);
    }

    writer.print(' ');

    // Write out the class name.
    writer.print(
        classSpecification.className != null
            ? ClassUtil.externalClassName(classSpecification.className)
            : ConfigurationConstants.ANY_CLASS_KEYWORD);

    // Write out the extends template, if any.
    if (classSpecification.extendsAnnotationType != null
        || classSpecification.extendsClassName != null) {
      writer.print(' ');
      writer.print(ConfigurationConstants.EXTENDS_KEYWORD);
      writer.print(' ');

      // Write out the required extends annotation, if any.
      if (classSpecification.extendsAnnotationType != null) {
        writer.print(ConfigurationConstants.ANNOTATION_KEYWORD);
        writer.print(ClassUtil.externalType(classSpecification.extendsAnnotationType));
        writer.print(' ');
      }

      // Write out the extended class name.
      writer.print(
          classSpecification.extendsClassName != null
              ? ClassUtil.externalClassName(classSpecification.extendsClassName)
              : ConfigurationConstants.ANY_CLASS_KEYWORD);
    }

    // Write out the keep field and keep method options, if any.
    if (classSpecification.fieldSpecifications != null
        || classSpecification.methodSpecifications != null) {
      writer.print(' ');
      writer.println(ConfigurationConstants.OPEN_KEYWORD);

      writeFieldSpecification(classSpecification.fieldSpecifications);
      writeMethodSpecification(classSpecification.methodSpecifications);

      writer.println(ConfigurationConstants.CLOSE_KEYWORD);
    } else {
      writer.println();
    }
  }