类 StandardTypeLocator

  • 所有已实现的接口:
    TypeLocator

    public class StandardTypeLocator
    extends Object
    implements TypeLocator
    A simple implementation of 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.
    从以下版本开始:
    3.0
    作者:
    Andy Clement, Juergen Hoeller
    • 构造器详细资料

      • StandardTypeLocator

        public StandardTypeLocator()
        Create a StandardTypeLocator for the default ClassLoader (typically, the thread context ClassLoader).
      • StandardTypeLocator

        public StandardTypeLocator​(ClassLoader classLoader)
        Create a StandardTypeLocator for the given ClassLoader.
        参数:
        classLoader - the ClassLoader to delegate to
    • 方法详细资料

      • registerImport

        public void registerImport​(String prefix)
        Register a new import prefix that will be used when searching for unqualified types. Expected format is something like "java.lang".
        参数:
        prefix - the prefix to register
      • removeImport

        public void removeImport​(String prefix)
        Remove that specified prefix from this locator's list of imports.
        参数:
        prefix - the prefix to remove
      • getImportPrefixes

        public List<StringgetImportPrefixes()
        Return a list of all the import prefixes registered with this StandardTypeLocator.
        返回:
        a list of registered import prefixes
      • findType

        public Class<?> findType​(String typeName)
                          throws EvaluationException
        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.
        指定者:
        findType 在接口中 TypeLocator
        参数:
        typeName - the type to locate
        返回:
        the class object for the type
        抛出:
        EvaluationException - if the type cannot be found