# Class Escaper (2.1.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.1.0 (latest)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.escape.Escaper)
- [2.0.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/2.0.3/com.google.api.client.util.escape.Escaper)
- [1.47.1](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.47.1/com.google.api.client.util.escape.Escaper)
- [1.46.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.46.3/com.google.api.client.util.escape.Escaper)
- [1.45.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.45.3/com.google.api.client.util.escape.Escaper)
- [1.44.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.44.2/com.google.api.client.util.escape.Escaper)
- [1.43.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.43.2/com.google.api.client.util.escape.Escaper)
- [1.42.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.42.3/com.google.api.client.util.escape.Escaper)
- [1.41.8](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.41.8/com.google.api.client.util.escape.Escaper)

    public abstract class Escaper

An object that converts literal text into a format safe for inclusion in a particular context
(such as an XML document). Typically (but not always), the inverse process of "unescaping" the
text is performed automatically by the relevant parser.

For example, an XML escaper would convert the literal string `"Foo<Bar>"` into `
"Foo<Bar>"` to prevent `"<Bar>"` from being confused with an XML tag. When the
resulting XML document is parsed, the parser API will return this text as the original literal
string `"Foo<Bar>"`.

An `Escaper` instance is required to be stateless, and safe when used concurrently by
multiple threads.

Several popular escapers are defined as constants in the class [CharEscapers](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.escape.CharEscapers).

## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> Escaper

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Constructors

### Escaper()

    public Escaper()

## Methods

### escape(String string)

    public abstract String escape(String string)

Returns the escaped form of a given literal string.

Note that this method may treat input characters differently depending on the specific
escaper implementation.

- [UnicodeEscaper](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.escape.UnicodeEscaper) handles [UTF-16](http://en.wikipedia.org/wiki/UTF-16) correctly, including surrogate character pairs. If the input is badly formed the escaper should throw IllegalArgumentException.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `string` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the literal string to be escaped |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` | the escaped form of `string` |