The Encog Project

org.encog.util
Class ReflectionUtil

java.lang.Object
  extended by org.encog.util.ReflectionUtil

public final class ReflectionUtil
extends java.lang.Object

This class includes some utilities to be used with reflection. This are mostly used by the Encog generic persistence classes.


Method Summary
static java.lang.reflect.Field findField(java.lang.Class<?> c, java.lang.String name)
          Find the specified field, look also in superclasses.
static java.util.Collection<java.lang.reflect.Field> getAllFields(java.lang.Class<?> c)
          Get all of the fields from the specified class as a collection.
static void getAllFields(java.lang.Class<?> c, java.util.Collection<java.lang.reflect.Field> fields)
          Get all of the fields in the specified class and super classes.
static boolean isInstanceOf(java.lang.Class<?> class1, java.lang.Class<?> class2)
          Determine if one class is an instance of the other class.
static boolean isPrimitive(java.lang.Object obj)
          Determine if the specified object is a primitive.
static boolean isSimple(java.lang.Object obj)
          Determine if an object is "simple", that is it should be persisted just with a .tostring.
static void loadClassmap()
          Load the classmap file.
static java.lang.Class<?> resolveEncogClass(java.lang.String name)
          Resolve an encog class using its simple name.
static boolean shouldAccessField(java.lang.reflect.Field field, boolean base)
          Determine if Encog persistence should access the specified field.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

findField

public static java.lang.reflect.Field findField(java.lang.Class<?> c,
                                                java.lang.String name)
Find the specified field, look also in superclasses.

Parameters:
c - The class to search.
name - The name of the field we are looking for.
Returns:
The field.

getAllFields

public static java.util.Collection<java.lang.reflect.Field> getAllFields(java.lang.Class<?> c)
Get all of the fields from the specified class as a collection.

Parameters:
c - The class to access.
Returns:
All of the fields from this class and subclasses.

getAllFields

public static void getAllFields(java.lang.Class<?> c,
                                java.util.Collection<java.lang.reflect.Field> fields)
Get all of the fields in the specified class and super classes.

Parameters:
c - The class to check.
fields - A collection to hold the classes.

isInstanceOf

public static boolean isInstanceOf(java.lang.Class<?> class1,
                                   java.lang.Class<?> class2)
Determine if one class is an instance of the other class.

Parameters:
class1 - The class to check.
class2 - Is class1 an instance of class 2.
Returns:
True if class 1 is an instance of class 2.

isPrimitive

public static boolean isPrimitive(java.lang.Object obj)
Determine if the specified object is a primitive.

Parameters:
obj - The object to check.
Returns:
True if this object is primitive.

isSimple

public static boolean isSimple(java.lang.Object obj)
Determine if an object is "simple", that is it should be persisted just with a .tostring.

Parameters:
obj - The object to check.
Returns:
True if the object is simple.

loadClassmap

public static void loadClassmap()
Load the classmap file. This allows classes to be resolved using just the simple name.


resolveEncogClass

public static java.lang.Class<?> resolveEncogClass(java.lang.String name)
Resolve an encog class using its simple name.

Parameters:
name - The simple name of the class.
Returns:
The class requested.

shouldAccessField

public static boolean shouldAccessField(java.lang.reflect.Field field,
                                        boolean base)
Determine if Encog persistence should access the specified field.

Parameters:
field - The field to check.
base - True if this is the actual Encog persisted class(top level)
Returns:
True if the class should be accessed.

The Encog Project