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