Package loci.common

Class ReflectedUniverse

java.lang.Object
loci.common.ReflectedUniverse

@Deprecated
public class ReflectedUniverse
extends java.lang.Object
Deprecated.
A general purpose reflection wrapper class.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected boolean force
    Deprecated.
    Whether to force our way past restrictive access modifiers.
    protected java.lang.ClassLoader loader
    Deprecated.
    Class loader for imported classes.
    protected java.util.HashMap<java.lang.String,​java.lang.Object> variables
    Deprecated.
    Hashtable containing all variables present in the universe.
  • Constructor Summary

    Constructors 
    Constructor Description
    ReflectedUniverse()
    Deprecated.
    Constructs a new reflected universe.
    ReflectedUniverse​(java.lang.ClassLoader loader)
    Deprecated.
    Constructs a new reflected universe that uses the given class loader.
    ReflectedUniverse​(java.net.URL[] urls)
    Deprecated.
    Constructs a new reflected universe, with the given URLs representing additional search paths for imported classes (in addition to the CLASSPATH).
  • Method Summary

    Modifier and Type Method Description
    java.lang.Object exec​(java.lang.String command)
    Deprecated.
    Executes a command in the universe.
    java.lang.Object getVar​(java.lang.String varName)
    Deprecated.
    Returns the value of a variable or field in the universe.
    boolean isAccessibilityIgnored()
    Deprecated.
    Gets whether access modifiers (protected, private, etc.) are ignored.
    static boolean isInstance​(java.lang.Class<?> c, java.lang.Object o)
    Deprecated.
    Returns whether the given object is compatible with the specified class for the purposes of reflection.
    static void main​(java.lang.String[] args)
    Deprecated.
    Allows exploration of a reflected universe in an interactive environment.
    void setAccessibilityIgnored​(boolean ignore)
    Deprecated.
    Sets whether access modifiers (protected, private, etc.) are ignored.
    void setVar​(java.lang.String varName, boolean b)
    Deprecated.
    Registers a variable of primitive type boolean in the universe.
    void setVar​(java.lang.String varName, byte b)
    Deprecated.
    Registers a variable of primitive type byte in the universe.
    void setVar​(java.lang.String varName, char c)
    Deprecated.
    Registers a variable of primitive type char in the universe.
    void setVar​(java.lang.String varName, double d)
    Deprecated.
    Registers a variable of primitive type double in the universe.
    void setVar​(java.lang.String varName, float f)
    Deprecated.
    Registers a variable of primitive type float in the universe.
    void setVar​(java.lang.String varName, int i)
    Deprecated.
    Registers a variable of primitive type int in the universe.
    void setVar​(java.lang.String varName, long l)
    Deprecated.
    Registers a variable of primitive type long in the universe.
    void setVar​(java.lang.String varName, short s)
    Deprecated.
    Registers a variable of primitive type short in the universe.
    void setVar​(java.lang.String varName, java.lang.Object obj)
    Deprecated.
    Registers a variable in the universe.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • variables

      protected java.util.HashMap<java.lang.String,​java.lang.Object> variables
      Deprecated.
      Hashtable containing all variables present in the universe.
    • loader

      protected java.lang.ClassLoader loader
      Deprecated.
      Class loader for imported classes.
    • force

      protected boolean force
      Deprecated.
      Whether to force our way past restrictive access modifiers.
  • Constructor Details

    • ReflectedUniverse

      public ReflectedUniverse()
      Deprecated.
      Constructs a new reflected universe.
    • ReflectedUniverse

      public ReflectedUniverse​(java.net.URL[] urls)
      Deprecated.
      Constructs a new reflected universe, with the given URLs representing additional search paths for imported classes (in addition to the CLASSPATH).
      Parameters:
      urls - array of URLs to search for additional classes. Each URL is typically a JAR file that is not on the CLASSPATH.
    • ReflectedUniverse

      public ReflectedUniverse​(java.lang.ClassLoader loader)
      Deprecated.
      Constructs a new reflected universe that uses the given class loader.
      Parameters:
      loader - the ClassLoader to use in this universe. If null, the default ClassLoader for the ReflectedUniverse class will be used.
  • Method Details

    • isInstance

      public static boolean isInstance​(java.lang.Class<?> c, java.lang.Object o)
      Deprecated.
      Returns whether the given object is compatible with the specified class for the purposes of reflection.
      Parameters:
      c - the base class
      o - the object that needs type checking
      Returns:
      true if the object is an instance of the base class
    • exec

      public java.lang.Object exec​(java.lang.String command) throws ReflectException
      Deprecated.
      Executes a command in the universe. The following syntaxes are valid:
      • import fully.qualified.package.ClassName
      • var = new ClassName(param1, ..., paramN)
      • var.method(param1, ..., paramN)
      • var2 = var.method(param1, ..., paramN)
      • ClassName.method(param1, ..., paramN)
      • var2 = ClassName.method(param1, ..., paramN)
      • var2 = var
      Important guidelines:
      • Any referenced class must be imported first using "import".
      • Variables can be exported from the universe with getVar().
      • Variables can be imported to the universe with setVar().
      • Each parameter must be either:
        1. a variable in the universe
        2. a static or instance field (i.e., no nested methods)
        3. a string literal (remember to escape the double quotes)
        4. an integer literal
        5. a long literal (ending in L)
        6. a double literal (containing a decimal point)
        7. a boolean literal (true or false)
        8. the null keyword
      Parameters:
      command - the command to be executed (see examples above)
      Returns:
      the result of executing the command. For import statements, the return value is null. Otherwise, the return value of the invoked method or the value assigned to a variable is returned (depending upon the command).
      Throws:
      ReflectException - if the command is invalid or fails to execute
    • setVar

      public void setVar​(java.lang.String varName, java.lang.Object obj)
      Deprecated.
      Registers a variable in the universe.
      Parameters:
      varName - the name of the variable to assign
      obj - the value to assign to the variable
    • setVar

      public void setVar​(java.lang.String varName, boolean b)
      Deprecated.
      Registers a variable of primitive type boolean in the universe.
      Parameters:
      varName - the name of the variable to assign
      b - the boolean value to assign to the variable
    • setVar

      public void setVar​(java.lang.String varName, byte b)
      Deprecated.
      Registers a variable of primitive type byte in the universe.
      Parameters:
      varName - the name of the variable to assign
      b - the byte value to assign to the variable
    • setVar

      public void setVar​(java.lang.String varName, char c)
      Deprecated.
      Registers a variable of primitive type char in the universe.
      Parameters:
      varName - the name of the variable to assign
      c - the char value to assign to the variable
    • setVar

      public void setVar​(java.lang.String varName, double d)
      Deprecated.
      Registers a variable of primitive type double in the universe.
      Parameters:
      varName - the name of the variable to assign
      d - the double value to assign to the variable
    • setVar

      public void setVar​(java.lang.String varName, float f)
      Deprecated.
      Registers a variable of primitive type float in the universe.
      Parameters:
      varName - the name of the variable to assign
      f - the float value to assign to the variable
    • setVar

      public void setVar​(java.lang.String varName, int i)
      Deprecated.
      Registers a variable of primitive type int in the universe.
      Parameters:
      varName - the name of the variable to assign
      i - the int value to assign to the variable
    • setVar

      public void setVar​(java.lang.String varName, long l)
      Deprecated.
      Registers a variable of primitive type long in the universe.
      Parameters:
      varName - the name of the variable to assign
      l - the long value to assign to the variable
    • setVar

      public void setVar​(java.lang.String varName, short s)
      Deprecated.
      Registers a variable of primitive type short in the universe.
      Parameters:
      varName - the name of the variable to assign
      s - the short value to assign to the variable
    • getVar

      public java.lang.Object getVar​(java.lang.String varName) throws ReflectException
      Deprecated.
      Returns the value of a variable or field in the universe. Primitive types will be wrapped in their Java Object wrapper classes.
      Parameters:
      varName - the name of the variable to retrieve
      Returns:
      the current value of the variable
      Throws:
      ReflectException - if the variable name or value is invalid
    • setAccessibilityIgnored

      public void setAccessibilityIgnored​(boolean ignore)
      Deprecated.
      Sets whether access modifiers (protected, private, etc.) are ignored.
      Parameters:
      ignore - true if access modifiers should be ignored
    • isAccessibilityIgnored

      public boolean isAccessibilityIgnored()
      Deprecated.
      Gets whether access modifiers (protected, private, etc.) are ignored.
      Returns:
      true if access modifiers are currently ignored
    • main

      public static void main​(java.lang.String[] args) throws java.io.IOException
      Deprecated.
      Allows exploration of a reflected universe in an interactive environment.
      Parameters:
      args - if non-empty, access modifiers will be ignored
      Throws:
      java.io.IOException - if there is an error reading from stdin