com.taco.text
Class CollectionConverter

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

public class CollectionConverter
extends InterpolatingConverter

An interpolating converter from resource bundles and strings to collections.


Field Summary
protected  java.util.Map _optionMap
          The option map used for StringListUtilities.createObjectList().
static CollectionConverter INSTANCE_COLLECTION_CONVERTER
          A converter to collections of instances.
static CollectionConverter INTEGER_COLLECTION_CONVERTER
          A converter to collections of integers.
static CollectionConverter STRING_COLLECTION_CONVERTER
          A converter to collections of strings.
 
Fields inherited from class com.taco.text.InterpolatingConverter
_BAD_OBJECT_MAPPER, _IGNORE_PROPERTY_VALUE, _IMPORTS, _STATIC_IMPORTS, _TO_OBJECT_MAPPER_CONVERTER, DEFAULT_INSTANCE
 
Fields inherited from class com.taco.text.AbstractInterpolatingStringToObjectConverter
_defArgMap, _defBundle
 
Constructor Summary
CollectionConverter(IInterpolatingStringToObjectConverter converter)
          Construct a new instance that uses the argument interpolating string to object converter to convert strings that represents elements into objects.
CollectionConverter(java.util.Map options)
          Create a new instance that uses the argument option map when calling StringListUtilities.createObjectList().
CollectionConverter(java.util.ResourceBundle bundle, INoReturnMap argMap, IInterpolatingStringToObjectConverter converter)
          Construct a new instance that uses the argument interpolating string to object converter to convert strings that represents elements into objects.
 
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.
protected  java.lang.Object _toObject(java.util.ResourceBundle bundle, java.lang.String baseKey, INoReturnMap argMap, KeyLookupRecord context, java.lang.String globalName)
          If baseKey is mapped to a string, send it to toObject(String, ResourceBundle, INoReturnMap, String).
 java.lang.String name()
          If the simple class name ends with "Converter", return the part before "Converter".
 
Methods inherited from class com.taco.text.InterpolatingConverter
_argMapReferenceToObject, _getStandardImports, _getStandardStaticImports, _literalResultToObject, _scriptSnippetToObject, _toObjectMapper, clone, 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

_optionMap

protected final java.util.Map _optionMap
The option map used for StringListUtilities.createObjectList().


STRING_COLLECTION_CONVERTER

public static final CollectionConverter STRING_COLLECTION_CONVERTER
A converter to collections of strings. Each element is converted to an instance via QuotedStringConverter.


INSTANCE_COLLECTION_CONVERTER

public static final CollectionConverter INSTANCE_COLLECTION_CONVERTER
A converter to collections of instances. Each element is converted to an instance via StringToBeanShellInstanceConverter.


INTEGER_COLLECTION_CONVERTER

public static final CollectionConverter INTEGER_COLLECTION_CONVERTER
A converter to collections of integers. Each element is converted to an instance via AtomConverter.INTEGER_CONVERTER.

Constructor Detail

CollectionConverter

public CollectionConverter(IInterpolatingStringToObjectConverter converter)
Construct a new instance that uses the argument interpolating string to object converter to convert strings that represents elements into objects. The string must be enclosed in square brackets and be separated by commas.


CollectionConverter

public CollectionConverter(java.util.ResourceBundle bundle,
                           INoReturnMap argMap,
                           IInterpolatingStringToObjectConverter converter)
Construct a new instance that uses the argument interpolating string to object converter to convert strings that represents elements into objects.

Throws:
java.lang.NullPointerException - if converter is null

CollectionConverter

public CollectionConverter(java.util.Map options)
Create a new instance that uses the argument option map when calling StringListUtilities.createObjectList(). Note, the argument map is not copied, so the caller must ensure it is not modified afterwards.

Method Detail

name

public java.lang.String name()
Description copied from class: InterpolatingConverter
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
Overrides:
name in class InterpolatingConverter

_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 baseKey is mapped to a string, send it to toObject(String, ResourceBundle, INoReturnMap, String). If it's mapped to something else, return it immediately. Otherwise, read the subkeys "0", "1", ... until an error occurs. Put the result of converting each subkey in the returned collection. If available, use the collection factory in the option map.

Overrides:
_toObject in class InterpolatingConverter
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
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