United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4106263 RFE: API: java.text.CollationKey needs a public constructor
JDK-4106263 : RFE: API: java.text.CollationKey needs a public constructor

Details
Type:
Enhancement
Submit Date:
1998-01-23
Status:
Resolved
Updated Date:
2005-04-25
Project Name:
JDK
Resolved Date:
2005-04-25
Component:
core-libs
OS:
generic
Sub-Component:
java.text
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
1.1.5,5.0
Fixed Versions:

Related Reports

Sub Tasks

Description
Name: dgC58589			Date: 01/23/98


Hi,
I have written two new key Collators, one is a Soundex Collator the other a Metaphone Collator. Because CollationKey has not been declared with a public constructor, the only way I can get these classes to work is by placing them in the java.text package - not very desirable.
(Review ID: 23244)
======================================================================
###@###.### 11/2/04 18:17 GMT

                                    

Comments
SUGGESTED FIX

A better fix is to also make the CollationKey non-final.  Then a custom collator could generate its own CollationKey instances.  This would enable the workaround suggested in 4716407, as the caller could add their own field to the CollationKey subclass.

There seems to be little downside to these trivial changes.
###@###.### 2003-07-31
                                     
2003-07-31
EVALUATION

It is impossible for third parties to subclass Collator effectively-- for example, to support current Unicode collation standards-- as it is not possible to create CollationKeys as required by the API.  The only alternative is complete replacement of the Collator API.

There would be no impact of making the constructor public.  I also see little or no impact of making the class non-final.
###@###.### 2003-07-31
                                     
2003-07-31
WORK AROUND



Name: dgC58589			Date: 01/23/98


Could you please provide a method for instansiating a new CollationKey outside the java.text package. One way might be to have an additional abstract class in java.text.Collator like;

public abstract String generateKey(String source);

then change Collator::getCollationKey to;

public CollationKey getCollationKey(String s)
{
return new CollationKey(s, generateKey(s));
}

This way only derived classes can instansiate CollationKeys.
======================================================================
                                     
2004-08-06



Hardware and Software, Engineered to Work Together