com.taco.text
Class InstanceConverter

java.lang.Object
  extended by com.taco.text.AbstractInterpolatingStringToObjectConverter
      extended by com.taco.text.InterpolatingConverter
          extended by com.taco.text.InstanceConverter
All Implemented Interfaces:
IInterpolatingConverter, IInterpolatingStringToObjectConverter, IStringToObjectConverter, IInterpolatingResourceBundleToObjectConverter, java.lang.Cloneable

public class InstanceConverter
extends InterpolatingConverter

A converter to instances via class names or scripts.


Field Summary
protected  java.util.Map _extraEnvironment
          A map from names of extra variable names to their values.
protected  java.util.Collection _extraImports
          The additional imports to add to the BeanShell interpreter when evaluating scripts.
protected  java.util.Collection _extraStaticImports
          The additional static imports to add to the BeanShell interpreter when evaluating scripts.
static InstanceConverter DEFAULT_INSTANCE
          The default instance of this class, which does not put any additional variables in the global environment or import any additional classes.
 
Fields inherited from class com.taco.text.InterpolatingConverter
_BAD_OBJECT_MAPPER, _IGNORE_PROPERTY_VALUE, _IMPORTS, _STATIC_IMPORTS, _TO_OBJECT_MAPPER_CONVERTER
 
Fields inherited from class com.taco.text.AbstractInterpolatingStringToObjectConverter
_defArgMap, _defBundle
 
Constructor Summary
protected InstanceConverter()
          Create a new instance that does not add any additional variables or imports to the BeanShell interpreter when evaluating scripts.
  InstanceConverter(java.util.Map extraEnvironment, java.util.Collection extraImports, java.util.Collection extraStaticImports)
          Create a new instance that adds the variable mappings in extraEnvironmentMap and the imports in extraImports to the BeanShell interpreter when evaluating scripts.
 
Method Summary
protected  java.lang.Object _literalToObject(java.lang.String s, java.util.ResourceBundle bundle, INoReturnMap argMap, java.lang.String globalName)
          If the trimmed version of s starts with '{' and ends with '}', treat the string as a script, and return the result of executing the script.
static void main(java.lang.String[] args)
          A simple test program.
 
Methods inherited from class com.taco.text.InterpolatingConverter
_argMapReferenceToObject, _getStandardImports, _getStandardStaticImports, _literalResultToObject, _scriptSnippetToObject, _toObject, _toObjectMapper, clone, name, toObject, toObject, toObject
 
Methods inherited from class com.taco.text.AbstractInterpolatingStringToObjectConverter
toObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_extraEnvironment

protected java.util.Map _extraEnvironment
A map from names of extra variable names to their values. These mappings are added to the BeanShell interpreter when evaluating scripts. If null, no extra variable mappings will be added.


_extraImports

protected java.util.Collection _extraImports
The additional imports to add to the BeanShell interpreter when evaluating scripts. If null, no extra imports will be added.


_extraStaticImports

protected java.util.Collection _extraStaticImports
The additional static imports to add to the BeanShell interpreter when evaluating scripts. If null, no extra static imports will be added.


DEFAULT_INSTANCE

public static final InstanceConverter DEFAULT_INSTANCE
The default instance of this class, which does not put any additional variables in the global environment or import any additional classes.

Constructor Detail

InstanceConverter

protected InstanceConverter()
Create a new instance that does not add any additional variables or imports to the BeanShell interpreter when evaluating scripts.


InstanceConverter

public InstanceConverter(java.util.Map extraEnvironment,
                         java.util.Collection extraImports,
                         java.util.Collection extraStaticImports)
Create a new instance that adds the variable mappings in extraEnvironmentMap and the imports in extraImports to the BeanShell interpreter when evaluating scripts. Either parameter may be null. None of the parameters are copied so the caller must be careful not to modify them afterwards.

Method Detail

main

public static void main(java.lang.String[] args)
A simple test program.


_literalToObject

protected java.lang.Object _literalToObject(java.lang.String s,
                                            java.util.ResourceBundle bundle,
                                            INoReturnMap argMap,
                                            java.lang.String globalName)
                                     throws java.text.ParseException,
                                            java.util.MissingResourceException
If the trimmed version of s starts with '{' and ends with '}', treat the string as a script, and return the result of executing the script. The script has the environment and imports as in _scriptSnippetToObject.

Overrides:
_literalToObject in class InterpolatingConverter
Throws:
java.text.ParseException
java.util.MissingResourceException