ImportHandler (EL 6.0 API Documentation - Apache Tomcat 11.0.24)
Description: declaration: package: jakarta.el, class: ImportHandler

# Class ImportHandler

java.lang.Object
jakarta.el.ImportHandler

public class ImportHandler extends Object
Manages class and package imports for EL expressions, similar to Java import statements. The ImportHandler resolves unqualified class names to their fully qualified counterparts, supports static imports, and maintains a set of standard packages that are automatically available in EL expressions.

Since:
  EL 3.0

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ImportHandler()`
  Constructs an ImportHandler with the `java.lang` package pre-imported.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `importClass(String name)`
  Imports a class so it can be referenced by its simple name in EL expressions.
  `void`
  `importPackage(String name)`
  Imports all classes from a package so they can be referenced by their simple names in EL expressions.
  `void`
  `importStatic(String name)`
  Imports a static field or method so it can be referenced by its simple name in EL expressions.
  `Class<?>`
  `resolveClass(String name)`
  Resolves an unqualified class name to a `Class` object by searching the registered class imports and package imports.
  `Class<?>`
  `resolveStatic(String name)`
  Resolves a statically imported member name to the `Class` that declares it.

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### ImportHandler

    public ImportHandler()
    Constructs an ImportHandler with the `java.lang` package pre-imported. The `java.lang` package is automatically available in all EL expressions.

- ## Method Details

  - ### importStatic

    public void importStatic(String name) throws ELException
    Imports a static field or method so it can be referenced by its simple name in EL expressions. The argument must be a fully qualified name in the form `className.staticMemberName`. The static member must be public.
    Parameters:
      `name` - the fully qualified name of the static member to import
    Throws:
      `ELException` - if the name is invalid, the class cannot be found, the static member does not exist, or the import would be ambiguous

  - ### importClass

    public void importClass(String name) throws ELException
    Imports a class so it can be referenced by its simple name in EL expressions. The argument must be a fully qualified class name. If the simple name conflicts with a previously imported class, an exception is thrown.
    Parameters:
      `name` - the fully qualified class name to import
    Throws:
      `ELException` - if the class name is invalid or conflicts with an existing import

  - ### importPackage

    public void importPackage(String name)
    Imports all classes from a package so they can be referenced by their simple names in EL expressions. Classes from the imported package are resolved during expression evaluation. If a simple name is ambiguous across multiple imported packages, an `ELException` is thrown at resolution time.
    Parameters:
      `name` - the package name to import

  - ### resolveClass

    public Class<?> resolveClass(String name)
    Resolves an unqualified class name to a `Class` object by searching the registered class imports and package imports. The name must not contain a dot. Results are cached for performance. If the name is ambiguous across multiple packages, an `ELException` is thrown.
    Parameters:
      `name` - the unqualified class name to resolve
    Returns:
      the resolved `Class`, or `null` if the class cannot be found
    Throws:
      `ELException` - if the class name is ambiguous across imported packages

  - ### resolveStatic

    public Class<?> resolveStatic(String name)
    Resolves a statically imported member name to the `Class` that declares it. The name is the simple name of the static field or method as registered by `importStatic(String)`.
    Parameters:
      `name` - the simple name of the static member
    Returns:
      the declaring `Class`, or `null` if not found