|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.taco.text.AbstractInterpolatingStringToObjectConverter
com.taco.text.InterpolatingConverter
com.taco.text.DispatchingConverter
public class DispatchingConverter
A string and resource bundle to object converter that uses the first word of a string or the key appended with ".dispatchType" in the resource bundle to dispatch to another converter.
Field Summary | |
---|---|
protected java.util.Map |
_suffixToTypeMap
A map between resource bundle key suffixes (lower-case String )and dispatch types (String ) that are
guesses for the dispatch type corresponding to resource bundle keys
ending with a suffix. |
protected java.util.Map |
_typeToConfigurerMap
A map between dispatch types ( String ) and instances of
CompositeConverter that handle the corresponding
types. |
protected java.util.Map |
_typeToConverterMap
A map between dispatch types ( String ) and instances of
IInterpolatingConverter that handle the corresponding
types. |
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 | |
---|---|
DispatchingConverter()
|
|
DispatchingConverter(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.String |
_getTypeForSuffix(java.lang.String suffix)
Return the dispatch type for the argument suffix, which should be in lower-case. |
protected java.lang.String |
_guessType(java.lang.String baseName)
The ".dispatchType" subkey was not found for the argument resource bundle key. |
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 the value associated with baseKey is a non-null string,
use this instance to convert it to an object. |
java.lang.Object |
clone()
|
void |
configureComposite(java.lang.String id,
java.lang.Object composite,
java.lang.String baseKey,
java.util.ResourceBundle bundle,
INoReturnMap argMap)
If there is a composite data converter installed for the argument type of object, use it to configure the composite. |
CompositeConverter |
getConfigurerForType(java.lang.String type)
Return the composite configurer associated with the argument type. |
IInterpolatingConverter |
getConverterForType(java.lang.String type)
Return the converter associated with the argument type. |
void |
installConfigurer(java.lang.String id,
CompositeConverter configurer)
Install a composite converter that uses a resource bundle to configure a composite object. |
void |
installConverter(java.lang.String id,
IInterpolatingConverter converter)
Install a converter from a string that begins with the argument string, or a from a resource bundle. |
void |
installTypeForSuffix(java.lang.String suffix,
java.lang.String type)
Install a type for resource bundle keys ending with the argument suffix. |
java.lang.String |
name()
Use this instance's simple class name to derive a name for this converter. |
Methods inherited from class com.taco.text.InterpolatingConverter |
---|
_argMapReferenceToObject, _getStandardImports, _getStandardStaticImports, _literalResultToObject, _scriptSnippetToObject, _toObjectMapper, 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 |
---|
protected java.util.Map _typeToConverterMap
String
) and instances of
IInterpolatingConverter
that handle the corresponding
types.
protected java.util.Map _typeToConfigurerMap
String
) and instances of
CompositeConverter
that handle the corresponding
types.
protected java.util.Map _suffixToTypeMap
String
)and dispatch types (String
) that are
guesses for the dispatch type corresponding to resource bundle keys
ending with a suffix.
Constructor Detail |
---|
public DispatchingConverter()
public DispatchingConverter(java.util.ResourceBundle bundle, INoReturnMap argMap)
IStringToObjectConverter
uses the specified resource
bundle and argument map to resolve references.
Method Detail |
---|
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class InterpolatingConverter
java.lang.CloneNotSupportedException
public void installConverter(java.lang.String id, IInterpolatingConverter converter)
Install a converter from a string that begins with the argument
string, or a from a resource bundle. If converter
is
null
, uninstall the converter for the ID.
This implementation associates id
with
converter
in _typeToConverterMap
.
public void installConfigurer(java.lang.String id, CompositeConverter configurer)
Install a composite converter that uses a resource bundle to
configure a composite object. If converter
is
null
, uninstall the configurer for the ID.
This implementation associates id
with
converter
in _typeToConfigurerMap
.
public void configureComposite(java.lang.String id, java.lang.Object composite, java.lang.String baseKey, java.util.ResourceBundle bundle, INoReturnMap argMap)
UnsupportedOperationException
.
public IInterpolatingConverter getConverterForType(java.lang.String type)
Return the converter associated with the argument type. If no
converter is associated with the argument type, return
null
.
This default implementation simply returns the result of looking up
type
in _typeToConverterMap
.
public CompositeConverter getConfigurerForType(java.lang.String type)
Return the composite configurer associated with the argument type.
If no configurer is associated with the argument type, return
null
.
This default implementation simply returns the result of looking up
type
in _typeToConfigurerMap
.
public void installTypeForSuffix(java.lang.String suffix, java.lang.String type)
null
is used for the type, no type will be guessed for the
argument suffix.
public java.lang.String name()
"Dispatching"
, discard it. Also discard the trailing
"Converter"
suffix if present.
name
in interface IInterpolatingConverter
name
in class InterpolatingConverter
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
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.
_literalToObject
in class InterpolatingConverter
java.text.ParseException
java.util.MissingResourceException
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
InterpolatingConverter
baseKey
is a non-null string,
use this instance to convert it to an object. Otherwise, return the
object.
_toObject
in class InterpolatingConverter
java.text.ParseException
java.util.MissingResourceException
protected java.lang.String _guessType(java.lang.String baseName)
The ".dispatchType" subkey was not found for the argument resource
bundle key. Using the name, guess the appropriate type. If no good
guess can be determined, return null
.
This default implementation sees if the base name ends with (case
insensitively) one of the suffixes in the suffix to type map, which is
modified by _installTypeForSuffix()
. If it does, it
returns the first type encountered.
protected java.lang.String _getTypeForSuffix(java.lang.String suffix)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |