com.taco.text
Class InterpolatingConverter

java.lang.Object
  extended by com.taco.text.AbstractInterpolatingStringToObjectConverter
      extended by com.taco.text.InterpolatingConverter
All Implemented Interfaces:
IInterpolatingConverter, IInterpolatingStringToObjectConverter, IStringToObjectConverter, IInterpolatingResourceBundleToObjectConverter, java.lang.Cloneable
Direct Known Subclasses:
AtomConverter, CollectionConverter, ComponentConstraintPairConverter, CompositeConverter, DispatchingConverter, DispatchingLayoutConverter.GridBagLayoutConverter, DispatchingLayoutConverter.OverlayLayoutConverter, InstanceConverter, MapConverter, MessageFormatConverter, PunctuationStrippingConverter, RangeConverter, StringConverter

public class InterpolatingConverter
extends AbstractInterpolatingStringToObjectConverter
implements java.lang.Cloneable, IInterpolatingConverter

An implementation of IInterpolatingConverter which has commonly used behavior.


Field Summary
protected static IObjectMapper _BAD_OBJECT_MAPPER
          A value that signals an error occurred converting a string to a arg map value to/from property value converter.
protected static java.lang.Object _IGNORE_PROPERTY_VALUE
          A value that indicates that a property value is to be monitored in the argument map, but not set by it.
protected static java.util.Collection _IMPORTS
          A collection of imports to add to the BeanShell interpreter.
protected static java.util.Collection _STATIC_IMPORTS
          A collection of static imports to add to the BeanShell interpreter.
protected static IInterpolatingConverter _TO_OBJECT_MAPPER_CONVERTER
          An converter to instances of IObjectMapper.
static InterpolatingConverter DEFAULT_INSTANCE
          The default instance of this class.
 
Fields inherited from class com.taco.text.AbstractInterpolatingStringToObjectConverter
_defArgMap, _defBundle
 
Constructor Summary
InterpolatingConverter()
          Create a new instance whose implementation of IStringToObjectConverter is incapable of resolving references.
InterpolatingConverter(java.util.ResourceBundle bundle, INoReturnMap argMap)
          Create a new instance whose implementation of IStringToObjectConverter uses the specified resource bundle and argument map to resolve references.
 
Method Summary
protected  java.lang.Object _argMapReferenceToObject(InterpolatedValueMatchResult result, java.util.ResourceBundle bundle, INoReturnMap argMap, KeyLookupRecord context)
          Convert a result which is a reference to a value in the argument map to an object.
protected  java.util.Collection _getStandardImports()
          Return a collection of imports to use for every invocation of _scriptSnippetToObject().
protected  java.util.Collection _getStandardStaticImports()
          Return a collection of static imports to use for every invocation of _scriptSnippetToObject().
protected  java.lang.Object _literalResultToObject(InterpolatedValueMatchResult result, java.util.ResourceBundle bundle, INoReturnMap argMap, KeyLookupRecord context)
          Convert a result which is a literal to an object.
protected  java.lang.Object _literalToObject(java.lang.String s, java.util.ResourceBundle bundle, INoReturnMap argMap, java.lang.String globalName)
          Given s, which is a string literal, not a reference to a resource bundle key or a key in the argument map, convert s to an object.
protected  java.lang.Object _scriptSnippetToObject(java.lang.String code, java.util.ResourceBundle bundle, INoReturnMap argMap, KeyLookupRecord context, java.util.Map extraEnvironment, java.util.Collection extraImports, java.util.Collection extraStaticImports)
          Given a code snippet, convert the code into an object.
protected  java.lang.Object _toObject(java.util.ResourceBundle bundle, java.lang.String baseKey, INoReturnMap argMap, KeyLookupRecord context, java.lang.String globalName)
          If the value associated with baseKey is a non-null string, use this instance to convert it to an object.
protected static IObjectMapper _toObjectMapper(java.lang.String s, java.util.ResourceBundle bundle, INoReturnMap argMap)
          Convert the string to an instance of IObjectMapper that converts to or from argument map values.
 java.lang.Object clone()
           
 java.lang.String name()
          If the simple class name ends with "Converter", return the part before "Converter".
 java.lang.Object toObject(InterpolatedValueMatchResult result, java.util.ResourceBundle bundle, INoReturnMap argMap, KeyLookupRecord context)
          Given a result that has just been parsed from a literal, return the object meant by the result.
 java.lang.Object toObject(java.util.ResourceBundle bundle, java.lang.String baseKey, INoReturnMap argMap, KeyLookupRecord context)
          Call _toObject(bundle, baseKey, argMap, context).
 java.lang.Object toObject(java.lang.String s, java.util.ResourceBundle bundle, INoReturnMap argMap, KeyLookupRecord context)
          If s is a reference, resolve it using this instance as both the resource and string converter for the eventual literal.
 
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

_BAD_OBJECT_MAPPER

protected static final IObjectMapper _BAD_OBJECT_MAPPER
A value that signals an error occurred converting a string to a arg map value to/from property value converter.


_IMPORTS

protected static final java.util.Collection _IMPORTS
A collection of imports to add to the BeanShell interpreter. This contains PropertyChangeEvent, PropertyChangeListener, and all classes in the com.taco.text and com.taco.swinger.text2gui packages.


_STATIC_IMPORTS

protected static final java.util.Collection _STATIC_IMPORTS
A collection of static imports to add to the BeanShell interpreter. This contains all members of GlobalUtilities and SwingInvokeProxyFactory.


_IGNORE_PROPERTY_VALUE

protected static final java.lang.Object _IGNORE_PROPERTY_VALUE
A value that indicates that a property value is to be monitored in the argument map, but not set by it.


_TO_OBJECT_MAPPER_CONVERTER

protected static final IInterpolatingConverter _TO_OBJECT_MAPPER_CONVERTER
An converter to instances of IObjectMapper. This makes it slightly easier for developers to write BeanShell expressions for one since IObjectMapper is automatically imported in the BeanShell environment.


DEFAULT_INSTANCE

public static final InterpolatingConverter DEFAULT_INSTANCE
The default instance of this class.

Constructor Detail

InterpolatingConverter

public InterpolatingConverter()
Create a new instance whose implementation of IStringToObjectConverter is incapable of resolving references.


InterpolatingConverter

public InterpolatingConverter(java.util.ResourceBundle bundle,
                              INoReturnMap argMap)
Create a new instance whose implementation of IStringToObjectConverter uses the specified resource bundle and argument map to resolve references.

Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

toObject

public java.lang.Object toObject(java.util.ResourceBundle bundle,
                                 java.lang.String baseKey,
                                 INoReturnMap argMap,
                                 KeyLookupRecord context)
                          throws java.text.ParseException,
                                 java.util.MissingResourceException
Call _toObject(bundle, baseKey, argMap, context). If (baseKey< + ".globalName") is mapped to a string, save the result in the "" property of the argument map, which is another map.

Specified by:
toObject in interface IInterpolatingResourceBundleToObjectConverter
Throws:
java.text.ParseException
java.util.MissingResourceException

toObject

public java.lang.Object toObject(java.lang.String s,
                                 java.util.ResourceBundle bundle,
                                 INoReturnMap argMap,
                                 KeyLookupRecord context)
                          throws java.text.ParseException,
                                 java.util.MissingResourceException
If s is a reference, resolve it using this instance as both the resource and string converter for the eventual literal. Otherwise, s is a literal; call _literalToObject() on it.

Specified by:
toObject in interface IInterpolatingStringToObjectConverter
Throws:
java.text.ParseException
java.util.MissingResourceException

toObject

public java.lang.Object toObject(InterpolatedValueMatchResult result,
                                 java.util.ResourceBundle bundle,
                                 INoReturnMap argMap,
                                 KeyLookupRecord context)
                          throws java.text.ParseException,
                                 java.util.MissingResourceException
Given a result that has just been parsed from a literal, return the object meant by the result.

Throws:
java.text.ParseException
java.util.MissingResourceException

name

public java.lang.String name()
If the simple class name ends with "Converter", return the part before "Converter". Otherwise, just return the simple class name.

Specified by:
name in interface IInterpolatingConverter

_toObject

protected java.lang.Object _toObject(java.util.ResourceBundle bundle,
                                     java.lang.String baseKey,
                                     INoReturnMap argMap,
                                     KeyLookupRecord context,
                                     java.lang.String globalName)
                              throws java.text.ParseException,
                                     java.util.MissingResourceException
If the value associated with baseKey is a non-null string, use this instance to convert it to an object. Otherwise, return the object.

Throws:
java.text.ParseException
java.util.MissingResourceException

_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

Given s, which is a string literal, not a reference to a resource bundle key or a key in the argument map, convert s to an object.

*

This implementation simply returns s unchanged.

Throws:
java.text.ParseException
java.util.MissingResourceException

_literalResultToObject

protected java.lang.Object _literalResultToObject(InterpolatedValueMatchResult result,
                                                  java.util.ResourceBundle bundle,
                                                  INoReturnMap argMap,
                                                  KeyLookupRecord context)
                                           throws java.text.ParseException,
                                                  java.util.MissingResourceException
Convert a result which is a literal to an object.

Throws:
java.text.ParseException
java.util.MissingResourceException

_argMapReferenceToObject

protected java.lang.Object _argMapReferenceToObject(InterpolatedValueMatchResult result,
                                                    java.util.ResourceBundle bundle,
                                                    INoReturnMap argMap,
                                                    KeyLookupRecord context)
                                             throws java.text.ParseException,
                                                    java.util.MissingResourceException
Convert a result which is a reference to a value in the argument map to an object. If the reference is write-only, return _IGNORE_PROPERTY_VALUE. Also record the lookup in the context.

Throws:
java.text.ParseException
java.util.MissingResourceException

_scriptSnippetToObject

protected java.lang.Object _scriptSnippetToObject(java.lang.String code,
                                                  java.util.ResourceBundle bundle,
                                                  INoReturnMap argMap,
                                                  KeyLookupRecord context,
                                                  java.util.Map extraEnvironment,
                                                  java.util.Collection extraImports,
                                                  java.util.Collection extraStaticImports)
                                           throws java.text.ParseException
Given a code snippet, convert the code into an object.

Throws:
java.text.ParseException

_getStandardImports

protected java.util.Collection _getStandardImports()
Return a collection of imports to use for every invocation of _scriptSnippetToObject(). The collection might not be modifiable, since it is copied. This implementation returns the a collection of fully qualified names of the PropertyChangeEvent and PropertyChangeListener classes, and package imports of com.taco.text and com.taco.swinger.text2gui.


_getStandardStaticImports

protected java.util.Collection _getStandardStaticImports()
Return a collection of static imports to use for every invocation of _scriptSnippetToObject(). The collection might not be modifiable, since it is copied. This implementation returns a collection consisting of the members of GlobalUtilities and SwingInvokeProxyFactory.


_toObjectMapper

protected static IObjectMapper _toObjectMapper(java.lang.String s,
                                               java.util.ResourceBundle bundle,
                                               INoReturnMap argMap)
                                        throws java.text.ParseException,
                                               java.util.MissingResourceException
Convert the string to an instance of IObjectMapper that converts to or from argument map values. If the string is null or empty, return null.

Throws:
java.text.ParseException
java.util.MissingResourceException