public class KvPlainEscaper extends Object
Here is a simple example:
a="yes" b="no"
Simple enough to detect that "yes" and "no" must be treated as opaque strings in there.
The tricky part is to deal with these example:
a="yes \"man\"" b="no"
a="yes man\" b="no"
In the first example the most probable escaped strings are "yes \"man\"" and "no".
While in the second it is "man\" and "no". The question is how to know that the character
'\' in "man\" is part of the string ?
To resolve that this class performs a reverse scan of the string that makes it easier to
check for the most consistent chain of '"' and '\"'.Constructor and Description |
---|
KvPlainEscaper()
Test constructor.
|
KvPlainEscaper(String enclosingDelimiters,
char escapeCharacter) |
Modifier and Type | Method and Description |
---|---|
String |
escape(String input,
List<KvPortion> opaque) |
List<KvPortion> |
reverseScan(String input,
KvPlainEscaperListener l)
This method is public to facilitate unit tests.
|
public KvPlainEscaper(String enclosingDelimiters, char escapeCharacter)
enclosingDelimiters
- a string to provide one or several
character to be used as delimiter.escapeCharacter
- the character used for escaping. Typically, '\'.public KvPlainEscaper()
public List<KvPortion> reverseScan(String input, KvPlainEscaperListener l)
input
- the input Stringl
- the listener to be told upon '"' and '\"' occurrences.Copyright © 2022. All rights reserved.