Top Description Fields Constructors Methods
org.apache.commons.text.translate

public Class UnicodeEscaper

extends CodePointTranslator
Class Inheritance
Known Direct Subclasses
org.apache.commons.text.translate.JavaUnicodeEscaper
Imports
java.io.IOException, .Writer

Translates code points to their Unicode escaped value.
Since
1.0

Field Summary

Modifier and TypeField and Description
private final int
above

The highest code point boundary.

private final int
below

The lowest code point boundary.

private final boolean
between

Whether to escape between the boundaries or outside them.

Constructor Summary

AccessConstructor and Description
public
UnicodeEscaper()

Constructs a UnicodeEscaper for all characters.

protected
UnicodeEscaper(final int
int value representing the lowest code point boundary.
below
,
final int
int value representing the highest code point boundary.
above
,
final boolean
whether to escape between the boundaries or outside them.
between
)

Constructs a UnicodeEscaper for the specified range.

Method Summary

Modifier and TypeMethod and Description
public static UnicodeEscaper

Returns:

The newly created UnicodeEscaper instance.
above
(final int
above which to escape.
codePoint
)

Constructs a UnicodeEscaper above the specified value (exclusive).

public static UnicodeEscaper

Returns:

The newly created UnicodeEscaper instance.
below
(final int
below which to escape.
codePoint
)

Constructs a UnicodeEscaper below the specified value (exclusive).

public static UnicodeEscaper

Returns:

The newly created UnicodeEscaper instance.
between
(final int
above which to escape.
codePointLow
,
final int
below which to escape.
codePointHigh
)

Constructs a UnicodeEscaper between the specified values (inclusive).

public static UnicodeEscaper

Returns:

The newly created UnicodeEscaper instance.
outsideOf
(final int
below which to escape.
codePointLow
,
final int
above which to escape.
codePointHigh
)

Constructs a UnicodeEscaper outside of the specified values (exclusive).

protected String

Returns:

The hexadecimal string for the given code point.
toUtf16Escape
(final int
a Unicode code point.
codePoint
)

Converts the given code point to a hexadecimal string of the form "\\uXXXX".

public boolean
translate(final int codePoint, final Writer writer)

Implements abstract org.apache.commons.text.translate.CodePointTranslator.translate.

Translates the specified code point into another.

Inherited from org.apache.commons.text.translate.CodePointTranslator:
translate

Field Detail

aboveback to summary
private final int above

The highest code point boundary.

belowback to summary
private final int below

The lowest code point boundary.

betweenback to summary
private final boolean between

Whether to escape between the boundaries or outside them.

Constructor Detail

UnicodeEscaperback to summary
public UnicodeEscaper()

Constructs a UnicodeEscaper for all characters.

UnicodeEscaperback to summary
protected UnicodeEscaper(final int below, final int above, final boolean between)

Constructs a UnicodeEscaper for the specified range. This is the underlying method for the other constructors/builders. The below and above boundaries are inclusive when between is true and exclusive when it is false.

Parameters
below:int

int value representing the lowest code point boundary.

above:int

int value representing the highest code point boundary.

between:boolean

whether to escape between the boundaries or outside them.

Method Detail

aboveback to summary
public static UnicodeEscaper above(final int codePoint)

Constructs a UnicodeEscaper above the specified value (exclusive).

Parameters
codePoint:int

above which to escape.

Returns:UnicodeEscaper

The newly created UnicodeEscaper instance.

belowback to summary
public static UnicodeEscaper below(final int codePoint)

Constructs a UnicodeEscaper below the specified value (exclusive).

Parameters
codePoint:int

below which to escape.

Returns:UnicodeEscaper

The newly created UnicodeEscaper instance.

betweenback to summary
public static UnicodeEscaper between(final int codePointLow, final int codePointHigh)

Constructs a UnicodeEscaper between the specified values (inclusive).

Parameters
codePointLow:int

above which to escape.

codePointHigh:int

below which to escape.

Returns:UnicodeEscaper

The newly created UnicodeEscaper instance.

outsideOfback to summary
public static UnicodeEscaper outsideOf(final int codePointLow, final int codePointHigh)

Constructs a UnicodeEscaper outside of the specified values (exclusive).

Parameters
codePointLow:int

below which to escape.

codePointHigh:int

above which to escape.

Returns:UnicodeEscaper

The newly created UnicodeEscaper instance.

toUtf16Escapeback to summary
protected String toUtf16Escape(final int codePoint)

Converts the given code point to a hexadecimal string of the form "\\uXXXX".

Parameters
codePoint:int

a Unicode code point.

Returns:String

The hexadecimal string for the given code point.

translateback to summary
public boolean translate(final int codePoint, final Writer writer) throws IOException

Implements abstract org.apache.commons.text.translate.CodePointTranslator.translate.

Doc from org.apache.commons.text.translate.CodePointTranslator.translate.

Translates the specified code point into another.

Annotations
@Override
Exceptions
IOException:
if and only if the Writer produces an IOException.