Class DisabledListDelimiterHandler
- java.lang.Object
-
- org.apache.commons.configuration2.convert.AbstractListDelimiterHandler
-
- org.apache.commons.configuration2.convert.DisabledListDelimiterHandler
-
- All Implemented Interfaces:
ListDelimiterHandler
public class DisabledListDelimiterHandler extends AbstractListDelimiterHandler
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 anUnsupportedOperationException
. 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 Summary
Fields Modifier and Type Field Description static ListDelimiterHandler
INSTANCE
A default instance of this class.-
Fields inherited from interface org.apache.commons.configuration2.convert.ListDelimiterHandler
NOOP_TRANSFORMER
-
-
Constructor Summary
Constructors Constructor Description DisabledListDelimiterHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
escapeList(java.util.List<?> values, ValueTransformer transformer)
Escapes all values in the given list and concatenates them to a single string.protected java.lang.String
escapeString(java.lang.String s)
Escapes the specified string.protected java.util.Collection<java.lang.String>
splitString(java.lang.String s, boolean trim)
Actually splits the passed in string which is guaranteed to be not null.-
Methods inherited from class org.apache.commons.configuration2.convert.AbstractListDelimiterHandler
escape, flatten, flattenIterator, parse, split
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.commons.configuration2.convert.ListDelimiterHandler
flatten
-
-
-
-
Field Detail
-
INSTANCE
public static final ListDelimiterHandler INSTANCE
A default instance of this class. Because it is safe to shareDisabledListDelimiterHandler
objects this instance can be used whenever such an object is needed.
-
-
Method Detail
-
escapeList
public java.lang.Object escapeList(java.util.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 anUnsupportedOperationException
exception.- Parameters:
values
- the list with all the values to be converted to a single valuetransformer
- aValueTransformer
for an additional encoding (must not be null)- Returns:
- the resulting escaped value
-
escapeString
protected java.lang.String escapeString(java.lang.String s)
Escapes the specified string. This method is called byescape()
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 classAbstractListDelimiterHandler
- Parameters:
s
- the string to be escaped (not null)- Returns:
- the escaped string
-
splitString
protected java.util.Collection<java.lang.String> splitString(java.lang.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 thesplit()
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, thetrim
flag is ignored. (Thetrim
flag refers to the components extracted from the string. Because no components are extracted nothing is trimmed.)- Specified by:
splitString
in classAbstractListDelimiterHandler
- 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
-
-