Spring Framework

org.springframework.expression.spel.support
Class StandardTypeLocator

java.lang.Object
  extended by org.springframework.expression.spel.support.StandardTypeLocator
All Implemented Interfaces:
TypeLocator

public class StandardTypeLocator
extends java.lang.Object
implements TypeLocator

A default implementation of a 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
StandardTypeLocator()
           
StandardTypeLocator(java.lang.ClassLoader loader)
           
 
Method Summary
 java.lang.Class<?> findType(java.lang.String typename)
          Find a (possibly unqualified) type reference - first using the typename as is, then trying any registered prefixes if the typename cannot be found.
 java.util.List<java.lang.String> getImportPrefixes()
          Return a list of all the import prefixes registered with this StandardTypeLocator.
 void registerImport(java.lang.String prefix)
          Register a new import prefix that will be used when searching for unqualified types.
 void removeImport(java.lang.String prefix)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StandardTypeLocator

public StandardTypeLocator()

StandardTypeLocator

public StandardTypeLocator(java.lang.ClassLoader loader)
Method Detail

findType

public java.lang.Class<?> findType(java.lang.String typename)
                            throws EvaluationException
Find a (possibly unqualified) type reference - first using the typename as is, then trying any registered prefixes if the typename 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

registerImport

public void registerImport(java.lang.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

getImportPrefixes

public java.util.List<java.lang.String> getImportPrefixes()
Return a list of all the import prefixes registered with this StandardTypeLocator.

Returns:
list of registered import prefixes

removeImport

public void removeImport(java.lang.String prefix)

Spring Framework