Example usage for com.google.common.base CharEscaper escape

List of usage examples for com.google.common.base CharEscaper escape

Introduction

In this page you can find the example usage for com.google.common.base CharEscaper escape.

Prototype

protected abstract char[] escape(char c);

Source Link

Document

Returns the escaped form of the given character, or null if this character does not need to be escaped.

Usage

From source file:com.google.gxp.base.GxpClosures.java

/**
 * Create a {@code GxpClosure} based on a {@code String} escaped with
 * the given {@code CharEscaper}.//from www.  j  av a  2 s .  c  om
 */
public static GxpClosure fromString(final String value, final CharEscaper escaper) {
    Preconditions.checkNotNull(value);
    Preconditions.checkNotNull(escaper);
    return new GxpClosure() {
        public void write(Appendable out, GxpContext gxpContext) throws IOException {
            escaper.escape(out).append(value);
        }
    };
}

From source file:com.google.gxp.base.GxpClosures.java

/**
 * Create a {@code GxpClosure} based on a {@code Localizable} escaped with
 * the given {@code CharEscaper}./*from w w  w  . j  av  a2  s.  c  o  m*/
 */
public static GxpClosure fromLocalizable(final Localizable value, final CharEscaper escaper) {
    Preconditions.checkNotNull(value);
    Preconditions.checkNotNull(escaper);
    return new GxpClosure() {
        public void write(Appendable out, GxpContext gxpContext) throws IOException {
            escaper.escape(out).append(value.toString(gxpContext.getLocale()));
        }
    };
}