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. @param name the fully qualified class name to import @throws ELException if the cl
(String name)
| 376 | * @throws ELException if the class name is invalid or conflicts with an existing import |
| 377 | */ |
| 378 | public void importClass(String name) throws ELException { |
| 379 | int lastPeriodIndex = name.lastIndexOf('.'); |
| 380 | |
| 381 | if (lastPeriodIndex < 0) { |
| 382 | throw new ELException(Util.message(null, "importHandler.invalidClassName", name)); |
| 383 | } |
| 384 | |
| 385 | String unqualifiedName = name.substring(lastPeriodIndex + 1); |
| 386 | String currentName = classNames.putIfAbsent(unqualifiedName, name); |
| 387 | |
| 388 | if (currentName != null && !currentName.equals(name)) { |
| 389 | // Conflict. Same unqualifiedName, different fully qualified names |
| 390 | throw new ELException(Util.message(null, "importHandler.ambiguousImport", name, currentName)); |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | |
| 395 | /** |