当前位置: 首页>>代码示例>>Java>>正文


Java Utility.accessToString方法代码示例

本文整理汇总了Java中org.apache.bcel.classfile.Utility.accessToString方法的典型用法代码示例。如果您正苦于以下问题:Java Utility.accessToString方法的具体用法?Java Utility.accessToString怎么用?Java Utility.accessToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.bcel.classfile.Utility的用法示例。


在下文中一共展示了Utility.accessToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeField

import org.apache.bcel.classfile.Utility; //导入方法依赖的package包/类
/**
 * Print field of class.
 *
 * @param field field to print
 * @exception java.io.IOException
 */
private void writeField( Field field ) throws IOException {
    String type = Utility.signatureToString(field.getSignature());
    String name = field.getName();
    String access = Utility.accessToString(field.getAccessFlags());
    Attribute[] attributes;
    access = Utility.replace(access, " ", " ");
    file.print("<TR><TD><FONT COLOR=\"#FF0000\">" + access + "</FONT></TD>\n<TD>"
            + Class2HTML.referenceType(type) + "</TD><TD><A NAME=\"field" + name + "\">" + name
            + "</A></TD>");
    attributes = field.getAttributes();
    // Write them to the Attributes.html file with anchor "<name>[<i>]"
    for (int i = 0; i < attributes.length; i++) {
        attribute_html.writeAttribute(attributes[i], name + "@" + i);
    }
    for (int i = 0; i < attributes.length; i++) {
        if (attributes[i].getTag() == ATTR_CONSTANT_VALUE) { // Default value
            String str = ((ConstantValue) attributes[i]).toString();
            // Reference attribute in _attributes.html
            file.print("<TD>= <A HREF=\"" + class_name + "_attributes.html#" + name + "@" + i
                    + "\" TARGET=\"Attributes\">" + str + "</TD>\n");
            break;
        }
    }
    file.println("</TR>");
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:32,代码来源:MethodHTML.java

示例2: toString

import org.apache.bcel.classfile.Utility; //导入方法依赖的package包/类
/**
 * Return string representation close to declaration format,
 * `public static final short MAX = 100', e.g..
 *
 * @return String representation of field
 */
public final String toString() {
    String name, signature, access; // Short cuts to constant pool
    access = Utility.accessToString(access_flags);
    access = access.equals("") ? "" : (access + " ");
    signature = type.toString();
    name = getName();
    StringBuffer buf = new StringBuffer(32);
    buf.append(access).append(signature).append(" ").append(name);
    String value = getInitValue();
    if (value != null) {
        buf.append(" = ").append(value);
    }
    return buf.toString();
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:21,代码来源:FieldGen.java

示例3: toString

import org.apache.bcel.classfile.Utility; //导入方法依赖的package包/类
/**
 * Return string representation close to declaration format,
 * `public static void main(String[]) throws IOException', e.g.
 *
 * @return String representation of the method.
 */
public final String toString() {
    String access = Utility.accessToString(access_flags);
    String signature = Type.getMethodSignature(type, arg_types);
    signature = Utility.methodSignatureToString(signature, name, access, true,
            getLocalVariableTable(cp));
    StringBuffer buf = new StringBuffer(signature);
    if (throws_vec.size() > 0) {
        for (Iterator e = throws_vec.iterator(); e.hasNext();) {
            buf.append("\n\t\tthrows ").append(e.next());
        }
    }
    return buf.toString();
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:20,代码来源:MethodGen.java

示例4: getAccessFlagName

import org.apache.bcel.classfile.Utility; //导入方法依赖的package包/类
public String getAccessFlagName() {
	return Utility.accessToString(this.getAccessFlags());
}
 
开发者ID:jdepend,项目名称:cooper,代码行数:4,代码来源:Method.java

示例5: printFields

import org.apache.bcel.classfile.Utility; //导入方法依赖的package包/类
/**
 * Returns some information about the class fields.
 * 
 * @param indent - an indentation.
 * @return an indented string with some information about the class fields.
 */
private String printFields(int indent) {
    StringBuffer result = new StringBuffer();

    Field fields[] = wrappedClass.getFields();
    if (fields.length > 0) {
        // Create the indentation string.
        String indentStr = indentString(indent);

        boolean found = false;
        for (int i = 0; i < fields.length; i++) {
            Field f = fields[i];

            // Skip a field, if we should not print an information about it.
            if (!isPrintable(f)) {
                continue;
            }
            found = true;

            result.append(n);
            result.append(indentStr);

            // Append an access string.
            String access = Utility.accessToString(f.getAccessFlags());
            if (access.length() > 0) {
                result.append(access);
                result.append(' ');
            }
            // Append a field signature and name.
            result.append(Utility.signatureToString(f.getSignature()));
            result.append(' ');
            result.append(f.getName());
            result.append(';');
            result.append(n);

            // Append a type signature.
            if (printTypeSignatures) {
                result.append(indentString(indent * 2, "Signature: "));
                result.append(f.getSignature());
                result.append(n);
            }

            if (verbose) {
                // Append a field constant value, if any.
                ConstantValue cv  = f.getConstantValue();
                if (cv != null) {
                    result.append(indentString(indent * 2,
                            "Constant value: "));
                    result.append(cv);
                    result.append(n);
                }

                Attribute attrs[] = f.getAttributes();
                for (int j = 0; j < attrs.length; j++) {
                    if (attrs[j].getTag() == Constants.ATTR_SYNTHETIC) {
                        result.append(indentString(indent * 2, 
                                "Synthetic: true"));
                        result.append(n);
                        break;
                    }
                }
            }

        }
        if (found) {
            result.append(n);
        }
    }
    return result.toString();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:76,代码来源:Clazz.java

示例6: toString

import org.apache.bcel.classfile.Utility; //导入方法依赖的package包/类
/**
 * Returns a string that represents a structural information about
 * a wrapped class.
 */
public String toString() {
    StringBuffer result = new StringBuffer();

    // Append a source file name.
    result.append(n);
    result.append("Compiled from ");
    result.append('\"');
    result.append(wrappedClass.getSourceFileName());
    result.append('\"');
    result.append(n);

    // Construct a class access string.
    int classAccess = wrappedClass.getAccessFlags();
    String classAccessStr = Utility.accessToString(classAccess, true);
    if (wrappedClass.isInterface()) {
        // Remove the "abstract" word, if this is an interface.
        classAccessStr = skipTokens(
                classAccessStr, new String[] {"abstract"});
    }
    // Append the access string.
    if (classAccessStr.length() > 0) {
        result.append(classAccessStr);
        result.append(' ');
    }

    // Append the word "class" or "interface".
    result.append(Utility.classOrInterface(classAccess));
    result.append(' ');
    result.append(wrappedClass.getClassName());

    // Append the name of an extended class.
    // We skip the sequence "extends java.lang.Object".
    if (!wrappedClass.getSuperclassName().equals("java.lang.Object")) {
        result.append(" extends ");
        result.append(Utility.compactClassName(
                wrappedClass.getSuperclassName(), false));
    }

    // Append the names of the implemented interfaces.
    String interfaces[] = wrappedClass.getInterfaceNames();
    if (interfaces.length > 0) {
        result.append(" implements");
        for (int i = 0; i < interfaces.length; i++) {
            if (i > 0) {
                result.append(',');
            }
            result.append(' ');
            result.append(interfaces[i]);
        }
    }

    // Append the open brace.
    result.append(' ');
    result.append('{');
    result.append(n);

    // The default value.
    int indent = 4;

    // Append some extra information, if verbose is true.
    if (verbose) {
        result.append(printExtra(indent));
    }

    // Append the filtered fields and their signatures.
    result.append(printFields(indent));

    // Append the filtered methods and their signatures.
    result.append(printMethods(indent));

    // Append the close brace.
    result.append(n);
    result.append('}');
    result.append(n);

    return result.toString();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:82,代码来源:Clazz.java

示例7: writeMethod

import org.apache.bcel.classfile.Utility; //导入方法依赖的package包/类
private final void writeMethod( Method method, int method_number ) throws IOException {
    // Get raw signature
    String signature = method.getSignature();
    // Get array of strings containing the argument types 
    String[] args = Utility.methodSignatureArgumentTypes(signature, false);
    // Get return type string
    String type = Utility.methodSignatureReturnType(signature, false);
    // Get method name
    String name = method.getName(), html_name;
    // Get method's access flags
    String access = Utility.accessToString(method.getAccessFlags());
    // Get the method's attributes, the Code Attribute in particular
    Attribute[] attributes = method.getAttributes();
    /* HTML doesn't like names like <clinit> and spaces are places to break
     * lines. Both we don't want...
     */
    access = Utility.replace(access, " ", "&nbsp;");
    html_name = Class2HTML.toHTML(name);
    file.print("<TR VALIGN=TOP><TD><FONT COLOR=\"#FF0000\"><A NAME=method" + method_number
            + ">" + access + "</A></FONT></TD>");
    file.print("<TD>" + Class2HTML.referenceType(type) + "</TD><TD>" + "<A HREF=" + class_name
            + "_code.html#method" + method_number + " TARGET=Code>" + html_name
            + "</A></TD>\n<TD>(");
    for (int i = 0; i < args.length; i++) {
        file.print(Class2HTML.referenceType(args[i]));
        if (i < args.length - 1) {
            file.print(", ");
        }
    }
    file.print(")</TD></TR>");
    // Check for thrown exceptions
    for (int i = 0; i < attributes.length; i++) {
        attribute_html.writeAttribute(attributes[i], "method" + method_number + "@" + i,
                method_number);
        byte tag = attributes[i].getTag();
        if (tag == ATTR_EXCEPTIONS) {
            file.print("<TR VALIGN=TOP><TD COLSPAN=2></TD><TH ALIGN=LEFT>throws</TH><TD>");
            int[] exceptions = ((ExceptionTable) attributes[i]).getExceptionIndexTable();
            for (int j = 0; j < exceptions.length; j++) {
                file.print(constant_html.referenceConstant(exceptions[j]));
                if (j < exceptions.length - 1) {
                    file.print(", ");
                }
            }
            file.println("</TD></TR>");
        } else if (tag == ATTR_CODE) {
            Attribute[] c_a = ((Code) attributes[i]).getAttributes();
            for (int j = 0; j < c_a.length; j++) {
                attribute_html.writeAttribute(c_a[j], "method" + method_number + "@" + i + "@"
                        + j, method_number);
            }
        }
    }
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:55,代码来源:MethodHTML.java


注:本文中的org.apache.bcel.classfile.Utility.accessToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。