1 /* GENERATED SOURCE. DO NOT MODIFY. */ 2 // © 2016 and later: Unicode, Inc. and others. 3 // License & terms of use: http://www.unicode.org/copyright.html#License 4 /* 5 ******************************************************************************* 6 * Copyright (C) 1996-2005, International Business Machines Corporation and * 7 * others. All Rights Reserved. * 8 ******************************************************************************* 9 */ 10 package ohos.global.icu.text; 11 import java.text.ParsePosition; 12 13 /** 14 * An interface that defines both lookup protocol and parsing of 15 * symbolic names. 16 * 17 * <p>This interface is used by UnicodeSet to resolve $Variable style 18 * references that appear in set patterns. RBBI and Transliteration 19 * both independently implement this interface. 20 * 21 * <p>A symbol table maintains two kinds of mappings. The first is 22 * between symbolic names and their values. For example, if the 23 * variable with the name "start" is set to the value "alpha" 24 * (perhaps, though not necessarily, through an expression such as 25 * "$start=alpha"), then the call lookup("start") will return the 26 * char[] array ['a', 'l', 'p', 'h', 'a']. 27 * 28 * <p>The second kind of mapping is between character values and 29 * UnicodeMatcher objects. This is used by RuleBasedTransliterator, 30 * which uses characters in the private use area to represent objects 31 * such as UnicodeSets. If U+E015 is mapped to the UnicodeSet [a-z], 32 * then lookupMatcher(0xE015) will return the UnicodeSet [a-z]. 33 * 34 * <p>Finally, a symbol table defines parsing behavior for symbolic 35 * names. All symbolic names start with the SYMBOL_REF character. 36 * When a parser encounters this character, it calls parseReference() 37 * with the position immediately following the SYMBOL_REF. The symbol 38 * table parses the name, if there is one, and returns it. 39 */ 40 public interface SymbolTable { 41 42 /** 43 * The character preceding a symbol reference name. 44 */ 45 static final char SYMBOL_REF = '$'; 46 47 /** 48 * Lookup the characters associated with this string and return it. 49 * Return <tt>null</tt> if no such name exists. The resultant 50 * array may have length zero. 51 * @param s the symbolic name to lookup 52 * @return a char array containing the name's value, or null if 53 * there is no mapping for s. 54 */ lookup(String s)55 char[] lookup(String s); 56 57 /** 58 * Lookup the UnicodeMatcher associated with the given character, and 59 * return it. Return <tt>null</tt> if not found. 60 * @param ch a 32-bit code point from 0 to 0x10FFFF inclusive. 61 * @return the UnicodeMatcher object represented by the given 62 * character, or null if there is no mapping for ch. 63 */ lookupMatcher(int ch)64 UnicodeMatcher lookupMatcher(int ch); 65 66 /** 67 * Parse a symbol reference name from the given string, starting 68 * at the given position. If no valid symbol reference name is 69 * found, return null and leave pos unchanged. That is, if the 70 * character at pos cannot start a name, or if pos is at or after 71 * text.length(), then return null. This indicates an isolated 72 * SYMBOL_REF character. 73 * @param text the text to parse for the name 74 * @param pos on entry, the index of the first character to parse. 75 * This is the character following the SYMBOL_REF character. On 76 * exit, the index after the last parsed character. If the parse 77 * failed, pos is unchanged on exit. 78 * @param limit the index after the last character to be parsed. 79 * @return the parsed name, or null if there is no valid symbolic 80 * name at the given position. 81 */ parseReference(String text, ParsePosition pos, int limit)82 String parseReference(String text, ParsePosition pos, int limit); 83 } 84