org.codehaus.jam
Class JamUtils

java.lang.Object
  extended by org.codehaus.jam.JamUtils

public class JamUtils
extends java.lang.Object

Singleton collection of utility methods which can be very useful in some samples, but not often enough to warrant inclusion in the main APIs.

Most of these are here to help you jump from the JClass hierarchy to the java.lang.reflect hierarchy. This is primarily useful when you find yourself, for example, wanting to actually invoke a method represented by a JMethod.

Author:
Patrick Calahan <email: pcal-at-bea-dot-com>

Method Summary
 java.lang.reflect.Constructor getConstructorOn(JConstructor ctor, java.lang.Class containedin)
          Returns the java.lang.Method on a given java.lang.Class which is represented by a given JMethod.
 java.lang.reflect.Field getFieldOn(JField field, java.lang.Class containedin)
          Returns the java.lang.Method on a given java.lang.Class which is represented by a given JMethod.
static JamUtils getInstance()
           
 java.lang.reflect.Method getMethodOn(JMethod method, java.lang.Class containedin)
          Returns the java.lang.Method on a given java.lang.Class which is represented by a given JMethod.
 java.lang.Class loadClass(JClass clazz, java.lang.ClassLoader inThisClassloader)
          Loads the java.lang.Class represented by a given JClass out of a given classloader.
 void placeInSourceOrder(JElement[] elements)
          Sorts the given array in place so that the elements are ordered by their sourcePosition's line numbers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static final JamUtils getInstance()

getMethodOn

public java.lang.reflect.Method getMethodOn(JMethod method,
                                            java.lang.Class containedin)
                                     throws java.lang.NoSuchMethodException,
                                            java.lang.ClassNotFoundException

Returns the java.lang.Method on a given java.lang.Class which is represented by a given JMethod.

Parameters:
containedin - Class to be searched for the method.
Returns:
Throws:
java.lang.ClassNotFoundException - if one of the paramType classes specified for this MethodName cannot be loaded from the given class' classloader.
java.lang.NoSuchMethodException - If the named method does not exist on this class.
java.lang.IllegalArgumentException - if any argument is null

getConstructorOn

public java.lang.reflect.Constructor getConstructorOn(JConstructor ctor,
                                                      java.lang.Class containedin)
                                               throws java.lang.NoSuchMethodException,
                                                      java.lang.ClassNotFoundException

Returns the java.lang.Method on a given java.lang.Class which is represented by a given JMethod.

Parameters:
containedin - Class to be searched for the ctor.
Returns:
Throws:
java.lang.ClassNotFoundException - if one of the paramType classes specified for this MethodName cannot be loaded from the given class' classloader.
java.lang.NoSuchMethodException - If the named ctor does not exist on this class.
java.lang.IllegalArgumentException - if any argument is null

getFieldOn

public java.lang.reflect.Field getFieldOn(JField field,
                                          java.lang.Class containedin)
                                   throws java.lang.NoSuchFieldException

Returns the java.lang.Method on a given java.lang.Class which is represented by a given JMethod.

Parameters:
containedin - Class to be searched for the method.
Returns:
Throws:
java.lang.NoSuchFieldException - if the field does not exist on the class.
java.lang.IllegalArgumentException - if any argument is null

loadClass

public java.lang.Class loadClass(JClass clazz,
                                 java.lang.ClassLoader inThisClassloader)
                          throws java.lang.ClassNotFoundException

Loads the java.lang.Class represented by a given JClass out of a given classloader.

Returns:
Throws:
java.lang.ClassNotFoundException - If the class is not found in the classloader

placeInSourceOrder

public void placeInSourceOrder(JElement[] elements)
Sorts the given array in place so that the elements are ordered by their sourcePosition's line numbers.