List of usage examples for org.apache.commons.lang3 StringEscapeUtils UNESCAPE_JAVA
CharSequenceTranslator UNESCAPE_JAVA
To view the source code for org.apache.commons.lang3 StringEscapeUtils UNESCAPE_JAVA.
Click Source Link
From source file:org.apache.bval.jsr.util.PathNavigation.java
private static String parseQuotedString(CharSequence path, PathPosition pos) throws Exception { int len = path.length(); int start = pos.getIndex(); if (start < len) { char quote = path.charAt(start); pos.next();/*from www . j av a2s . com*/ StringWriter w = new StringWriter(); while (pos.getIndex() < len) { int here = pos.getIndex(); // look for matching quote if (path.charAt(here) == quote) { pos.next(); return w.toString(); } int codePoints = StringEscapeUtils.UNESCAPE_JAVA.translate(path, here, w); if (codePoints == 0) { w.write(Character.toChars(Character.codePointAt(path, here))); pos.next(); } else { for (int i = 0; i < codePoints; i++) { pos.plus(Character.charCount(Character.codePointAt(path, pos.getIndex()))); } } } // if reached, reset due to no ending quote found pos.setIndex(start); } return null; }