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.
-
Field Details
-
variables
protected java.util.HashMap<java.lang.String,java.lang.Object> variablesDeprecated.Hashtable containing all variables present in the universe. -
loader
protected java.lang.ClassLoader loaderDeprecated.Class loader for imported classes. -
force
protected boolean forceDeprecated.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 classo
- the object that needs type checking- Returns:
- true if the object is an instance of the base class
-
exec
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
- 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:
- a variable in the universe
- a static or instance field (i.e., no nested methods)
- a string literal (remember to escape the double quotes)
- an integer literal
- a long literal (ending in L)
- a double literal (containing a decimal point)
- a boolean literal (true or false)
- 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 assignobj
- 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 assignb
- 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 assignb
- 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 assignc
- 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 assignd
- 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 assignf
- 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 assigni
- 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 assignl
- 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 assigns
- the short value to assign to the variable
-
getVar
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.IOExceptionDeprecated.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
-