com.ikokoon.serenity.instrumentation
Class VisitorFactory

java.lang.Object
  extended by com.ikokoon.serenity.instrumentation.VisitorFactory

public class VisitorFactory
extends java.lang.Object

This class instantiates visitors for classes, methods, field, signature and annotations.

Since:
09.12.09
Version:
01.00
Author:
Michael Couck

Constructor Summary
VisitorFactory()
           
 
Method Summary
static org.objectweb.asm.AnnotationVisitor getAnnotationVisitor(org.objectweb.asm.AnnotationVisitor visitor, java.lang.String className, java.lang.String description)
          This method constructs an annotation visitor to visit annotations.
static org.objectweb.asm.ClassVisitor getClassVisitor(java.lang.Class<org.objectweb.asm.ClassVisitor>[] classAdapterClasses, java.lang.String className, byte[] classBytes, java.io.ByteArrayOutputStream source)
          Instantiates a chain of class visitors.
static org.objectweb.asm.FieldVisitor getFieldVisitor(org.objectweb.asm.FieldVisitor visitor, java.lang.Class<?> klass, java.lang.String className, java.lang.String description, java.lang.String signature)
          This method constructs a field visitor chain that will visit the byte code for a field in a class.
static org.objectweb.asm.MethodVisitor getMethodVisitor(org.objectweb.asm.MethodVisitor visitor, java.lang.Class<?> klass, java.lang.String className, java.lang.String name, java.lang.String desc)
          This method constructs a method visitor chain based on the class of the method adapter passed as a parameter.
static org.objectweb.asm.signature.SignatureVisitor getSignatureVisitor(java.lang.String className, java.lang.String signature)
          This method constructs a signature visitor that will visit a signature for something, could be an annotation or a method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VisitorFactory

public VisitorFactory()
Method Detail

getClassVisitor

public static org.objectweb.asm.ClassVisitor getClassVisitor(java.lang.Class<org.objectweb.asm.ClassVisitor>[] classAdapterClasses,
                                                             java.lang.String className,
                                                             byte[] classBytes,
                                                             java.io.ByteArrayOutputStream source)
Instantiates a chain of class visitors. Each visitor can modify or add code to the class as it is parsed and the writer will output the new class byte code.

Parameters:
classAdapterClasses - the class visitor classes
className - the name of the class to be visited
classBytes - the byte array of the byte code
source - the output stream of the source code for the class
Returns:
the class visitor/writer

getMethodVisitor

public static org.objectweb.asm.MethodVisitor getMethodVisitor(org.objectweb.asm.MethodVisitor visitor,
                                                               java.lang.Class<?> klass,
                                                               java.lang.String className,
                                                               java.lang.String name,
                                                               java.lang.String desc)
This method constructs a method visitor chain based on the class of the method adapter passed as a parameter.

Parameters:
visitor - the parent method visitor
klass - the class of the method visitor to initialise
className - the name of the class that the method visitor will visit
name - the name of the method
desc - the description or signature of the method in byte code format
Returns:
the method visitor

getFieldVisitor

public static org.objectweb.asm.FieldVisitor getFieldVisitor(org.objectweb.asm.FieldVisitor visitor,
                                                             java.lang.Class<?> klass,
                                                             java.lang.String className,
                                                             java.lang.String description,
                                                             java.lang.String signature)
This method constructs a field visitor chain that will visit the byte code for a field in a class.

Parameters:
visitor - the parent field visitor
klass - the field visitor class type
className - the name of the class the field is in
description - the description of the field in byte code format
signature - the signature of the field in byte code
Returns:
the field visitor

getSignatureVisitor

public static org.objectweb.asm.signature.SignatureVisitor getSignatureVisitor(java.lang.String className,
                                                                               java.lang.String signature)
This method constructs a signature visitor that will visit a signature for something, could be an annotation or a method.

Parameters:
className - the name of the class the signature is in
signature - the signature in byte code to visit
Returns:
the signature to be visited

getAnnotationVisitor

public static org.objectweb.asm.AnnotationVisitor getAnnotationVisitor(org.objectweb.asm.AnnotationVisitor visitor,
                                                                       java.lang.String className,
                                                                       java.lang.String description)
This method constructs an annotation visitor to visit annotations.

Parameters:
visitor - the parent annotation visitor
className - the name of the class with the annotation
description - the description or signature of the annotation
Returns:
the annotation visitor


Copyright © 2010. All Rights Reserved.