public static String removeWhitespaceQuoting(final String userText) {
        final String storedText;
        if (userText == null || userText.isEmpty()) {
            storedText = userText;
        } else {
            final String trimmedStr = userText.trim();
            if (trimmedStr.startsWith("\"")
                    && trimmedStr.endsWith("\"")) {

                final int openQuoteIdx = trimmedStr.indexOf("\"");
                final int endQuoteIdx = trimmedStr.lastIndexOf("\"");
                if (openQuoteIdx == endQuoteIdx) {
                    // '"'
                    storedText = trimmedStr;
                } else {
                    // Everything inside the db quotes, un-escaping any dbl quote used
                    storedText = trimmedStr.substring(openQuoteIdx + 1, endQuoteIdx)
                            .replace("\\\"", "\"");
                }
            } else {
                storedText = trimmedStr.replace("\\\"", "\"");
            }
        }
        return storedText;
    }
Converts user input, that has been double-quoted to include whitespace,
into the un-quoted value. Any double quotes inside the outermost double
quotes will be escaped with a single backslash. Any Unquoted whitespace
or whitespace outside the outer double quotes will be trimmed.
See the tests for examples.
stroom-util-shared/src/main/java/stroom/util/shared/StringUtil.java