The default implementation of the {@code ListDelimiterHandler} interface.
This class supports list splitting and delimiter escaping using a delimiter character that can be specified when constructing an instance. Splitting of strings works by scanning the input for the list delimiter character. The list delimiter character can be escaped by a backslash. So, provided that a comma is configured as list delimiter, in the example {@code val1,val2,val3}three values are recognized. In {@code 3\,1415} the list delimiter is escapedso that only a single element is detected. (Note that when writing these examples in Java code, each backslash has to be doubled. This is also true for all other examples in this documentation.)
Because the backslash has a special meaning as escaping character it is always treated in a special way. If it occurs as a normal character in a property value, it has to be escaped using another backslash (similar to the rules of the Java programming language). The following example shows the correct way to define windows network shares: {@code \\\\Server\\path}. Note that each backslash is doubled. When combining the list delimiter with backslashes the same escaping rules apply. For instance, in {@code C:\\Temp\\,D:\\data\\} the list delimiter is recognized; it is notescaped by the preceding backslash because this backslash is itself escaped. In contrast, {@code C:\\Temp\\\,D:\\data\\} defines a single element with acomma being part of the value; two backslashes after {@code Temp} result in asingle one, the third backslash escapes the list delimiter.
As can be seen, there are some constellations which are a bit tricky and cause a larger number of backslashes in sequence. Nevertheless, the escaping rules are consistent and do not cause ambiguous results.
Implementation node: An instance of this class can safely be shared between multiple {@code Configuration} instances.
@version $Id: DefaultListDelimiterHandler.java 1624601 2014-09-12 18:04:36Z oheger $ @since 2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|