|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.text.Transliterator | +--com.ibm.text.UnicodeToHexTransliterator
A transliterator that converts from Unicode characters to hexadecimal Unicode escape sequences. It outputs a prefix specified in the constructor and optionally converts the hex digits to uppercase.
The format of the output is set by a pattern. This pattern
follows the same syntax as HexToUnicodeTransliterator
,
except it does not allow multiple specifications. The pattern sets
the prefix string, suffix string, and minimum and maximum digit
count. There are no setters or getters for these attributes; they
are set only through the pattern.
The setUppercase() and isUppercase() methods control whether 'a' through 'f' or 'A' through 'F' are output as hex digits. This is not controlled through the pattern; only through the methods. The default is uppercase.
Inner classes inherited from class com.ibm.text.Transliterator |
Transliterator.Factory, Transliterator.Position |
Fields inherited from class com.ibm.text.Transliterator |
FORWARD, ID_DELIM, ID_SEP, REVERSE, VARIANT_SEP |
Constructor Summary | |
UnicodeToHexTransliterator()
Constructs a transliterator with the default prefix "\u" that outputs four uppercase hex digits. |
|
UnicodeToHexTransliterator(java.lang.String pattern)
Constructs an uppercase transliterator with no filter. |
|
UnicodeToHexTransliterator(java.lang.String pattern,
boolean uppercase,
UnicodeFilter filter)
Constructs a transliterator. |
Method Summary | |
void |
applyPattern(java.lang.String thePattern)
Set the pattern recognized by this transliterator. |
java.lang.String |
getPrefix()
Returns the string that precedes the four hex digits. |
protected void |
handleTransliterate(Replaceable text,
Transliterator.Position offsets,
boolean incremental)
Implements Transliterator.handleTransliterate(com.ibm.text.Replaceable, com.ibm.text.Transliterator.Position, boolean) . |
boolean |
isUppercase()
Returns true if this transliterator outputs uppercase hex digits. |
void |
setPrefix(java.lang.String prefix)
Sets the string that precedes the four hex digits. |
void |
setUppercase(boolean outputUppercase)
Sets if this transliterator outputs uppercase hex digits. |
java.lang.String |
toPattern()
Return this transliterator's pattern. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public UnicodeToHexTransliterator(java.lang.String pattern, boolean uppercase, UnicodeFilter filter)
pattern
- The pattern for this transliterator. See
applyPattern() for pattern syntax.uppercase
- if true, the four hex digits will be
converted to uppercase; otherwise they will be lowercase.
Ignored if direction is HEX_UNICODE.filter
- the filter for this transliterator, or
null if none.public UnicodeToHexTransliterator(java.lang.String pattern)
pattern
- The pattern for this transliterator. See
applyPattern() for pattern syntax.public UnicodeToHexTransliterator()
Method Detail |
public void applyPattern(java.lang.String thePattern)
Example: "U+0000" specifies a prefix of "U+", exactly four digits, and no suffix. "<###0>" has a prefix of "<", between one and four digits, and a suffix of ">".
pattern := prefix-char* digit-spec suffix-char* digit-spec := '#'* '0'+ prefix-char := [^special-char] | '\\' special-char suffix-char := [^special-char] | '\\' special-char special-char := ';' | '0' | '#' | '\\'
Limitations: There is no way to set the uppercase attribute in the pattern. (applyPattern() does not alter the uppercase attribute.)
public java.lang.String toPattern()
public java.lang.String getPrefix()
public void setPrefix(java.lang.String prefix)
Callers must take care if a transliterator is in use by multiple threads. The prefix should not be changed by one thread while another thread may be transliterating.
prefix
- prefix stringpublic boolean isUppercase()
public void setUppercase(boolean outputUppercase)
Callers must take care if a transliterator is in use by multiple threads. The uppercase mode should not be changed by one thread while another thread may be transliterating.
outputUppercase
- if true, then this transliterator
outputs uppercase hex digits.protected void handleTransliterate(Replaceable text, Transliterator.Position offsets, boolean incremental)
Transliterator.handleTransliterate(com.ibm.text.Replaceable, com.ibm.text.Transliterator.Position, boolean)
.handleTransliterate
in class Transliterator
com.ibm.text.Transliterator
text
- the buffer holding transliterated and
untransliterated textpos
- the start and limit of the text, the position
of the cursor, and the start and limit of transliteration.incremental
- if true, assume more text may be coming after
pos.contextLimit. Otherwise, assume the text is complete.Transliterator.transliterate(com.ibm.text.Replaceable, int, int)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |