/** * Unescape character references and built-in entity references in a string * * @param token the input string, which may include XML-style character references or built-in * entity references * @return the string with character references and built-in entity references replaced by their expansion * @throws XPathException if a malformed character or entity reference is found */ private FastStringBuffer unescape(String token) throws XPathException { FastStringBuffer sb = new FastStringBuffer(80); for (int i = 0; i < token.length(); i++) { char c = token.charAt(i); if (c == '&') { int semic = token.indexOf(';', i); if (semic < 0) { grumble("No closing ';' found for entity or character reference"); } else { String entity = token.substring(i + 1, semic); sb.append(analyzeEntityReference(entity)); i = semic; } } else { sb.append(c); } } return sb; }
/** * Unescape character references and built-in entity references in a string * * @param token the input string, which may include XML-style character references or built-in * entity references * @return the string with character references and built-in entity references replaced by their expansion * @throws XPathException if a malformed character or entity reference is found */ private FastStringBuffer unescape(String token) throws XPathException { FastStringBuffer sb = new FastStringBuffer(80); for (int i = 0; i < token.length(); i++) { char c = token.charAt(i); if (c == '&') { int semic = token.indexOf(';', i); if (semic < 0) { grumble("No closing ';' found for entity or character reference"); } else { String entity = token.substring(i + 1, semic); sb.append(analyzeEntityReference(entity)); i = semic; } } else { sb.append(c); } } return sb; }
} else { String entity = avt.substring(i + 1, semic); sb.append(analyzeEntityReference(entity)); i = semic;
} else { String entity = avt.substring(i + 1, semic); sb.append(analyzeEntityReference(entity)); i = semic;
/** * Read a pseudo-XML character reference or entity reference. * * @return The character represented by the character or entity reference. Note * that this is a string rather than a char because a char only accommodates characters * up to 65535. * @throws XPathException if the character or entity reference is not well-formed */ private String readEntityReference() throws XPathException { try { FastStringBuffer sb = new FastStringBuffer(40); while (true) { char c = t.nextChar(); if (c == ';') { break; } sb.append(c); } String entity = sb.toString(); return analyzeEntityReference(entity); } catch (StringIndexOutOfBoundsException err) { grumble("No closing ';' found for entity or character reference"); } return null; // to keep the Java compiler happy }
/** * Read a pseudo-XML character reference or entity reference. * * @return The character represented by the character or entity reference. Note * that this is a string rather than a char because a char only accommodates characters * up to 65535. * @throws XPathException if the character or entity reference is not well-formed */ private String readEntityReference() throws XPathException { try { FastStringBuffer sb = new FastStringBuffer(40); while (true) { char c = t.nextChar(); if (c == ';') { break; } sb.append(c); } String entity = sb.toString(); return analyzeEntityReference(entity); } catch (StringIndexOutOfBoundsException err) { grumble("No closing ';' found for entity or character reference"); } return null; // to keep the Java compiler happy }