]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_2_1-src/src/com/ibm/icu/impl/UCharacterProperty.java
icu4jsrc
[Dictionary.git] / jars / icu4j-4_2_1-src / src / com / ibm / icu / impl / UCharacterProperty.java
1 /**\r
2 *******************************************************************************\r
3 * Copyright (C) 1996-2008, International Business Machines Corporation and    *\r
4 * others. All Rights Reserved.                                                *\r
5 *******************************************************************************\r
6 */\r
7 \r
8 package com.ibm.icu.impl;\r
9 \r
10 import java.io.BufferedInputStream;\r
11 import java.io.InputStream;\r
12 import java.io.IOException;\r
13 import java.util.MissingResourceException;\r
14 \r
15 import com.ibm.icu.lang.UCharacter;\r
16 import com.ibm.icu.lang.UCharacterCategory;\r
17 import com.ibm.icu.lang.UProperty;\r
18 import com.ibm.icu.text.Normalizer;\r
19 import com.ibm.icu.text.UnicodeSet;\r
20 import com.ibm.icu.text.UTF16;\r
21 import com.ibm.icu.util.RangeValueIterator;\r
22 import com.ibm.icu.util.VersionInfo;\r
23 \r
24 import com.ibm.icu.impl.NormalizerImpl;\r
25 \r
26 /**\r
27 * <p>Internal class used for Unicode character property database.</p>\r
28 * <p>This classes store binary data read from uprops.icu.\r
29 * It does not have the capability to parse the data into more high-level\r
30 * information. It only returns bytes of information when required.</p>\r
31 * <p>Due to the form most commonly used for retrieval, array of char is used\r
32 * to store the binary data.</p>\r
33 * <p>UCharacterPropertyDB also contains information on accessing indexes to\r
34 * significant points in the binary data.</p>\r
35 * <p>Responsibility for molding the binary data into more meaning form lies on\r
36 * <a href=UCharacter.html>UCharacter</a>.</p>\r
37 * @author Syn Wee Quek\r
38 * @since release 2.1, february 1st 2002\r
39 */\r
40 \r
41 public final class UCharacterProperty\r
42 {\r
43     // public data members -----------------------------------------------\r
44 \r
45     /**\r
46     * Trie data\r
47     */\r
48     public CharTrie m_trie_;\r
49     /**\r
50      * Optimization\r
51      * CharTrie index array\r
52      */\r
53     public char[] m_trieIndex_;\r
54     /**\r
55      * Optimization\r
56      * CharTrie data array\r
57      */\r
58     public char[] m_trieData_;\r
59     /**\r
60      * Optimization\r
61      * CharTrie data offset\r
62      */\r
63     public int m_trieInitialValue_;\r
64     /**\r
65     * Unicode version\r
66     */\r
67     public VersionInfo m_unicodeVersion_;\r
68     /**\r
69     * Latin capital letter i with dot above\r
70     */\r
71     public static final char LATIN_CAPITAL_LETTER_I_WITH_DOT_ABOVE_ = 0x130;\r
72     /**\r
73     * Latin small letter i with dot above\r
74     */\r
75     public static final char LATIN_SMALL_LETTER_DOTLESS_I_ = 0x131;\r
76     /**\r
77     * Latin lowercase i\r
78     */\r
79     public static final char LATIN_SMALL_LETTER_I_ = 0x69;\r
80     /**\r
81     * Character type mask\r
82     */\r
83     public static final int TYPE_MASK = 0x1F;\r
84 \r
85     // uprops.h enum UPropertySource --------------------------------------- ***\r
86 \r
87     /** No source, not a supported property. */\r
88     public static final int SRC_NONE=0;\r
89     /** From uchar.c/uprops.icu main trie */\r
90     public static final int SRC_CHAR=1;\r
91     /** From uchar.c/uprops.icu properties vectors trie */\r
92     public static final int SRC_PROPSVEC=2;\r
93     /** Hangul_Syllable_Type, from uchar.c/uprops.icu */\r
94     public static final int SRC_HST=3;\r
95     /** From unames.c/unames.icu */\r
96     public static final int SRC_NAMES=4;\r
97     /** From unorm.cpp/unorm.icu */\r
98     public static final int SRC_NORM=5;\r
99     /** From ucase.c/ucase.icu */\r
100     public static final int SRC_CASE=6;\r
101     /** From ubidi_props.c/ubidi.icu */\r
102     public static final int SRC_BIDI=7;\r
103     /** From uchar.c/uprops.icu main trie as well as properties vectors trie */\r
104     public static final int SRC_CHAR_AND_PROPSVEC=8;\r
105     /** One more than the highest UPropertySource (SRC_) constant. */\r
106     public static final int SRC_COUNT=9;\r
107 \r
108     // public methods ----------------------------------------------------\r
109 \r
110     /**\r
111      * Java friends implementation\r
112      */\r
113     public void setIndexData(CharTrie.FriendAgent friendagent)\r
114     {\r
115         m_trieIndex_ = friendagent.getPrivateIndex();\r
116         m_trieData_ = friendagent.getPrivateData();\r
117         m_trieInitialValue_ = friendagent.getPrivateInitialValue();\r
118     }\r
119 \r
120     /**\r
121     * Gets the property value at the index.\r
122     * This is optimized.\r
123     * Note this is alittle different from CharTrie the index m_trieData_\r
124     * is never negative.\r
125     * @param ch code point whose property value is to be retrieved\r
126     * @return property value of code point\r
127     */\r
128     public final int getProperty(int ch)\r
129     {\r
130         if (ch < UTF16.LEAD_SURROGATE_MIN_VALUE\r
131             || (ch > UTF16.LEAD_SURROGATE_MAX_VALUE\r
132                 && ch < UTF16.SUPPLEMENTARY_MIN_VALUE)) {\r
133             // BMP codepoint 0000..D7FF or DC00..FFFF\r
134             // optimized\r
135             try { // using try for ch < 0 is faster than using an if statement\r
136                 return m_trieData_[\r
137                     (m_trieIndex_[ch >> Trie.INDEX_STAGE_1_SHIFT_]\r
138                           << Trie.INDEX_STAGE_2_SHIFT_)\r
139                     + (ch & Trie.INDEX_STAGE_3_MASK_)];\r
140             } catch (ArrayIndexOutOfBoundsException e) {\r
141                 return m_trieInitialValue_;\r
142             }\r
143         }\r
144         if (ch <= UTF16.LEAD_SURROGATE_MAX_VALUE) {\r
145             // lead surrogate D800..DBFF\r
146             return m_trieData_[\r
147                     (m_trieIndex_[Trie.LEAD_INDEX_OFFSET_\r
148                                   + (ch >> Trie.INDEX_STAGE_1_SHIFT_)]\r
149                           << Trie.INDEX_STAGE_2_SHIFT_)\r
150                     + (ch & Trie.INDEX_STAGE_3_MASK_)];\r
151         }\r
152         if (ch <= UTF16.CODEPOINT_MAX_VALUE) {\r
153             // supplementary code point 10000..10FFFF\r
154             // look at the construction of supplementary characters\r
155             // trail forms the ends of it.\r
156             return m_trie_.getSurrogateValue(\r
157                                           UTF16.getLeadSurrogate(ch),\r
158                                           (char)(ch & Trie.SURROGATE_MASK_));\r
159         }\r
160         // ch is out of bounds\r
161         // return m_dataOffset_ if there is an error, in this case we return\r
162         // the default value: m_initialValue_\r
163         // we cannot assume that m_initialValue_ is at offset 0\r
164         // this is for optimization.\r
165         return m_trieInitialValue_;\r
166 \r
167         // this all is an inlined form of return m_trie_.getCodePointValue(ch);\r
168     }\r
169 \r
170     /*\r
171     * Getting the signed numeric value of a character embedded in the property\r
172     * argument\r
173     * @param prop the character\r
174     * @return signed numberic value\r
175     */\r
176 //    public static int getSignedValue(int prop)\r
177 //    {\r
178 //        return ((short)prop >> VALUE_SHIFT_);\r
179 //    }\r
180 \r
181     /**\r
182     * Getting the unsigned numeric value of a character embedded in the property\r
183     * argument\r
184     * @param prop the character\r
185     * @return unsigned numberic value\r
186     */\r
187     public static int getUnsignedValue(int prop)\r
188     {\r
189         return (prop >> VALUE_SHIFT_) & UNSIGNED_VALUE_MASK_AFTER_SHIFT_;\r
190     }\r
191 \r
192     /* internal numeric pseudo-types for special encodings of numeric values */\r
193     public static final int NT_FRACTION=4; /* ==UCharacter.NumericType.COUNT, must not change unless binary format version changes */\r
194     public static final int NT_LARGE=5;\r
195     public static final int NT_COUNT=6;\r
196 \r
197     /**\r
198      * Gets the unicode additional properties.\r
199      * C version getUnicodeProperties.\r
200      * @param codepoint codepoint whose additional properties is to be\r
201      *                  retrieved\r
202      * @param column\r
203      * @return unicode properties\r
204      */\r
205        public int getAdditional(int codepoint, int column) {\r
206         if (column == -1) {\r
207             return getProperty(codepoint);\r
208         }\r
209            if (column < 0 || column >= m_additionalColumnsCount_) {\r
210            return 0;\r
211        }\r
212        return m_additionalVectors_[\r
213                      m_additionalTrie_.getCodePointValue(codepoint) + column];\r
214        }\r
215 \r
216     static final int MY_MASK = UCharacterProperty.TYPE_MASK\r
217         & ((1<<UCharacterCategory.UPPERCASE_LETTER) |\r
218             (1<<UCharacterCategory.LOWERCASE_LETTER) |\r
219             (1<<UCharacterCategory.TITLECASE_LETTER) |\r
220             (1<<UCharacterCategory.MODIFIER_LETTER) |\r
221             (1<<UCharacterCategory.OTHER_LETTER));\r
222 \r
223 \r
224        /**\r
225      * <p>Get the "age" of the code point.</p>\r
226      * <p>The "age" is the Unicode version when the code point was first\r
227      * designated (as a non-character or for Private Use) or assigned a\r
228      * character.</p>\r
229      * <p>This can be useful to avoid emitting code points to receiving\r
230      * processes that do not accept newer characters.</p>\r
231      * <p>The data is from the UCD file DerivedAge.txt.</p>\r
232      * <p>This API does not check the validity of the codepoint.</p>\r
233      * @param codepoint The code point.\r
234      * @return the Unicode version number\r
235      */\r
236     public VersionInfo getAge(int codepoint)\r
237     {\r
238         int version = getAdditional(codepoint, 0) >> AGE_SHIFT_;\r
239         return VersionInfo.getInstance(\r
240                            (version >> FIRST_NIBBLE_SHIFT_) & LAST_NIBBLE_MASK_,\r
241                            version & LAST_NIBBLE_MASK_, 0, 0);\r
242     }\r
243 \r
244     private static final long UNSIGNED_INT_MASK = 0xffffffffL;\r
245 \r
246     private static final int GC_CN_MASK = getMask(UCharacter.UNASSIGNED);\r
247     private static final int GC_CC_MASK = getMask(UCharacter.CONTROL);\r
248     private static final int GC_CS_MASK = getMask(UCharacter.SURROGATE);\r
249     private static final int GC_ZS_MASK = getMask(UCharacter.SPACE_SEPARATOR);\r
250     private static final int GC_ZL_MASK = getMask(UCharacter.LINE_SEPARATOR);\r
251     private static final int GC_ZP_MASK = getMask(UCharacter.PARAGRAPH_SEPARATOR);\r
252     /** Mask constant for multiple UCharCategory bits (Z Separators). */\r
253     private static final int GC_Z_MASK = GC_ZS_MASK|GC_ZL_MASK|GC_ZP_MASK;\r
254 \r
255     /**\r
256      * Checks if c is in\r
257      * [^\p{space}\p{gc=Control}\p{gc=Surrogate}\p{gc=Unassigned}]\r
258      * with space=\p{Whitespace} and Control=Cc.\r
259      * Implements UCHAR_POSIX_GRAPH.\r
260      * @internal\r
261      */\r
262     private static final boolean isgraphPOSIX(int c) {\r
263         /* \p{space}\p{gc=Control} == \p{gc=Z}\p{Control} */\r
264         /* comparing ==0 returns FALSE for the categories mentioned */\r
265         return (getMask(UCharacter.getType(c))&\r
266                 (GC_CC_MASK|GC_CS_MASK|GC_CN_MASK|GC_Z_MASK))\r
267                ==0;\r
268     }\r
269 \r
270     private static final class BinaryProperties{\r
271        int column;\r
272        long mask;\r
273        public BinaryProperties(int column,long mask){\r
274                this.column = column;\r
275                this.mask  = mask;\r
276        }\r
277    }\r
278    BinaryProperties[] binProps={\r
279        /*\r
280         * column and mask values for binary properties from u_getUnicodeProperties().\r
281         * Must be in order of corresponding UProperty,\r
282         * and there must be exacly one entry per binary UProperty.\r
283         */\r
284        new BinaryProperties(  1,                (  1 << ALPHABETIC_PROPERTY_) ),\r
285        new BinaryProperties(  1,                (  1 << ASCII_HEX_DIGIT_PROPERTY_) ),\r
286        new BinaryProperties( SRC_BIDI,   0 ),                                       /* UCHAR_BIDI_CONTROL */\r
287        new BinaryProperties( SRC_BIDI,   0 ),                                       /* UCHAR_BIDI_MIRRORED */\r
288        new BinaryProperties(  1,                (  1 << DASH_PROPERTY_) ),\r
289        new BinaryProperties(  1,                (  1 << DEFAULT_IGNORABLE_CODE_POINT_PROPERTY_) ),\r
290        new BinaryProperties(  1,                (  1 << DEPRECATED_PROPERTY_) ),\r
291        new BinaryProperties(  1,                (  1 << DIACRITIC_PROPERTY_) ),\r
292        new BinaryProperties(  1,                (  1 << EXTENDER_PROPERTY_) ),\r
293        new BinaryProperties( SRC_NORM,   0 ),                                       /* UCHAR_FULL_COMPOSITION_EXCLUSION */\r
294        new BinaryProperties(  1,                (  1 << GRAPHEME_BASE_PROPERTY_) ),\r
295        new BinaryProperties(  1,                (  1 << GRAPHEME_EXTEND_PROPERTY_) ),\r
296        new BinaryProperties(  1,                (  1 << GRAPHEME_LINK_PROPERTY_) ),\r
297        new BinaryProperties(  1,                (  1 << HEX_DIGIT_PROPERTY_) ),\r
298        new BinaryProperties(  1,                (  1 << HYPHEN_PROPERTY_) ),\r
299        new BinaryProperties(  1,                (  1 << ID_CONTINUE_PROPERTY_) ),\r
300        new BinaryProperties(  1,                (  1 << ID_START_PROPERTY_) ),\r
301        new BinaryProperties(  1,                (  1 << IDEOGRAPHIC_PROPERTY_) ),\r
302        new BinaryProperties(  1,                (  1 << IDS_BINARY_OPERATOR_PROPERTY_) ),\r
303        new BinaryProperties(  1,                (  1 << IDS_TRINARY_OPERATOR_PROPERTY_) ),\r
304        new BinaryProperties( SRC_BIDI,   0 ),                                       /* UCHAR_JOIN_CONTROL */\r
305        new BinaryProperties(  1,                (  1 << LOGICAL_ORDER_EXCEPTION_PROPERTY_) ),\r
306        new BinaryProperties( SRC_CASE,   0 ),                                       /* UCHAR_LOWERCASE */\r
307        new BinaryProperties(  1,                (  1 << MATH_PROPERTY_) ),\r
308        new BinaryProperties(  1,                (  1 << NONCHARACTER_CODE_POINT_PROPERTY_) ),\r
309        new BinaryProperties(  1,                (  1 << QUOTATION_MARK_PROPERTY_) ),\r
310        new BinaryProperties(  1,                (  1 << RADICAL_PROPERTY_) ),\r
311        new BinaryProperties( SRC_CASE,   0 ),                                       /* UCHAR_SOFT_DOTTED */\r
312        new BinaryProperties(  1,                (  1 << TERMINAL_PUNCTUATION_PROPERTY_) ),\r
313        new BinaryProperties(  1,                (  1 << UNIFIED_IDEOGRAPH_PROPERTY_) ),\r
314        new BinaryProperties( SRC_CASE,   0 ),                                       /* UCHAR_UPPERCASE */\r
315        new BinaryProperties(  1,                (  1 << WHITE_SPACE_PROPERTY_) ),\r
316        new BinaryProperties(  1,                (  1 << XID_CONTINUE_PROPERTY_) ),\r
317        new BinaryProperties(  1,                (  1 << XID_START_PROPERTY_) ),\r
318        new BinaryProperties( SRC_CASE,   0 ),                                       /* UCHAR_CASE_SENSITIVE */\r
319        new BinaryProperties(  1,                (  1 << S_TERM_PROPERTY_) ),\r
320        new BinaryProperties(  1,                (  1 << VARIATION_SELECTOR_PROPERTY_) ),\r
321        new BinaryProperties( SRC_NORM,   0 ),                                       /* UCHAR_NFD_INERT */\r
322        new BinaryProperties( SRC_NORM,   0 ),                                       /* UCHAR_NFKD_INERT */\r
323        new BinaryProperties( SRC_NORM,   0 ),                                       /* UCHAR_NFC_INERT */\r
324        new BinaryProperties( SRC_NORM,   0 ),                                       /* UCHAR_NFKC_INERT */\r
325        new BinaryProperties( SRC_NORM,   0 ),                                       /* UCHAR_SEGMENT_STARTER */\r
326        new BinaryProperties(  1,                (  1 << PATTERN_SYNTAX) ),\r
327        new BinaryProperties(  1,                (  1 << PATTERN_WHITE_SPACE) ),\r
328        new BinaryProperties( SRC_CHAR_AND_PROPSVEC,  0 ),                           /* UCHAR_POSIX_ALNUM */\r
329        new BinaryProperties( SRC_CHAR,  0 ),                                        /* UCHAR_POSIX_BLANK */\r
330        new BinaryProperties( SRC_CHAR,  0 ),                                        /* UCHAR_POSIX_GRAPH */\r
331        new BinaryProperties( SRC_CHAR,  0 ),                                        /* UCHAR_POSIX_PRINT */\r
332        new BinaryProperties( SRC_CHAR,  0 )                                         /* UCHAR_POSIX_XDIGIT */\r
333    };\r
334 \r
335 \r
336     /**\r
337      * <p>Check a binary Unicode property for a code point.</p>\r
338      * <p>Unicode, especially in version 3.2, defines many more properties\r
339      * than the original set in UnicodeData.txt.</p>\r
340      * <p>This API is intended to reflect Unicode properties as defined in\r
341      * the Unicode Character Database (UCD) and Unicode Technical Reports\r
342      * (UTR).</p>\r
343      * <p>For details about the properties see\r
344      * <a href=http://www.unicode.org/>http://www.unicode.org/</a>.</p>\r
345      * <p>For names of Unicode properties see the UCD file\r
346      * PropertyAliases.txt.</p>\r
347      * <p>This API does not check the validity of the codepoint.</p>\r
348      * <p>Important: If ICU is built with UCD files from Unicode versions\r
349      * below 3.2, then properties marked with "new" are not or\r
350      * not fully available.</p>\r
351      * @param codepoint Code point to test.\r
352      * @param property selector constant from com.ibm.icu.lang.UProperty,\r
353      *        identifies which binary property to check.\r
354      * @return true or false according to the binary Unicode property value\r
355      *         for ch. Also false if property is out of bounds or if the\r
356      *         Unicode version does not have data for the property at all, or\r
357      *         not for this code point.\r
358      * @see com.ibm.icu.lang.UProperty\r
359      */\r
360 \r
361     public boolean hasBinaryProperty(int codepoint, int property)\r
362     {\r
363          if(property <UProperty.BINARY_START || UProperty.BINARY_LIMIT<=property) {\r
364             // not a known binary property\r
365             return false;\r
366         } else {\r
367             long mask=binProps[property].mask;\r
368             int column=binProps[property].column;\r
369             if(mask!=0) {\r
370                 // systematic, directly stored properties\r
371                 return ((UNSIGNED_INT_MASK & getAdditional(codepoint, column)) & mask)!=0;\r
372             } else {\r
373                 if(column==SRC_CASE) {\r
374                     /* case mapping properties */\r
375                     UCaseProps csp;\r
376                     try {\r
377                         csp = UCaseProps.getSingleton();\r
378                     } catch (IOException e) {\r
379                         return false;\r
380                     }\r
381                     switch(property) {\r
382                     case UProperty.LOWERCASE:\r
383                         return UCaseProps.LOWER==csp.getType(codepoint);\r
384                     case UProperty.UPPERCASE:\r
385                         return UCaseProps.UPPER==csp.getType(codepoint);\r
386                     case UProperty.SOFT_DOTTED:\r
387                         return csp.isSoftDotted(codepoint);\r
388                     case UProperty.CASE_SENSITIVE:\r
389                         return csp.isCaseSensitive(codepoint);\r
390                     default:\r
391                         break;\r
392                     }\r
393                 } else if(column==SRC_NORM) {\r
394                     /* normalization properties from unorm.icu */\r
395                     switch(property) {\r
396                     case UProperty.FULL_COMPOSITION_EXCLUSION:\r
397                         return NormalizerImpl.isFullCompositionExclusion(codepoint);\r
398                     case UProperty.NFD_INERT:\r
399                         return Normalizer.isNFSkippable(codepoint, Normalizer.NFD);\r
400                     case UProperty.NFKD_INERT:\r
401                         return Normalizer.isNFSkippable(codepoint, Normalizer.NFKD);\r
402                     case UProperty.NFC_INERT:\r
403                         return Normalizer.isNFSkippable(codepoint, Normalizer.NFC);\r
404                     case UProperty.NFKC_INERT:\r
405                         return Normalizer.isNFSkippable(codepoint, Normalizer.NFKC);\r
406                     case UProperty.SEGMENT_STARTER:\r
407                         return NormalizerImpl.isCanonSafeStart(codepoint);\r
408                     default:\r
409                         break;\r
410                     }\r
411                 } else if(column==SRC_BIDI) {\r
412                     /* bidi/shaping properties */\r
413                     UBiDiProps bdp;\r
414                     try {\r
415                         bdp = UBiDiProps.getSingleton();\r
416                     } catch (IOException e) {\r
417                         return false;\r
418                     }\r
419                     switch(property) {\r
420                     case UProperty.BIDI_MIRRORED:\r
421                         return bdp.isMirrored(codepoint);\r
422                     case UProperty.BIDI_CONTROL:\r
423                         return bdp.isBidiControl(codepoint);\r
424                     case UProperty.JOIN_CONTROL:\r
425                         return bdp.isJoinControl(codepoint);\r
426                     default:\r
427                         break;\r
428                     }\r
429                 } else if(column==SRC_CHAR) {\r
430                     switch(property) {\r
431                     case UProperty.POSIX_BLANK:\r
432                         // "horizontal space"\r
433                         if(codepoint<=0x9f) {\r
434                             return codepoint==9 || codepoint==0x20; /* TAB or SPACE */\r
435                         } else {\r
436                             /* Zs */\r
437                             return UCharacter.getType(codepoint)==UCharacter.SPACE_SEPARATOR;\r
438                         }\r
439                     case UProperty.POSIX_GRAPH:\r
440                         return isgraphPOSIX(codepoint);\r
441                     case UProperty.POSIX_PRINT:\r
442                         /*\r
443                          * Checks if codepoint is in \p{graph}\p{blank} - \p{cntrl}.\r
444                          *\r
445                          * The only cntrl character in graph+blank is TAB (in blank).\r
446                          * Here we implement (blank-TAB)=Zs instead of calling u_isblank().\r
447                          */\r
448                         return (UCharacter.getType(codepoint)==UCharacter.SPACE_SEPARATOR) || isgraphPOSIX(codepoint);\r
449                     case UProperty.POSIX_XDIGIT:\r
450                         /* check ASCII and Fullwidth ASCII a-fA-F */\r
451                         if(\r
452                             (codepoint<=0x66 && codepoint>=0x41 && (codepoint<=0x46 || codepoint>=0x61)) ||\r
453                             (codepoint>=0xff21 && codepoint<=0xff46 && (codepoint<=0xff26 || codepoint>=0xff41))\r
454                         ) {\r
455                             return true;\r
456                         }\r
457     \r
458                         return UCharacter.getType(codepoint)==UCharacter.DECIMAL_DIGIT_NUMBER;\r
459                     default:\r
460                         break;\r
461                     }\r
462                 } else if(column==SRC_CHAR_AND_PROPSVEC) {\r
463                     switch(property) {\r
464                     case UProperty.POSIX_ALNUM:\r
465                         return UCharacter.isUAlphabetic(codepoint) || UCharacter.isDigit(codepoint);\r
466                     default:\r
467                         break;\r
468                     }\r
469                 }\r
470             }\r
471         }\r
472         return false;\r
473     }\r
474 \r
475     public final int getSource(int which) {\r
476         if(which<UProperty.BINARY_START) {\r
477             return SRC_NONE; /* undefined */\r
478         } else if(which<UProperty.BINARY_LIMIT) {\r
479             if(binProps[which].mask!=0) {\r
480                 return SRC_PROPSVEC;\r
481             } else {\r
482                 return binProps[which].column;\r
483             }\r
484         } else if(which<UProperty.INT_START) {\r
485             return SRC_NONE; /* undefined */\r
486         } else if(which<UProperty.INT_LIMIT) {\r
487             switch(which) {\r
488             case UProperty.GENERAL_CATEGORY:\r
489             case UProperty.NUMERIC_TYPE:\r
490                 return SRC_CHAR;\r
491 \r
492             case UProperty.HANGUL_SYLLABLE_TYPE:\r
493                 return SRC_HST;\r
494 \r
495             case UProperty.CANONICAL_COMBINING_CLASS:\r
496             case UProperty.NFD_QUICK_CHECK:\r
497             case UProperty.NFKD_QUICK_CHECK:\r
498             case UProperty.NFC_QUICK_CHECK:\r
499             case UProperty.NFKC_QUICK_CHECK:\r
500             case UProperty.LEAD_CANONICAL_COMBINING_CLASS:\r
501             case UProperty.TRAIL_CANONICAL_COMBINING_CLASS:\r
502                 return SRC_NORM;\r
503 \r
504             case UProperty.BIDI_CLASS:\r
505             case UProperty.JOINING_GROUP:\r
506             case UProperty.JOINING_TYPE:\r
507                 return SRC_BIDI;\r
508 \r
509             default:\r
510                 return SRC_PROPSVEC;\r
511             }\r
512         } else if(which<UProperty.STRING_START) {\r
513             switch(which) {\r
514             case UProperty.GENERAL_CATEGORY_MASK:\r
515             case UProperty.NUMERIC_VALUE:\r
516                 return SRC_CHAR;\r
517 \r
518             default:\r
519                 return SRC_NONE;\r
520             }\r
521         } else if(which<UProperty.STRING_LIMIT) {\r
522             switch(which) {\r
523             case UProperty.AGE:\r
524                 return SRC_PROPSVEC;\r
525 \r
526             case UProperty.BIDI_MIRRORING_GLYPH:\r
527                 return SRC_BIDI;\r
528 \r
529             case UProperty.CASE_FOLDING:\r
530             case UProperty.LOWERCASE_MAPPING:\r
531             case UProperty.SIMPLE_CASE_FOLDING:\r
532             case UProperty.SIMPLE_LOWERCASE_MAPPING:\r
533             case UProperty.SIMPLE_TITLECASE_MAPPING:\r
534             case UProperty.SIMPLE_UPPERCASE_MAPPING:\r
535             case UProperty.TITLECASE_MAPPING:\r
536             case UProperty.UPPERCASE_MAPPING:\r
537                 return SRC_CASE;\r
538 \r
539             case UProperty.ISO_COMMENT:\r
540             case UProperty.NAME:\r
541             case UProperty.UNICODE_1_NAME:\r
542                 return SRC_NAMES;\r
543 \r
544             default:\r
545                 return SRC_NONE;\r
546             }\r
547         } else {\r
548             return SRC_NONE; /* undefined */\r
549         }\r
550     }\r
551 \r
552     /**\r
553     * Forms a supplementary code point from the argument character<br>\r
554     * Note this is for internal use hence no checks for the validity of the\r
555     * surrogate characters are done\r
556     * @param lead lead surrogate character\r
557     * @param trail trailing surrogate character\r
558     * @return code point of the supplementary character\r
559     */\r
560     public static int getRawSupplementary(char lead, char trail)\r
561     {\r
562         return (lead << LEAD_SURROGATE_SHIFT_) + trail + SURROGATE_OFFSET_;\r
563     }\r
564 \r
565     /**\r
566     * Loads the property data and initialize the UCharacterProperty instance.\r
567     * @throws MissingResourceException when data is missing or data has been corrupted\r
568     */\r
569     public static UCharacterProperty getInstance()\r
570     {\r
571         if(INSTANCE_ == null) {\r
572             try {\r
573                 INSTANCE_ = new UCharacterProperty();\r
574             }\r
575             catch (Exception e) {\r
576                 throw new MissingResourceException(e.getMessage(),"","");\r
577             }\r
578         }\r
579         return INSTANCE_;\r
580     }\r
581 \r
582     /**\r
583      * <p>\r
584      * Unicode property names and property value names are compared\r
585      * "loosely". Property[Value]Aliases.txt say:\r
586      * <quote>\r
587      *   "With loose matching of property names, the case distinctions,\r
588      *    whitespace, and '_' are ignored."\r
589      * </quote>\r
590      * </p>\r
591      * <p>\r
592      * This function does just that, for ASCII (char *) name strings.\r
593      * It is almost identical to ucnv_compareNames() but also ignores\r
594      * ASCII White_Space characters (U+0009..U+000d).\r
595      * </p>\r
596      * @param name1 name to compare\r
597      * @param name2 name to compare\r
598      * @return 0 if names are equal, < 0 if name1 is less than name2 and > 0\r
599      *         if name1 is greater than name2.\r
600      */\r
601     /* to be implemented in 2.4\r
602      * public static int comparePropertyNames(String name1, String name2)\r
603     {\r
604         int result = 0;\r
605         int i1 = 0;\r
606         int i2 = 0;\r
607         while (true) {\r
608             char ch1 = 0;\r
609             char ch2 = 0;\r
610             // Ignore delimiters '-', '_', and ASCII White_Space\r
611             if (i1 < name1.length()) {\r
612                 ch1 = name1.charAt(i1 ++);\r
613             }\r
614             while (ch1 == '-' || ch1 == '_' || ch1 == ' ' || ch1 == '\t'\r
615                    || ch1 == '\n' // synwee what is || ch1 == '\v'\r
616                    || ch1 == '\f' || ch1=='\r') {\r
617                 if (i1 < name1.length()) {\r
618                     ch1 = name1.charAt(i1 ++);\r
619                 }\r
620                 else {\r
621                     ch1 = 0;\r
622                 }\r
623             }\r
624             if (i2 < name2.length()) {\r
625                 ch2 = name2.charAt(i2 ++);\r
626             }\r
627             while (ch2 == '-' || ch2 == '_' || ch2 == ' ' || ch2 == '\t'\r
628                    || ch2 == '\n' // synwee what is || ch1 == '\v'\r
629                    || ch2 == '\f' || ch2=='\r') {\r
630                 if (i2 < name2.length()) {\r
631                     ch2 = name2.charAt(i2 ++);\r
632                 }\r
633                 else {\r
634                     ch2 = 0;\r
635                 }\r
636             }\r
637 \r
638             // If we reach the ends of both strings then they match\r
639             if (ch1 == 0 && ch2 == 0) {\r
640                 return 0;\r
641             }\r
642 \r
643             // Case-insensitive comparison\r
644             if (ch1 != ch2) {\r
645                 result = Character.toLowerCase(ch1)\r
646                                                 - Character.toLowerCase(ch2);\r
647                 if (result != 0) {\r
648                     return result;\r
649                 }\r
650             }\r
651         }\r
652     }\r
653     */\r
654 \r
655     /**\r
656      * Checks if the argument c is to be treated as a white space in ICU\r
657      * rules. Usually ICU rule white spaces are ignored unless quoted.\r
658      * Equivalent to test for Pattern_White_Space Unicode property.\r
659      * Stable set of characters, won't change.\r
660      * See UAX #31 Identifier and Pattern Syntax: http://www.unicode.org/reports/tr31/\r
661      * @param c codepoint to check\r
662      * @return true if c is a ICU white space\r
663      */\r
664     public static boolean isRuleWhiteSpace(int c)\r
665     {\r
666         /* "white space" in the sense of ICU rule parsers\r
667            This is a FIXED LIST that is NOT DEPENDENT ON UNICODE PROPERTIES.\r
668            See UAX #31 Identifier and Pattern Syntax: http://www.unicode.org/reports/tr31/\r
669            U+0009..U+000D, U+0020, U+0085, U+200E..U+200F, and U+2028..U+2029\r
670            Equivalent to test for Pattern_White_Space Unicode property.\r
671         */\r
672         return (c >= 0x0009 && c <= 0x2029 &&\r
673                 (c <= 0x000D || c == 0x0020 || c == 0x0085 ||\r
674                  c == 0x200E || c == 0x200F || c >= 0x2028));\r
675     }\r
676 \r
677     /**\r
678      * Get the the maximum values for some enum/int properties.\r
679      * @return maximum values for the integer properties.\r
680      */\r
681     public int getMaxValues(int column)\r
682     {\r
683        // return m_maxBlockScriptValue_;\r
684 \r
685         switch(column) {\r
686         case 0:\r
687             return m_maxBlockScriptValue_;\r
688         case 2:\r
689             return m_maxJTGValue_;\r
690         default:\r
691             return 0;\r
692         }\r
693     }\r
694 \r
695     /**\r
696      * Gets the type mask\r
697      * @param type character type\r
698      * @return mask\r
699      */\r
700     public static final int getMask(int type)\r
701     {\r
702         return 1 << type;\r
703     }\r
704 \r
705     // protected variables -----------------------------------------------\r
706 \r
707     /**\r
708      * Extra property trie\r
709      */\r
710     CharTrie m_additionalTrie_;\r
711     /**\r
712      * Extra property vectors, 1st column for age and second for binary\r
713      * properties.\r
714      */\r
715     int m_additionalVectors_[];\r
716     /**\r
717      * Number of additional columns\r
718      */\r
719     int m_additionalColumnsCount_;\r
720     /**\r
721      * Maximum values for block, bits used as in vector word\r
722      * 0\r
723      */\r
724     int m_maxBlockScriptValue_;\r
725     /**\r
726      * Maximum values for script, bits used as in vector word\r
727      * 0\r
728      */\r
729      int m_maxJTGValue_;\r
730     // private variables -------------------------------------------------\r
731 \r
732       /**\r
733      * UnicodeData.txt property object\r
734      */\r
735     private static UCharacterProperty INSTANCE_ = null;\r
736 \r
737     /**\r
738     * Default name of the datafile\r
739     */\r
740     private static final String DATA_FILE_NAME_ = ICUResourceBundle.ICU_BUNDLE+"/uprops.icu";\r
741 \r
742     /**\r
743     * Default buffer size of datafile\r
744     */\r
745     private static final int DATA_BUFFER_SIZE_ = 25000;\r
746 \r
747     /**\r
748     * Numeric value shift\r
749     */\r
750     private static final int VALUE_SHIFT_ = 8;\r
751 \r
752     /**\r
753     * Mask to be applied after shifting to obtain an unsigned numeric value\r
754     */\r
755     private static final int UNSIGNED_VALUE_MASK_AFTER_SHIFT_ = 0xFF;\r
756 \r
757     /*\r
758      *\r
759      */\r
760     //private static final int NUMERIC_TYPE_SHIFT = 5;\r
761 \r
762     /*\r
763     * To get the last 5 bits out from a data type\r
764     */\r
765     //private static final int LAST_5_BIT_MASK_ = 0x1F;\r
766 \r
767     /**\r
768     * Shift value for lead surrogate to form a supplementary character.\r
769     */\r
770     private static final int LEAD_SURROGATE_SHIFT_ = 10;\r
771     /**\r
772     * Offset to add to combined surrogate pair to avoid msking.\r
773     */\r
774     private static final int SURROGATE_OFFSET_ =\r
775                            UTF16.SUPPLEMENTARY_MIN_VALUE -\r
776                            (UTF16.SURROGATE_MIN_VALUE <<\r
777                            LEAD_SURROGATE_SHIFT_) -\r
778                            UTF16.TRAIL_SURROGATE_MIN_VALUE;\r
779 \r
780 \r
781     // additional properties ----------------------------------------------\r
782 \r
783     /**\r
784      * Additional properties used in internal trie data\r
785      */\r
786     /*\r
787      * Properties in vector word 1\r
788      * Each bit encodes one binary property.\r
789      * The following constants represent the bit number, use 1<<UPROPS_XYZ.\r
790      * UPROPS_BINARY_1_TOP<=32!\r
791      *\r
792      * Keep this list of property enums in sync with\r
793      * propListNames[] in icu/source/tools/genprops/props2.c!\r
794      *\r
795      * ICU 2.6/uprops format version 3.2 stores full properties instead of "Other_".\r
796      */\r
797     private static final int WHITE_SPACE_PROPERTY_ = 0;\r
798     private static final int DASH_PROPERTY_ = 1;\r
799     private static final int HYPHEN_PROPERTY_ = 2;\r
800     private static final int QUOTATION_MARK_PROPERTY_ = 3;\r
801     private static final int TERMINAL_PUNCTUATION_PROPERTY_ = 4;\r
802     private static final int MATH_PROPERTY_ = 5;\r
803     private static final int HEX_DIGIT_PROPERTY_ = 6;\r
804     private static final int ASCII_HEX_DIGIT_PROPERTY_ = 7;\r
805     private static final int ALPHABETIC_PROPERTY_ = 8;\r
806     private static final int IDEOGRAPHIC_PROPERTY_ = 9;\r
807     private static final int DIACRITIC_PROPERTY_ = 10;\r
808     private static final int EXTENDER_PROPERTY_ = 11;\r
809     private static final int NONCHARACTER_CODE_POINT_PROPERTY_ = 12;\r
810     private static final int GRAPHEME_EXTEND_PROPERTY_ = 13;\r
811     private static final int GRAPHEME_LINK_PROPERTY_ = 14;\r
812     private static final int IDS_BINARY_OPERATOR_PROPERTY_ = 15;\r
813     private static final int IDS_TRINARY_OPERATOR_PROPERTY_ = 16;\r
814     private static final int RADICAL_PROPERTY_ = 17;\r
815     private static final int UNIFIED_IDEOGRAPH_PROPERTY_ = 18;\r
816     private static final int DEFAULT_IGNORABLE_CODE_POINT_PROPERTY_ = 19;\r
817     private static final int DEPRECATED_PROPERTY_ = 20;\r
818     private static final int LOGICAL_ORDER_EXCEPTION_PROPERTY_ = 21;\r
819     private static final int XID_START_PROPERTY_ = 22;\r
820     private static final int XID_CONTINUE_PROPERTY_ = 23;\r
821     private static final int ID_START_PROPERTY_    = 24;\r
822     private static final int ID_CONTINUE_PROPERTY_ = 25;\r
823     private static final int GRAPHEME_BASE_PROPERTY_ = 26;\r
824     private static final int S_TERM_PROPERTY_ = 27;\r
825     private static final int VARIATION_SELECTOR_PROPERTY_ = 28;\r
826     private static final int PATTERN_SYNTAX = 29;                   /* new in ICU 3.4 and Unicode 4.1 */\r
827     private static final int PATTERN_WHITE_SPACE = 30;\r
828 \r
829     /**\r
830      * First nibble shift\r
831      */\r
832     private static final int FIRST_NIBBLE_SHIFT_ = 0x4;\r
833     /**\r
834      * Second nibble mask\r
835      */\r
836     private static final int LAST_NIBBLE_MASK_ = 0xF;\r
837     /**\r
838      * Age value shift\r
839      */\r
840     private static final int AGE_SHIFT_ = 24;\r
841 \r
842 \r
843     // private constructors --------------------------------------------------\r
844 \r
845     /**\r
846     * Constructor\r
847     * @exception IOException thrown when data reading fails or data corrupted\r
848     */\r
849     private UCharacterProperty() throws IOException\r
850     {\r
851         // jar access\r
852         InputStream is = ICUData.getRequiredStream(DATA_FILE_NAME_);\r
853         BufferedInputStream b = new BufferedInputStream(is, DATA_BUFFER_SIZE_);\r
854         UCharacterPropertyReader reader = new UCharacterPropertyReader(b);\r
855         reader.read(this);\r
856         b.close();\r
857 \r
858         m_trie_.putIndexData(this);\r
859     }\r
860 \r
861     // private methods -------------------------------------------------------\r
862 \r
863     /*\r
864      * Compare additional properties to see if it has argument type\r
865      * @param property 32 bit properties\r
866      * @param type character type\r
867      * @return true if property has type\r
868      */\r
869     /*private boolean compareAdditionalType(int property, int type)\r
870     {\r
871         return (property & (1 << type)) != 0;\r
872     }*/\r
873 \r
874     // property starts for UnicodeSet -------------------------------------- ***\r
875 \r
876     private static final int TAB     = 0x0009;\r
877     //private static final int LF      = 0x000a;\r
878     //private static final int FF      = 0x000c;\r
879     private static final int CR      = 0x000d;\r
880     private static final int U_A     = 0x0041;\r
881     private static final int U_F     = 0x0046;\r
882     private static final int U_Z     = 0x005a;\r
883     private static final int U_a     = 0x0061;\r
884     private static final int U_f     = 0x0066;\r
885     private static final int U_z     = 0x007a;\r
886     private static final int DEL     = 0x007f;\r
887     private static final int NL      = 0x0085;\r
888     private static final int NBSP    = 0x00a0;\r
889     private static final int CGJ     = 0x034f;\r
890     private static final int FIGURESP= 0x2007;\r
891     private static final int HAIRSP  = 0x200a;\r
892     //private static final int ZWNJ    = 0x200c;\r
893     //private static final int ZWJ     = 0x200d;\r
894     private static final int RLM     = 0x200f;\r
895     private static final int NNBSP   = 0x202f;\r
896     private static final int WJ      = 0x2060;\r
897     private static final int INHSWAP = 0x206a;\r
898     private static final int NOMDIG  = 0x206f;\r
899     private static final int U_FW_A  = 0xff21;\r
900     private static final int U_FW_F  = 0xff26;\r
901     private static final int U_FW_Z  = 0xff3a;\r
902     private static final int U_FW_a  = 0xff41;\r
903     private static final int U_FW_f  = 0xff46;\r
904     private static final int U_FW_z  = 0xff5a;\r
905     private static final int ZWNBSP  = 0xfeff;\r
906 \r
907     /* for Hangul_Syllable_Type */\r
908     public void uhst_addPropertyStarts(UnicodeSet set) {\r
909         /* add code points with hardcoded properties, plus the ones following them */\r
910 \r
911         /*\r
912          * Add Jamo type boundaries for UCHAR_HANGUL_SYLLABLE_TYPE.\r
913          * First, we add fixed boundaries for the blocks of Jamos.\r
914          * Then we check in loops to see where the current Unicode version\r
915          * actually stops assigning such Jamos. We start each loop\r
916          * at the end of the per-Jamo-block assignments in Unicode 4 or earlier.\r
917          * (These have not changed since Unicode 2.)\r
918          */\r
919         int c, value, value2;\r
920 \r
921         set.add(0x1100);\r
922         value=UCharacter.HangulSyllableType.LEADING_JAMO;\r
923         for(c=0x115a; c<=0x115f; ++c) {\r
924             value2= UCharacter.getIntPropertyValue(c, UProperty.HANGUL_SYLLABLE_TYPE);\r
925             if(value!=value2) {\r
926                 value=value2;\r
927                 set.add(c);\r
928             }\r
929         }\r
930 \r
931         set.add(0x1160);\r
932         value=UCharacter.HangulSyllableType.VOWEL_JAMO;\r
933         for(c=0x11a3; c<=0x11a7; ++c) {\r
934             value2=UCharacter.getIntPropertyValue(c, UProperty.HANGUL_SYLLABLE_TYPE);\r
935             if(value!=value2) {\r
936                 value=value2;\r
937                 set.add(c);\r
938             }\r
939         }\r
940 \r
941         set.add(0x11a8);\r
942         value=UCharacter.HangulSyllableType.TRAILING_JAMO;\r
943         for(c=0x11fa; c<=0x11ff; ++c) {\r
944             value2=UCharacter.getIntPropertyValue(c, UProperty.HANGUL_SYLLABLE_TYPE);\r
945             if(value!=value2) {\r
946                 value=value2;\r
947                 set.add(c);\r
948             }\r
949         }\r
950 \r
951         /* Add Hangul type boundaries for UCHAR_HANGUL_SYLLABLE_TYPE. */\r
952         for(c=NormalizerImpl.HANGUL_BASE; c<(NormalizerImpl.HANGUL_BASE+NormalizerImpl.HANGUL_COUNT); c+=NormalizerImpl.JAMO_T_COUNT) {\r
953             set.add(c);\r
954             set.add(c+1);\r
955         }\r
956         set.add(c);\r
957     }\r
958 \r
959     public UnicodeSet addPropertyStarts(UnicodeSet set) {\r
960         /* add the start code point of each same-value range of the main trie */\r
961         TrieIterator propsIter = new TrieIterator(m_trie_);\r
962         RangeValueIterator.Element propsResult = new RangeValueIterator.Element();\r
963           while(propsIter.next(propsResult)){\r
964             set.add(propsResult.start);\r
965         }\r
966 \r
967         /* add code points with hardcoded properties, plus the ones following them */\r
968 \r
969         /* add for u_isblank() */\r
970         set.add(TAB);\r
971         set.add(TAB+1);\r
972 \r
973         /* add for IS_THAT_CONTROL_SPACE() */\r
974         set.add(CR+1); /* range TAB..CR */\r
975         set.add(0x1c);\r
976         set.add(0x1f+1);\r
977         set.add(NL);\r
978         set.add(NL+1);\r
979 \r
980         /* add for u_isIDIgnorable() what was not added above */\r
981         set.add(DEL); /* range DEL..NBSP-1, NBSP added below */\r
982         set.add(HAIRSP);\r
983         set.add(RLM+1);\r
984         set.add(INHSWAP);\r
985         set.add(NOMDIG+1);\r
986         set.add(ZWNBSP);\r
987         set.add(ZWNBSP+1);\r
988 \r
989         /* add no-break spaces for u_isWhitespace() what was not added above */\r
990         set.add(NBSP);\r
991         set.add(NBSP+1);\r
992         set.add(FIGURESP);\r
993         set.add(FIGURESP+1);\r
994         set.add(NNBSP);\r
995         set.add(NNBSP+1);\r
996 \r
997         /* add for u_charDigitValue() */\r
998         // TODO remove when UCharacter.getHanNumericValue() is changed to just return\r
999         // Unicode numeric values \r
1000         set.add(0x3007);\r
1001         set.add(0x3008);\r
1002         set.add(0x4e00);\r
1003         set.add(0x4e01);\r
1004         set.add(0x4e8c);\r
1005         set.add(0x4e8d);\r
1006         set.add(0x4e09);\r
1007         set.add(0x4e0a);\r
1008         set.add(0x56db);\r
1009         set.add(0x56dc);\r
1010         set.add(0x4e94);\r
1011         set.add(0x4e95);\r
1012         set.add(0x516d);\r
1013         set.add(0x516e);\r
1014         set.add(0x4e03);\r
1015         set.add(0x4e04);\r
1016         set.add(0x516b);\r
1017         set.add(0x516c);\r
1018         set.add(0x4e5d);\r
1019         set.add(0x4e5e);\r
1020 \r
1021         /* add for u_digit() */\r
1022         set.add(U_a);\r
1023         set.add(U_z+1);\r
1024         set.add(U_A);\r
1025         set.add(U_Z+1);\r
1026         set.add(U_FW_a);\r
1027         set.add(U_FW_z+1);\r
1028         set.add(U_FW_A);\r
1029         set.add(U_FW_Z+1);\r
1030 \r
1031         /* add for u_isxdigit() */\r
1032         set.add(U_f+1);\r
1033         set.add(U_F+1);\r
1034         set.add(U_FW_f+1);\r
1035         set.add(U_FW_F+1);\r
1036 \r
1037         /* add for UCHAR_DEFAULT_IGNORABLE_CODE_POINT what was not added above */\r
1038         set.add(WJ); /* range WJ..NOMDIG */\r
1039         set.add(0xfff0);\r
1040         set.add(0xfffb+1);\r
1041         set.add(0xe0000);\r
1042         set.add(0xe0fff+1);\r
1043 \r
1044         /* add for UCHAR_GRAPHEME_BASE and others */\r
1045         set.add(CGJ);\r
1046         set.add(CGJ+1);\r
1047 \r
1048         return set; // for chaining\r
1049     }\r
1050 \r
1051     public void upropsvec_addPropertyStarts(UnicodeSet set) {\r
1052         /* add the start code point of each same-value range of the properties vectors trie */\r
1053         if(m_additionalColumnsCount_>0) {\r
1054             /* if m_additionalColumnsCount_==0 then the properties vectors trie may not be there at all */\r
1055             TrieIterator propsVectorsIter = new TrieIterator(m_additionalTrie_);\r
1056             RangeValueIterator.Element propsVectorsResult = new RangeValueIterator.Element();\r
1057             while(propsVectorsIter.next(propsVectorsResult)){\r
1058                 set.add(propsVectorsResult.start);\r
1059             }\r
1060         }\r
1061     }\r
1062 \r
1063 /*----------------------------------------------------------------\r
1064  * Inclusions list\r
1065  *----------------------------------------------------------------*/\r
1066 \r
1067     /*\r
1068      * Return a set of characters for property enumeration.\r
1069      * The set implicitly contains 0x110000 as well, which is one more than the highest\r
1070      * Unicode code point.\r
1071      *\r
1072      * This set is used as an ordered list - its code points are ordered, and\r
1073      * consecutive code points (in Unicode code point order) in the set define a range.\r
1074      * For each two consecutive characters (start, limit) in the set,\r
1075      * all of the UCD/normalization and related properties for\r
1076      * all code points start..limit-1 are all the same,\r
1077      * except for character names and ISO comments.\r
1078      *\r
1079      * All Unicode code points U+0000..U+10ffff are covered by these ranges.\r
1080      * The ranges define a partition of the Unicode code space.\r
1081      * ICU uses the inclusions set to enumerate properties for generating\r
1082      * UnicodeSets containing all code points that have a certain property value.\r
1083      *\r
1084      * The Inclusion List is generated from the UCD. It is generated\r
1085      * by enumerating the data tries, and code points for hardcoded properties\r
1086      * are added as well.\r
1087      *\r
1088      * --------------------------------------------------------------------------\r
1089      *\r
1090      * The following are ideas for getting properties-unique code point ranges,\r
1091      * with possible optimizations beyond the current implementation.\r
1092      * These optimizations would require more code and be more fragile.\r
1093      * The current implementation generates one single list (set) for all properties.\r
1094      *\r
1095      * To enumerate properties efficiently, one needs to know ranges of\r
1096      * repetitive values, so that the value of only each start code point\r
1097      * can be applied to the whole range.\r
1098      * This information is in principle available in the uprops.icu/unorm.icu data.\r
1099      *\r
1100      * There are two obstacles:\r
1101      *\r
1102      * 1. Some properties are computed from multiple data structures,\r
1103      *    making it necessary to get repetitive ranges by intersecting\r
1104      *    ranges from multiple tries.\r
1105      *\r
1106      * 2. It is not economical to write code for getting repetitive ranges\r
1107      *    that are precise for each of some 50 properties.\r
1108      *\r
1109      * Compromise ideas:\r
1110      *\r
1111      * - Get ranges per trie, not per individual property.\r
1112      *   Each range contains the same values for a whole group of properties.\r
1113      *   This would generate currently five range sets, two for uprops.icu tries\r
1114      *   and three for unorm.icu tries.\r
1115      *\r
1116      * - Combine sets of ranges for multiple tries to get sufficient sets\r
1117      *   for properties, e.g., the uprops.icu main and auxiliary tries\r
1118      *   for all non-normalization properties.\r
1119      *\r
1120      * Ideas for representing ranges and combining them:\r
1121      *\r
1122      * - A UnicodeSet could hold just the start code points of ranges.\r
1123      *   Multiple sets are easily combined by or-ing them together.\r
1124      *\r
1125      * - Alternatively, a UnicodeSet could hold each even-numbered range.\r
1126      *   All ranges could be enumerated by using each start code point\r
1127      *   (for the even-numbered ranges) as well as each limit (end+1) code point\r
1128      *   (for the odd-numbered ranges).\r
1129      *   It should be possible to combine two such sets by xor-ing them,\r
1130      *   but no more than two.\r
1131      *\r
1132      * The second way to represent ranges may(?!) yield smaller UnicodeSet arrays,\r
1133      * but the first one is certainly simpler and applicable for combining more than\r
1134      * two range sets.\r
1135      *\r
1136      * It is possible to combine all range sets for all uprops/unorm tries into one\r
1137      * set that can be used for all properties.\r
1138      * As an optimization, there could be less-combined range sets for certain\r
1139      * groups of properties.\r
1140      * The relationship of which less-combined range set to use for which property\r
1141      * depends on the implementation of the properties and must be hardcoded\r
1142      * - somewhat error-prone and higher maintenance but can be tested easily\r
1143      * by building property sets "the simple way" in test code.\r
1144      *\r
1145      * ---\r
1146      *\r
1147      * Do not use a UnicodeSet pattern because that causes infinite recursion;\r
1148      * UnicodeSet depends on the inclusions set.\r
1149      *\r
1150      * ---\r
1151      *\r
1152      * getInclusions() is commented out starting 2005-feb-12 because\r
1153      * UnicodeSet now calls the uxyz_addPropertyStarts() directly,\r
1154      * and only for the relevant property source.\r
1155      */\r
1156     /*\r
1157     public UnicodeSet getInclusions() {\r
1158         UnicodeSet set = new UnicodeSet();\r
1159         NormalizerImpl.addPropertyStarts(set);\r
1160         addPropertyStarts(set);\r
1161         return set;\r
1162     }\r
1163     */\r
1164 }\r