public class Tools extends Object
Constructor and Description |
---|
Tools() |
Modifier and Type | Method and Description |
---|---|
static List<Class<?>> |
findSubclasses(Class<?> parentClass)
Finds all subclasses of a given class or interface.
|
static Long |
gensym()
Returns a Long wich is unique during the current run.
|
static Long |
genTime() |
static Constructor<?> |
getMostSpecificConstructor(Class<?> targetClass,
Class<?> paramClass)
Find the constructor to use to create an instance of
targetClass from one of paramClass . |
static boolean |
isUnicodeEnabled()
Checks wheter Gate is Unicode enabled
|
static void |
printStackTrace(PrintStream pStream)
Prints the stack trace of the current thread to the specified print stream.
|
static void |
setUnicodeEnabled(boolean value)
Specifies whether Gate should or shouldn't know about Unicode
|
public static Long gensym()
public static Long genTime()
public static void setUnicodeEnabled(boolean value)
public static boolean isUnicodeEnabled()
public static List<Class<?>> findSubclasses(Class<?> parentClass)
parentClass
- the class for which subclasses are soughtClass
objects.public static Constructor<?> getMostSpecificConstructor(Class<?> targetClass, Class<?> paramClass) throws NoSuchMethodException
Find the constructor to use to create an instance of
targetClass
from one of paramClass
.
We use the same rules as Java in finding the constructor
to call, i.e. we find the constructor that javac would call for
the expression
parameterValue = new PropertyType(parameterValue)
:
T1
is assignable from
paramType
T2
is more specific than the argument type S
of every
other one i.e.
for all S, S.isAssignableFrom(T2)
If there is no applicable single argument constructor that is
more specific than all the others, then the above expression
would be a compile error (constructor ParamType(X)
is
ambiguous).
(The "most specific" check is to catch situations such as
paramClass implements SortedSet
,
targetClass = TreeSet
. Here both
TreeSet(SortedSet)
and TreeSet(Collection)
are applicable but the former is more specific. However, if
paramType also implements Comparator
then there are
three applicable constructors, taking SortedSet
,
Collection
and Comparator
respectively
and none of these types is assignable to both the others. This
is ambiguous according to the Java Language Specification,
2nd edition, section 15.12.2)
targetClass
- the class we wish to constructparamClass
- the type of the object to pass as a parameter to
the constructor.targetClass
that is applicable to an argument of paramClass
NoSuchMethodException
- if there are no applicable constructors,
or if there is no single most-specific one.public static final void printStackTrace(PrintStream pStream)
pStream
- Copyright © 2024 GATE. All rights reserved.