org.mvel2.integration
Interface VariableResolverFactory

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
BaseVariableResolverFactory, CachedMapVariableResolverFactory, ClassImportResolverFactory, DefaultLocalVariableResolverFactory, FunctionVariableResolverFactory, ImmutableDefaultFactory, IndexedVariableResolverFactory, ItemResolverFactory, MapVariableResolverFactory, Proto.InvokationContextFactory, Proto.ProtoContextFactory, SimpleVariableResolverFactory, StaticMethodImportResolverFactory, TypeInjectionResolverFactoryImpl

public interface VariableResolverFactory
extends java.io.Serializable

A VariableResolverFactory is the primary integration point for tying in external variables. The factory is responsible for returing VariableResolver's to the MVEL runtime. Factories are also structured in a chain to maintain locality-of-reference.


Method Summary
 VariableResolver createIndexedVariable(int index, java.lang.String name, java.lang.Object value)
           
 VariableResolver createIndexedVariable(int index, java.lang.String name, java.lang.Object value, java.lang.Class<?> typee)
           
 VariableResolver createVariable(java.lang.String name, java.lang.Object value)
          Creates a new variable.
 VariableResolver createVariable(java.lang.String name, java.lang.Object value, java.lang.Class<?> type)
          Creates a new variable, and assigns a static type.
 VariableResolver getIndexedVariableResolver(int index)
           
 java.util.Set<java.lang.String> getKnownVariables()
          Return a list of known variables inside the factory.
 VariableResolverFactory getNextFactory()
          Returns the next factory in the factory chain.
 VariableResolver getVariableResolver(java.lang.String name)
          Return a variable resolver for the specified variable name.
 boolean isIndexedFactory()
           
 boolean isResolveable(java.lang.String name)
          Determines whether or not the variable is resolver in the chain of factories.
 boolean isTarget(java.lang.String name)
          Deterimines whether or not the current VariableResolverFactory is the physical target for the actual variable.
 VariableResolver setIndexedVariableResolver(int index, VariableResolver variableResolver)
           
 VariableResolverFactory setNextFactory(VariableResolverFactory resolverFactory)
          Sets the next factory in the chain.
 int variableIndexOf(java.lang.String name)
           
 

Method Detail

createVariable

VariableResolver createVariable(java.lang.String name,
                                java.lang.Object value)
Creates a new variable. This probably doesn't need to be implemented in most scenarios. This is used for variable assignment.

Parameters:
name - - name of the variable being created
value - - value of the variable
Returns:
instance of the variable resolver associated with the variable

createIndexedVariable

VariableResolver createIndexedVariable(int index,
                                       java.lang.String name,
                                       java.lang.Object value)

createVariable

VariableResolver createVariable(java.lang.String name,
                                java.lang.Object value,
                                java.lang.Class<?> type)
Creates a new variable, and assigns a static type. It is expected the underlying factory and resolver will enforce this.

Parameters:
name - - name of the variable being created
value - - value of the variable
type - - the static type
Returns:
instance of the variable resolver associated with the variable

createIndexedVariable

VariableResolver createIndexedVariable(int index,
                                       java.lang.String name,
                                       java.lang.Object value,
                                       java.lang.Class<?> typee)

setIndexedVariableResolver

VariableResolver setIndexedVariableResolver(int index,
                                            VariableResolver variableResolver)

getNextFactory

VariableResolverFactory getNextFactory()
Returns the next factory in the factory chain. MVEL uses a hierarchical variable resolution strategy, much in the same way as Classloaders in Java. For performance reasons, it is the responsibility of the individual VariableResolverFactory to pass off to the next one.

Returns:
instance of the next factory - null if none.

setNextFactory

VariableResolverFactory setNextFactory(VariableResolverFactory resolverFactory)
Sets the next factory in the chain. Proper implementation:

return this.nextFactory = resolverFactory;

Parameters:
resolverFactory - - instance of next resolver factory
Returns:
- instance of next resolver factory

getVariableResolver

VariableResolver getVariableResolver(java.lang.String name)
Return a variable resolver for the specified variable name. This method is expected to traverse the heirarchy of ResolverFactories.

Parameters:
name - - variable name
Returns:
- instance of the VariableResolver for the specified variable

getIndexedVariableResolver

VariableResolver getIndexedVariableResolver(int index)

isTarget

boolean isTarget(java.lang.String name)
Deterimines whether or not the current VariableResolverFactory is the physical target for the actual variable.

Parameters:
name - - variable name
Returns:
- boolean indicating whether or not factory is the physical target

isResolveable

boolean isResolveable(java.lang.String name)
Determines whether or not the variable is resolver in the chain of factories.

Parameters:
name - - variable name
Returns:
- boolean

getKnownVariables

java.util.Set<java.lang.String> getKnownVariables()
Return a list of known variables inside the factory. This method should not recurse into other factories. But rather return only the variables living inside this factory.

Returns:

variableIndexOf

int variableIndexOf(java.lang.String name)

isIndexedFactory

boolean isIndexedFactory()


Copyright © 2010. All Rights Reserved.