Class ImportHandler
java.lang.Object
jakarta.el.ImportHandler
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
ConstructorsConstructorDescriptionConstructs an ImportHandler with thejava.langpackage pre-imported. -
Method Summary
Modifier and TypeMethodDescriptionvoidimportClass(String name) Imports a class so it can be referenced by its simple name in EL expressions.voidimportPackage(String name) Imports all classes from a package so they can be referenced by their simple names in EL expressions.voidimportStatic(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 aClassobject by searching the registered class imports and package imports.Class<?> resolveStatic(String name) Resolves a statically imported member name to theClassthat declares it.
-
Constructor Details
-
ImportHandler
public ImportHandler()Constructs an ImportHandler with thejava.langpackage pre-imported. Thejava.langpackage is automatically available in all EL expressions.
-
-
Method Details
-
importStatic
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 formclassName.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
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
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, anELExceptionis thrown at resolution time.- Parameters:
name- the package name to import
-
resolveClass
Resolves an unqualified class name to aClassobject 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, anELExceptionis thrown.- Parameters:
name- the unqualified class name to resolve- Returns:
- the resolved
Class, ornullif the class cannot be found - Throws:
ELException- if the class name is ambiguous across imported packages
-
resolveStatic
Resolves a statically imported member name to theClassthat declares it. The name is the simple name of the static field or method as registered byimportStatic(String).- Parameters:
name- the simple name of the static member- Returns:
- the declaring
Class, ornullif not found
-