/** * <p> * Escapes the characters in a <code>String</code>. * </p> * * <p> * For example, if you have called addEntity("foo", 0xA1), escape("\u00A1") will return * "&foo;" * </p> * * @param str * The <code>String</code> to escape. * @return A new escaped <code>String</code>. */ public String escape(String str) { StringBuilder sb = createStringBuilder(str); escape(sb, str); return sb.toString(); }
/** * <p> * Unescapes the entities in a <code>String</code>. * </p> * * <p> * For example, if you have called addEntity("foo", 0xA1), unescape("&foo;") will return * "\u00A1" * </p> * * @param str * The <code>String</code> to escape. * @return A new escaped <code>String</code>. */ public String unescape(String str) { int firstAmp = str.indexOf('&'); if (firstAmp < 0) { return str; } else { StringBuilder sb = createStringBuilder(str); doUnescape(sb, str, firstAmp); return sb.toString(); } }
/** * <p> * Escapes the characters in a <code>String</code>. * </p> * * <p> * For example, if you have called addEntity("foo", 0xA1), escape("\u00A1") will return * "&foo;" * </p> * * @param str * The <code>String</code> to escape. * @return A new escaped <code>String</code>. */ public String escape(String str) { StringBuilder sb = createStringBuilder(str); escape(sb, str); return sb.toString(); }
/** * <p> * Escapes the characters in a <code>String</code>. * </p> * * <p> * For example, if you have called addEntity("foo", 0xA1), escape("\u00A1") will return * "&foo;" * </p> * * @param str * The <code>String</code> to escape. * @return A new escaped <code>String</code>. */ public String escape(String str) { StringBuilder sb = createStringBuilder(str); escape(sb, str); return sb.toString(); }
/** * <p> * Unescapes the entities in a <code>String</code>. * </p> * * <p> * For example, if you have called addEntity("foo", 0xA1), unescape("&foo;") will return * "\u00A1" * </p> * * @param str * The <code>String</code> to escape. * @return A new escaped <code>String</code>. */ public String unescape(String str) { int firstAmp = str.indexOf('&'); if (firstAmp < 0) { return str; } else { StringBuilder sb = createStringBuilder(str); doUnescape(sb, str, firstAmp); return sb.toString(); } }
/** * <p> * Unescapes the entities in a <code>String</code>. * </p> * * <p> * For example, if you have called addEntity("foo", 0xA1), unescape("&foo;") will return * "\u00A1" * </p> * * @param str * The <code>String</code> to escape. * @return A new escaped <code>String</code>. */ public String unescape(String str) { int firstAmp = str.indexOf('&'); if (firstAmp < 0) { return str; } else { StringBuilder sb = createStringBuilder(str); doUnescape(sb, str, firstAmp); return sb.toString(); } }