public class StandardTypeLocator extends java.lang.Object implements TypeLocator
TypeLocator
that uses the context ClassLoader
(or any ClassLoader set upon it). It supports 'well-known' packages: So if a
type cannot be found, it will try the registered imports to locate it.Constructor and Description |
---|
StandardTypeLocator()
Create a StandardTypeLocator for the default ClassLoader
(typically, the thread context ClassLoader).
|
StandardTypeLocator(java.lang.ClassLoader classLoader)
Create a StandardTypeLocator for the given ClassLoader.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Class<?> |
findType(java.lang.String typeName)
Find a (possibly unqualified) type reference - first using the type name as-is,
then trying any registered prefixes if the type name cannot be found.
|
java.util.List<java.lang.String> |
getImportPrefixes()
Return a list of all the import prefixes registered with this StandardTypeLocator.
|
void |
registerImport(java.lang.String prefix)
Register a new import prefix that will be used when searching for unqualified types.
|
void |
removeImport(java.lang.String prefix)
Remove that specified prefix from this locator's list of imports.
|
public StandardTypeLocator()
public StandardTypeLocator(@Nullable java.lang.ClassLoader classLoader)
classLoader
- the ClassLoader to delegate topublic void registerImport(java.lang.String prefix)
prefix
- the prefix to registerpublic void removeImport(java.lang.String prefix)
prefix
- the prefix to removepublic java.util.List<java.lang.String> getImportPrefixes()
public java.lang.Class<?> findType(java.lang.String typeName) throws EvaluationException
findType
in interface TypeLocator
typeName
- the type to locateEvaluationException
- if the type cannot be found