📄 saxclassadapter.java
字号:
sb.append( "static " );
}
if ( (access & Opcodes.ACC_FINAL) != 0 ) {
sb.append( "final " );
}
if ( (access & Opcodes.ACC_VOLATILE) != 0 ) {
sb.append( "volatile " );
}
if ( (access & Opcodes.ACC_TRANSIENT) != 0 ) {
sb.append( "transient " );
}
if ( (access & Opcodes.ACC_SYNTHETIC) != 0 ) {
sb.append( "synthetic " );
}
if ( (access & Opcodes.ACC_ENUM) != 0 ) {
sb.append( "enum " );
}
if ( (access & Opcodes.ACC_DEPRECATED) != 0 ) {
sb.append( "deprecated " );
}
final AttributesImpl att = new AttributesImpl();
att.addAttribute( "",
"access",
"access",
"",
sb.toString() );
att.addAttribute( "",
"name",
"name",
"",
name );
att.addAttribute( "",
"desc",
"desc",
"",
desc );
if ( signature != null ) {
att.addAttribute( "",
"signature",
"signature",
"",
encode( signature ) );
}
if ( value != null ) {
att.addAttribute( "",
"value",
"value",
"",
encode( value.toString() ) );
}
return new SAXFieldAdapter( getContentHandler(),
att );
}
public MethodVisitor visitMethod(final int access,
final String name,
final String desc,
final String signature,
final String[] exceptions) {
final StringBuffer sb = new StringBuffer();
if ( (access & Opcodes.ACC_PUBLIC) != 0 ) {
sb.append( "public " );
}
if ( (access & Opcodes.ACC_PRIVATE) != 0 ) {
sb.append( "private " );
}
if ( (access & Opcodes.ACC_PROTECTED) != 0 ) {
sb.append( "protected " );
}
if ( (access & Opcodes.ACC_STATIC) != 0 ) {
sb.append( "static " );
}
if ( (access & Opcodes.ACC_FINAL) != 0 ) {
sb.append( "final " );
}
if ( (access & Opcodes.ACC_SYNCHRONIZED) != 0 ) {
sb.append( "synchronized " );
}
if ( (access & Opcodes.ACC_BRIDGE) != 0 ) {
sb.append( "bridge " );
}
if ( (access & Opcodes.ACC_VARARGS) != 0 ) {
sb.append( "varargs " );
}
if ( (access & Opcodes.ACC_NATIVE) != 0 ) {
sb.append( "native " );
}
if ( (access & Opcodes.ACC_ABSTRACT) != 0 ) {
sb.append( "abstract " );
}
if ( (access & Opcodes.ACC_STRICT) != 0 ) {
sb.append( "strict " );
}
if ( (access & Opcodes.ACC_SYNTHETIC) != 0 ) {
sb.append( "synthetic " );
}
if ( (access & Opcodes.ACC_DEPRECATED) != 0 ) {
sb.append( "deprecated " );
}
final AttributesImpl att = new AttributesImpl();
att.addAttribute( "",
"access",
"access",
"",
sb.toString() );
att.addAttribute( "",
"name",
"name",
"",
name );
att.addAttribute( "",
"desc",
"desc",
"",
desc );
if ( signature != null ) {
att.addAttribute( "",
"signature",
"signature",
"",
signature );
}
addStart( "method",
att );
addStart( "exceptions",
new AttributesImpl() );
if ( exceptions != null && exceptions.length > 0 ) {
for ( int i = 0; i < exceptions.length; i++ ) {
final AttributesImpl att2 = new AttributesImpl();
att2.addAttribute( "",
"name",
"name",
"",
exceptions[i] );
addElement( "exception",
att2 );
}
}
addEnd( "exceptions" );
return new SAXCodeAdapter( getContentHandler(),
access );
}
public final void visitInnerClass(final String name,
final String outerName,
final String innerName,
final int access) {
final StringBuffer sb = new StringBuffer();
if ( (access & Opcodes.ACC_PUBLIC) != 0 ) {
sb.append( "public " );
}
if ( (access & Opcodes.ACC_PRIVATE) != 0 ) {
sb.append( "private " );
}
if ( (access & Opcodes.ACC_PROTECTED) != 0 ) {
sb.append( "protected " );
}
if ( (access & Opcodes.ACC_STATIC) != 0 ) {
sb.append( "static " );
}
if ( (access & Opcodes.ACC_FINAL) != 0 ) {
sb.append( "final " );
}
if ( (access & Opcodes.ACC_SUPER) != 0 ) {
sb.append( "super " );
}
if ( (access & Opcodes.ACC_INTERFACE) != 0 ) {
sb.append( "interface " );
}
if ( (access & Opcodes.ACC_ABSTRACT) != 0 ) {
sb.append( "abstract " );
}
if ( (access & Opcodes.ACC_SYNTHETIC) != 0 ) {
sb.append( "synthetic " );
}
if ( (access & Opcodes.ACC_ANNOTATION) != 0 ) {
sb.append( "annotation " );
}
if ( (access & Opcodes.ACC_ENUM) != 0 ) {
sb.append( "enum " );
}
if ( (access & Opcodes.ACC_DEPRECATED) != 0 ) {
sb.append( "deprecated " );
}
final AttributesImpl att = new AttributesImpl();
att.addAttribute( "",
"access",
"access",
"",
sb.toString() );
if ( name != null ) {
att.addAttribute( "",
"name",
"name",
"",
name );
}
if ( outerName != null ) {
att.addAttribute( "",
"outerName",
"outerName",
"",
outerName );
}
if ( innerName != null ) {
att.addAttribute( "",
"innerName",
"innerName",
"",
innerName );
}
addElement( "innerclass",
att );
}
public final void visitEnd() {
addEnd( "class" );
if ( !this.singleDocument ) {
addDocumentEnd();
}
}
static final String encode(final String s) {
final StringBuffer sb = new StringBuffer();
for ( int i = 0; i < s.length(); i++ ) {
final char c = s.charAt( i );
if ( c == '\\' ) {
sb.append( "\\\\" );
} else if ( c < 0x20 || c > 0x7f ) {
sb.append( "\\u" );
if ( c < 0x10 ) {
sb.append( "000" );
} else if ( c < 0x100 ) {
sb.append( "00" );
} else if ( c < 0x1000 ) {
sb.append( "0" );
}
sb.append( Integer.toString( c,
16 ) );
} else {
sb.append( c );
}
}
return sb.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -