com.taco.text
Class BracedPropertyCompositeConverter

java.lang.Object
  extended by com.taco.text.AbstractInterpolatingStringToObjectConverter
      extended by com.taco.text.InterpolatingConverter
          extended by com.taco.text.CompositeConverter
              extended by com.taco.text.BracedPropertyCompositeConverter
All Implemented Interfaces:
ICommonRegexConstants, IInterpolatingConverter, IInterpolatingStringToObjectConverter, IStringToObjectConverter, IInterpolatingResourceBundleToObjectConverter, java.lang.Cloneable
Direct Known Subclasses:
ComponentConverter, DimensionConverter, ExtensionFileFilterConverter, GridBagConstraintsConverter, ImmutableCompositeConverter, IntArrayConverter, JTabbedPaneConverter.TabConverter, PointConverter, RectangleConverter, TableColumnConverter, TableColumnModelConverter

public abstract class BracedPropertyCompositeConverter
extends CompositeConverter
implements ICommonRegexConstants

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
 
Nested classes/interfaces inherited from class com.taco.text.CompositeConverter
CompositeConverter.AbstractCompositeUpdater, CompositeConverter.AbstractMapConsistencyListener, CompositeConverter.CompositeUpdater, CompositeConverter.DefaultMapConsistencyListener, CompositeConverter.DelayedConvertedResult, CompositeConverter.ICompositeUpdater, CompositeConverter.IMapConsistencyListener, CompositeConverter.ISetPropertyAction, CompositeConverter.NotUpdaterListenerFilter, CompositeConverter.ReflectionSetPropertyAction
 
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
 
Fields inherited from interface com.taco.text.ICommonRegexConstants
BOOLEAN_REGEX_STRING, CHAR_REGEX_STRING, FLOAT_REGEX_STRING, HEX_NUMBER_REGEX_STRING, INTEGER_REGEX_STRING, JAVA_CLASS_NAME_REGEX_STRING, LONG_HEX_REGEX_STRING, LONG_INTEGER_REGEX_STRING, NON_NEGATIVE_FLOAT_REGEX_STRING, PROPERTY_PREFIX_PATTERN, PROPERTY_PREFIX_REGEX_STRING, QUOTED_STRING_REGEX_STRING, WHITESPACE_PATTERN
 
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.CompositeConverter
_addMapConsistencyListener, _addMapConsistencyListeners, _addProperties, _addUpdaterListeners, _configureComposite, _createComposite, _createUpdaterListener, _getActionForProperty, _makeInitConverter, _setProperties, _toObject, configureComposite, getConverterForProperty, getConverterNameForProperty, getCreationPropertyNames, getPropertyNames, isPropertyReadable, isPropertyUpdatable, isPropertyWritable
 
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

_KEEP_ENCLOSING_PUNCTUATION_PATTERN

protected static final 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 '&'. A property assignment prefix consists of initial whitespace, an initial word (which may have letters, digits, '_', and/or '.'), optional whitespace, and a '=' character. No groups are captured.

Constructor Detail

BracedPropertyCompositeConverter

public BracedPropertyCompositeConverter()
Create a new instance whose implementation of IStringToObjectConverter is incapable of resolving references.


BracedPropertyCompositeConverter

public 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 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
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. 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.

Specified by:
_literalToObject in class CompositeConverter
Throws:
java.text.ParseException
java.util.MissingResourceException

_gatherPropertyMatchResults

protected java.util.Map _gatherPropertyMatchResults(java.lang.CharSequence cs)
                                             throws java.text.ParseException
Return a new map from property names to instances of InterpolatedValueMatchResult that arise from parsing the argument character sequence.

Throws:
java.text.ParseException

_addProperties

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.


_extractPropertiesSubSequence

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().

Throws:
java.text.ParseException

_extractPropertyValue

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.

Throws:
java.text.ParseException

_shouldKeepEnclosingPunctuation

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. 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.