Class DisabledListDelimiterHandler

java.lang.Object
org.apache.commons.configuration2.convert.AbstractListDelimiterHandler
org.apache.commons.configuration2.convert.DisabledListDelimiterHandler
All Implemented Interfaces:
ListDelimiterHandler

A specialized implementation of the ListDelimiterHandler interface which disables list splitting.

This class does not recognize any list delimiters; passed in strings are returned unchanged. Also the escape() method is a dummy - there is no need for escaping delimiter characters as none are supported. Note that the method for escaping a list throws an UnsupportedOperationException. If list delimiters are not supported, there is no point in squashing multiple values into a single one.

Implementation note: An instance of this class can be shared between multiple configuration objects. It is state-less and thread-safe.

Since:
2.0
  • Field Details

    • INSTANCE

      public static final ListDelimiterHandler INSTANCE
      A default instance of this class. Because it is safe to share DisabledListDelimiterHandler objects this instance can be used whenever such an object is needed.
  • Constructor Details

  • Method Details

    • escapeList

      public Object escapeList(List<?> values, ValueTransformer transformer)
      Escapes all values in the given list and concatenates them to a single string. This operation is required by configurations that have to represent properties with multiple values in a single line in their external configuration representation. This may require an advanced escaping in some cases. This implementation always throws an UnsupportedOperationException exception.
      Parameters:
      values - the list with all the values to be converted to a single value
      transformer - a ValueTransformer for an additional encoding (must not be null)
      Returns:
      the resulting escaped value
    • splitString

      protected Collection<String> splitString(String s, boolean trim)
      Actually splits the passed in string which is guaranteed to be not null. This method is called by the base implementation of the split() method. Here the actual splitting logic has to be implemented. This implementation always returns a collection containing the passed in string as its single element. The string is not changed, the trim flag is ignored. (The trim flag refers to the components extracted from the string. Because no components are extracted nothing is trimmed.)
      Specified by:
      splitString in class AbstractListDelimiterHandler
      Parameters:
      s - the string to be split (not null)
      trim - a flag whether the single components have to be trimmed
      Returns:
      a collection with the extracted components of the passed in string
    • escapeString

      protected String escapeString(String s)
      Escapes the specified string. This method is called by escape() if the passed in object is a string. Concrete subclasses have to implement their specific escaping logic here, so that the list delimiters they support are properly escaped. This implementation returns the passed in string without any changes.
      Specified by:
      escapeString in class AbstractListDelimiterHandler
      Parameters:
      s - the string to be escaped (not null)
      Returns:
      the escaped string