com.taco.text
Class QuotedStringConverter

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

public class QuotedStringConverter
extends StringConverter

A converter from both resource bundles and strings to strings. If the string is quoted, the quotes will be stripped, and escaped characters will be unescaped. If the string is braced, the first part after the brace will be interpreted as a message format, and the second part will be interpreted as an array of instances to use to format the message.


Field Summary
static QuotedStringConverter instance
          The singleton instance of this class.
 
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
protected QuotedStringConverter()
           
 
Method Summary
protected  java.lang.String _formatMessage(java.lang.CharSequence cs, java.util.ResourceBundle bundle, INoReturnMap argMap)
          Given a message format then an optional array of instances to use in the format, form the message and return it.
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 null, return null.
static void main(java.lang.String[] args)
          A simple test program.
 java.lang.String toString(java.util.ResourceBundle bundle, java.lang.String baseKey, INoReturnMap argMap)
          A convenience method that returns the result casted to a string.
 
Methods inherited from class com.taco.text.StringConverter
toString
 
Methods inherited from class com.taco.text.InterpolatingConverter
_argMapReferenceToObject, _getStandardImports, _getStandardStaticImports, _literalResultToObject, _scriptSnippetToObject, _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

instance

public static final QuotedStringConverter instance
The singleton instance of this class.

Constructor Detail

QuotedStringConverter

protected QuotedStringConverter()
Method Detail

toString

public java.lang.String toString(java.util.ResourceBundle bundle,
                                 java.lang.String baseKey,
                                 INoReturnMap argMap)
                          throws java.text.ParseException,
                                 java.util.MissingResourceException
A convenience method that returns the result casted to a string.

Overrides:
toString in class StringConverter
Throws:
java.text.ParseException
java.util.MissingResourceException

_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
Description copied from class: StringConverter
If baseKey is mapped to null, return null. If it is mapped to a string, convert it to another string using this instance as a string to string converter. Otherwise, convert the mapped value to a string by calling its toString() method.

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

_formatMessage

protected java.lang.String _formatMessage(java.lang.CharSequence cs,
                                          java.util.ResourceBundle bundle,
                                          INoReturnMap argMap)
                                   throws java.text.ParseException
Given a message format then an optional array of instances to use in the format, form the message and return it.

Throws:
java.text.ParseException

main

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