mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 07:39:16 +00:00
ICU-19 Proposed API changes implementation
X-SVN-Rev: 6423
This commit is contained in:
parent
fdb5a592e1
commit
947b852232
10 changed files with 282 additions and 514 deletions
|
@ -43,9 +43,9 @@ public class TestUScript extends TestFmwk{
|
|||
int numErrors =0;
|
||||
|
||||
for( ; i<testNames.length; i++){
|
||||
int code = UScript.getCode(testNames[i]);
|
||||
if( code != expected[i]){
|
||||
logln("Error getting script code Got: " +code + " Expected: " +expected[i] +" for name "+testNames[i]);
|
||||
int[] code = UScript.getCode(testNames[i]);
|
||||
if( code[0] != expected[i]){
|
||||
logln("Error getting script code Got: " +code[0] + " Expected: " +expected[i] +" for name "+testNames[i]);
|
||||
numErrors++;
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,24 @@ public class TestUScript extends TestFmwk{
|
|||
errln("Number of Errors in UScript.getCode() : " + numErrors);
|
||||
}
|
||||
}
|
||||
|
||||
public void TestMultipleCode(){
|
||||
final String[] testNames = { "ja" ,"ko_KR","zh","zh_TW"};
|
||||
final int[][] expected = {
|
||||
{UScript.KATAKANA,UScript.HIRAGANA,UScript.HAN},
|
||||
{UScript.HANGUL, UScript.HAN},
|
||||
{UScript.HAN},
|
||||
{UScript.HAN,UScript.BOPOMOFO}
|
||||
};
|
||||
for(int i=0; i<testNames.length;i++){
|
||||
int[] code = UScript.getCode(testNames[i]);
|
||||
int[] expt = (int[]) expected[i];
|
||||
for(int j =0; j< code.length;j++){
|
||||
if(code[j]!=expt[j]){
|
||||
logln("Error getting script code Got: " +code[j] + " Expected: " +expt[j] +" for name "+testNames[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void TestGetCode(){
|
||||
|
||||
final String[] testNames={
|
||||
|
@ -101,9 +118,9 @@ public class TestUScript extends TestFmwk{
|
|||
int numErrors =0;
|
||||
|
||||
for( ; i<testNames.length; i++){
|
||||
int code = UScript.getCode(testNames[i]);
|
||||
if( code != expected[i]){
|
||||
logln("Error getting script code Got: " +code + " Expected: " +expected[i] +" for name "+testNames[i]);
|
||||
int[] code = UScript.getCode(testNames[i]);
|
||||
if( code[0] != expected[i]){
|
||||
logln("Error getting script code Got: " +code[0] + " Expected: " +expected[i] +" for name "+testNames[i]);
|
||||
numErrors++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.text.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
@ -16,399 +15,252 @@ public class LocaleScript extends ListResourceBundle {
|
|||
}
|
||||
|
||||
private static final Object[][] localeScript = new Object[][] {
|
||||
{"root", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
}
|
||||
},
|
||||
{"af", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
}
|
||||
},
|
||||
{"am", new String[] {
|
||||
"Ethiopic",
|
||||
"Ethi",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"ar", new String[] {
|
||||
"Arabic",
|
||||
"Arab",
|
||||
"ARAB",
|
||||
}
|
||||
},
|
||||
{"be", new String[] {
|
||||
"Cyrillic",
|
||||
"Cyrl",
|
||||
"Cyrs",
|
||||
"CYRL",
|
||||
}
|
||||
},
|
||||
{"bg", new String[] {
|
||||
"Cyrillic",
|
||||
"Cyrl",
|
||||
"Cyrs",
|
||||
}
|
||||
},
|
||||
{"bn", new String[] {
|
||||
"Bengali",
|
||||
"Beng",
|
||||
"CYRL",
|
||||
}
|
||||
},
|
||||
{"ca", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"cs", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"da", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"de", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"el", new String[] {
|
||||
"Greek",
|
||||
"Grek",
|
||||
"GREK",
|
||||
}
|
||||
},
|
||||
{"en", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"eo", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"es", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"et", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"eu", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"fa", new String[] {
|
||||
"Arabic",
|
||||
"Arab",
|
||||
"ARAB",
|
||||
}
|
||||
},
|
||||
{"fi", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"fo", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"fr", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"ga", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"gl", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"gv", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"he", new String[] {
|
||||
"Hebrew",
|
||||
"Hebr",
|
||||
"HEBR",
|
||||
}
|
||||
},
|
||||
{"hi", new String[] {
|
||||
"Devanagari",
|
||||
"Deva",
|
||||
"DEVA",
|
||||
}
|
||||
},
|
||||
{"hr", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"hu", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
}
|
||||
},
|
||||
{"hy", new String[] {
|
||||
"Armn",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"id", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"is", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"it", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"iw", new String[] {
|
||||
"Hebrew",
|
||||
"Hebr",
|
||||
"HEBR",
|
||||
}
|
||||
},
|
||||
{"ja", new String[] {
|
||||
"KANA",
|
||||
"HIRA",
|
||||
"HANI"
|
||||
}
|
||||
},
|
||||
{"kl", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"ko", new String[] {
|
||||
"HANG",
|
||||
"HANI",
|
||||
}
|
||||
},
|
||||
{"kok", new String[] {
|
||||
"Devanagari",
|
||||
"Deva",
|
||||
"DEVA",
|
||||
}
|
||||
},
|
||||
{"kw", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"lt", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"lv", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"mk", new String[] {
|
||||
"Cyrillic",
|
||||
"Cyrs",
|
||||
"CYRL",
|
||||
}
|
||||
},
|
||||
{"mr", new String[] {
|
||||
"Devanagari",
|
||||
"Deva",
|
||||
}
|
||||
},
|
||||
{"ms", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"DEVA",
|
||||
}
|
||||
},
|
||||
{"mt", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"nb", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"nl", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"nn", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"pl", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"pt", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"ro", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"ru", new String[] {
|
||||
"Cyrillic",
|
||||
"Cyrs",
|
||||
"CYRL",
|
||||
}
|
||||
},
|
||||
{"sh", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"sk", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"sl", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"sq", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"sr", new String[] {
|
||||
"Cyrillic",
|
||||
"Cyrs",
|
||||
"CYRL",
|
||||
}
|
||||
},
|
||||
{"sv", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"sw", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"ta", new String[] {
|
||||
"Tamil",
|
||||
"Taml",
|
||||
"TAML",
|
||||
}
|
||||
},
|
||||
{"te", new String[] {
|
||||
"Telugu",
|
||||
"Telu",
|
||||
"TELU",
|
||||
}
|
||||
},
|
||||
{"th", new String[] {
|
||||
"Thai",
|
||||
"Thai",
|
||||
"THAI",
|
||||
}
|
||||
},
|
||||
{"tr", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"uk", new String[] {
|
||||
"Cyrillic",
|
||||
"Cyrs",
|
||||
"CYRL",
|
||||
}
|
||||
},
|
||||
{"vi", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"zh", new String[] {
|
||||
"HANI",
|
||||
}
|
||||
},
|
||||
{"zh_TW", new String[] {
|
||||
"HANI",
|
||||
"BOPO",
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -20,7 +20,12 @@ import com.ibm.text.UCharacter;
|
|||
* Scripts.txt.
|
||||
*/
|
||||
public final class UScript {
|
||||
|
||||
/**
|
||||
* Puts a copyright in the .class file
|
||||
*/
|
||||
private static final String copyrightNotice
|
||||
= "Copyright \u00a92001 IBM Corp. All rights reserved.";
|
||||
|
||||
public static final int INVALID_CODE = -1;
|
||||
public static final int COMMON = 0; /* Zyyy */
|
||||
public static final int INHERITED = 1; /* Qaai */
|
||||
|
@ -250,7 +255,7 @@ public final class UScript {
|
|||
INHERITED ,
|
||||
RUNIC ,
|
||||
SINHALA ,
|
||||
SYRIAC ,
|
||||
/* SYRIAC , */
|
||||
/* SYRIAC , */
|
||||
/* SYRIAC , */
|
||||
SYRIAC ,
|
||||
|
@ -763,21 +768,30 @@ public final class UScript {
|
|||
|
||||
private static final String localeScript = "com.ibm.text.resources.LocaleScript";
|
||||
|
||||
private static int findCodeFromLocale(Locale locale)
|
||||
private static int[] findCodeFromLocale(Locale locale)
|
||||
throws MissingResourceException{
|
||||
//TODO: Currently we use a hacked fallback mechanism.
|
||||
//Should be changed once ICU4J bundles locale data
|
||||
//with the distribution
|
||||
int code = INVALID_CODE;
|
||||
int[] code = new int[1];
|
||||
code[0] = INVALID_CODE;
|
||||
|
||||
ResourceBundle resB = ResourceBundle.getBundle(localeScript);
|
||||
String temp = locale.toString();
|
||||
do{
|
||||
while(true){
|
||||
try{
|
||||
String[] scriptArray = resB.getStringArray(temp);
|
||||
int strIndex = findStringIndex(scriptNames,scriptArray[0]);
|
||||
if(strIndex>=0 && strIndex < scriptAbbr.length){
|
||||
code = scriptNameCodes[strIndex];
|
||||
code = new int[scriptArray.length];
|
||||
for(int i= 0; i< scriptArray.length ;i++){
|
||||
int strIndex = findStringIndex(scriptAbbr,scriptArray[i]);
|
||||
|
||||
if(strIndex>=0 && strIndex < scriptAbbr.length){
|
||||
code[i] = scriptAbbrCodes[strIndex];
|
||||
}else{
|
||||
code[i] = INVALID_CODE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}catch(MissingResourceException e){
|
||||
|
||||
/* handle fallback */
|
||||
|
@ -789,7 +803,7 @@ public final class UScript {
|
|||
}
|
||||
continue;
|
||||
}
|
||||
}while(code==INVALID_CODE);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -834,7 +848,7 @@ public final class UScript {
|
|||
* @exception IllegalArgumentException, MissingResourceException
|
||||
* @draft
|
||||
*/
|
||||
public static final int getCode(Locale locale)
|
||||
public static final int[] getCode(Locale locale)
|
||||
throws IllegalArgumentException, MissingResourceException{
|
||||
return findCodeFromLocale(locale);
|
||||
}
|
||||
|
@ -848,27 +862,28 @@ public final class UScript {
|
|||
* @exception IllegalArgumentException, MissingResourceException
|
||||
* @draft
|
||||
*/
|
||||
public static final int getCode(String nameOrAbbrOrLocale)
|
||||
public static final int[] getCode(String nameOrAbbrOrLocale)
|
||||
throws IllegalArgumentException, MissingResourceException{
|
||||
|
||||
int code = INVALID_CODE;
|
||||
int[] code = new int[1];
|
||||
code[0] = INVALID_CODE;
|
||||
int strIndex=0;
|
||||
|
||||
/* try the Names array first */
|
||||
strIndex = findStringIndex(scriptNames, nameOrAbbrOrLocale);
|
||||
|
||||
if(strIndex>=0 && strIndex < scriptNames.length){
|
||||
code = scriptNameCodes[strIndex];
|
||||
code[0] = scriptNameCodes[strIndex];
|
||||
}
|
||||
/* we did not find in names array so try abbr array*/
|
||||
if(code == INVALID_CODE){
|
||||
if(code[0] == INVALID_CODE){
|
||||
strIndex = findStringIndex(scriptAbbr, nameOrAbbrOrLocale);
|
||||
if(strIndex>=0 && strIndex < scriptAbbr.length){
|
||||
code = scriptAbbrCodes[strIndex];
|
||||
code[0] = scriptAbbrCodes[strIndex];
|
||||
}
|
||||
}
|
||||
/* we still haven't found it try locale */
|
||||
if(code==INVALID_CODE){
|
||||
if(code[0]==INVALID_CODE){
|
||||
code = findCodeFromLocale(new Locale(nameOrAbbrOrLocale,""));
|
||||
}
|
||||
return code;
|
||||
|
|
|
@ -43,9 +43,9 @@ public class TestUScript extends TestFmwk{
|
|||
int numErrors =0;
|
||||
|
||||
for( ; i<testNames.length; i++){
|
||||
int code = UScript.getCode(testNames[i]);
|
||||
if( code != expected[i]){
|
||||
logln("Error getting script code Got: " +code + " Expected: " +expected[i] +" for name "+testNames[i]);
|
||||
int[] code = UScript.getCode(testNames[i]);
|
||||
if( code[0] != expected[i]){
|
||||
logln("Error getting script code Got: " +code[0] + " Expected: " +expected[i] +" for name "+testNames[i]);
|
||||
numErrors++;
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,24 @@ public class TestUScript extends TestFmwk{
|
|||
errln("Number of Errors in UScript.getCode() : " + numErrors);
|
||||
}
|
||||
}
|
||||
|
||||
public void TestMultipleCode(){
|
||||
final String[] testNames = { "ja" ,"ko_KR","zh","zh_TW"};
|
||||
final int[][] expected = {
|
||||
{UScript.KATAKANA,UScript.HIRAGANA,UScript.HAN},
|
||||
{UScript.HANGUL, UScript.HAN},
|
||||
{UScript.HAN},
|
||||
{UScript.HAN,UScript.BOPOMOFO}
|
||||
};
|
||||
for(int i=0; i<testNames.length;i++){
|
||||
int[] code = UScript.getCode(testNames[i]);
|
||||
int[] expt = (int[]) expected[i];
|
||||
for(int j =0; j< code.length;j++){
|
||||
if(code[j]!=expt[j]){
|
||||
logln("Error getting script code Got: " +code[j] + " Expected: " +expt[j] +" for name "+testNames[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void TestGetCode(){
|
||||
|
||||
final String[] testNames={
|
||||
|
@ -101,9 +118,9 @@ public class TestUScript extends TestFmwk{
|
|||
int numErrors =0;
|
||||
|
||||
for( ; i<testNames.length; i++){
|
||||
int code = UScript.getCode(testNames[i]);
|
||||
if( code != expected[i]){
|
||||
logln("Error getting script code Got: " +code + " Expected: " +expected[i] +" for name "+testNames[i]);
|
||||
int[] code = UScript.getCode(testNames[i]);
|
||||
if( code[0] != expected[i]){
|
||||
logln("Error getting script code Got: " +code[0] + " Expected: " +expected[i] +" for name "+testNames[i]);
|
||||
numErrors++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,9 +117,9 @@ class TransliteratorRegistry {
|
|||
}
|
||||
|
||||
// Canonicalize script name -or- do locale->script mapping
|
||||
int s = UScript.getCode(top);
|
||||
if (s != UScript.INVALID_CODE) {
|
||||
scriptName = UScript.getName(s);
|
||||
int[] s = UScript.getCode(top);
|
||||
if (s[0] != UScript.INVALID_CODE) {
|
||||
scriptName = UScript.getName(s[0]);
|
||||
}
|
||||
|
||||
// assert(spec != top);
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/Attic/UnicodePropertySet.java,v $
|
||||
* $Date: 2001/10/22 05:36:25 $
|
||||
* $Revision: 1.2 $
|
||||
* $Date: 2001/10/25 02:23:53 $
|
||||
* $Revision: 1.3 $
|
||||
**********************************************************************
|
||||
*/
|
||||
package com.ibm.text;
|
||||
|
@ -52,7 +52,7 @@ import com.ibm.util.Utility;
|
|||
* '+' indicates a supported property.
|
||||
*
|
||||
* @author Alan Liu
|
||||
* @version $RCSfile: UnicodePropertySet.java,v $ $Revision: 1.2 $ $Date: 2001/10/22 05:36:25 $
|
||||
* @version $RCSfile: UnicodePropertySet.java,v $ $Revision: 1.3 $ $Date: 2001/10/25 02:23:53 $
|
||||
*/
|
||||
class UnicodePropertySet {
|
||||
|
||||
|
@ -264,12 +264,12 @@ class UnicodePropertySet {
|
|||
* @param valueName a pre-munged script value name
|
||||
*/
|
||||
private static UnicodeSet createScriptSet(String valueName) {
|
||||
int script = UScript.getCode(valueName);
|
||||
if (script == UScript.INVALID_CODE) {
|
||||
int[] script = UScript.getCode(valueName);
|
||||
if (script[0] == UScript.INVALID_CODE) {
|
||||
// Syntax error; unknown short name
|
||||
return null;
|
||||
}
|
||||
return new UnicodeSet(getScriptSet(script));
|
||||
return new UnicodeSet(getScriptSet(script[0]));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
|
|
@ -117,9 +117,9 @@ class TransliteratorRegistry {
|
|||
}
|
||||
|
||||
// Canonicalize script name -or- do locale->script mapping
|
||||
int s = UScript.getCode(top);
|
||||
if (s != UScript.INVALID_CODE) {
|
||||
scriptName = UScript.getName(s);
|
||||
int[] s = UScript.getCode(top);
|
||||
if (s[0] != UScript.INVALID_CODE) {
|
||||
scriptName = UScript.getName(s[0]);
|
||||
}
|
||||
|
||||
// assert(spec != top);
|
||||
|
|
|
@ -20,7 +20,12 @@ import com.ibm.text.UCharacter;
|
|||
* Scripts.txt.
|
||||
*/
|
||||
public final class UScript {
|
||||
|
||||
/**
|
||||
* Puts a copyright in the .class file
|
||||
*/
|
||||
private static final String copyrightNotice
|
||||
= "Copyright \u00a92001 IBM Corp. All rights reserved.";
|
||||
|
||||
public static final int INVALID_CODE = -1;
|
||||
public static final int COMMON = 0; /* Zyyy */
|
||||
public static final int INHERITED = 1; /* Qaai */
|
||||
|
@ -250,7 +255,7 @@ public final class UScript {
|
|||
INHERITED ,
|
||||
RUNIC ,
|
||||
SINHALA ,
|
||||
SYRIAC ,
|
||||
/* SYRIAC , */
|
||||
/* SYRIAC , */
|
||||
/* SYRIAC , */
|
||||
SYRIAC ,
|
||||
|
@ -763,21 +768,30 @@ public final class UScript {
|
|||
|
||||
private static final String localeScript = "com.ibm.text.resources.LocaleScript";
|
||||
|
||||
private static int findCodeFromLocale(Locale locale)
|
||||
private static int[] findCodeFromLocale(Locale locale)
|
||||
throws MissingResourceException{
|
||||
//TODO: Currently we use a hacked fallback mechanism.
|
||||
//Should be changed once ICU4J bundles locale data
|
||||
//with the distribution
|
||||
int code = INVALID_CODE;
|
||||
int[] code = new int[1];
|
||||
code[0] = INVALID_CODE;
|
||||
|
||||
ResourceBundle resB = ResourceBundle.getBundle(localeScript);
|
||||
String temp = locale.toString();
|
||||
do{
|
||||
while(true){
|
||||
try{
|
||||
String[] scriptArray = resB.getStringArray(temp);
|
||||
int strIndex = findStringIndex(scriptNames,scriptArray[0]);
|
||||
if(strIndex>=0 && strIndex < scriptAbbr.length){
|
||||
code = scriptNameCodes[strIndex];
|
||||
code = new int[scriptArray.length];
|
||||
for(int i= 0; i< scriptArray.length ;i++){
|
||||
int strIndex = findStringIndex(scriptAbbr,scriptArray[i]);
|
||||
|
||||
if(strIndex>=0 && strIndex < scriptAbbr.length){
|
||||
code[i] = scriptAbbrCodes[strIndex];
|
||||
}else{
|
||||
code[i] = INVALID_CODE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}catch(MissingResourceException e){
|
||||
|
||||
/* handle fallback */
|
||||
|
@ -789,7 +803,7 @@ public final class UScript {
|
|||
}
|
||||
continue;
|
||||
}
|
||||
}while(code==INVALID_CODE);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -834,7 +848,7 @@ public final class UScript {
|
|||
* @exception IllegalArgumentException, MissingResourceException
|
||||
* @draft
|
||||
*/
|
||||
public static final int getCode(Locale locale)
|
||||
public static final int[] getCode(Locale locale)
|
||||
throws IllegalArgumentException, MissingResourceException{
|
||||
return findCodeFromLocale(locale);
|
||||
}
|
||||
|
@ -848,27 +862,28 @@ public final class UScript {
|
|||
* @exception IllegalArgumentException, MissingResourceException
|
||||
* @draft
|
||||
*/
|
||||
public static final int getCode(String nameOrAbbrOrLocale)
|
||||
public static final int[] getCode(String nameOrAbbrOrLocale)
|
||||
throws IllegalArgumentException, MissingResourceException{
|
||||
|
||||
int code = INVALID_CODE;
|
||||
int[] code = new int[1];
|
||||
code[0] = INVALID_CODE;
|
||||
int strIndex=0;
|
||||
|
||||
/* try the Names array first */
|
||||
strIndex = findStringIndex(scriptNames, nameOrAbbrOrLocale);
|
||||
|
||||
if(strIndex>=0 && strIndex < scriptNames.length){
|
||||
code = scriptNameCodes[strIndex];
|
||||
code[0] = scriptNameCodes[strIndex];
|
||||
}
|
||||
/* we did not find in names array so try abbr array*/
|
||||
if(code == INVALID_CODE){
|
||||
if(code[0] == INVALID_CODE){
|
||||
strIndex = findStringIndex(scriptAbbr, nameOrAbbrOrLocale);
|
||||
if(strIndex>=0 && strIndex < scriptAbbr.length){
|
||||
code = scriptAbbrCodes[strIndex];
|
||||
code[0] = scriptAbbrCodes[strIndex];
|
||||
}
|
||||
}
|
||||
/* we still haven't found it try locale */
|
||||
if(code==INVALID_CODE){
|
||||
if(code[0]==INVALID_CODE){
|
||||
code = findCodeFromLocale(new Locale(nameOrAbbrOrLocale,""));
|
||||
}
|
||||
return code;
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/text/Attic/UnicodePropertySet.java,v $
|
||||
* $Date: 2001/10/22 05:36:25 $
|
||||
* $Revision: 1.2 $
|
||||
* $Date: 2001/10/25 02:23:53 $
|
||||
* $Revision: 1.3 $
|
||||
**********************************************************************
|
||||
*/
|
||||
package com.ibm.text;
|
||||
|
@ -52,7 +52,7 @@ import com.ibm.util.Utility;
|
|||
* '+' indicates a supported property.
|
||||
*
|
||||
* @author Alan Liu
|
||||
* @version $RCSfile: UnicodePropertySet.java,v $ $Revision: 1.2 $ $Date: 2001/10/22 05:36:25 $
|
||||
* @version $RCSfile: UnicodePropertySet.java,v $ $Revision: 1.3 $ $Date: 2001/10/25 02:23:53 $
|
||||
*/
|
||||
class UnicodePropertySet {
|
||||
|
||||
|
@ -264,12 +264,12 @@ class UnicodePropertySet {
|
|||
* @param valueName a pre-munged script value name
|
||||
*/
|
||||
private static UnicodeSet createScriptSet(String valueName) {
|
||||
int script = UScript.getCode(valueName);
|
||||
if (script == UScript.INVALID_CODE) {
|
||||
int[] script = UScript.getCode(valueName);
|
||||
if (script[0] == UScript.INVALID_CODE) {
|
||||
// Syntax error; unknown short name
|
||||
return null;
|
||||
}
|
||||
return new UnicodeSet(getScriptSet(script));
|
||||
return new UnicodeSet(getScriptSet(script[0]));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.text.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
@ -16,399 +15,252 @@ public class LocaleScript extends ListResourceBundle {
|
|||
}
|
||||
|
||||
private static final Object[][] localeScript = new Object[][] {
|
||||
{"root", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
}
|
||||
},
|
||||
{"af", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
}
|
||||
},
|
||||
{"am", new String[] {
|
||||
"Ethiopic",
|
||||
"Ethi",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"ar", new String[] {
|
||||
"Arabic",
|
||||
"Arab",
|
||||
"ARAB",
|
||||
}
|
||||
},
|
||||
{"be", new String[] {
|
||||
"Cyrillic",
|
||||
"Cyrl",
|
||||
"Cyrs",
|
||||
"CYRL",
|
||||
}
|
||||
},
|
||||
{"bg", new String[] {
|
||||
"Cyrillic",
|
||||
"Cyrl",
|
||||
"Cyrs",
|
||||
}
|
||||
},
|
||||
{"bn", new String[] {
|
||||
"Bengali",
|
||||
"Beng",
|
||||
"CYRL",
|
||||
}
|
||||
},
|
||||
{"ca", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"cs", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"da", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"de", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"el", new String[] {
|
||||
"Greek",
|
||||
"Grek",
|
||||
"GREK",
|
||||
}
|
||||
},
|
||||
{"en", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"eo", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"es", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"et", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"eu", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"fa", new String[] {
|
||||
"Arabic",
|
||||
"Arab",
|
||||
"ARAB",
|
||||
}
|
||||
},
|
||||
{"fi", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"fo", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"fr", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"ga", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"gl", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"gv", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"he", new String[] {
|
||||
"Hebrew",
|
||||
"Hebr",
|
||||
"HEBR",
|
||||
}
|
||||
},
|
||||
{"hi", new String[] {
|
||||
"Devanagari",
|
||||
"Deva",
|
||||
"DEVA",
|
||||
}
|
||||
},
|
||||
{"hr", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"hu", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
}
|
||||
},
|
||||
{"hy", new String[] {
|
||||
"Armn",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"id", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"is", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"it", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"iw", new String[] {
|
||||
"Hebrew",
|
||||
"Hebr",
|
||||
"HEBR",
|
||||
}
|
||||
},
|
||||
{"ja", new String[] {
|
||||
"KANA",
|
||||
"HIRA",
|
||||
"HANI"
|
||||
}
|
||||
},
|
||||
{"kl", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"ko", new String[] {
|
||||
"HANG",
|
||||
"HANI",
|
||||
}
|
||||
},
|
||||
{"kok", new String[] {
|
||||
"Devanagari",
|
||||
"Deva",
|
||||
"DEVA",
|
||||
}
|
||||
},
|
||||
{"kw", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"lt", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"lv", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"mk", new String[] {
|
||||
"Cyrillic",
|
||||
"Cyrs",
|
||||
"CYRL",
|
||||
}
|
||||
},
|
||||
{"mr", new String[] {
|
||||
"Devanagari",
|
||||
"Deva",
|
||||
}
|
||||
},
|
||||
{"ms", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"DEVA",
|
||||
}
|
||||
},
|
||||
{"mt", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"nb", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"nl", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"nn", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"pl", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"pt", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"ro", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"ru", new String[] {
|
||||
"Cyrillic",
|
||||
"Cyrs",
|
||||
"CYRL",
|
||||
}
|
||||
},
|
||||
{"sh", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"sk", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"sl", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"sq", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"sr", new String[] {
|
||||
"Cyrillic",
|
||||
"Cyrs",
|
||||
"CYRL",
|
||||
}
|
||||
},
|
||||
{"sv", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"sw", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"ta", new String[] {
|
||||
"Tamil",
|
||||
"Taml",
|
||||
"TAML",
|
||||
}
|
||||
},
|
||||
{"te", new String[] {
|
||||
"Telugu",
|
||||
"Telu",
|
||||
"TELU",
|
||||
}
|
||||
},
|
||||
{"th", new String[] {
|
||||
"Thai",
|
||||
"Thai",
|
||||
"THAI",
|
||||
}
|
||||
},
|
||||
{"tr", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"uk", new String[] {
|
||||
"Cyrillic",
|
||||
"Cyrs",
|
||||
"CYRL",
|
||||
}
|
||||
},
|
||||
{"vi", new String[] {
|
||||
"Latin",
|
||||
"Latn",
|
||||
"Latf",
|
||||
"Latg",
|
||||
"LATN",
|
||||
}
|
||||
},
|
||||
{"zh", new String[] {
|
||||
"HANI",
|
||||
}
|
||||
},
|
||||
{"zh_TW", new String[] {
|
||||
"HANI",
|
||||
"BOPO",
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue