|
||||||||||
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.CompositeConverter
com.taco.text.BracedPropertyCompositeConverter
public abstract class BracedPropertyCompositeConverter
A subclass of CompositeConverter
that matches C-style
punctuation in property values. Strings that have the general format
PREFIX PROPERTY_NAME={ PROPERTY_VALUE } PROPERTY_NAME={
PROPERTY_VALUE } ...
can be converted by this class's
_literalToObject()
method, which overrides the superclass's
method.
Nested Class Summary |
---|
Field Summary | |
---|---|
protected static java.util.regex.Pattern |
_KEEP_ENCLOSING_PUNCTUATION_PATTERN
A regex pattern for the prefix of a property assignment of a property of a property value, or for something starting with an opening punctuation character, '%', '$', or '&'. |
Fields inherited from class com.taco.text.CompositeConverter |
---|
_DEFAULT_COMPOSITE_CONVERTER_MAP, _DEFAULT_COMPOSITE_CREATION_PROPERTY_NAMES, _SHOULD_READ_GLOBAL_NAME |
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 | |
---|---|
BracedPropertyCompositeConverter()
Create a new instance whose implementation of IStringToObjectConverter is incapable of resolving
references. |
|
BracedPropertyCompositeConverter(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 void |
_addProperties(java.lang.Object composite,
java.util.Map resultMap,
java.util.Collection propertyNames,
java.util.ResourceBundle bundle,
INoReturnMap argMap,
KeyLookupRecord keyLookupRecord,
java.util.Map propertyMap)
Given a map of property names to InterpolatedValueMatchResult , convert the results that are
members of propertyNames to property values and put them
in propertyMap . |
protected java.lang.CharSequence |
_extractPropertiesSubSequence(java.lang.CharSequence cs)
Given a literal string to convert, return the part of the string that is a series of property name / value pairs. |
protected InterpolatedValueMatchResult |
_extractPropertyValue(java.lang.String propertyName,
java.lang.CharSequence cs)
Given a character sequence beginning with the string representation of a property value for the argument property name, return a new instance of InterpolatedValueMatchResult whose
s field is the portion of the character sequence that
represents the property value, and whose endIndex field is
set to the index just after the property value representation. |
protected java.util.Map |
_gatherPropertyMatchResults(java.lang.CharSequence cs)
Return a new map from property names to instances of InterpolatedValueMatchResult that arise from parsing the
argument character sequence. |
protected java.lang.Object |
_literalToObject(java.lang.String s,
java.util.ResourceBundle bundle,
INoReturnMap argMap,
java.lang.String globalName)
First call _extractPropertiesSubSequence() to get the
string representation of property name / value pairs, and then for each
property, call _extractPropertyValueString() to eat the
part of the string used for the property. |
protected boolean |
_shouldKeepEnclosingPunctuation(java.lang.String propertyName,
java.lang.CharSequence cs)
This method is called by _extractPropertyValueString() to
determine if the opening and closing braces should be kept around a
string representing a property value. |
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 |
---|
protected static final java.util.regex.Pattern _KEEP_ENCLOSING_PUNCTUATION_PATTERN
Constructor Detail |
---|
public BracedPropertyCompositeConverter()
IStringToObjectConverter
is incapable of resolving
references.
public BracedPropertyCompositeConverter(java.util.ResourceBundle bundle, INoReturnMap argMap)
IStringToObjectConverter
uses the specified resource
bundle and argument map to resolve references.
Method Detail |
---|
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
_extractPropertiesSubSequence()
to get the
string representation of property name / value pairs, and then for each
property, call _extractPropertyValueString()
to eat the
part of the string used for the property. Use the object converters in
the map returned by _getPropertyNameToConverterPairMap()
to convert each property string to a property value. Put all property
name / value pairs in a map, then call _makeComposite()
and _setProperties()
to create the returned object.
_literalToObject
in class CompositeConverter
java.text.ParseException
java.util.MissingResourceException
protected java.util.Map _gatherPropertyMatchResults(java.lang.CharSequence cs) throws java.text.ParseException
InterpolatedValueMatchResult
that arise from parsing the
argument character sequence.
java.text.ParseException
protected void _addProperties(java.lang.Object composite, java.util.Map resultMap, java.util.Collection propertyNames, java.util.ResourceBundle bundle, INoReturnMap argMap, KeyLookupRecord keyLookupRecord, java.util.Map propertyMap)
InterpolatedValueMatchResult
, convert the results that are
members of propertyNames
to property values and put them
in propertyMap
.
protected java.lang.CharSequence _extractPropertiesSubSequence(java.lang.CharSequence cs) throws java.text.ParseException
Given a literal string to convert, return the part of the string
that is a series of property name / value pairs. If any information can
be obtained from the string that is not in the format of a property
name / value pair, put it in the property map, which will later be
passed to _makeComposite()
and
_setProperties()
.
This default implementation calls
StringConverterUtilities.extractPropertiesSubSequence()
.
java.text.ParseException
protected InterpolatedValueMatchResult _extractPropertyValue(java.lang.String propertyName, java.lang.CharSequence cs) throws java.text.ParseException
Given a character sequence beginning with the string representation
of a property value for the argument property name, return a new
instance of InterpolatedValueMatchResult
whose
s
field is the portion of the character sequence that
represents the property value, and whose endIndex
field is
set to the index just after the property value representation.
The remainder of this documentation pertains to this base
implemention. If cs
begins with a C-style opening
punctuation character, verify that the punctuation is matched, and
return the contents of the punctuation pair in string of the returned
match result. If cs
does not begin with a C-style opening
punctuation character, put the characters up to the next whitespace
character or the end of the cs
in the string of the
returned match result. Set the endIndex
field of the
returned match result to the index of the next character after the
string representing the property value.
java.text.ParseException
protected boolean _shouldKeepEnclosingPunctuation(java.lang.String propertyName, java.lang.CharSequence cs)
_extractPropertyValueString()
to
determine if the opening and closing braces should be kept around a
string representing a property value. This default implementation
returns false
if the first character is anything other
than an opening curly brace. Otherwise, it looks to see if the property
value starts with an assignment of an inner property, a variable
reference, or an opening punctuation character. If so, the enclosing
punctuation is kept. This method is intended to be overridden by
subclasses to control whether or not enclosing punctuation is to be
kept for each property.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |