| java.lang.Object com.ibm.icu.text.TransliteratorIDParser
TransliteratorIDParser | class TransliteratorIDParser (Code) | | Parsing component for transliterator IDs. This class contains only
static members; it cannot be instantiated. Methods in this class
parse various ID formats, including the following:
A basic ID, which contains source, target, and variant, but no
filter and no explicit inverse. Examples include
"Latin-Greek/UNGEGN" and "Null".
A single ID, which is a basic ID plus optional filter and optional
explicit inverse. Examples include "[a-zA-Z] Latin-Greek" and
"Lower (Upper)".
A compound ID, which is a sequence of one or more single IDs,
separated by semicolons, with optional forward and reverse global
filters. The global filters are UnicodeSet patterns prepended or
appended to the IDs, separated by semicolons. An appended filter
must be enclosed in parentheses and applies in the reverse
direction.
author: Alan Liu |
Inner Class :static class SingleID | |
Method Summary | |
public static String[] | IDtoSTV(String id) Parse an ID into pieces. | public static String | STVtoID(String source, String target, String variant) Given source, target, and variant strings, concatenate them into a
full ID. | public static void | instantiateList(Vector list) Convert the elements of the 'list' vector, which are SingleID
objects, into actual Transliterator objects. | public static boolean | parseCompoundID(String id, int dir, StringBuffer canonID, Vector list, UnicodeSet[] globalFilter) Parse a compound ID, consisting of an optional forward global
filter, a separator, one or more single IDs delimited by
separators, an an optional reverse global filter. | public static SingleID | parseFilterID(String id, int[] pos) Parse a filter ID, that is, an ID of the general form
"[f1] s1-t1/v1", with the filters optional, and the variants optional.
Parameters: id - the id to be parsed Parameters: pos - INPUT-OUTPUT parameter. | public static UnicodeSet | parseGlobalFilter(String id, int[] pos, int dir, int[] withParens, StringBuffer canonID) Parse a global filter of the form "[f]" or "([f])", depending
on 'withParens'.
Parameters: id - the pattern the parse Parameters: pos - INPUT-OUTPUT parameter. | public static SingleID | parseSingleID(String id, int[] pos, int dir) Parse a single ID, that is, an ID of the general form
"[f1] s1-t1/v1 ([f2] s2-t3/v2)", with the parenthesized element
optional, the filters optional, and the variants optional.
Parameters: id - the id to be parsed Parameters: pos - INPUT-OUTPUT parameter. | public static void | registerSpecialInverse(String target, String inverseTarget, boolean bidirectional) Register two targets as being inverses of one another. |
IDtoSTV | public static String[] IDtoSTV(String id)(Code) | | Parse an ID into pieces. Take IDs of the form T, T/V, S-T,
S-T/V, or S/V-T. If the source is missing, return a source of
ANY.
Parameters: id - the id string, in any of several forms an array of 4 strings: source, target, variant, andisSourcePresent. If the source is not present, ANY will begiven as the source, and isSourcePresent will be null. OtherwiseisSourcePresent will be non-null. The target may be empty if theid is not well-formed. The variant may be empty. |
STVtoID | public static String STVtoID(String source, String target, String variant)(Code) | | Given source, target, and variant strings, concatenate them into a
full ID. If the source is empty, then "Any" will be used for the
source, so the ID will always be of the form s-t/v or s-t.
|
instantiateList | public static void instantiateList(Vector list)(Code) | | Convert the elements of the 'list' vector, which are SingleID
objects, into actual Transliterator objects. In the course of
this, some (or all) entries may be removed. If all entries
are removed, the Null transliterator will be added.
Delete entries with empty basicIDs; these are generated by
elements like "(A)" in the forward direction, or "A()" in
the reverse. THIS MAY RESULT IN AN EMPTY VECTOR. Convert
SingleID entries to actual transliterators.
Parameters: list - vector of SingleID objects. On exit, vectorof one or more Transliterators. |
parseCompoundID | public static boolean parseCompoundID(String id, int dir, StringBuffer canonID, Vector list, UnicodeSet[] globalFilter)(Code) | | Parse a compound ID, consisting of an optional forward global
filter, a separator, one or more single IDs delimited by
separators, an an optional reverse global filter. The
separator is a semicolon. The global filters are UnicodeSet
patterns. The reverse global filter must be enclosed in
parentheses.
Parameters: id - the pattern the parse Parameters: dir - the direction. Parameters: canonID - OUTPUT parameter that receives the canonical ID,consisting of canonical IDs for all elements, as returned byparseSingleID(), separated by semicolons. Previous contentsare discarded. Parameters: list - OUTPUT parameter that receives a list of SingleIDobjects representing the parsed IDs. Previous contents arediscarded. Parameters: globalFilter - OUTPUT parameter that receives a pointer toa newly created global filter for this ID in this direction, ornull if there is none. true if the parse succeeds, that is, if the entireid is consumed without syntax error. |
parseFilterID | public static SingleID parseFilterID(String id, int[] pos)(Code) | | Parse a filter ID, that is, an ID of the general form
"[f1] s1-t1/v1", with the filters optional, and the variants optional.
Parameters: id - the id to be parsed Parameters: pos - INPUT-OUTPUT parameter. On input, the position ofthe first character to parse. On output, the position afterthe last character parsed. a SingleID object or null if the parse fails |
parseGlobalFilter | public static UnicodeSet parseGlobalFilter(String id, int[] pos, int dir, int[] withParens, StringBuffer canonID)(Code) | | Parse a global filter of the form "[f]" or "([f])", depending
on 'withParens'.
Parameters: id - the pattern the parse Parameters: pos - INPUT-OUTPUT parameter. On input, the position ofthe first character to parse. On output, the position afterthe last character parsed. Parameters: dir - the direction. Parameters: withParens - INPUT-OUTPUT parameter. On entry, ifwithParens[0] is 0, then parens are disallowed. If it is 1,then parens are requires. If it is -1, then parens areoptional, and the return result will be set to 0 or 1. Parameters: canonID - OUTPUT parameter. The pattern for the filteradded to the canonID, either at the end, if dir is FORWARD, orat the start, if dir is REVERSE. The pattern will be enclosedin parentheses if appropriate, and will be suffixed with anID_DELIM character. May be null. a UnicodeSet object or null. A non-null resultsindicates a successful parse, regardless of whether the filterapplies to the given direction. The caller should discard itif withParens != (dir == REVERSE). |
parseSingleID | public static SingleID parseSingleID(String id, int[] pos, int dir)(Code) | | Parse a single ID, that is, an ID of the general form
"[f1] s1-t1/v1 ([f2] s2-t3/v2)", with the parenthesized element
optional, the filters optional, and the variants optional.
Parameters: id - the id to be parsed Parameters: pos - INPUT-OUTPUT parameter. On input, the position ofthe first character to parse. On output, the position afterthe last character parsed. Parameters: dir - the direction. If the direction is REVERSE then theSingleID is constructed for the reverse direction. a SingleID object or null |
registerSpecialInverse | public static void registerSpecialInverse(String target, String inverseTarget, boolean bidirectional)(Code) | | Register two targets as being inverses of one another. For
example, calling registerSpecialInverse("NFC", "NFD", true) causes
Transliterator to form the following inverse relationships:
NFC => NFD
Any-NFC => Any-NFD
NFD => NFC
Any-NFD => Any-NFC
(Without the special inverse registration, the inverse of NFC
would be NFC-Any.) Note that NFD is shorthand for Any-NFD, but
that the presence or absence of "Any-" is preserved.
The relationship is symmetrical; registering (a, b) is
equivalent to registering (b, a).
The relevant IDs must still be registered separately as
factories or classes.
Only the targets are specified. Special inverses always
have the form Any-Target1 <=> Any-Target2. The target should
have canonical casing (the casing desired to be produced when
an inverse is formed) and should contain no whitespace or other
extraneous characters.
Parameters: target - the target against which to register the inverse Parameters: inverseTarget - the inverse of target, that isAny-target.getInverse() => Any-inverseTarget Parameters: bidirectional - if true, register the reverse relationas well, that is, Any-inverseTarget.getInverse() => Any-target |
|
|