Package cn.wensiqun.visitor.annotated

Source Code of cn.wensiqun.visitor.annotated.AnnotationDefVisitor

package cn.wensiqun.visitor.annotated;

import java.util.ArrayList;
import java.util.List;

import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.commons.EmptyVisitor;

import cn.wensiqun.GrepRobotInternal;
import cn.wensiqun.grep.annotated.AnnotationGrep;
import cn.wensiqun.info.AnnotationInfo;

public class AnnotationDefVisitor extends CommonDef implements AnnotationVisitor {

  private AnnotationInfo info;
 
  private AnnotationGrep annotationGrep;
 
  public AnnotationDefVisitor(GrepRobotInternal grepClient, AnnotationInfo info) {
    super(grepClient);
    this.info = info;
    this.annotationGrep = grepClient.getAnnotationGrep();
  }

  public void visit(String name, Object value) {
  }

  public void visitEnum(String name, String desc, String value) {
  }

  public AnnotationVisitor visitAnnotation(String name, String desc) {
    AnnotationInfo annotationInfo = new AnnotationInfo(desc);
    if(grepClient.getAnnotationCriterion().contains(annotationInfo.getName())){
          info.getAnnotations().add(annotationInfo);
          List<AnnotationInfo> infos = annotationGrep.getAnnotatedAnnotationMap().get(annotationInfo.getName());
          if (infos == null) {
              infos = new ArrayList<AnnotationInfo>();
              annotationGrep.getAnnotatedAnnotationMap().put(annotationInfo.getName(), infos);
          }
          infos.add(info);
          return new AnnotationDefVisitor(grepClient, annotationInfo);
    }else{
      return new EmptyVisitor();
    }
  }

  public AnnotationVisitor visitArray(String name) {
    return null;
  }

  public void visitEnd() {

  }

}
TOP

Related Classes of cn.wensiqun.visitor.annotated.AnnotationDefVisitor

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.