001: /*
002: *******************************************************************************
003: * Copyright (C) 1998-2004, International Business Machines Corporation and *
004: * others. All Rights Reserved. *
005: *******************************************************************************
006: *
007: * Created on Apr 4, 2003
008: *
009: *******************************************************************************
010: */
011: package com.ibm.icu.dev.tool.layout;
012:
013: /**
014: * This class holds the list of languages.
015: *
016: * @author emader
017: *
018: */
019: public class LanguageData extends TagValueData {
020: public static class Record {
021: private String tag;
022: private String name;
023:
024: public Record(String tag, String name) {
025: this .tag = tag;
026: this .name = name;
027: }
028:
029: public String tag() {
030: return tag;
031: }
032:
033: public String name() {
034: return name;
035: }
036:
037: public String label() {
038: return TagUtilities.tagLabel(tag);
039: }
040:
041: public String makeTag() {
042: return TagUtilities.makeTag(tag);
043: }
044: }
045:
046: /*
047: * This is temporary data until there is some resolution between
048: * the OpenType language system tags and the ISO and RFC standards...
049: */
050: private Record[] languages = { new Record("", "null"),
051: new Record("ARA", "Arabic"), new Record("ASM", "Assamese"),
052: new Record("BEN", "Bengali"), new Record("FAR", "Farsi"),
053: new Record("GUJ", "Gujarati"), new Record("HIN", "Hindi"),
054: new Record("IWR", "Hebrew"), new Record("JII", "Yiddish"),
055: new Record("JAN", "Japanese"),
056: new Record("KAN", "Kannada"), new Record("KOK", "Konkani"),
057: new Record("KOR", "Korean"), new Record("KSH", "Kashmiri"),
058: new Record("MAL", "Malayalam (Traditional)"),
059: new Record("MAR", "Marathi"),
060: new Record("MLR", "Malayalam (Reformed)"),
061: new Record("MNI", "Manipuri"), new Record("ORI", "Oriya"),
062: new Record("SAN", "Sanscrit"), new Record("SND", "Sindhi"),
063: new Record("SNH", "Sinhalese"),
064: new Record("SYR", "Syriac"), new Record("TAM", "Tamil"),
065: new Record("TEL", "Telugu"), new Record("THA", "Thai"),
066: new Record("URD", "Urdu"),
067: new Record("ZHP", "Chinese (Phonetic)"),
068: new Record("ZHS", "Chinese (Simplified)"),
069: new Record("ZHT", "Chinese (Traditional)") };
070:
071: private int minLanguage = 0;
072: private int maxLanguage = minLanguage + languages.length - 1;
073:
074: public int getMinValue() {
075: return minLanguage;
076: }
077:
078: public int getMaxValue() {
079: return maxLanguage;
080: }
081:
082: public String getTag(int value) {
083: if (value < minLanguage || value > maxLanguage) {
084: return null;
085: }
086:
087: return languages[value - minLanguage].tag();
088: }
089:
090: public String getTagLabel(int value) {
091: if (value < minLanguage || value > maxLanguage) {
092: return null;
093: }
094:
095: return languages[value - minLanguage].label();
096: }
097:
098: public String makeTag(int value) {
099: if (value < minLanguage || value > maxLanguage) {
100: return null;
101: }
102:
103: return languages[value - minLanguage].makeTag();
104: }
105:
106: public String getName(int value) {
107: if (value < minLanguage || value > maxLanguage) {
108: return "(UNKNOWN)";
109: }
110:
111: return languages[value - minLanguage].name();
112: }
113: }
|