United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6373053 : [Coll] Doc: RuleBasedCollator API doc shouldn't assume the Collator.getInstance return type

Details
Type:
Bug
Submit Date:
2006-01-17
Status:
Resolved
Updated Date:
2010-07-29
Project Name:
JDK
Resolved Date:
2006-03-14
Component:
core-libs
OS:
generic
Sub-Component:
java.text
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
1.1
Fixed Versions:

Related Reports

Sub Tasks

Description
The following code samples cast the return value from the Collator factory to RuleBasedCollator. However, it's not the factory method spec to return a RuleBasedCollator.
 
// Create an en_US Collator object
 RuleBasedCollator en_USCollator = (RuleBasedCollator)
     Collator.getInstance(new Locale("en", "US", ""));
 // Create a da_DK Collator object
 RuleBasedCollator da_DKCollator = (RuleBasedCollator)
     Collator.getInstance(new Locale("da", "DK", ""));
 // Combine the two
 // First, get the collation rules from en_USCollator
 String en_USRules = en_USCollator.getRules();
 // Second, get the collation rules from da_DKCollator
 String da_DKRules = da_DKCollator.getRules();
 RuleBasedCollator newCollator =
     new RuleBasedCollator(en_USRules + da_DKRules);
 // newCollator has the combined rules


 // get en_US Collator rules
 RuleBasedCollator en_USCollator = (RuleBasedCollator)Collator.getInstance(Locale.US);
 // add a few Japanese character to sort before English characters
 // suppose the last character before the first base letter 'a' in
 // the English collation rule is \u2212
 String jaString = "& \u2212 < \u3041, \u3042 < \u3043, \u3044";
 RuleBasedCollator myJapaneseCollator = new
     RuleBasedCollator(en_USCollator.getRules() + jaString);

                                    

Comments
EVALUATION

In addition, the following description must be removed.

    Normally, to create a rule-based Collator object, you will use 
    Collator's factory method getInstance.
                                     
2006-02-28



Hardware and Software, Engineered to Work Together