/**
* Visits an annotation of this class,field or method.
*
* @param desc the class descriptor of the annotation class.
* @param visible <tt>true</tt> if the annotation is visible at runtime.
* @return a visitor to visit the annotation values.
*/
public AnnotationVisitor visitAnnotation(
final String desc,final boolean visible)
{
AnnotationNode an = new AnnotationNode(desc);
if (visible) {
if (visibleAnnotations == null) {
visibleAnnotations = new ArrayList(1);
}
visibleAnnotations.add(an);
} else {
if (invisibleAnnotations == null) {
invisibleAnnotations = new ArrayList(1);
}
invisibleAnnotations.add(an);
}
return an;
}
/**
* Makes the given visitor visit a given annotation value.
*
* @param av an annotation visitor. Maybe <tt>null</tt>.
* @param name the value name.
* @param value the actual value.
*/
static void accept(
final AnnotationVisitor av,final String name,final Object value)
{
if (av != null) {
if (value instanceof String[]) {
String[] typeconst = (String[]) value;
av.visitEnum(name,typeconst[0],typeconst[1]);
} else if (value instanceof AnnotationNode) {
AnnotationNode an = (AnnotationNode) value;
an.accept(av.visitAnnotation(name,an.desc));
} else if (value instanceof List) {
AnnotationVisitor v = av.visitArray(name);
List array = (List) value;
for (int j = 0; j < array.size(); ++j) {
accept(v,null,array.get(j));
}
v.visitEnd();
} else {
av.visit(name,value);
}
}
}
public AnnotationVisitor visitParameterannotation(
final int parameter,final String desc,final boolean visible)
{
buf.setLength(0);
buf.append(tab2).append('@');
appendDescriptor(FIELD_DESCRIPTOR,desc);
buf.append('(');
text.add(buf.toString());
TraceAnnotationVisitor tav = createTraceAnnotationVisitor();
text.add(tav.getText());
text.add(visible ? ") // parameter " : ") // invisible,parameter ");
text.add(new Integer(parameter));
text.add("\n");
if (mv != null) {
tav.av = mv.visitParameterannotation(parameter,desc,visible);
}
return tav;
}
public AnnotationVisitor visitAnnotation(
final String name,final String desc)
{
buf.setLength(0);
buf.append("{\n");
buf.append("AnnotationVisitor av").append(id + 1).append(" = av");
buf.append(id).append(".visitAnnotation(");
ASMifierAbstractVisitor.appendConstant(buf,name);
buf.append(",");
ASMifierAbstractVisitor.appendConstant(buf,desc);
buf.append(");\n");
text.add(buf.toString());
ASMifierAnnotationVisitor av = new ASMifierAnnotationVisitor(id + 1);
text.add(av.getText());
text.add("}\n");
return av;
}
/**
* Prints the ASM code that generates the given annotation.
*
* @param desc the class descriptor of the annotation class.
* @param visible <tt>true</tt> if the annotation is visible at runtime.
* @return a visitor to visit the annotation values.
*/
public AnnotationVisitor visitAnnotation(
final String desc,final boolean visible)
{
buf.setLength(0);
buf.append("{\n")
.append("av0 = ")
.append(name)
.append(".visitAnnotation(");
appendConstant(desc);
buf.append(",").append(visible).append(");\n");
text.add(buf.toString());
ASMifierAnnotationVisitor av = new ASMifierAnnotationVisitor(0);
text.add(av.getText());
text.add("}\n");
return av;
}
public AnnotationVisitor visitAnnotation(
final String name,final String desc)
{
buf.setLength(0);
appendComa(valueNumber++);
if (name != null) {
buf.append(name).append('=');
}
buf.append('@');
appendDescriptor(FIELD_DESCRIPTOR,desc);
buf.append('(');
text.add(buf.toString());
TraceAnnotationVisitor tav = createTraceAnnotationVisitor();
text.add(tav.getText());
text.add(")");
if (av != null) {
tav.av = av.visitAnnotation(name,desc);
}
return tav;
}
public AnnotationVisitor visitArray(final String name) {
buf.setLength(0);
appendComa(valueNumber++);
if (name != null) {
buf.append(name).append('=');
}
buf.append('{');
text.add(buf.toString());
TraceAnnotationVisitor tav = createTraceAnnotationVisitor();
text.add(tav.getText());
text.add("}");
if (av != null) {
tav.av = av.visitArray(name);
}
return tav;
}
public AnnotationVisitor visitAnnotation(
final String desc,final boolean visible)
{
buf.setLength(0);
buf.append("{\n");
buf.append("av0 = cw.visitAnnotation(");
appendConstant(desc);
buf.append(",");
buf.append(visible);
buf.append(");\n");
text.add(buf.toString());
ASMifierAnnotationVisitor av = new ASMifierAnnotationVisitor(0);
text.add(av.getText());
text.add("}\n");
return av;
}
public AnnotationVisitor visitParameterannotation(
final int parameter,final boolean visible)
{
buf.setLength(0);
buf.append("{\n")
.append("av0 = mv.visitParameterannotation(")
.append(parameter)
.append(",");
appendConstant(desc);
buf.append(",").append(visible).append(");\n");
text.add(buf.toString());
ASMifierAnnotationVisitor av = new ASMifierAnnotationVisitor(0);
text.add(av.getText());
text.add("}\n");
return av;
}
项目:astor
文件:MemberNode.java
/**
* Visits an annotation of this class,final boolean visible)
{
AnnotationNode an = new AnnotationNode(desc);
if (visible) {
if (visibleAnnotations == null) {
visibleAnnotations = new ArrayList(1);
}
visibleAnnotations.add(an);
} else {
if (invisibleAnnotations == null) {
invisibleAnnotations = new ArrayList(1);
}
invisibleAnnotations.add(an);
}
return an;
}
项目:astor
文件:AnnotationNode.java
项目:astor
文件:TraceMethodVisitor.java
项目:astor
文件:ASMifierAnnotationVisitor.java
public AnnotationVisitor visitAnnotation(
final String name,desc);
buf.append(");\n");
text.add(buf.toString());
ASMifierAnnotationVisitor av = new ASMifierAnnotationVisitor(id + 1);
text.add(av.getText());
text.add("}\n");
return av;
}
项目:astor
文件:ASMifierAbstractVisitor.java
/**
* Prints the ASM code that generates the given annotation.
*
* @param desc the class descriptor of the annotation class.
* @param visible <tt>true</tt> if the annotation is visible at runtime.
* @return a visitor to visit the annotation values.
*/
public AnnotationVisitor visitAnnotation(
final String desc,").append(visible).append(");\n");
text.add(buf.toString());
ASMifierAnnotationVisitor av = new ASMifierAnnotationVisitor(0);
text.add(av.getText());
text.add("}\n");
return av;
}
项目:astor
文件:TraceAnnotationVisitor.java
public AnnotationVisitor visitAnnotation(
final String name,desc);
}
return tav;
}
项目:astor
文件:TraceAnnotationVisitor.java
public AnnotationVisitor visitArray(final String name) {
buf.setLength(0);
appendComa(valueNumber++);
if (name != null) {
buf.append(name).append('=');
}
buf.append('{');
text.add(buf.toString());
TraceAnnotationVisitor tav = createTraceAnnotationVisitor();
text.add(tav.getText());
text.add("}");
if (av != null) {
tav.av = av.visitArray(name);
}
return tav;
}
项目:astor
文件:ASMifierClassVisitor.java
public AnnotationVisitor visitAnnotation(
final String desc,");
buf.append(visible);
buf.append(");\n");
text.add(buf.toString());
ASMifierAnnotationVisitor av = new ASMifierAnnotationVisitor(0);
text.add(av.getText());
text.add("}\n");
return av;
}
项目:astor
文件:ASMifierMethodVisitor.java
public static AnnotationVisitor getInstance(AnnotationVisitor av1,AnnotationVisitor av2) {
if (av1 == null)
return av2;
if (av2 == null)
return av1;
return new AnnotationVisitorTee(av1,av2);
}
public AnnotationVisitor visitAnnotation(
final String name,final String desc)
{
if (values == null) {
values = new ArrayList(this.desc != null ? 2 : 1);
}
if (this.desc != null) {
values.add(name);
}
AnnotationNode annotation = new AnnotationNode(desc);
values.add(annotation);
return annotation;
}
public AnnotationVisitor visitArray(final String name) {
if (values == null) {
values = new ArrayList(this.desc != null ? 2 : 1);
}
if (this.desc != null) {
values.add(name);
}
List array = new ArrayList();
values.add(array);
return new AnnotationNode(array);
}
/**
* Makes the given visitor visit this annotation.
*
* @param av an annotation visitor. Maybe <tt>null</tt>.
*/
public void accept(final AnnotationVisitor av) {
if (av != null) {
if (values != null) {
for (int i = 0; i < values.size(); i += 2) {
String name = (String) values.get(i);
Object value = values.get(i + 1);
accept(av,name,value);
}
}
av.visitEnd();
}
}
public AnnotationVisitor visitAnnotationDefault() {
return new AnnotationNode(new ArrayList(0) {
public boolean add(final Object o) {
annotationDefault = o;
return super.add(o);
}
});
}
public AnnotationVisitor visitAnnotation(
final String desc,final boolean visible)
{
checkEnd();
CheckMethodAdapter.checkDesc(desc,false);
return new CheckAnnotationAdapter(fv.visitAnnotation(desc,visible));
}
public AnnotationVisitor visitAnnotation(
final String desc,final boolean visible)
{
checkState();
CheckMethodAdapter.checkDesc(desc,false);
return new CheckAnnotationAdapter(cv.visitAnnotation(desc,visible));
}
public AnnotationVisitor visitAnnotation(
final String desc,final boolean visible)
{
checkEndMethod();
checkDesc(desc,false);
return new CheckAnnotationAdapter(mv.visitAnnotation(desc,visible));
}
public AnnotationVisitor visitAnnotation(
final String desc,final boolean visible)
{
AnnotationVisitor av = super.visitAnnotation(desc,visible);
if (fv != null) {
((TraceAnnotationVisitor) av).av = fv.visitAnnotation(desc,visible);
}
return av;
}
public AnnotationVisitor visitAnnotation(
final String desc,visible);
if (mv != null) {
((TraceAnnotationVisitor) av).av = mv.visitAnnotation(desc,visible);
}
return av;
}
public AnnotationVisitor visitAnnotationDefault() {
text.add(tab2 + "default=");
TraceAnnotationVisitor tav = createTraceAnnotationVisitor();
text.add(tav.getText());
text.add("\n");
if (mv != null) {
tav.av = mv.visitAnnotationDefault();
}
return tav;
}
public AnnotationVisitor visitAnnotation(
final String desc,final boolean visible)
{
text.add("\n");
AnnotationVisitor tav = super.visitAnnotation(desc,visible);
if (cv != null) {
((TraceAnnotationVisitor) tav).av = cv.visitAnnotation(desc,visible);
}
return tav;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。