Exemplo n.º 1
0
 /**
  * Get a {@link java.lang.reflect.Field Field} from a {@link java.lang.Class Class} that you
  * normally can't use.
  *
  * @param temp The {@link java.lang.Class Class} that you want to get the {@link
  *     java.lang.reflect.Field Field} form.
  * @param parameters The parameters of the {@link java.lang.reflect.Field Field} that you want to
  *     get.
  * @return The {@link java.lang.reflect.Field Field} that you requested and makes them accessible.
  */
 public static Field getField(Class<?> temp, String fieldName) {
   try {
     return temp.getDeclaredField(fieldName);
   } catch (NoSuchFieldException e) {
     Log.error("there is no field by this name : " + fieldName + " :");
     return null;
   } catch (SecurityException e) {
     Log.error("you can not access the field by this name : " + fieldName + " :");
     return null;
   }
 }
Exemplo n.º 2
0
 /**
  * Get a {@link java.lang.reflect.Method Method} from a {@link java.lang.Class Class} that you
  * normally can't use.
  *
  * @param temp The {@link java.lang.Class Class} that you want to get the {@link
  *     java.lang.reflect.Method Method} form.
  * @param parameters The parameters of the {@link java.lang.reflect.Method Method} that you want
  *     to get.
  * @return The {@link java.lang.reflect.Method Method} that you requested and makes them
  *     accessible.
  */
 public static Method getSpecificMethod(Class<?> temp, String methodName, Class<?>... parameters) {
   try {
     return temp.getDeclaredMethod(methodName, parameters);
   } catch (NoSuchMethodException e) {
     Log.error("there is no method by this name : " + methodName + " :");
     return null;
   } catch (SecurityException e) {
     Log.error("you can not access the method by this name : " + methodName + " :");
     return null;
   }
 }
Exemplo n.º 3
0
 /**
  * Get a {@link java.lang.reflect.Constructor Constructor} from a {@link java.lang.Class Class}
  * that you normally can't use.
  *
  * @param temp The {@link java.lang.Class Class} that you want to get the {@link
  *     java.lang.reflect.Constructor Constructor} form.
  * @param parameters The parameters of the {@link java.lang.reflect.Constructor Constructor} that
  *     you want to get.
  * @return The {@link java.lang.reflect.Constructor Constructor} that you requested and makes them
  *     accessible.
  */
 public static Constructor getConstructor(Class<?> temp, Class... parameters) {
   try {
     Constructor constructor = temp.getDeclaredConstructor(parameters);
     return constructor;
   } catch (NoSuchMethodException e) {
     Log.error("There is no constructor for the class : " + temp.toString() + " :");
     return null;
   } catch (SecurityException e) {
     Log.error("you can not access the constructor of this class : " + temp.toString() + " :");
     return null;
   }
 }