com.futureshocked.classloader
Class ClassTransforms

java.lang.Object
  extended by com.futureshocked.classloader.ClassTransforms

public class ClassTransforms
extends java.lang.Object

A contain for InterceptedMethod, which also has boolean methods that will let DebuggerClassLoader know if a class should be modified, and DebuggerClassVisitor know if a method should be modified.


Field Summary
private  java.util.HashMap classes
          A HashMap that contains String keys, consisting of class names, that map to List objects that hold InterceptedMethod.
 
Constructor Summary
ClassTransforms()
          Constructor that simply creates a new HashMap for this.classes.
 
Method Summary
 InterceptedMethod addCodeStyleInterceptedMethod(java.lang.String code)
          Add a new method to be intercepted.
 void addInterceptedMethod(InterceptedMethod im)
          Adds an already created InterceptedMethod object to this container.
 InterceptedMethod addInterceptedMethod(java.lang.String className, java.lang.String method, java.lang.String desc)
          Add a new method to be intercepted.
 InterceptedMethod getInterceptedMethod(java.lang.String className, java.lang.String method, java.lang.String desc)
          Returns an InterceptedMethod that matches className, method, and desc.
 java.util.List getMethodsByClass(java.lang.String className)
          Returns all InterceptedMethod objects that belong to className.
 boolean modifyClass(java.lang.String className)
          Checks classes for a key equal to className.
 boolean modifyMethod(java.lang.String className, java.lang.String method, java.lang.String desc)
          Checks to see if a method needs to be modified.
 void removeInterceptedMethod(InterceptedMethod im)
          Removes an InterceptedMethod from this container.

This method matches using reference equality (==), rather than the InterceptedMethod.matches() method, so to remove an object the exact object should first be obtained from this container, rather than creating a new InterceptedMethod with the same values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classes

private java.util.HashMap classes
A HashMap that contains String keys, consisting of class names, that map to List objects that hold InterceptedMethod.

Constructor Detail

ClassTransforms

public ClassTransforms()
Constructor that simply creates a new HashMap for this.classes.

Method Detail

modifyClass

public boolean modifyClass(java.lang.String className)
Checks classes for a key equal to className. Since a HashMap is checked it should be the fastest way to check if a class needs to be modified, which is important since this will be called for every loaded class.

Parameters:
className - The name of the class about to be loaded.
Returns:
true if the class needs to be modified.

modifyMethod

public boolean modifyMethod(java.lang.String className,
                            java.lang.String method,
                            java.lang.String desc)
Checks to see if a method needs to be modified.

Parameters:
className - The name of the class the method belongs to.
method - The method being checked.
desc - The description of the method.
Returns:
true if the method needs to be modified.

getInterceptedMethod

public InterceptedMethod getInterceptedMethod(java.lang.String className,
                                              java.lang.String method,
                                              java.lang.String desc)
Returns an InterceptedMethod that matches className, method, and desc. See InterceptedMethod for information related to matching.

Parameters:
className - The name of the class the method belongs to.
method - The name of the method.
desc - The description of the method - see ApplicationDebugger for information about the format.
Returns:
null if the InterceptedMethod is not found, the correct object if it's found.

getMethodsByClass

public java.util.List getMethodsByClass(java.lang.String className)
Returns all InterceptedMethod objects that belong to className.

Parameters:
className - The name of the class being queried.
Returns:
null if no methods are to be intercepted, a List of InterceptedMethod objects if any methods are to be intercepted.

addCodeStyleInterceptedMethod

public InterceptedMethod addCodeStyleInterceptedMethod(java.lang.String code)
Add a new method to be intercepted. Format should be:
java.lang.String testMethod(int arg1, com.user.package.Test arg2)

Parameters:
code - A code style method description.
Returns:
InterceptedMethod that will match the user specified method.

addInterceptedMethod

public InterceptedMethod addInterceptedMethod(java.lang.String className,
                                              java.lang.String method,
                                              java.lang.String desc)
Add a new method to be intercepted. This method should be used only if you understand the format for desc.

Parameters:
className - The name of the class the method belongs to.
method - The name of the method to be intercepted.
desc - The description of the method, see ApplicationDebugger for an example of the format, or the ASM documentation.
Returns:
InterceptedMethod that will match the user specified method.

addInterceptedMethod

public void addInterceptedMethod(InterceptedMethod im)
Adds an already created InterceptedMethod object to this container.

Parameters:
im - InterceptedMethod object

removeInterceptedMethod

public void removeInterceptedMethod(InterceptedMethod im)
Removes an InterceptedMethod from this container.

This method matches using reference equality (==), rather than the InterceptedMethod.matches() method, so to remove an object the exact object should first be obtained from this container, rather than creating a new InterceptedMethod with the same values.

Parameters:
im -