本文整理汇总了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>");
}
示例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();
}
示例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();
}
示例4: getAccessFlagName
import org.apache.bcel.classfile.Utility; //导入方法依赖的package包/类
public String getAccessFlagName() {
return Utility.accessToString(this.getAccessFlags());
}
示例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();
}
示例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();
}
示例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, " ", " ");
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);
}
}
}
}