001: /*
002: *******************************************************************************
003: * Copyright (C) 1998-2006, International Business Machines Corporation and *
004: * others. All Rights Reserved. *
005: *******************************************************************************
006: */
007: package com.ibm.icu.dev.tool.layout;
008:
009: import com.ibm.icu.text.MessageFormat;
010: import com.ibm.icu.util.VersionInfo;
011:
012: public class ScriptIDModuleWriter extends ScriptModuleWriter {
013: public ScriptIDModuleWriter(ScriptData scriptData,
014: LanguageData languageData) {
015: super (scriptData, languageData);
016: }
017:
018: public void writeScriptHeader(String fileName) {
019: int minScript = scriptData.getMinValue();
020: int maxScript = scriptData.getMaxValue();
021: int verMajor = VersionInfo.ICU_VERSION.getMajor();
022: int verMinor = VersionInfo.ICU_VERSION.getMinor();
023:
024: openFile(fileName);
025: writeHeader("__LESCRIPTS_H", includeFiles, scriptBrief);
026:
027: MessageFormat format = new MessageFormat(scriptPreamble);
028: Object args[] = { new Integer(verMajor), new Integer(verMinor) };
029:
030: output.println(format.format(args));
031:
032: for (int script = minScript; script <= maxScript; script += 1) {
033: output.print(" ");
034: output.print(scriptData.getTagLabel(script));
035: output.print("ScriptCode = ");
036:
037: if (script < 10) {
038: output.print(" ");
039: }
040:
041: output.print(script);
042: output.println(",");
043: }
044:
045: output.println();
046: output.print(" scriptCodeCount = ");
047: output.println(maxScript - minScript + 1);
048:
049: output.println(postamble);
050:
051: writeTrailer();
052: closeFile();
053: }
054:
055: public void writeLanguageHeader(String fileName) {
056: int minLanguage = languageData.getMinValue();
057: int maxLanguage = languageData.getMaxValue();
058: int verMajor = VersionInfo.ICU_VERSION.getMajor();
059: int verMinor = VersionInfo.ICU_VERSION.getMinor();
060:
061: openFile(fileName);
062: writeHeader("__LELANGUAGES_H", includeFiles, languageBrief);
063:
064: MessageFormat format = new MessageFormat(languagePreamble);
065: Object args[] = { new Integer(verMajor), new Integer(verMinor) };
066:
067: output.println(format.format(args));
068:
069: for (int language = minLanguage; language <= maxLanguage; language += 1) {
070: output.print(" ");
071: output.print(languageData.getTagLabel(language)
072: .toLowerCase());
073: output.print("LanguageCode = ");
074:
075: if (language < 10) {
076: output.print(" ");
077: }
078:
079: output.print(language);
080: output.println(",");
081: }
082:
083: output.println();
084: output.print(" languageCodeCount = ");
085: output.println(maxLanguage - minLanguage + 1);
086:
087: output.println(postamble);
088:
089: writeTrailer();
090: closeFile();
091: }
092:
093: private static final String[] includeFiles = { "LETypes.h" };
094:
095: private static final String scriptPreamble = "/**\n"
096: + " * Constants for Unicode script values, generated using\n"
097: + " * ICU4J''s <code>UScript</code> class.\n" + " *\n"
098: + " * @draft ICU {0}.{1}\n" + " */\n" + "\n"
099: + "enum ScriptCodes '{'";
100:
101: private static final String scriptBrief = "/**\n"
102: + " * \\file\n"
103: + " * \\brief C++ API: Constants for Unicode script values\n"
104: + " */\n" + "\n";
105:
106: private static final String languagePreamble = "/**\n"
107: + " * A provisional list of language codes. For now,\n"
108: + " * this is just a list of languages which the LayoutEngine\n"
109: + " * supports.\n" + " *\n" + " * @draft ICU {0}.{1}\n"
110: + " */\n" + "\n" + "enum LanguageCodes '{'";
111:
112: private static final String languageBrief = "/**\n"
113: + " * \\file\n"
114: + " * \\brief C++ API: List of language codes for LayoutEngine\n"
115: + " */\n" + "\n";
116:
117: private static final String postamble = "};\n";
118: }
|