Java Code Examples for proguard.classfile.ClassConstants#INTERNAL_ACC_ENUM

The following examples show how to use proguard.classfile.ClassConstants#INTERNAL_ACC_ENUM . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClassUtil.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Converts internal class access flags into an external access description.
 * @param accessFlags the class access flags.
 * @param prefix      a prefix that is added to each access modifier.
 * @return the external class access description,
 *         e.g. "<code>public final </code>".
 */
public static String externalClassAccessFlags(int accessFlags, String prefix)
{
    if (accessFlags == 0)
    {
        return EMPTY_STRING;
    }

    StringBuffer string = new StringBuffer(50);

    if ((accessFlags & ClassConstants.INTERNAL_ACC_PUBLIC) != 0)
    {
        string.append(prefix).append(ClassConstants.EXTERNAL_ACC_PUBLIC).append(' ');
    }
    if ((accessFlags & ClassConstants.INTERNAL_ACC_PRIVATE) != 0)
    {
        // Only in InnerClasses attributes.
        string.append(prefix).append(ClassConstants.EXTERNAL_ACC_PRIVATE).append(' ');
    }
    if ((accessFlags & ClassConstants.INTERNAL_ACC_PROTECTED) != 0)
    {
        // Only in InnerClasses attributes.
        string.append(prefix).append(ClassConstants.EXTERNAL_ACC_PROTECTED).append(' ');
    }
    if ((accessFlags & ClassConstants.INTERNAL_ACC_STATIC) != 0)
    {
        // Only in InnerClasses attributes.
        string.append(prefix).append(ClassConstants.EXTERNAL_ACC_STATIC).append(' ');
    }
    if ((accessFlags & ClassConstants.INTERNAL_ACC_FINAL) != 0)
    {
        string.append(prefix).append(ClassConstants.EXTERNAL_ACC_FINAL).append(' ');
    }
    if ((accessFlags & ClassConstants.INTERNAL_ACC_ANNOTATTION) != 0)
    {
        string.append(prefix).append(ClassConstants.EXTERNAL_ACC_ANNOTATION);
    }
    if ((accessFlags & ClassConstants.INTERNAL_ACC_INTERFACE) != 0)
    {
        string.append(prefix).append(ClassConstants.EXTERNAL_ACC_INTERFACE).append(' ');
    }
    else if ((accessFlags & ClassConstants.INTERNAL_ACC_ENUM) != 0)
    {
        string.append(prefix).append(ClassConstants.EXTERNAL_ACC_ENUM).append(' ');
    }
    else if ((accessFlags & ClassConstants.INTERNAL_ACC_ABSTRACT) != 0)
    {
        string.append(prefix).append(ClassConstants.EXTERNAL_ACC_ABSTRACT).append(' ');
    }
    else if ((accessFlags & ClassConstants.INTERNAL_ACC_SYNTHETIC) != 0)
    {
        string.append(prefix).append(ClassConstants.EXTERNAL_ACC_SYNTHETIC).append(' ');
    }

    return string.toString();
}
 
Example 2
Source File: ConfigurationWriter.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
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.INTERNAL_ACC_INTERFACE |
          ClassConstants.INTERNAL_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();
    }
}