codesimian
Class Reflect

java.lang.Object
  extended by codesimian.Reflect

public class Reflect
extends java.lang.Object


Nested Class Summary
static class Reflect.T
           
 
Field Summary
static java.lang.String[] actions
          in function names, most common text that represents what the function does.
static java.util.Map<java.lang.String,java.lang.Class> letterToClass
          code: Reflect.letterToClass.get("D") returns double.class
static java.util.Map<java.lang.String,java.lang.String> letterToPrimitiveName
           
static java.util.Map<java.lang.Object,Reflect.T> types
           
static java.lang.String[] typesArray
          in function names, most common letters that represent all types of: primitive, object, and void.
 
Constructor Summary
Reflect()
           
 
Method Summary
static void addType(java.lang.String letter, java.lang.String name, java.lang.Class type)
           
static int arrayDim(java.lang.Class arrayOrObject)
          quantity of array dimensions of the Class.
static java.lang.Class[] catchWhich(java.lang.Class[] throwableTypes)
          reduces array size by only including those that shouldCatch(Class) returns true for
static java.lang.String classToPrimitiveLetter(java.lang.Class primitiveType)
          example: int.class --> "I".
static java.lang.reflect.Method getCSMethod(java.lang.String type, java.lang.String action, java.lang.String target)
           
 Reflect.T getType(java.lang.Object key)
          key is a 1-letter primitive type name, Java keyword for that type, or Class for that type
static java.lang.String javaCodeForNewSubclassOfCS(java.lang.String nameOfNewClass, java.lang.Class parentClass, java.lang.reflect.Method callMe)
          Builds a class that wraps any java Method in a CS.
static java.lang.String javaCodeForType(java.lang.Class type)
          javaCodeForType(List.class) returns "java.util.List".
static java.lang.String javaCodeToExecuteCS(java.lang.Class returnType)
          Returns code that calls one of CS's execute functions: L(Class) D() F() J() I() S() C() B() Z() V().
static java.lang.String preferredClassName(java.lang.reflect.Method wrapMe)
          for wrapping a Method in a new automatically-generated Java class, returns the name the class should be called if possible.
 CS[] reflectFunctionsOf(java.lang.Object anyObject)
          returns 1 CS for each function of anyObject.getClass(), and puts anyObject into those CSs params so they know which Object they're for.
static java.lang.String repeatString(java.lang.String s, int quantity)
           
static boolean shouldCatch(java.lang.Class throwableType)
          what the Java compiler requires you catch if you write code that throws Throwables
static java.lang.String simpleName(java.lang.Class type)
          Name of a Class or primitive type with no array brackets.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

typesArray

public static final java.lang.String[] typesArray
in function names, most common letters that represent all types of: primitive, object, and void. P is the root type: Parameter of a CS. D-Z are primitive. L represents Object or array. V is void.


letterToClass

public static final java.util.Map<java.lang.String,java.lang.Class> letterToClass
code: Reflect.letterToClass.get("D") returns double.class


letterToPrimitiveName

public static final java.util.Map<java.lang.String,java.lang.String> letterToPrimitiveName

types

public static java.util.Map<java.lang.Object,Reflect.T> types

actions

public static final java.lang.String[] actions
in function names, most common text that represents what the function does. The first String is empty because some functions, like P(int) have the implied action: get, but no "get" in the name.

Constructor Detail

Reflect

public Reflect()
Method Detail

classToPrimitiveLetter

public static java.lang.String classToPrimitiveLetter(java.lang.Class primitiveType)
example: int.class --> "I". no array or object classes. primitives only


addType

public static void addType(java.lang.String letter,
                           java.lang.String name,
                           java.lang.Class type)

getType

public Reflect.T getType(java.lang.Object key)
key is a 1-letter primitive type name, Java keyword for that type, or Class for that type


javaCodeForNewSubclassOfCS

public static java.lang.String javaCodeForNewSubclassOfCS(java.lang.String nameOfNewClass,
                                                          java.lang.Class parentClass,
                                                          java.lang.reflect.Method callMe)
Builds a class that wraps any java Method in a CS.

Returns a String of Java code that, when put into a Java compiler (javac *.java), builds a Java Class whose code calls a specific Method when that class's DForProxy() function is executed.

Parameters:
nameOfParentClass - - name of any subclass of CS
m - - any Method from any Class

shouldCatch

public static boolean shouldCatch(java.lang.Class throwableType)
what the Java compiler requires you catch if you write code that throws Throwables


catchWhich

public static java.lang.Class[] catchWhich(java.lang.Class[] throwableTypes)
reduces array size by only including those that shouldCatch(Class) returns true for


javaCodeForType

public static java.lang.String javaCodeForType(java.lang.Class type)
javaCodeForType(List.class) returns "java.util.List". javaCodeForType(List[][][].class) returns "java.util.List[][][]"


arrayDim

public static int arrayDim(java.lang.Class arrayOrObject)
quantity of array dimensions of the Class. 0 if not array


repeatString

public static java.lang.String repeatString(java.lang.String s,
                                            int quantity)

simpleName

public static java.lang.String simpleName(java.lang.Class type)
Name of a Class or primitive type with no array brackets. boolean[][].class --> "boolean". Integer.class --> "java.lang.Integer".


javaCodeToExecuteCS

public static java.lang.String javaCodeToExecuteCS(java.lang.Class returnType)
Returns code that calls one of CS's execute functions: L(Class) D() F() J() I() S() C() B() Z() V(). Examples: int.class --> "I()". JButton[].class --> "L(JButton[].class)". ReturnType can not be CS.class.


getCSMethod

public static java.lang.reflect.Method getCSMethod(java.lang.String type,
                                                   java.lang.String action,
                                                   java.lang.String target)
Parameters:
type - any of: "Z" "B" "C" "S" "I" "J" "F" "D" "L" "P"
action - any of: "get" "set" "insert" "delete"
target - any of: "this" "oneParam" "paramRange"

preferredClassName

public static java.lang.String preferredClassName(java.lang.reflect.Method wrapMe)
for wrapping a Method in a new automatically-generated Java class, returns the name the class should be called if possible.


reflectFunctionsOf

public CS[] reflectFunctionsOf(java.lang.Object anyObject)
returns 1 CS for each function of anyObject.getClass(), and puts anyObject into those CSs params so they know which Object they're for. reflectFunctionsOf(new Integer(5)) should include a CS something like this: intValue(Integer) because intValue() is a function of class Integer, an needs 1 Integer instance object.