author | peytoia |
Thu, 12 Nov 2009 18:59:19 +0900 | |
changeset 4280 | 74c4e0c5d936 |
parent 2 | 90ce3da70b43 |
child 5281 | fb279b232508 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
2 |
* Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Sun designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Sun in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 |
* have any questions. |
|
24 |
*/ |
|
25 |
||
26 |
package java.awt.font; |
|
27 |
||
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
28 |
import java.io.IOException; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
29 |
import java.io.ObjectOutputStream; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
30 |
import java.util.Arrays; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
31 |
import java.util.Comparator; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
32 |
import java.util.EnumSet; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
33 |
import java.util.Set; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
34 |
|
2 | 35 |
/** |
36 |
* The <code>NumericShaper</code> class is used to convert Latin-1 (European) |
|
37 |
* digits to other Unicode decimal digits. Users of this class will |
|
38 |
* primarily be people who wish to present data using |
|
39 |
* national digit shapes, but find it more convenient to represent the |
|
40 |
* data internally using Latin-1 (European) digits. This does not |
|
41 |
* interpret the deprecated numeric shape selector character (U+206E). |
|
42 |
* <p> |
|
43 |
* Instances of <code>NumericShaper</code> are typically applied |
|
44 |
* as attributes to text with the |
|
45 |
* {@link TextAttribute#NUMERIC_SHAPING NUMERIC_SHAPING} attribute |
|
46 |
* of the <code>TextAttribute</code> class. |
|
47 |
* For example, this code snippet causes a <code>TextLayout</code> to |
|
48 |
* shape European digits to Arabic in an Arabic context:<br> |
|
49 |
* <blockquote><pre> |
|
50 |
* Map map = new HashMap(); |
|
51 |
* map.put(TextAttribute.NUMERIC_SHAPING, |
|
52 |
* NumericShaper.getContextualShaper(NumericShaper.ARABIC)); |
|
53 |
* FontRenderContext frc = ...; |
|
54 |
* TextLayout layout = new TextLayout(text, map, frc); |
|
55 |
* layout.draw(g2d, x, y); |
|
56 |
* </pre></blockquote> |
|
57 |
* <br> |
|
58 |
* It is also possible to perform numeric shaping explicitly using instances |
|
59 |
* of <code>NumericShaper</code>, as this code snippet demonstrates:<br> |
|
60 |
* <blockquote><pre> |
|
61 |
* char[] text = ...; |
|
62 |
* // shape all EUROPEAN digits (except zero) to ARABIC digits |
|
63 |
* NumericShaper shaper = NumericShaper.getShaper(NumericShaper.ARABIC); |
|
64 |
* shaper.shape(text, start, count); |
|
65 |
* |
|
66 |
* // shape European digits to ARABIC digits if preceding text is Arabic, or |
|
67 |
* // shape European digits to TAMIL digits if preceding text is Tamil, or |
|
68 |
* // leave European digits alone if there is no preceding text, or |
|
69 |
* // preceding text is neither Arabic nor Tamil |
|
70 |
* NumericShaper shaper = |
|
71 |
* NumericShaper.getContextualShaper(NumericShaper.ARABIC | |
|
72 |
* NumericShaper.TAMIL, |
|
73 |
* NumericShaper.EUROPEAN); |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
74 |
* shaper.shape(text, start, count); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
75 |
* </pre></blockquote> |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
76 |
* |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
77 |
* <p><b>Bit mask- and enum-based Unicode ranges</b></p> |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
78 |
* |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
79 |
* <p>This class supports two different programming interfaces to |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
80 |
* represent Unicode ranges for script-specific digits: bit |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
81 |
* mask-based ones, such as {@link #ARABIC NumericShaper.ARABIC}, and |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
82 |
* enum-based ones, such as {@link NumericShaper.Range#ARABIC}. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
83 |
* Multiple ranges can be specified by ORing bit mask-based constants, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
84 |
* such as: |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
85 |
* <blockquote><pre> |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
86 |
* NumericShaper.ARABIC | NumericShaper.TAMIL |
2 | 87 |
* </pre></blockquote> |
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
88 |
* or creating a {@code Set} with the {@link NumericShaper.Range} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
89 |
* constants, such as: |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
90 |
* <blockquote><pre> |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
91 |
* EnumSet.of(NumericShaper.Scirpt.ARABIC, NumericShaper.Range.TAMIL) |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
92 |
* </pre></blockquote> |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
93 |
* The enum-based ranges are a super set of the bit mask-based ones. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
94 |
* |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
95 |
* <p>If the two interfaces are mixed (including serialization), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
96 |
* Unicode range values are mapped to their counterparts where such |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
97 |
* mapping is possible, such as {@code NumericShaper.Range.ARABIC} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
98 |
* from/to {@code NumericShaper.ARABIC}. If any unmappable range |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
99 |
* values are specified, such as {@code NumericShaper.Range.BALINESE}, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
100 |
* those ranges are ignored. |
2 | 101 |
* |
102 |
* @since 1.4 |
|
103 |
*/ |
|
104 |
||
105 |
public final class NumericShaper implements java.io.Serializable { |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
106 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
107 |
* A {@code NumericShaper.Range} represents a Unicode range of a |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
108 |
* script having its own decimal digits. For example, the {@link |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
109 |
* NumericShaper.Range#THAI} range has the Thai digits, THAI DIGIT |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
110 |
* ZERO (U+0E50) to THAI DIGIT NINE (U+0E59). |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
111 |
* |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
112 |
* <p>The <code>Range</code> enum replaces the traditional bit |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
113 |
* mask-based values (e.g., {@link NumericShaper#ARABIC}), and |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
114 |
* supports more Unicode ranges than the bit mask-based ones. For |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
115 |
* example, the following code using the bit mask: |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
116 |
* <blockquote><pre> |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
117 |
* NumericShaper.getContextualShaper(NumericShaper.ARABIC | |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
118 |
* NumericShaper.TAMIL, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
119 |
* NumericShaper.EUROPEAN); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
120 |
* </pre></blockquote> |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
121 |
* can be written using this enum as: |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
122 |
* <blockquote><pre> |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
123 |
* NumericShaper.getContextualShaper(EnumSet.of( |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
124 |
* NumericShaper.Range.ARABIC, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
125 |
* NumericShaper.Range.TAMIL), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
126 |
* NumericShaper.Range.EUROPEAN); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
127 |
* </pre></blockquote> |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
128 |
* |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
129 |
* @since 1.7 |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
130 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
131 |
public static enum Range { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
132 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
133 |
* The Latin (European) range with the Latin (ASCII) digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
134 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
135 |
EUROPEAN ('\u0030', '\u0000', '\u0300'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
136 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
137 |
* The Arabic range with the Arabic-Indic digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
138 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
139 |
ARABIC ('\u0660', '\u0600', '\u0780'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
140 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
141 |
* The Arabic range with the Eastern Arabic-Indic digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
142 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
143 |
EASTERN_ARABIC ('\u06f0', '\u0600', '\u0780'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
144 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
145 |
* The Devanagari range with the Devanagari digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
146 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
147 |
DEVANAGARI ('\u0966', '\u0900', '\u0980'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
148 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
149 |
* The Bengali range with the Bengali digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
150 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
151 |
BENGALI ('\u09e6', '\u0980', '\u0a00'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
152 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
153 |
* The Gurmukhi range with the Gurmukhi digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
154 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
155 |
GURMUKHI ('\u0a66', '\u0a00', '\u0a80'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
156 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
157 |
* The Gujarati range with the Gujarati digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
158 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
159 |
GUJARATI ('\u0ae6', '\u0b00', '\u0b80'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
160 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
161 |
* The Oriya range with the Oriya digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
162 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
163 |
ORIYA ('\u0b66', '\u0b00', '\u0b80'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
164 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
165 |
* The Tamil range with the Tamil digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
166 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
167 |
TAMIL ('\u0be6', '\u0b80', '\u0c00'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
168 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
169 |
* The Telugu range with the Telugu digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
170 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
171 |
TELUGU ('\u0c66', '\u0c00', '\u0c80'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
172 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
173 |
* The Kannada range with the Kannada digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
174 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
175 |
KANNADA ('\u0ce6', '\u0c80', '\u0d00'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
176 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
177 |
* The Malayalam range with the Malayalam digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
178 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
179 |
MALAYALAM ('\u0d66', '\u0d00', '\u0d80'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
180 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
181 |
* The Thai range with the Thai digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
182 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
183 |
THAI ('\u0e50', '\u0e00', '\u0e80'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
184 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
185 |
* The Lao range with the Lao digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
186 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
187 |
LAO ('\u0ed0', '\u0e80', '\u0f00'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
188 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
189 |
* The Tibetan range with the Tibetan digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
190 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
191 |
TIBETAN ('\u0f20', '\u0f00', '\u1000'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
192 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
193 |
* The Myanmar range with the Myanmar digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
194 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
195 |
MYANMAR ('\u1040', '\u1000', '\u1080'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
196 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
197 |
* The Ethiopic range with the Ethiopic digits. Ethiopic |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
198 |
* does not have a decimal digit 0 so Latin (European) 0 is |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
199 |
* used. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
200 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
201 |
ETHIOPIC ('\u1369', '\u1200', '\u1380') { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
202 |
@Override |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
203 |
char getNumericBase() { return 1; } |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
204 |
}, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
205 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
206 |
* The Khmer range with the Khmer digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
207 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
208 |
KHMER ('\u17e0', '\u1780', '\u1800'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
209 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
210 |
* The Mongolian range with the Mongolian digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
211 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
212 |
MONGOLIAN ('\u1810', '\u1800', '\u1900'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
213 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
214 |
* The N'Ko range with the N'Ko digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
215 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
216 |
NKO ('\u07c0', '\u07c0', '\u0800'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
217 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
218 |
* The Myanmar range with the Myanmar Shan digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
219 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
220 |
MYANMAR_SHAN ('\u1090', '\u1000', '\u10a0'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
221 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
222 |
* The Limbu range with the Limbu digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
223 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
224 |
LIMBU ('\u1946', '\u1900', '\u1950'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
225 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
226 |
* The New Tai Lue range with the New Tai Lue digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
227 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
228 |
NEW_TAI_LUE ('\u19d0', '\u1980', '\u19e0'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
229 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
230 |
* The Balinese range with the Balinese digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
231 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
232 |
BALINESE ('\u1b50', '\u1b00', '\u1b80'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
233 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
234 |
* The Sundanese range with the Sundanese digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
235 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
236 |
SUNDANESE ('\u1bb0', '\u1b80', '\u1bc0'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
237 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
238 |
* The Lepcha range with the Lepcha digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
239 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
240 |
LEPCHA ('\u1c40', '\u1c00', '\u1c50'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
241 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
242 |
* The Ol Chiki range with the Ol Chiki digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
243 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
244 |
OL_CHIKI ('\u1c50', '\u1c50', '\u1c80'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
245 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
246 |
* The Vai range with the Vai digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
247 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
248 |
VAI ('\ua620', '\ua500', '\ua640'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
249 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
250 |
* The Saurashtra range with the Saurashtra digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
251 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
252 |
SAURASHTRA ('\ua8d0', '\ua880', '\ua8e0'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
253 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
254 |
* The Kayah Li range with the Kayah Li digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
255 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
256 |
KAYAH_LI ('\ua900', '\ua900', '\ua930'), |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
257 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
258 |
* The Cham range with the Cham digits. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
259 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
260 |
CHAM ('\uaa50', '\uaa00', '\uaa60'); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
261 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
262 |
private static final Range[] ranges = Range.class.getEnumConstants(); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
263 |
static { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
264 |
// sort ranges[] by base for binary search |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
265 |
Arrays.sort(ranges, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
266 |
new Comparator<Range>() { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
267 |
public int compare(Range s1, Range s2) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
268 |
return s1.base > s2.base ? 1 : s1.base == s2.base ? 0 : -1; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
269 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
270 |
}); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
271 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
272 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
273 |
private static int toRangeIndex(Range script) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
274 |
int index = script.ordinal(); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
275 |
return index < NUM_KEYS ? index : -1; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
276 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
277 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
278 |
private static Range indexToRange(int index) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
279 |
return index < NUM_KEYS ? Range.values()[index] : null; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
280 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
281 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
282 |
private static int toRangeMask(Set<Range> ranges) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
283 |
int m = 0; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
284 |
for (Range range : ranges) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
285 |
int index = range.ordinal(); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
286 |
if (index < NUM_KEYS) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
287 |
m |= 1 << index; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
288 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
289 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
290 |
return m; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
291 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
292 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
293 |
private static Set<Range> maskToRangeSet(int mask) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
294 |
Set<Range> set = EnumSet.noneOf(Range.class); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
295 |
Range[] a = Range.values(); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
296 |
for (int i = 0; i < NUM_KEYS; i++) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
297 |
if ((mask & (1 << i)) != 0) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
298 |
set.add(a[i]); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
299 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
300 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
301 |
return set; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
302 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
303 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
304 |
// base character of range digits |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
305 |
private final int base; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
306 |
// Unicode range |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
307 |
private final int start, // inclusive |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
308 |
end; // exclusive |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
309 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
310 |
private Range(int base, int start, int end) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
311 |
this.base = base - ('0' + getNumericBase()); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
312 |
this.start = start; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
313 |
this.end = end; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
314 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
315 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
316 |
private int getDigitBase() { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
317 |
return base; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
318 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
319 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
320 |
char getNumericBase() { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
321 |
return 0; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
322 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
323 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
324 |
private boolean inRange(int c) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
325 |
return start <= c && c < end; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
326 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
327 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
328 |
|
2 | 329 |
/** index of context for contextual shaping - values range from 0 to 18 */ |
330 |
private int key; |
|
331 |
||
332 |
/** flag indicating whether to shape contextually (high bit) and which |
|
333 |
* digit ranges to shape (bits 0-18) |
|
334 |
*/ |
|
335 |
private int mask; |
|
336 |
||
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
337 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
338 |
* The context {@code Range} for contextual shaping or the {@code |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
339 |
* Range} for non-contextual shaping. {@code null} for the bit |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
340 |
* mask-based API. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
341 |
* |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
342 |
* @since 1.7 |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
343 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
344 |
private Range shapingRange; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
345 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
346 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
347 |
* {@code Set<Range>} indicating which Unicode ranges to |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
348 |
* shape. {@code null} for the bit mask-based API. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
349 |
* |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
350 |
* @since 1.7 |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
351 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
352 |
private transient Set<Range> rangeSet; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
353 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
354 |
private static final long serialVersionUID = -8022764705923730308L; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
355 |
|
2 | 356 |
/** Identifies the Latin-1 (European) and extended range, and |
357 |
* Latin-1 (European) decimal base. |
|
358 |
*/ |
|
359 |
public static final int EUROPEAN = 1<<0; |
|
360 |
||
361 |
/** Identifies the ARABIC range and decimal base. */ |
|
362 |
public static final int ARABIC = 1<<1; |
|
363 |
||
364 |
/** Identifies the ARABIC range and ARABIC_EXTENDED decimal base. */ |
|
365 |
public static final int EASTERN_ARABIC = 1<<2; |
|
366 |
||
367 |
/** Identifies the DEVANAGARI range and decimal base. */ |
|
368 |
public static final int DEVANAGARI = 1<<3; |
|
369 |
||
370 |
/** Identifies the BENGALI range and decimal base. */ |
|
371 |
public static final int BENGALI = 1<<4; |
|
372 |
||
373 |
/** Identifies the GURMUKHI range and decimal base. */ |
|
374 |
public static final int GURMUKHI = 1<<5; |
|
375 |
||
376 |
/** Identifies the GUJARATI range and decimal base. */ |
|
377 |
public static final int GUJARATI = 1<<6; |
|
378 |
||
379 |
/** Identifies the ORIYA range and decimal base. */ |
|
380 |
public static final int ORIYA = 1<<7; |
|
381 |
||
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
382 |
/** Identifies the TAMIL range and decimal base. */ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
383 |
// TAMIL DIGIT ZERO was added in Unicode 4.1 |
2 | 384 |
public static final int TAMIL = 1<<8; |
385 |
||
386 |
/** Identifies the TELUGU range and decimal base. */ |
|
387 |
public static final int TELUGU = 1<<9; |
|
388 |
||
389 |
/** Identifies the KANNADA range and decimal base. */ |
|
390 |
public static final int KANNADA = 1<<10; |
|
391 |
||
392 |
/** Identifies the MALAYALAM range and decimal base. */ |
|
393 |
public static final int MALAYALAM = 1<<11; |
|
394 |
||
395 |
/** Identifies the THAI range and decimal base. */ |
|
396 |
public static final int THAI = 1<<12; |
|
397 |
||
398 |
/** Identifies the LAO range and decimal base. */ |
|
399 |
public static final int LAO = 1<<13; |
|
400 |
||
401 |
/** Identifies the TIBETAN range and decimal base. */ |
|
402 |
public static final int TIBETAN = 1<<14; |
|
403 |
||
404 |
/** Identifies the MYANMAR range and decimal base. */ |
|
405 |
public static final int MYANMAR = 1<<15; |
|
406 |
||
407 |
/** Identifies the ETHIOPIC range and decimal base. */ |
|
408 |
public static final int ETHIOPIC = 1<<16; |
|
409 |
||
410 |
/** Identifies the KHMER range and decimal base. */ |
|
411 |
public static final int KHMER = 1<<17; |
|
412 |
||
413 |
/** Identifies the MONGOLIAN range and decimal base. */ |
|
414 |
public static final int MONGOLIAN = 1<<18; |
|
415 |
||
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
416 |
/** Identifies all ranges, for full contextual shaping. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
417 |
* |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
418 |
* <p>This constant specifies all of the bit mask-based |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
419 |
* ranges. Use {@code EmunSet.allOf(NumericShaper.Range.class)} to |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
420 |
* specify all of the enum-based ranges. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
421 |
*/ |
2 | 422 |
public static final int ALL_RANGES = 0x0007ffff; |
423 |
||
424 |
private static final int EUROPEAN_KEY = 0; |
|
425 |
private static final int ARABIC_KEY = 1; |
|
426 |
private static final int EASTERN_ARABIC_KEY = 2; |
|
427 |
private static final int DEVANAGARI_KEY = 3; |
|
428 |
private static final int BENGALI_KEY = 4; |
|
429 |
private static final int GURMUKHI_KEY = 5; |
|
430 |
private static final int GUJARATI_KEY = 6; |
|
431 |
private static final int ORIYA_KEY = 7; |
|
432 |
private static final int TAMIL_KEY = 8; |
|
433 |
private static final int TELUGU_KEY = 9; |
|
434 |
private static final int KANNADA_KEY = 10; |
|
435 |
private static final int MALAYALAM_KEY = 11; |
|
436 |
private static final int THAI_KEY = 12; |
|
437 |
private static final int LAO_KEY = 13; |
|
438 |
private static final int TIBETAN_KEY = 14; |
|
439 |
private static final int MYANMAR_KEY = 15; |
|
440 |
private static final int ETHIOPIC_KEY = 16; |
|
441 |
private static final int KHMER_KEY = 17; |
|
442 |
private static final int MONGOLIAN_KEY = 18; |
|
443 |
||
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
444 |
private static final int NUM_KEYS = MONGOLIAN_KEY + 1; // fixed |
2 | 445 |
|
446 |
private static final int CONTEXTUAL_MASK = 1<<31; |
|
447 |
||
448 |
private static final char[] bases = { |
|
449 |
'\u0030' - '\u0030', // EUROPEAN |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
450 |
'\u0660' - '\u0030', // ARABIC-INDIC |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
451 |
'\u06f0' - '\u0030', // EXTENDED ARABIC-INDIC (EASTERN_ARABIC) |
2 | 452 |
'\u0966' - '\u0030', // DEVANAGARI |
453 |
'\u09e6' - '\u0030', // BENGALI |
|
454 |
'\u0a66' - '\u0030', // GURMUKHI |
|
455 |
'\u0ae6' - '\u0030', // GUJARATI |
|
456 |
'\u0b66' - '\u0030', // ORIYA |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
457 |
'\u0be6' - '\u0030', // TAMIL - zero was added in Unicode 4.1 |
2 | 458 |
'\u0c66' - '\u0030', // TELUGU |
459 |
'\u0ce6' - '\u0030', // KANNADA |
|
460 |
'\u0d66' - '\u0030', // MALAYALAM |
|
461 |
'\u0e50' - '\u0030', // THAI |
|
462 |
'\u0ed0' - '\u0030', // LAO |
|
463 |
'\u0f20' - '\u0030', // TIBETAN |
|
464 |
'\u1040' - '\u0030', // MYANMAR |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
465 |
'\u1369' - '\u0031', // ETHIOPIC - no zero |
2 | 466 |
'\u17e0' - '\u0030', // KHMER |
467 |
'\u1810' - '\u0030', // MONGOLIAN |
|
468 |
}; |
|
469 |
||
470 |
// some ranges adjoin or overlap, rethink if we want to do a binary search on this |
|
471 |
||
472 |
private static final char[] contexts = { |
|
473 |
'\u0000', '\u0300', // 'EUROPEAN' (really latin-1 and extended) |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
474 |
'\u0600', '\u0780', // ARABIC |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
475 |
'\u0600', '\u0780', // EASTERN_ARABIC -- note overlap with arabic |
2 | 476 |
'\u0900', '\u0980', // DEVANAGARI |
477 |
'\u0980', '\u0a00', // BENGALI |
|
478 |
'\u0a00', '\u0a80', // GURMUKHI |
|
479 |
'\u0a80', '\u0b00', // GUJARATI |
|
480 |
'\u0b00', '\u0b80', // ORIYA |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
481 |
'\u0b80', '\u0c00', // TAMIL |
2 | 482 |
'\u0c00', '\u0c80', // TELUGU |
483 |
'\u0c80', '\u0d00', // KANNADA |
|
484 |
'\u0d00', '\u0d80', // MALAYALAM |
|
485 |
'\u0e00', '\u0e80', // THAI |
|
486 |
'\u0e80', '\u0f00', // LAO |
|
487 |
'\u0f00', '\u1000', // TIBETAN |
|
488 |
'\u1000', '\u1080', // MYANMAR |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
489 |
'\u1200', '\u1380', // ETHIOPIC - note missing zero |
2 | 490 |
'\u1780', '\u1800', // KHMER |
491 |
'\u1800', '\u1900', // MONGOLIAN |
|
492 |
'\uffff', |
|
493 |
}; |
|
494 |
||
495 |
// assume most characters are near each other so probing the cache is infrequent, |
|
496 |
// and a linear probe is ok. |
|
497 |
||
498 |
private static int ctCache = 0; |
|
499 |
private static int ctCacheLimit = contexts.length - 2; |
|
500 |
||
501 |
// warning, synchronize access to this as it modifies state |
|
502 |
private static int getContextKey(char c) { |
|
503 |
if (c < contexts[ctCache]) { |
|
504 |
while (ctCache > 0 && c < contexts[ctCache]) --ctCache; |
|
505 |
} else if (c >= contexts[ctCache + 1]) { |
|
506 |
while (ctCache < ctCacheLimit && c >= contexts[ctCache + 1]) ++ctCache; |
|
507 |
} |
|
508 |
||
509 |
// if we're not in a known range, then return EUROPEAN as the range key |
|
510 |
return (ctCache & 0x1) == 0 ? (ctCache / 2) : EUROPEAN_KEY; |
|
511 |
} |
|
512 |
||
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
513 |
// cache for the NumericShaper.Range version |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
514 |
private transient volatile Range currentRange = Range.EUROPEAN; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
515 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
516 |
private Range rangeForCodePoint(int codepoint) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
517 |
Range range = currentRange; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
518 |
if (range.inRange(codepoint)) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
519 |
return range; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
520 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
521 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
522 |
final Range[] ranges = Range.ranges; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
523 |
int lo = 0; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
524 |
int hi = ranges.length - 1; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
525 |
while (lo <= hi) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
526 |
int mid = (lo + hi) / 2; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
527 |
range = ranges[mid]; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
528 |
if (codepoint < range.start) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
529 |
hi = mid - 1; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
530 |
} else if (codepoint >= range.end) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
531 |
lo = mid + 1; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
532 |
} else { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
533 |
currentRange = range; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
534 |
return range; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
535 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
536 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
537 |
return Range.EUROPEAN; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
538 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
539 |
|
2 | 540 |
/* |
541 |
* A range table of strong directional characters (types L, R, AL). |
|
542 |
* Even (left) indexes are starts of ranges of non-strong-directional (or undefined) |
|
543 |
* characters, odd (right) indexes are starts of ranges of strong directional |
|
544 |
* characters. |
|
545 |
*/ |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
546 |
private static int[] strongTable = { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
547 |
0x0000, 0x0041, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
548 |
0x005b, 0x0061, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
549 |
0x007b, 0x00aa, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
550 |
0x00ab, 0x00b5, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
551 |
0x00b6, 0x00ba, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
552 |
0x00bb, 0x00c0, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
553 |
0x00d7, 0x00d8, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
554 |
0x00f7, 0x00f8, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
555 |
0x02b9, 0x02bb, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
556 |
0x02c2, 0x02d0, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
557 |
0x02d2, 0x02e0, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
558 |
0x02e5, 0x02ee, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
559 |
0x02ef, 0x0370, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
560 |
0x0374, 0x0376, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
561 |
0x037e, 0x0386, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
562 |
0x0387, 0x0388, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
563 |
0x03f6, 0x03f7, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
564 |
0x0483, 0x048a, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
565 |
0x058a, 0x05be, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
566 |
0x05bf, 0x05c0, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
567 |
0x05c1, 0x05c3, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
568 |
0x05c4, 0x05c6, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
569 |
0x05c7, 0x05d0, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
570 |
0x0600, 0x0608, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
571 |
0x0609, 0x060b, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
572 |
0x060c, 0x060d, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
573 |
0x060e, 0x061b, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
574 |
0x064b, 0x066d, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
575 |
0x0670, 0x0671, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
576 |
0x06d6, 0x06e5, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
577 |
0x06e7, 0x06ee, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
578 |
0x06f0, 0x06fa, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
579 |
0x070f, 0x0710, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
580 |
0x0711, 0x0712, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
581 |
0x0730, 0x074d, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
582 |
0x07a6, 0x07b1, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
583 |
0x07eb, 0x07f4, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
584 |
0x07f6, 0x07fa, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
585 |
0x0901, 0x0903, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
586 |
0x093c, 0x093d, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
587 |
0x0941, 0x0949, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
588 |
0x094d, 0x0950, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
589 |
0x0951, 0x0958, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
590 |
0x0962, 0x0964, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
591 |
0x0981, 0x0982, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
592 |
0x09bc, 0x09bd, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
593 |
0x09c1, 0x09c7, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
594 |
0x09cd, 0x09ce, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
595 |
0x09e2, 0x09e6, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
596 |
0x09f2, 0x09f4, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
597 |
0x0a01, 0x0a03, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
598 |
0x0a3c, 0x0a3e, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
599 |
0x0a41, 0x0a59, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
600 |
0x0a70, 0x0a72, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
601 |
0x0a75, 0x0a83, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
602 |
0x0abc, 0x0abd, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
603 |
0x0ac1, 0x0ac9, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
604 |
0x0acd, 0x0ad0, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
605 |
0x0ae2, 0x0ae6, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
606 |
0x0af1, 0x0b02, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
607 |
0x0b3c, 0x0b3d, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
608 |
0x0b3f, 0x0b40, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
609 |
0x0b41, 0x0b47, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
610 |
0x0b4d, 0x0b57, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
611 |
0x0b62, 0x0b66, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
612 |
0x0b82, 0x0b83, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
613 |
0x0bc0, 0x0bc1, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
614 |
0x0bcd, 0x0bd0, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
615 |
0x0bf3, 0x0c01, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
616 |
0x0c3e, 0x0c41, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
617 |
0x0c46, 0x0c58, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
618 |
0x0c62, 0x0c66, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
619 |
0x0c78, 0x0c7f, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
620 |
0x0cbc, 0x0cbd, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
621 |
0x0ccc, 0x0cd5, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
622 |
0x0ce2, 0x0ce6, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
623 |
0x0cf1, 0x0d02, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
624 |
0x0d41, 0x0d46, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
625 |
0x0d4d, 0x0d57, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
626 |
0x0d62, 0x0d66, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
627 |
0x0dca, 0x0dcf, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
628 |
0x0dd2, 0x0dd8, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
629 |
0x0e31, 0x0e32, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
630 |
0x0e34, 0x0e40, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
631 |
0x0e47, 0x0e4f, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
632 |
0x0eb1, 0x0eb2, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
633 |
0x0eb4, 0x0ebd, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
634 |
0x0ec8, 0x0ed0, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
635 |
0x0f18, 0x0f1a, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
636 |
0x0f35, 0x0f36, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
637 |
0x0f37, 0x0f38, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
638 |
0x0f39, 0x0f3e, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
639 |
0x0f71, 0x0f7f, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
640 |
0x0f80, 0x0f85, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
641 |
0x0f86, 0x0f88, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
642 |
0x0f90, 0x0fbe, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
643 |
0x0fc6, 0x0fc7, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
644 |
0x102d, 0x1031, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
645 |
0x1032, 0x1038, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
646 |
0x1039, 0x103b, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
647 |
0x103d, 0x103f, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
648 |
0x1058, 0x105a, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
649 |
0x105e, 0x1061, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
650 |
0x1071, 0x1075, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
651 |
0x1082, 0x1083, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
652 |
0x1085, 0x1087, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
653 |
0x108d, 0x108e, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
654 |
0x135f, 0x1360, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
655 |
0x1390, 0x13a0, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
656 |
0x1680, 0x1681, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
657 |
0x169b, 0x16a0, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
658 |
0x1712, 0x1720, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
659 |
0x1732, 0x1735, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
660 |
0x1752, 0x1760, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
661 |
0x1772, 0x1780, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
662 |
0x17b7, 0x17be, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
663 |
0x17c6, 0x17c7, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
664 |
0x17c9, 0x17d4, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
665 |
0x17db, 0x17dc, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
666 |
0x17dd, 0x17e0, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
667 |
0x17f0, 0x1810, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
668 |
0x18a9, 0x18aa, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
669 |
0x1920, 0x1923, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
670 |
0x1927, 0x1929, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
671 |
0x1932, 0x1933, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
672 |
0x1939, 0x1946, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
673 |
0x19de, 0x1a00, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
674 |
0x1a17, 0x1a19, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
675 |
0x1b00, 0x1b04, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
676 |
0x1b34, 0x1b35, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
677 |
0x1b36, 0x1b3b, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
678 |
0x1b3c, 0x1b3d, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
679 |
0x1b42, 0x1b43, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
680 |
0x1b6b, 0x1b74, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
681 |
0x1b80, 0x1b82, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
682 |
0x1ba2, 0x1ba6, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
683 |
0x1ba8, 0x1baa, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
684 |
0x1c2c, 0x1c34, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
685 |
0x1c36, 0x1c3b, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
686 |
0x1dc0, 0x1e00, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
687 |
0x1fbd, 0x1fbe, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
688 |
0x1fbf, 0x1fc2, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
689 |
0x1fcd, 0x1fd0, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
690 |
0x1fdd, 0x1fe0, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
691 |
0x1fed, 0x1ff2, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
692 |
0x1ffd, 0x200e, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
693 |
0x2010, 0x2071, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
694 |
0x2074, 0x207f, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
695 |
0x2080, 0x2090, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
696 |
0x20a0, 0x2102, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
697 |
0x2103, 0x2107, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
698 |
0x2108, 0x210a, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
699 |
0x2114, 0x2115, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
700 |
0x2116, 0x2119, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
701 |
0x211e, 0x2124, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
702 |
0x2125, 0x2126, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
703 |
0x2127, 0x2128, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
704 |
0x2129, 0x212a, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
705 |
0x212e, 0x212f, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
706 |
0x213a, 0x213c, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
707 |
0x2140, 0x2145, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
708 |
0x214a, 0x214e, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
709 |
0x2153, 0x2160, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
710 |
0x2190, 0x2336, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
711 |
0x237b, 0x2395, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
712 |
0x2396, 0x249c, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
713 |
0x24ea, 0x26ac, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
714 |
0x26ad, 0x2800, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
715 |
0x2900, 0x2c00, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
716 |
0x2ce5, 0x2d00, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
717 |
0x2de0, 0x3005, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
718 |
0x3008, 0x3021, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
719 |
0x302a, 0x3031, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
720 |
0x3036, 0x3038, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
721 |
0x303d, 0x3041, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
722 |
0x3099, 0x309d, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
723 |
0x30a0, 0x30a1, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
724 |
0x30fb, 0x30fc, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
725 |
0x31c0, 0x31f0, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
726 |
0x321d, 0x3220, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
727 |
0x3250, 0x3260, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
728 |
0x327c, 0x327f, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
729 |
0x32b1, 0x32c0, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
730 |
0x32cc, 0x32d0, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
731 |
0x3377, 0x337b, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
732 |
0x33de, 0x33e0, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
733 |
0x33ff, 0x3400, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
734 |
0x4dc0, 0x4e00, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
735 |
0xa490, 0xa500, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
736 |
0xa60d, 0xa610, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
737 |
0xa66f, 0xa680, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
738 |
0xa700, 0xa722, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
739 |
0xa788, 0xa789, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
740 |
0xa802, 0xa803, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
741 |
0xa806, 0xa807, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
742 |
0xa80b, 0xa80c, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
743 |
0xa825, 0xa827, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
744 |
0xa828, 0xa840, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
745 |
0xa874, 0xa880, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
746 |
0xa8c4, 0xa8ce, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
747 |
0xa926, 0xa92e, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
748 |
0xa947, 0xa952, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
749 |
0xaa29, 0xaa2f, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
750 |
0xaa31, 0xaa33, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
751 |
0xaa35, 0xaa40, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
752 |
0xaa43, 0xaa44, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
753 |
0xaa4c, 0xaa4d, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
754 |
0xfb1e, 0xfb1f, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
755 |
0xfb29, 0xfb2a, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
756 |
0xfd3e, 0xfd50, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
757 |
0xfdfd, 0xfe70, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
758 |
0xfeff, 0xff21, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
759 |
0xff3b, 0xff41, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
760 |
0xff5b, 0xff66, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
761 |
0xffe0, 0x10000, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
762 |
0x10101, 0x10102, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
763 |
0x10140, 0x101d0, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
764 |
0x101fd, 0x10280, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
765 |
0x1091f, 0x10920, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
766 |
0x10a01, 0x10a10, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
767 |
0x10a38, 0x10a40, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
768 |
0x1d167, 0x1d16a, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
769 |
0x1d173, 0x1d183, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
770 |
0x1d185, 0x1d18c, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
771 |
0x1d1aa, 0x1d1ae, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
772 |
0x1d200, 0x1d360, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
773 |
0x1d7ce, 0x20000, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
774 |
0xe0001, 0xf0000, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
775 |
0x10fffe, 0x10ffff // sentinel |
2 | 776 |
}; |
777 |
||
778 |
||
779 |
// use a binary search with a cache |
|
780 |
||
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
781 |
private transient volatile int stCache = 0; |
2 | 782 |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
783 |
private boolean isStrongDirectional(char c) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
784 |
int cachedIndex = stCache; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
785 |
if (c < strongTable[cachedIndex]) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
786 |
cachedIndex = search(c, strongTable, 0, cachedIndex); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
787 |
} else if (c >= strongTable[cachedIndex + 1]) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
788 |
cachedIndex = search(c, strongTable, cachedIndex + 1, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
789 |
strongTable.length - cachedIndex - 1); |
2 | 790 |
} |
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
791 |
boolean val = (cachedIndex & 0x1) == 1; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
792 |
stCache = cachedIndex; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
793 |
return val; |
2 | 794 |
} |
795 |
||
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
796 |
private static int getKeyFromMask(int mask) { |
2 | 797 |
int key = 0; |
798 |
while (key < NUM_KEYS && ((mask & (1<<key)) == 0)) { |
|
799 |
++key; |
|
800 |
} |
|
801 |
if (key == NUM_KEYS || ((mask & ~(1<<key)) != 0)) { |
|
802 |
throw new IllegalArgumentException("invalid shaper: " + Integer.toHexString(mask)); |
|
803 |
} |
|
804 |
return key; |
|
805 |
} |
|
806 |
||
807 |
/** |
|
808 |
* Returns a shaper for the provided unicode range. All |
|
809 |
* Latin-1 (EUROPEAN) digits are converted |
|
810 |
* to the corresponding decimal unicode digits. |
|
811 |
* @param singleRange the specified Unicode range |
|
812 |
* @return a non-contextual numeric shaper |
|
813 |
* @throws IllegalArgumentException if the range is not a single range |
|
814 |
*/ |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
815 |
public static NumericShaper getShaper(int singleRange) { |
2 | 816 |
int key = getKeyFromMask(singleRange); |
817 |
return new NumericShaper(key, singleRange); |
|
818 |
} |
|
819 |
||
820 |
/** |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
821 |
* Returns a shaper for the provided Unicode |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
822 |
* range. All Latin-1 (EUROPEAN) digits are converted to the |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
823 |
* corresponding decimal digits of the specified Unicode range. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
824 |
* |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
825 |
* @param singleRange the Unicode range given by a {@link |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
826 |
* NumericShaper.Range} constant. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
827 |
* @return a non-contextual {@code NumericShaper}. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
828 |
* @throws NullPointerException if {@code singleRange} is {@code null} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
829 |
* @since 1.7 |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
830 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
831 |
public static NumericShaper getShaper(Range singleRange) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
832 |
return new NumericShaper(singleRange, EnumSet.of(singleRange)); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
833 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
834 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
835 |
/** |
2 | 836 |
* Returns a contextual shaper for the provided unicode range(s). |
837 |
* Latin-1 (EUROPEAN) digits are converted to the decimal digits |
|
838 |
* corresponding to the range of the preceding text, if the |
|
839 |
* range is one of the provided ranges. Multiple ranges are |
|
840 |
* represented by or-ing the values together, such as, |
|
841 |
* <code>NumericShaper.ARABIC | NumericShaper.THAI</code>. The |
|
842 |
* shaper assumes EUROPEAN as the starting context, that is, if |
|
843 |
* EUROPEAN digits are encountered before any strong directional |
|
844 |
* text in the string, the context is presumed to be EUROPEAN, and |
|
845 |
* so the digits will not shape. |
|
846 |
* @param ranges the specified Unicode ranges |
|
847 |
* @return a shaper for the specified ranges |
|
848 |
*/ |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
849 |
public static NumericShaper getContextualShaper(int ranges) { |
2 | 850 |
ranges |= CONTEXTUAL_MASK; |
851 |
return new NumericShaper(EUROPEAN_KEY, ranges); |
|
852 |
} |
|
853 |
||
854 |
/** |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
855 |
* Returns a contextual shaper for the provided Unicode |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
856 |
* range(s). The Latin-1 (EUROPEAN) digits are converted to the |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
857 |
* decimal digits corresponding to the range of the preceding |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
858 |
* text, if the range is one of the provided ranges. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
859 |
* |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
860 |
* <p>The shaper assumes EUROPEAN as the starting context, that |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
861 |
* is, if EUROPEAN digits are encountered before any strong |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
862 |
* directional text in the string, the context is presumed to be |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
863 |
* EUROPEAN, and so the digits will not shape. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
864 |
* |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
865 |
* @param ranges the specified Unicode ranges |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
866 |
* @return a contextual shaper for the specified ranges |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
867 |
* @throws NullPointerException if {@code ranges} is {@code null}. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
868 |
* @since 1.7 |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
869 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
870 |
public static NumericShaper getContextualShaper(Set<Range> ranges) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
871 |
NumericShaper shaper = new NumericShaper(Range.EUROPEAN, ranges); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
872 |
shaper.mask = CONTEXTUAL_MASK; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
873 |
return shaper; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
874 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
875 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
876 |
/** |
2 | 877 |
* Returns a contextual shaper for the provided unicode range(s). |
878 |
* Latin-1 (EUROPEAN) digits will be converted to the decimal digits |
|
879 |
* corresponding to the range of the preceding text, if the |
|
880 |
* range is one of the provided ranges. Multiple ranges are |
|
881 |
* represented by or-ing the values together, for example, |
|
882 |
* <code>NumericShaper.ARABIC | NumericShaper.THAI</code>. The |
|
883 |
* shaper uses defaultContext as the starting context. |
|
884 |
* @param ranges the specified Unicode ranges |
|
885 |
* @param defaultContext the starting context, such as |
|
886 |
* <code>NumericShaper.EUROPEAN</code> |
|
887 |
* @return a shaper for the specified Unicode ranges. |
|
888 |
* @throws IllegalArgumentException if the specified |
|
889 |
* <code>defaultContext</code> is not a single valid range. |
|
890 |
*/ |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
891 |
public static NumericShaper getContextualShaper(int ranges, int defaultContext) { |
2 | 892 |
int key = getKeyFromMask(defaultContext); |
893 |
ranges |= CONTEXTUAL_MASK; |
|
894 |
return new NumericShaper(key, ranges); |
|
895 |
} |
|
896 |
||
897 |
/** |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
898 |
* Returns a contextual shaper for the provided Unicode range(s). |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
899 |
* The Latin-1 (EUROPEAN) digits will be converted to the decimal |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
900 |
* digits corresponding to the range of the preceding text, if the |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
901 |
* range is one of the provided ranges. The shaper uses {@code |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
902 |
* defaultContext} as the starting context. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
903 |
* |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
904 |
* @param ranges the specified Unicode ranges |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
905 |
* @param defaultContext the starting context, such as |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
906 |
* {@code NumericShaper.Range.EUROPEAN} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
907 |
* @return a contextual shaper for the specified Unicode ranges. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
908 |
* @throws NullPointerException |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
909 |
* if {@code ranges} or {@code defaultContext} is {@code null} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
910 |
* @since 1.7 |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
911 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
912 |
public static NumericShaper getContextualShaper(Set<Range> ranges, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
913 |
Range defaultContext) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
914 |
if (defaultContext == null) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
915 |
throw new NullPointerException(); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
916 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
917 |
NumericShaper shaper = new NumericShaper(defaultContext, ranges); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
918 |
shaper.mask = CONTEXTUAL_MASK; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
919 |
return shaper; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
920 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
921 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
922 |
/** |
2 | 923 |
* Private constructor. |
924 |
*/ |
|
925 |
private NumericShaper(int key, int mask) { |
|
926 |
this.key = key; |
|
927 |
this.mask = mask; |
|
928 |
} |
|
929 |
||
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
930 |
private NumericShaper(Range defaultContext, Set<Range> ranges) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
931 |
this.shapingRange = defaultContext; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
932 |
this.rangeSet = EnumSet.copyOf(ranges); // throws NPE if ranges is null. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
933 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
934 |
|
2 | 935 |
/** |
936 |
* Converts the digits in the text that occur between start and |
|
937 |
* start + count. |
|
938 |
* @param text an array of characters to convert |
|
939 |
* @param start the index into <code>text</code> to start |
|
940 |
* converting |
|
941 |
* @param count the number of characters in <code>text</code> |
|
942 |
* to convert |
|
943 |
* @throws IndexOutOfBoundsException if start or start + count is |
|
944 |
* out of bounds |
|
945 |
* @throws NullPointerException if text is null |
|
946 |
*/ |
|
947 |
public void shape(char[] text, int start, int count) { |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
948 |
checkParams(text, start, count); |
2 | 949 |
if (isContextual()) { |
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
950 |
if (rangeSet == null) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
951 |
shapeContextually(text, start, count, key); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
952 |
} else { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
953 |
shapeContextually(text, start, count, shapingRange); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
954 |
} |
2 | 955 |
} else { |
956 |
shapeNonContextually(text, start, count); |
|
957 |
} |
|
958 |
} |
|
959 |
||
960 |
/** |
|
961 |
* Converts the digits in the text that occur between start and |
|
962 |
* start + count, using the provided context. |
|
963 |
* Context is ignored if the shaper is not a contextual shaper. |
|
964 |
* @param text an array of characters |
|
965 |
* @param start the index into <code>text</code> to start |
|
966 |
* converting |
|
967 |
* @param count the number of characters in <code>text</code> |
|
968 |
* to convert |
|
969 |
* @param context the context to which to convert the |
|
970 |
* characters, such as <code>NumericShaper.EUROPEAN</code> |
|
971 |
* @throws IndexOutOfBoundsException if start or start + count is |
|
972 |
* out of bounds |
|
973 |
* @throws NullPointerException if text is null |
|
974 |
* @throws IllegalArgumentException if this is a contextual shaper |
|
975 |
* and the specified <code>context</code> is not a single valid |
|
976 |
* range. |
|
977 |
*/ |
|
978 |
public void shape(char[] text, int start, int count, int context) { |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
979 |
checkParams(text, start, count); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
980 |
if (isContextual()) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
981 |
int ctxKey = getKeyFromMask(context); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
982 |
if (rangeSet == null) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
983 |
shapeContextually(text, start, count, ctxKey); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
984 |
} else { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
985 |
shapeContextually(text, start, count, Range.values()[ctxKey]); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
986 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
987 |
} else { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
988 |
shapeNonContextually(text, start, count); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
989 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
990 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
991 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
992 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
993 |
* Converts the digits in the text that occur between {@code |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
994 |
* start} and {@code start + count}, using the provided {@code |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
995 |
* context}. {@code Context} is ignored if the shaper is not a |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
996 |
* contextual shaper. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
997 |
* |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
998 |
* @param text a {@code char} array |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
999 |
* @param start the index into {@code text} to start converting |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1000 |
* @param count the number of {@code char}s in {@code text} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1001 |
* to convert |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1002 |
* @param context the context to which to convert the characters, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1003 |
* such as {@code NumericShaper.Range.EUROPEAN} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1004 |
* @throws IndexOutOfBoundsException |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1005 |
* if {@code start} or {@code start + count} is out of bounds |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1006 |
* @throws NullPointerException |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1007 |
* if {@code text} or {@code context} is null |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1008 |
* @since 1.7 |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1009 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1010 |
public void shape(char[] text, int start, int count, Range context) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1011 |
checkParams(text, start, count); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1012 |
if (context == null) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1013 |
throw new NullPointerException("context is null"); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1014 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1015 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1016 |
if (isContextual()) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1017 |
if (rangeSet != null) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1018 |
shapeContextually(text, start, count, context); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1019 |
} else { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1020 |
int key = Range.toRangeIndex(context); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1021 |
if (key >= 0) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1022 |
shapeContextually(text, start, count, key); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1023 |
} else { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1024 |
shapeContextually(text, start, count, shapingRange); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1025 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1026 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1027 |
} else { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1028 |
shapeNonContextually(text, start, count); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1029 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1030 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1031 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1032 |
private void checkParams(char[] text, int start, int count) { |
2 | 1033 |
if (text == null) { |
1034 |
throw new NullPointerException("text is null"); |
|
1035 |
} |
|
1036 |
if ((start < 0) |
|
1037 |
|| (start > text.length) |
|
1038 |
|| ((start + count) < 0) |
|
1039 |
|| ((start + count) > text.length)) { |
|
1040 |
throw new IndexOutOfBoundsException( |
|
1041 |
"bad start or count for text of length " + text.length); |
|
1042 |
} |
|
1043 |
} |
|
1044 |
||
1045 |
/** |
|
1046 |
* Returns a <code>boolean</code> indicating whether or not |
|
1047 |
* this shaper shapes contextually. |
|
1048 |
* @return <code>true</code> if this shaper is contextual; |
|
1049 |
* <code>false</code> otherwise. |
|
1050 |
*/ |
|
1051 |
public boolean isContextual() { |
|
1052 |
return (mask & CONTEXTUAL_MASK) != 0; |
|
1053 |
} |
|
1054 |
||
1055 |
/** |
|
1056 |
* Returns an <code>int</code> that ORs together the values for |
|
1057 |
* all the ranges that will be shaped. |
|
1058 |
* <p> |
|
1059 |
* For example, to check if a shaper shapes to Arabic, you would use the |
|
1060 |
* following: |
|
1061 |
* <blockquote> |
|
1062 |
* <code>if ((shaper.getRanges() & shaper.ARABIC) != 0) { ... </code> |
|
1063 |
* </blockquote> |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1064 |
* |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1065 |
* <p>Note that this method supports only the bit mask-based |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1066 |
* ranges. Call {@link #getRangeSet()} for the enum-based ranges. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1067 |
* |
2 | 1068 |
* @return the values for all the ranges to be shaped. |
1069 |
*/ |
|
1070 |
public int getRanges() { |
|
1071 |
return mask & ~CONTEXTUAL_MASK; |
|
1072 |
} |
|
1073 |
||
1074 |
/** |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1075 |
* Returns a {@code Set} representing all the Unicode ranges in |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1076 |
* this {@code NumericShaper} that will be shaped. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1077 |
* |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1078 |
* @return all the Unicode ranges to be shaped. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1079 |
* @since 1.7 |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1080 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1081 |
public Set<Range> getRangeSet() { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1082 |
if (rangeSet != null) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1083 |
return EnumSet.copyOf(rangeSet); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1084 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1085 |
return Range.maskToRangeSet(mask); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1086 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1087 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1088 |
/** |
2 | 1089 |
* Perform non-contextual shaping. |
1090 |
*/ |
|
1091 |
private void shapeNonContextually(char[] text, int start, int count) { |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1092 |
int base; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1093 |
char minDigit = '0'; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1094 |
if (shapingRange != null) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1095 |
base = shapingRange.getDigitBase(); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1096 |
minDigit += shapingRange.getNumericBase(); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1097 |
} else { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1098 |
base = bases[key]; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1099 |
if (key == ETHIOPIC_KEY) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1100 |
minDigit++; // Ethiopic doesn't use decimal zero |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1101 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1102 |
} |
2 | 1103 |
for (int i = start, e = start + count; i < e; ++i) { |
1104 |
char c = text[i]; |
|
1105 |
if (c >= minDigit && c <= '\u0039') { |
|
1106 |
text[i] = (char)(c + base); |
|
1107 |
} |
|
1108 |
} |
|
1109 |
} |
|
1110 |
||
1111 |
/** |
|
1112 |
* Perform contextual shaping. |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1113 |
* Synchronized to protect caches used in getContextKey. |
2 | 1114 |
*/ |
1115 |
private synchronized void shapeContextually(char[] text, int start, int count, int ctxKey) { |
|
1116 |
||
1117 |
// if we don't support this context, then don't shape |
|
1118 |
if ((mask & (1<<ctxKey)) == 0) { |
|
1119 |
ctxKey = EUROPEAN_KEY; |
|
1120 |
} |
|
1121 |
int lastkey = ctxKey; |
|
1122 |
||
1123 |
int base = bases[ctxKey]; |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1124 |
char minDigit = ctxKey == ETHIOPIC_KEY ? '1' : '0'; // Ethiopic doesn't use decimal zero |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1125 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1126 |
synchronized (NumericShaper.class) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1127 |
for (int i = start, e = start + count; i < e; ++i) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1128 |
char c = text[i]; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1129 |
if (c >= minDigit && c <= '\u0039') { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1130 |
text[i] = (char)(c + base); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1131 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1132 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1133 |
if (isStrongDirectional(c)) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1134 |
int newkey = getContextKey(c); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1135 |
if (newkey != lastkey) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1136 |
lastkey = newkey; |
2 | 1137 |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1138 |
ctxKey = newkey; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1139 |
if (((mask & EASTERN_ARABIC) != 0) && (ctxKey == ARABIC_KEY || ctxKey == EASTERN_ARABIC_KEY)) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1140 |
ctxKey = EASTERN_ARABIC_KEY; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1141 |
} else if ((mask & (1<<ctxKey)) == 0) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1142 |
ctxKey = EUROPEAN_KEY; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1143 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1144 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1145 |
base = bases[ctxKey]; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1146 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1147 |
minDigit = ctxKey == ETHIOPIC_KEY ? '1' : '0'; // Ethiopic doesn't use decimal zero |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1148 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1149 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1150 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1151 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1152 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1153 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1154 |
private void shapeContextually(char[] text, int start, int count, Range ctxKey) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1155 |
if (ctxKey == null) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1156 |
ctxKey = Range.EUROPEAN; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1157 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1158 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1159 |
Range lastKey = ctxKey; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1160 |
int base = ctxKey.getDigitBase(); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1161 |
char minDigit = (char)('0' + ctxKey.getNumericBase()); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1162 |
for (int i = start, end = start + count; i < end; ++i) { |
2 | 1163 |
char c = text[i]; |
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1164 |
if (c >= minDigit && c <= '9') { |
2 | 1165 |
text[i] = (char)(c + base); |
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1166 |
continue; |
2 | 1167 |
} |
1168 |
if (isStrongDirectional(c)) { |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1169 |
Range newKey = rangeForCodePoint(c); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1170 |
if (newKey != lastKey) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1171 |
lastKey = newKey; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1172 |
ctxKey = newKey; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1173 |
if (rangeSet.contains(Range.EUROPEAN) |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1174 |
&& (ctxKey == Range.ARABIC || ctxKey == Range.EASTERN_ARABIC)) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1175 |
ctxKey = Range.EASTERN_ARABIC; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1176 |
} else if (!rangeSet.contains(ctxKey)) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1177 |
ctxKey = Range.EUROPEAN; |
2 | 1178 |
} |
1179 |
||
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1180 |
base = ctxKey.getDigitBase(); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1181 |
minDigit = (char)('0' + ctxKey.getNumericBase()); |
2 | 1182 |
} |
1183 |
} |
|
1184 |
} |
|
1185 |
} |
|
1186 |
||
1187 |
/** |
|
1188 |
* Returns a hash code for this shaper. |
|
1189 |
* @return this shaper's hash code. |
|
1190 |
* @see java.lang.Object#hashCode |
|
1191 |
*/ |
|
1192 |
public int hashCode() { |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1193 |
int hash = mask; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1194 |
if (rangeSet != null) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1195 |
// Use the CONTEXTUAL_MASK bit only for the enum-based |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1196 |
// NumericShaper. A deserialized NumericShaper might have |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1197 |
// bit masks. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1198 |
hash &= CONTEXTUAL_MASK; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1199 |
hash ^= rangeSet.hashCode(); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1200 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1201 |
return hash; |
2 | 1202 |
} |
1203 |
||
1204 |
/** |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1205 |
* Returns {@code true} if the specified object is an instance of |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1206 |
* <code>NumericShaper</code> and shapes identically to this one, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1207 |
* regardless of the range representations, the bit mask or the |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1208 |
* enum. For example, the following code produces {@code "true"}. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1209 |
* <blockquote><pre> |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1210 |
* NumericShaper ns1 = NumericShaper.getShaper(NumericShaper.ARABIC); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1211 |
* NumericShaper ns2 = NumericShaper.getShaper(NumericShaper.Range.ARABIC); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1212 |
* System.out.println(ns1.equals(ns2)); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1213 |
* </pre></blockquote> |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1214 |
* |
2 | 1215 |
* @param o the specified object to compare to this |
1216 |
* <code>NumericShaper</code> |
|
1217 |
* @return <code>true</code> if <code>o</code> is an instance |
|
1218 |
* of <code>NumericShaper</code> and shapes in the same way; |
|
1219 |
* <code>false</code> otherwise. |
|
1220 |
* @see java.lang.Object#equals(java.lang.Object) |
|
1221 |
*/ |
|
1222 |
public boolean equals(Object o) { |
|
1223 |
if (o != null) { |
|
1224 |
try { |
|
1225 |
NumericShaper rhs = (NumericShaper)o; |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1226 |
if (rangeSet != null) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1227 |
if (rhs.rangeSet != null) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1228 |
return isContextual() == rhs.isContextual() |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1229 |
&& rangeSet.equals(rhs.rangeSet) |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1230 |
&& shapingRange == rhs.shapingRange; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1231 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1232 |
return isContextual() == rhs.isContextual() |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1233 |
&& rangeSet.equals(Range.maskToRangeSet(rhs.mask)) |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1234 |
&& shapingRange == Range.indexToRange(rhs.key); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1235 |
} else if (rhs.rangeSet != null) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1236 |
Set<Range> rset = Range.maskToRangeSet(mask); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1237 |
Range srange = Range.indexToRange(key); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1238 |
return isContextual() == rhs.isContextual() |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1239 |
&& rset.equals(rhs.rangeSet) |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1240 |
&& srange == rhs.shapingRange; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1241 |
} |
2 | 1242 |
return rhs.mask == mask && rhs.key == key; |
1243 |
} |
|
1244 |
catch (ClassCastException e) { |
|
1245 |
} |
|
1246 |
} |
|
1247 |
return false; |
|
1248 |
} |
|
1249 |
||
1250 |
/** |
|
1251 |
* Returns a <code>String</code> that describes this shaper. This method |
|
1252 |
* is used for debugging purposes only. |
|
1253 |
* @return a <code>String</code> describing this shaper. |
|
1254 |
*/ |
|
1255 |
public String toString() { |
|
1256 |
StringBuilder buf = new StringBuilder(super.toString()); |
|
1257 |
||
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1258 |
buf.append("[contextual:").append(isContextual()); |
2 | 1259 |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1260 |
String[] keyNames = null; |
2 | 1261 |
if (isContextual()) { |
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1262 |
buf.append(", context:"); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1263 |
buf.append(shapingRange == null ? Range.values()[key] : shapingRange); |
2 | 1264 |
} |
1265 |
||
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1266 |
if (rangeSet == null) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1267 |
buf.append(", range(s): "); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1268 |
boolean first = true; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1269 |
for (int i = 0; i < NUM_KEYS; ++i) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1270 |
if ((mask & (1 << i)) != 0) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1271 |
if (first) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1272 |
first = false; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1273 |
} else { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1274 |
buf.append(", "); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1275 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1276 |
buf.append(Range.values()[i]); |
2 | 1277 |
} |
1278 |
} |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1279 |
} else { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1280 |
buf.append(", range set: ").append(rangeSet); |
2 | 1281 |
} |
1282 |
buf.append(']'); |
|
1283 |
||
1284 |
return buf.toString(); |
|
1285 |
} |
|
1286 |
||
1287 |
/** |
|
1288 |
* Returns the index of the high bit in value (assuming le, actually |
|
1289 |
* power of 2 >= value). value must be positive. |
|
1290 |
*/ |
|
1291 |
private static int getHighBit(int value) { |
|
1292 |
if (value <= 0) { |
|
1293 |
return -32; |
|
1294 |
} |
|
1295 |
||
1296 |
int bit = 0; |
|
1297 |
||
1298 |
if (value >= 1 << 16) { |
|
1299 |
value >>= 16; |
|
1300 |
bit += 16; |
|
1301 |
} |
|
1302 |
||
1303 |
if (value >= 1 << 8) { |
|
1304 |
value >>= 8; |
|
1305 |
bit += 8; |
|
1306 |
} |
|
1307 |
||
1308 |
if (value >= 1 << 4) { |
|
1309 |
value >>= 4; |
|
1310 |
bit += 4; |
|
1311 |
} |
|
1312 |
||
1313 |
if (value >= 1 << 2) { |
|
1314 |
value >>= 2; |
|
1315 |
bit += 2; |
|
1316 |
} |
|
1317 |
||
1318 |
if (value >= 1 << 1) { |
|
1319 |
bit += 1; |
|
1320 |
} |
|
1321 |
||
1322 |
return bit; |
|
1323 |
} |
|
1324 |
||
1325 |
/** |
|
1326 |
* fast binary search over subrange of array. |
|
1327 |
*/ |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1328 |
private static int search(int value, int[] array, int start, int length) |
2 | 1329 |
{ |
1330 |
int power = 1 << getHighBit(length); |
|
1331 |
int extra = length - power; |
|
1332 |
int probe = power; |
|
1333 |
int index = start; |
|
1334 |
||
1335 |
if (value >= array[index + extra]) { |
|
1336 |
index += extra; |
|
1337 |
} |
|
1338 |
||
1339 |
while (probe > 1) { |
|
1340 |
probe >>= 1; |
|
1341 |
||
1342 |
if (value >= array[index + probe]) { |
|
1343 |
index += probe; |
|
1344 |
} |
|
1345 |
} |
|
1346 |
||
1347 |
return index; |
|
1348 |
} |
|
4280
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1349 |
|
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1350 |
/** |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1351 |
* Converts the {@code NumericShaper.Range} enum-based parameters, |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1352 |
* if any, to the bit mask-based counterparts and writes this |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1353 |
* object to the {@code stream}. Any enum constants that have no |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1354 |
* bit mask-based counterparts are ignored in the conversion. |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1355 |
* |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1356 |
* @param stream the output stream to write to |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1357 |
* @throws IOException if an I/O error occurs while writing to {@code stream} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1358 |
* @since 1.7 |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1359 |
*/ |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1360 |
private void writeObject(ObjectOutputStream stream) throws IOException { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1361 |
if (shapingRange != null) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1362 |
int index = Range.toRangeIndex(shapingRange); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1363 |
if (index >= 0) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1364 |
key = index; |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1365 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1366 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1367 |
if (rangeSet != null) { |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1368 |
mask |= Range.toRangeMask(rangeSet); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1369 |
} |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1370 |
stream.defaultWriteObject(); |
74c4e0c5d936
6842557: NumericShaper needs to be updated for Unicode 5.1 support
peytoia
parents:
2
diff
changeset
|
1371 |
} |
2 | 1372 |
} |