38 |
|
|
39 |
package java.text; |
package java.text; |
40 |
|
|
41 |
import java.util.Vector; |
import java.util.ArrayList; |
42 |
|
|
43 |
/* Written using "Java Class Libraries", 2nd edition, plus online |
/* Written using "Java Class Libraries", 2nd edition, plus online |
44 |
* API docs for JDK 1.2 from http://www.javasoft.com. |
* API docs for JDK 1.2 from http://www.javasoft.com. |
89 |
* Array containing the collation decomposition of the |
* Array containing the collation decomposition of the |
90 |
* text given to the constructor. |
* text given to the constructor. |
91 |
*/ |
*/ |
92 |
private Object[] text_decomposition; |
private RuleBasedCollator.CollationElement[] text_decomposition; |
93 |
|
|
94 |
/** |
/** |
95 |
* Array containing the index of the specified block. |
* Array containing the index of the specified block. |
116 |
if (index >= text_decomposition.length) |
if (index >= text_decomposition.length) |
117 |
return null; |
return null; |
118 |
|
|
119 |
RuleBasedCollator.CollationElement e = |
RuleBasedCollator.CollationElement e = text_decomposition[index]; |
|
(RuleBasedCollator.CollationElement) text_decomposition[index]; |
|
120 |
|
|
121 |
textIndex = text_indexes[index+1]; |
textIndex = text_indexes[index+1]; |
122 |
|
|
131 |
return null; |
return null; |
132 |
|
|
133 |
index--; |
index--; |
134 |
RuleBasedCollator.CollationElement e = |
RuleBasedCollator.CollationElement e = text_decomposition[index]; |
|
(RuleBasedCollator.CollationElement) text_decomposition[index]; |
|
135 |
|
|
136 |
textIndex = text_indexes[index+1]; |
textIndex = text_indexes[index+1]; |
137 |
|
|
245 |
|
|
246 |
String work_text = text.intern(); |
String work_text = text.intern(); |
247 |
|
|
248 |
Vector v = new Vector(); |
ArrayList a_element = new ArrayList(); |
249 |
Vector vi = new Vector(); |
ArrayList a_idx = new ArrayList(); |
250 |
|
|
251 |
// Build element collection ordered as they come in "text". |
// Build element collection ordered as they come in "text". |
252 |
while (idx < work_text.length()) |
while (idx < work_text.length()) |
299 |
RuleBasedCollator.CollationElement e = |
RuleBasedCollator.CollationElement e = |
300 |
collator.getDefaultAccentedElement (work_text.charAt (idx)); |
collator.getDefaultAccentedElement (work_text.charAt (idx)); |
301 |
|
|
302 |
v.add (e); |
a_element.add (e); |
303 |
vi.add (new Integer(idx_idx)); |
a_idx.add (new Integer(idx_idx)); |
304 |
idx++; |
idx++; |
305 |
alreadyExpanded--; |
alreadyExpanded--; |
306 |
if (alreadyExpanded == 0) |
if (alreadyExpanded == 0) |
324 |
/* Don't forget to mark it as a special sequence so the |
/* Don't forget to mark it as a special sequence so the |
325 |
* string can be ordered. |
* string can be ordered. |
326 |
*/ |
*/ |
327 |
v.add (RuleBasedCollator.SPECIAL_UNKNOWN_SEQ); |
a_element.add (RuleBasedCollator.SPECIAL_UNKNOWN_SEQ); |
328 |
vi.add (i_ref); |
a_idx.add (i_ref); |
329 |
v.add (e); |
a_element.add (e); |
330 |
vi.add (i_ref); |
a_idx.add (i_ref); |
331 |
idx_idx++; |
idx_idx++; |
332 |
idx++; |
idx++; |
333 |
} |
} |
344 |
work_text = prefix.expansion |
work_text = prefix.expansion |
345 |
+ work_text.substring (idx+prefix.key.length()); |
+ work_text.substring (idx+prefix.key.length()); |
346 |
idx = 0; |
idx = 0; |
347 |
v.add (prefix); |
a_element.add (prefix); |
348 |
vi.add (new Integer(idx_idx)); |
a_idx.add (new Integer(idx_idx)); |
349 |
if (alreadyExpanded == 0) |
if (alreadyExpanded == 0) |
350 |
idxToMove = prefix.key.length(); |
idxToMove = prefix.key.length(); |
351 |
alreadyExpanded += prefix.expansion.length()-prefix.key.length(); |
alreadyExpanded += prefix.expansion.length()-prefix.key.length(); |
355 |
/* Third case: the simplest. We have got the prefix and it |
/* Third case: the simplest. We have got the prefix and it |
356 |
* has not to be expanded. |
* has not to be expanded. |
357 |
*/ |
*/ |
358 |
v.add (prefix); |
a_element.add (prefix); |
359 |
vi.add (new Integer(idx_idx)); |
a_idx.add (new Integer(idx_idx)); |
360 |
idx += prefix.key.length(); |
idx += prefix.key.length(); |
361 |
/* If the sequence is in an expansion, we must decrease the |
/* If the sequence is in an expansion, we must decrease the |
362 |
* counter. |
* counter. |
374 |
} |
} |
375 |
} |
} |
376 |
|
|
377 |
text_decomposition = v.toArray(); |
text_decomposition = (RuleBasedCollator.CollationElement[]) |
378 |
text_indexes = new int[vi.size()+1]; |
a_element.toArray(new RuleBasedCollator.CollationElement[a_element.size()]); |
379 |
for (int i = 0; i < vi.size(); i++) |
text_indexes = new int[a_idx.size()+1]; |
380 |
|
for (int i = 0; i < a_idx.size(); i++) |
381 |
{ |
{ |
382 |
text_indexes[i] = ((Integer)vi.elementAt(i)).intValue(); |
text_indexes[i] = ((Integer)a_idx.get(i)).intValue(); |
383 |
} |
} |
384 |
text_indexes[vi.size()] = text.length(); |
text_indexes[a_idx.size()] = text.length(); |
385 |
} |
} |
386 |
|
|
387 |
/** |
/** |