Package com.artemis.utils.reflect

Examples of com.artemis.utils.reflect.ReflectionException


  /** Returns the Class object associated with the class or interface with the supplied string name. */
  static public Class forName (String name) throws ReflectionException {
    try {
      return ReflectionCache.forName(name).getClassOfType();
    } catch (ClassNotFoundException e) {
      throw new ReflectionException("Class not found: " + name);
    }
  }
View Full Code Here


  /** Creates a new instance of the class represented by the supplied Class. */
  static public <T> T newInstance (Class<T> c) throws ReflectionException {
    try {
      return (T)ReflectionCache.getType(c).newInstance();
    } catch (NoSuchMethodException e) {
      throw new ReflectionException("Could not use default constructor of " + c.getName(), e);
    }
  }
View Full Code Here

   * parameter types. */
  static public Constructor getConstructor (Class c, Class... parameterTypes) throws ReflectionException {
    try {
      return new Constructor(ReflectionCache.getType(c).getConstructor(parameterTypes));
    } catch (SecurityException e) {
      throw new ReflectionException("Security violation while getting constructor for class: " + c.getName(), e);
    } catch (NoSuchMethodException e) {
      throw new ReflectionException("Constructor not found for class: " + c.getName(), e);
    }
  }
View Full Code Here

   * types. */
  static public Constructor getDeclaredConstructor (Class c, Class... parameterTypes) throws ReflectionException {
    try {
      return new Constructor(ReflectionCache.getType(c).getDeclaredConstructor(parameterTypes));
    } catch (SecurityException e) {
      throw new ReflectionException("Security violation while getting constructor for class: " + c.getName(), e);
    } catch (NoSuchMethodException e) {
      throw new ReflectionException("Constructor not found for class: " + c.getName(), e);
    }
  }
View Full Code Here

   * types. */
  static public Method getMethod (Class c, String name, Class... parameterTypes) throws ReflectionException {
    try {
      return new Method(ReflectionCache.getType(c).getMethod(name, parameterTypes));
    } catch (SecurityException e) {
      throw new ReflectionException("Security violation while getting method: " + name + ", for class: " + c.getName(), e);
    } catch (NoSuchMethodException e) {
      throw new ReflectionException("Method not found: " + name + ", for class: " + c.getName(), e);
    }
  }
View Full Code Here

  /** Returns a {@link Method} that represents the method declared by the supplied class which takes the supplied parameter types. */
  static public Method getDeclaredMethod (Class c, String name, Class... parameterTypes) throws ReflectionException {
    try {
      return new Method(ReflectionCache.getType(c).getMethod(name, parameterTypes));
    } catch (SecurityException e) {
      throw new ReflectionException("Security violation while getting method: " + name + ", for class: " + c.getName(), e);
    } catch (NoSuchMethodException e) {
      throw new ReflectionException("Method not found: " + name + ", for class: " + c.getName(), e);
    }
  }
View Full Code Here

  /** Returns a {@link Field} that represents the specified public member field for the supplied class. */
  static public Field getField (Class c, String name) throws ReflectionException {
    try {
      return new Field(ReflectionCache.getType(c).getField(name));
    } catch (SecurityException e) {
      throw new ReflectionException("Security violation while getting field: " + name + ", for class: " + c.getName(), e);
    }
  }
View Full Code Here

  /** Returns a {@link Field} that represents the specified declared field for the supplied class. */
  static public Field getDeclaredField (Class c, String name) throws ReflectionException {
    try {
      return new Field(ReflectionCache.getType(c).getField(name));
    } catch (SecurityException e) {
      throw new ReflectionException("Security violation while getting field: " + name + ", for class: " + c.getName(), e);
    }
  }
View Full Code Here

  /** Invokes the underlying method on the supplied object with the supplied parameters. */
  public Object invoke (Object obj, Object... args) throws ReflectionException {
    try {
      return method.invoke(obj, args);
    } catch (IllegalArgumentException e) {
      throw new ReflectionException("Illegal argument(s) supplied to method: " + getName(), e);
    }
  }
View Full Code Here

  /** Returns the value of the field on the supplied object. */
  public Object get (Object obj) throws ReflectionException {
    try {
      return field.get(obj);
    } catch (IllegalArgumentException e) {
      throw new ReflectionException("Could not get " + getDeclaringClass() + "#" + getName() + ": " + e.getMessage(), e);
    } catch (IllegalAccessException e) {
      throw new ReflectionException("Illegal access to field " + getName() + ": " + e.getMessage(), e);
    }
  }
View Full Code Here

TOP

Related Classes of com.artemis.utils.reflect.ReflectionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.