Package loci.common
Class ReflectedUniverse
- java.lang.Object
-
- loci.common.ReflectedUniverse
-
@Deprecated public class ReflectedUniverse extends 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 ClassLoader
loader
Deprecated.Class loader for imported classes.protected HashMap<String,Object>
variables
Deprecated.Hashtable containing all variables present in the universe.
-
Constructor Summary
Constructors Constructor Description ReflectedUniverse()
Deprecated.Constructs a new reflected universe.ReflectedUniverse(ClassLoader loader)
Deprecated.Constructs a new reflected universe that uses the given class loader.ReflectedUniverse(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
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Object
exec(String command)
Deprecated.Executes a command in the universe.Object
getVar(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(Class<?> c, Object o)
Deprecated.Returns whether the given object is compatible with the specified class for the purposes of reflection.static void
main(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(String varName, boolean b)
Deprecated.Registers a variable of primitive type boolean in the universe.void
setVar(String varName, byte b)
Deprecated.Registers a variable of primitive type byte in the universe.void
setVar(String varName, char c)
Deprecated.Registers a variable of primitive type char in the universe.void
setVar(String varName, double d)
Deprecated.Registers a variable of primitive type double in the universe.void
setVar(String varName, float f)
Deprecated.Registers a variable of primitive type float in the universe.void
setVar(String varName, int i)
Deprecated.Registers a variable of primitive type int in the universe.void
setVar(String varName, long l)
Deprecated.Registers a variable of primitive type long in the universe.void
setVar(String varName, short s)
Deprecated.Registers a variable of primitive type short in the universe.void
setVar(String varName, Object obj)
Deprecated.Registers a variable in the universe.
-
-
-
Field Detail
-
variables
protected HashMap<String,Object> variables
Deprecated.Hashtable containing all variables present in the universe.
-
loader
protected ClassLoader loader
Deprecated.Class loader for imported classes.
-
force
protected boolean force
Deprecated.Whether to force our way past restrictive access modifiers.
-
-
Constructor Detail
-
ReflectedUniverse
public ReflectedUniverse()
Deprecated.Constructs a new reflected universe.
-
ReflectedUniverse
public ReflectedUniverse(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(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 Detail
-
isInstance
public static boolean isInstance(Class<?> c, 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
public Object exec(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
- 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(String varName, 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(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(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(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(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(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(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(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(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
public Object getVar(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(String[] args) throws IOException
Deprecated.Allows exploration of a reflected universe in an interactive environment.- Parameters:
args
- if non-empty, access modifiers will be ignored- Throws:
IOException
- if there is an error reading from stdin
-
-