Package org.basex.util
Class Reflect
java.lang.Object
org.basex.util.Reflect
This class assembles some reflection methods. Most exceptions are caught and replaced
by a
null value.- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanChecks if the class specified by the pattern is available.static FieldCaches and returns a reference to the specified field ornull.static <O> Constructor<O>Caches and returns a constructor by parameter types.static Class<?>Caches and returns a reference to the specified class.static Class<?>Caches and returns a reference to the class specified by the pattern, ornull.static Class<?>Caches and returns a reference to the specified class, or throws an exception.static <O> OReturns a class instance.static <O> Oget(Constructor<O> clazz, Object... args) Returns a class instance ornull.static ObjectReturns the value of a field.static ObjectInvokes the specified method.static MethodFinds a public, protected or private method by name and parameter types.
-
Method Details
-
available
Checks if the class specified by the pattern is available.- Parameters:
pattern- class patternext- optional extension- Returns:
- result of check
-
find
Caches and returns a reference to the specified class.- Parameters:
name- fully qualified class name- Returns:
- reference, or
nullif the class is not found
-
forName
Caches and returns a reference to the specified class, or throws an exception.- Parameters:
name- fully qualified class name- Returns:
- class reference
- Throws:
ClassNotFoundException- any exception or error
-
field
Caches and returns a reference to the specified field ornull.- Parameters:
clazz- class to search for the constructorname- field name- Returns:
- reference or
nullif the field is not found
-
find
Caches and returns a reference to the class specified by the pattern, ornull.- Parameters:
pattern- class patternext- optional extension- Returns:
- reference or
nullif the class is not found
-
find
Caches and returns a constructor by parameter types.- Type Parameters:
O- class type- Parameters:
clazz- class to search for the constructortypes- constructor parameters- Returns:
- constructor, or
nullif the constructor is not found
-
method
Finds a public, protected or private method by name and parameter types.- Parameters:
clazz- class to search for the methodname- method nametypes- method parameters- Returns:
- method, or
nullif the method is not found
-
get
Returns a class instance.- Type Parameters:
O- type- Parameters:
clazz- class- Returns:
- instance or
null
-
get
Returns a class instance ornull.- Type Parameters:
O- class type- Parameters:
clazz- classargs- arguments- Returns:
- instance or
null
-
invoke
Invokes the specified method.- Parameters:
method- method to runobject- object (nullfor static methods)args- arguments- Returns:
- result of method call or
null
-
get
Returns the value of a field.- Parameters:
field- field to accessobject- object (nullfor static methods)- Returns:
- value of field
-