com.taco.text
Class MapConverter

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

public class MapConverter
extends InterpolatingConverter

An interpolating converter to maps.


Field Summary
protected  IInterpolatingStringToObjectConverter _keyConverter
          The converter for key strings.
protected  IMapFactory _mapFactory
          The factory used to create the map to return in _literalToObject().
protected  IInterpolatingStringToObjectConverter _valueConverter
          The converter for value strings.
static MapConverter DEFAULT_INSTANCE
          The default instance of this class which creates an instance of HashMap and uses the default string to object converter for both keys and values.
 
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 MapConverter()
          Since an instance with the default parameters is saved in DEFAULT_INSTANCE, this constructor is protected.
  MapConverter(IInterpolatingStringToObjectConverter keyConverter, IInterpolatingStringToObjectConverter valueConverter)
          Create an instance that returns a LinkedHashMap when toObject() is called.
  MapConverter(IMapFactory mapFactory, IInterpolatingStringToObjectConverter keyConverter, IInterpolatingStringToObjectConverter valueConverter)
          Create an instance that uses the argument map factory to create a map when toObject() is called.
 
Method Summary
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.
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

_keyConverter

protected final IInterpolatingStringToObjectConverter _keyConverter
The converter for key strings.


_valueConverter

protected final IInterpolatingStringToObjectConverter _valueConverter
The converter for value strings.


_mapFactory

protected final IMapFactory _mapFactory
The factory used to create the map to return in _literalToObject().


DEFAULT_INSTANCE

public static final MapConverter DEFAULT_INSTANCE
The default instance of this class which creates an instance of HashMap and uses the default string to object converter for both keys and values.

Constructor Detail

MapConverter

protected MapConverter()
Since an instance with the default parameters is saved in DEFAULT_INSTANCE, this constructor is protected. Create an instance that returns a LinkedHashMap when toObject() is called. The default instance converter will be used to convert both keys and values.


MapConverter

public MapConverter(IInterpolatingStringToObjectConverter keyConverter,
                    IInterpolatingStringToObjectConverter valueConverter)
Create an instance that returns a LinkedHashMap when toObject() is called. Convert strings to keys using keyConverter and convert strings to values using valueConverter.


MapConverter

public MapConverter(IMapFactory mapFactory,
                    IInterpolatingStringToObjectConverter keyConverter,
                    IInterpolatingStringToObjectConverter valueConverter)
Create an instance that uses the argument map factory to create a map when toObject() is called. Convert strings to keys using keyConverter and convert strings to values using valueConverter.

Method Detail

_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
Description copied from class: InterpolatingConverter

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.

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

main

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