/*
* Created on Apr 15, 2005
*/
/**
* This class offers a few helpful methods for handling primitive datatypes in the Java Reflection API
*
* @author Michael Daenzer
*/
public class ReflectionUtils {
/**
* Takes a Class Variable for primitive Datatype or its Wrapper-Classes and a String.
* Then an instance of the Class (for primitive Datatypes an instance of its Wrapper-Class)
* is created and the string value is assigned to the instance.
*
* @param lexicalValue
* @param type
* @return An instance of type with the assigned lexicalValue
*/
return lexicalValue;
try {
return new URL(lexicalValue);
}
catch( MalformedURLException e ) {
e.printStackTrace();
}
}
return new Short(lexicalValue);
return new Byte(lexicalValue);
//return new Integer(lexicalValue);
return new Long(lexicalValue);
return new Float(lexicalValue);
return new Double(lexicalValue);
return new Boolean(lexicalValue);
// TODO dmi catch classes with a constructor with one string param
return retVal;
}
/**
* Takes a String and returns a Class Object represented by the value of the String. This is
* intended for use with Class.getDeclaredMethods()
* Returns xx.TYPE Classes for primitive Datatypes
*
* @return Class Object specified by strClass
* @see java.lang.Class#getDeclaredMethod(java.lang.String, java.lang.Class[])
*/
// treat primitive datatypes
// treat real classes
try {
} catch (Exception e) {
}
return javaClass;
}
/**
* Takes a primitive data type (as a string) and returns the corresponding
* wrapper class (as a string), i.e. returns java.lang.Integer for int.
*
* @return String the name of the wrapper class for the given primitive data type
*/
// treat primitive datatypes
// treat real classes
return primitive;
}
}
}
return inferredFields;
}
}