/** * Get the text in the CDATA block.<p> * * @return the string up to the <code>]]></code> * @throws JSONException if the <code>]]></code> is not found */ public String nextCDATA() throws JSONException { char c; int i; StringBuffer sb = new StringBuffer(); for (;;) { c = next(); if (c == 0) { throw syntaxError("Unclosed CDATA"); } sb.append(c); i = sb.length() - 3; if ((i >= 0) && (sb.charAt(i) == ']') && (sb.charAt(i + 1) == ']') && (sb.charAt(i + 2) == '>')) { sb.setLength(i); return sb.toString(); } } }
/** * Get the text in the CDATA block.<p> * * @return the string up to the <code>]]></code> * @throws JSONException if the <code>]]></code> is not found */ public String nextCDATA() throws JSONException { char c; int i; StringBuffer sb = new StringBuffer(); for (;;) { c = next(); if (c == 0) { throw syntaxError("Unclosed CDATA"); } sb.append(c); i = sb.length() - 3; if (i >= 0 && sb.charAt(i) == ']' && sb.charAt(i + 1) == ']' && sb.charAt(i + 2) == '>') { sb.setLength(i); return sb.toString(); } } }
/** * Return the next ENTITY. These entities are translated to Characters: * <code>& ' > < "</code>.<p> * * @param a an ampersand character * @return a Character or an entity String if the entity is not recognized * @throws JSONException if missing ';' in XML entity */ public Object nextEntity(char a) throws JSONException { StringBuffer sb = new StringBuffer(); for (;;) { char c = next(); if (Character.isLetterOrDigit(c) || c == '#') { sb.append(Character.toLowerCase(c)); } else if (c == ';') { break; } else { throw syntaxError("Missing ';' in XML ENTITY: &" + sb); } } String s = sb.toString(); Object e = ENTITY.get(s); return e != null ? e : a + s + ";"; }
/** * Return the next ENTITY. These entities are translated to Characters: * <code>& ' > < "</code>.<p> * * @param a an ampersand character * @return a Character or an entity String if the entity is not recognized * @throws JSONException if missing ';' in XML entity */ public Object nextEntity(char a) throws JSONException { StringBuffer sb = new StringBuffer(); for (;;) { char c = next(); if (Character.isLetterOrDigit(c) || (c == '#')) { sb.append(Character.toLowerCase(c)); } else if (c == ';') { break; } else { throw syntaxError("Missing ';' in XML ENTITY: &" + sb); } } String s = sb.toString(); Object e = ENTITY.get(s); return e != null ? e : a + s + ";"; }