loci.formats
Class ReflectedUniverse

java.lang.Object
  extended by loci.formats.ReflectedUniverse

public class ReflectedUniverse
extends Object

A general-purpose reflection wrapper class.

Source code:
Trac, SVN


Field Summary
protected  boolean debug
          Debugging flag.
protected  boolean force
          Whether to force our way past restrictive access modifiers.
protected  ClassLoader loader
          Class loader for imported classes.
protected  Hashtable variables
          Hashtable containing all variables present in the universe.
 
Constructor Summary
ReflectedUniverse()
          Constructs a new reflected universe.
ReflectedUniverse(ClassLoader loader)
          Constructs a new reflected universe that uses the given class loader.
ReflectedUniverse(URL[] urls)
          Constructs a new reflected universe, with the given URLs representing additional search paths for imported classes (in addition to the CLASSPATH).
 
Method Summary
 Object exec(String command)
          Executes a command in the universe.
 Object getVar(String varName)
          Returns the value of a variable or field in the universe.
 boolean isAccessibilityIgnored()
          Gets whether access modifiers (protected, private, etc.) are ignored.
 boolean isDebug()
          Gets whether extended debugging output is enabled.
static boolean isInstance(Class c, Object o)
          Returns whether the given object is compatible with the specified class for the purposes of reflection.
static void main(String[] args)
          Allows exploration of a reflected universe in an interactive environment.
 void setAccessibilityIgnored(boolean ignore)
          Sets whether access modifiers (protected, private, etc.) are ignored.
 void setDebug(boolean debug)
          Enables or disables extended debugging output.
 void setVar(String varName, boolean b)
          Registers a variable of primitive type boolean in the universe.
 void setVar(String varName, byte b)
          Registers a variable of primitive type byte in the universe.
 void setVar(String varName, char c)
          Registers a variable of primitive type char in the universe.
 void setVar(String varName, double d)
          Registers a variable of primitive type double in the universe.
 void setVar(String varName, float f)
          Registers a variable of primitive type float in the universe.
 void setVar(String varName, int i)
          Registers a variable of primitive type int in the universe.
 void setVar(String varName, long l)
          Registers a variable of primitive type long in the universe.
 void setVar(String varName, Object obj)
          Registers a variable in the universe.
 void setVar(String varName, short s)
          Registers a variable of primitive type short in the universe.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

protected boolean debug
Debugging flag.


force

protected boolean force
Whether to force our way past restrictive access modifiers.


loader

protected ClassLoader loader
Class loader for imported classes.


variables

protected Hashtable variables
Hashtable containing all variables present in the universe.

Constructor Detail

ReflectedUniverse

public ReflectedUniverse()
Constructs a new reflected universe.


ReflectedUniverse

public ReflectedUniverse(ClassLoader loader)
Constructs a new reflected universe that uses the given class loader.


ReflectedUniverse

public ReflectedUniverse(URL[] urls)
Constructs a new reflected universe, with the given URLs representing additional search paths for imported classes (in addition to the CLASSPATH).

Method Detail

exec

public Object exec(String command)
            throws ReflectException
Executes a command in the universe. The following syntaxes are valid: Important guidelines:

Throws:
ReflectException

getVar

public Object getVar(String varName)
              throws ReflectException
Returns the value of a variable or field in the universe. Primitive types will be wrapped in their Java Object wrapper classes.

Throws:
ReflectException

isAccessibilityIgnored

public boolean isAccessibilityIgnored()
Gets whether access modifiers (protected, private, etc.) are ignored.


isDebug

public boolean isDebug()
Gets whether extended debugging output is enabled.


isInstance

public static boolean isInstance(Class c,
                                 Object o)
Returns whether the given object is compatible with the specified class for the purposes of reflection.


main

public static void main(String[] args)
                 throws IOException
Allows exploration of a reflected universe in an interactive environment.

Throws:
IOException

setAccessibilityIgnored

public void setAccessibilityIgnored(boolean ignore)
Sets whether access modifiers (protected, private, etc.) are ignored.


setDebug

public void setDebug(boolean debug)
Enables or disables extended debugging output.


setVar

public void setVar(String varName,
                   boolean b)
Registers a variable of primitive type boolean in the universe.


setVar

public void setVar(String varName,
                   byte b)
Registers a variable of primitive type byte in the universe.


setVar

public void setVar(String varName,
                   char c)
Registers a variable of primitive type char in the universe.


setVar

public void setVar(String varName,
                   double d)
Registers a variable of primitive type double in the universe.


setVar

public void setVar(String varName,
                   float f)
Registers a variable of primitive type float in the universe.


setVar

public void setVar(String varName,
                   int i)
Registers a variable of primitive type int in the universe.


setVar

public void setVar(String varName,
                   long l)
Registers a variable of primitive type long in the universe.


setVar

public void setVar(String varName,
                   Object obj)
Registers a variable in the universe.


setVar

public void setVar(String varName,
                   short s)
Registers a variable of primitive type short in the universe.



Copyright © 2008 Laboratory for Optical and Computational Instrumentation