@Beta @GwtCompatible public abstract class ArrayBasedUnicodeEscaper extends UnicodeEscaper
UnicodeEscaperthat uses an array to quickly look up replacement characters for a given code point. An additional safe range is provided that determines whether code points without specific replacements are to be considered safe and left unescaped or should be escaped in a general way.
A good example of usage of this class is for HTML escaping where the
replacement array contains information about the named HTML entities
overridden to handle general escaping of the form
The size of the data structure used by
proportional to the highest valued code point that requires escaping.
For example a replacement map containing the single character
u1000' will require approximately 16K of memory. If you
need to create multiple escaper instances that have the same character
replacement mapping consider using
|Modifier and Type||Method and Description|
Returns the escaped form of a given literal string.
public final java.lang.String escape(java.lang.String s)
If you are escaping input in arbitrary successive chunks, then it is not
generally safe to use this method. If an input string ends with an
unmatched high surrogate character, then this method will throw
IllegalArgumentException. You should ensure your input is valid UTF-16 before calling this
Note: When implementing an escaper it is a good idea to override
this method for efficiency by inlining the implementation of
UnicodeEscaper.nextEscapeIndex(CharSequence, int, int) directly. Doing this for
PercentEscaper more than doubled the
performance for unescaped strings (as measured by
Copyright © 2010 - 2019 Adobe. All Rights Reserved