ovm.polyd
Class Utils

java.lang.Object
  extended by ovm.polyd.Utils

public abstract class Utils
extends java.lang.Object

A convenience class that implements a few handy utilities.

See Also:
Utils.Diff

Nested Class Summary
static class Utils.Diff
          Used to describe the result of a comparison between two classes or arrays of classes.
 
Method Summary
static Utils.Diff classArrayDiff(java.lang.Class[] a, java.lang.Class[] b)
          Compares two arrays of classes.
static Utils.Diff classArrayDiff(java.lang.Class[] a, java.lang.Class[] b, java.lang.Class[] cross)
          Compares two arrays of classes, and attempts to build an array that is a subclass of both arrays.
static Utils.Diff classDiff(java.lang.Class a, java.lang.Class b)
          Compares two classes.
static boolean isEqualOrSub(java.lang.Class a, java.lang.Class b)
          Compares two classes, and determines whether the first one is equal or a subclass or the second.
static boolean isEqualOrSubArrayNull(java.lang.Class[] a, java.lang.Class[] b)
          Compares two arrays of classes, and determines whether each element of the first is equal or a subclass of the second.
static int isThere(java.lang.Class[] params, java.lang.reflect.Method[] meth)
          Determines whether any of those methods has has a given combination of formal parameters.
static java.lang.String methodString(java.lang.reflect.Method m)
          Generates a user-friendly string representation of a method.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

classDiff

public static Utils.Diff classDiff(java.lang.Class a,
                                   java.lang.Class b)
Compares two classes.

Parameters:
a - the first class that will be compared
b - the second class that will be compared
Returns:
the result of the comparison

classArrayDiff

public static Utils.Diff classArrayDiff(java.lang.Class[] a,
                                        java.lang.Class[] b)
Compares two arrays of classes.

Parameters:
a - the first array that will be compared
b - the second array that will be compared
Returns:
the result of the comparison

classArrayDiff

public static Utils.Diff classArrayDiff(java.lang.Class[] a,
                                        java.lang.Class[] b,
                                        java.lang.Class[] cross)
Compares two arrays of classes, and attempts to build an array that is a subclass of both arrays.

If the result of the method is anything but NotCompatible, the two arrays of classes will be combined and the resulting combination stored in the array specified by the third argument.

The new array will contain the narrowest element of each pair (the class which is a subclass of the other one).

If the result of the method is NotCompatible, the data the third array will receive is unspecified.

Parameters:
a - the first array that will be compared
b - the second array that will be compared
cross - the array where the new combination will be stored
Returns:
the result of the comparison

isEqualOrSub

public static boolean isEqualOrSub(java.lang.Class a,
                                   java.lang.Class b)
Compares two classes, and determines whether the first one is equal or a subclass or the second.

Parameters:
a - the first class that will be compared
b - the second class that will be compared
Returns:
the result of the comparison

isEqualOrSubArrayNull

public static boolean isEqualOrSubArrayNull(java.lang.Class[] a,
                                            java.lang.Class[] b)
Compares two arrays of classes, and determines whether each element of the first is equal or a subclass of the second.

The first array can contain null values, which will not be included in the overall comparison.

Parameters:
a - the first array that will be compared
b - the second array that will be compared
Returns:
the result of the comparison

isThere

public static int isThere(java.lang.Class[] params,
                          java.lang.reflect.Method[] meth)
Determines whether any of those methods has has a given combination of formal parameters.

Parameters:
params - an array of desired parameter classes
meth - an array of methods
Returns:
the index of the first method that matches, if one is found, or -1 if not found.

methodString

public static java.lang.String methodString(java.lang.reflect.Method m)
Generates a user-friendly string representation of a method.

Parameters:
m - the method than needs to be printed
Returns:
the string representation of the method