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