org.springframework.expression.spel.support

## Class StandardTypeLocator

- java.lang.Object
- - org.springframework.expression.spel.support.StandardTypeLocator

- All Implemented Interfaces:
    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.
  Since:
    3.0
  Author:
    Andy Clement, Juergen Hoeller

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `StandardTypeLocator()` Create a StandardTypeLocator for the default ClassLoader (typically, the thread context ClassLoader).
    `StandardTypeLocator(ClassLoader classLoader)` Create a StandardTypeLocator for the given ClassLoader.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Class<?>` | `findType(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.
    `List<String>` | `getImportPrefixes()` Return a list of all the import prefixes registered with this StandardTypeLocator.
    `void` | `registerImport(String prefix)` Register a new import prefix that will be used when searching for unqualified types.
    `void` | `removeImport(String prefix)` Remove that specified prefix from this locator's list of imports.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### 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.
      Parameters:
        `classLoader` - the ClassLoader to delegate to

  - ### Method Detail

    - #### 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".
      Parameters:
        `prefix` - the prefix to register

    - #### removeImport

          public void removeImport(String prefix)

      Remove that specified prefix from this locator's list of imports.
      Parameters:
        `prefix` - the prefix to remove

    - #### getImportPrefixes

          public List<String> getImportPrefixes()

      Return a list of all the import prefixes registered with this StandardTypeLocator.
      Returns:
        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.
      Specified by:
        `findType` in interface `TypeLocator`
      Parameters:
        `typeName` - the type to locate
      Returns:
        the class object for the type
      Throws:
        `EvaluationException` - if the type cannot be found