ICU4J API proposal: add getLocale method to locale based services
Vladimir Weinstein <[email protected]> Tue, 11 Nov 2003 17:38:15 -0800
| Newsgroups | gmane.comp.lib.icu.general |
|---|---|
| Message-ID | <[email protected]> |
Expiration: 11/18/2003
Please refer to the previous message regarding getLocale, titled:
"API addition proposal: getLocale APIs for locale driven services"
Java requires several changes:
- In ICU4J 3.0, we are going to add the ULocale class, which will allow us to
support keywords in locales. I propose to make this addition early. This class
will currently have a Locale object and the only method implemented will be
Locale toLocale(); which will return the Locale object. The motivation is that
we will work completely through the ULocale object and if we add the getLocale
methods now, we will come in a situation where we would have overloads that
differ only in the return type, which is not good. This class also defines the
constants required for getLocale API.
package com.ibm.icu.util;
public class ULocale {
public static final class ULocaleDataType{
/**
* Actual locale where data is coming from
* @draft ICU 2.8
*/
public static final ULocaleDataType ACTUAL_LOCALE =
new ULocaleDataType(0);
/**
* Valid locale for an object
* @draft ICU 2.8
*/
public static final ULocaleDataType VALID_LOCALE =
new ULocaleDataType(1);
private int localeType;
private ULocaleDataType(int id){
localeType = id;
}
private boolean equals(int id){
return localeType == id;
}
}
private Locale locale;
public Locale toLocale() {
return locale;
}
public ULocale(Locale loc) {
locale = loc;
}
}
- since we cannot add methods to the base Format class, it will be inherited by
UFormat class - this will be the parent for all the ICU4J formatting classes.
package com.ibm.icu.text;
public abstract class UFormat extends Format {
public abstract ULocale getLocale(ULocale.ULocaleDataType type);
}
- all the classes that were inheriting from Format will implement getLocale
- we will also add the following:
com.ibm.icu.text.BreakIterator:
public abstract ULocale getLocale(ULocale.ULocaleDataType type);
com.ibm.icu.util.Calendar:
public abstract ULocale getLocale(ULocale.ULocaleDataType type);
com.ibm.icu.util.Collator:
public abstract ULocale getLocale(ULocale.ULocaleDataType type);
Thank you!
Regards,
v.
--
Vladimir Weinstein, IBM GCoC-Unicode/ICU San Jose, CA [email protected]