/** * Perform a CSS <strong>unescape</strong> operation on a <tt>char[]</tt> input. * * <p>No additional configuration arguments are required. Unescape operations will always perform * <em>complete</em> CSS unescape of backslash and hexadecimal escape sequences. * * <p>This method is <strong>thread-safe</strong>. * * @param text the <tt>char[]</tt> to be unescaped. * @param offset the position in <tt>text</tt> at which the unescape operation should start. * @param len the number of characters in <tt>text</tt> that should be unescaped. * @param writer the <tt>java.io.Writer</tt> to which the unescaped result will be written. * Nothing will be written at all to this writer if <tt>text</tt> is <tt>null</tt>. * @throws IOException if an input/output exception occurs */ public static void unescapeCss( final char[] text, final int offset, final int len, final Writer writer) throws IOException { if (writer == null) { throw new IllegalArgumentException("Argument 'writer' cannot be null"); } final int textLen = (text == null ? 0 : text.length); if (offset < 0 || offset > textLen) { throw new IllegalArgumentException( "Invalid (offset, len). offset=" + offset + ", len=" + len + ", text.length=" + textLen); } if (len < 0 || (offset + len) > textLen) { throw new IllegalArgumentException( "Invalid (offset, len). offset=" + offset + ", len=" + len + ", text.length=" + textLen); } CssUnescapeUtil.unescape(text, offset, len, writer); }
/** * Perform a CSS <strong>unescape</strong> operation on a <tt>String</tt> input. * * <p>No additional configuration arguments are required. Unescape operations will always perform * <em>complete</em> CSS unescape of backslash and hexadecimal escape sequences. * * <p>This method is <strong>thread-safe</strong>. * * @param text the <tt>String</tt> to be unescaped. * @return The unescaped result <tt>String</tt>. As a memory-performance improvement, will return * the exact same object as the <tt>text</tt> input argument if no unescaping modifications * were required (and no additional <tt>String</tt> objects will be created during * processing). Will return <tt>null</tt> if <tt>text</tt> is <tt>null</tt>. */ public static String unescapeCss(final String text) { return CssUnescapeUtil.unescape(text); }