/** ******************************************************************************* * Copyright (C) 1996-2001, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* * * $Source: /xsrl/Nsvn/icu/unicodetools/com/ibm/text/UCA/WriteCharts.java,v $ * $Date: 2002/03/15 01:57:01 $ * $Revision: 1.4 $ * ******************************************************************************* */ package com.ibm.text.UCA; import java.util.*; import java.io.*; import com.ibm.text.UCD.*; import com.ibm.text.utility.*; import com.ibm.icu.text.UTF16; public class WriteCharts implements UCD_Types { static UCD ucd; static final byte UNSUPPORTED = 120; static public void test(UCA uca) throws IOException { uca.setAlternate(UCA.NON_IGNORABLE); ucd = UCD.make(); Normalizer nfd = new Normalizer(Normalizer.NFD); Normalizer nfc = new Normalizer(Normalizer.NFC); UCA.UCAContents cc = uca.getContents(UCA.FIXED_CE, null); // nfd instead of null if skipping decomps cc.enableSamples(); Set set = new TreeSet(); while (true) { String x = cc.next(); if (x == null) break; set.add(new Pair(uca.getSortKey(x), x)); } PrintWriter output = null; Iterator it = set.iterator(); byte oldScript = -127; int[] scriptCount = new int[128]; int counter = 0; int lastPrimary = -1; String lastSortKey = "\u0000"; int high = uca.getSortKey("a").charAt(0); int variable = UCA.getPrimary(uca.getVariableHigh()); int columnCount = 0; Utility.copyTextFile("index.html", true, "CollationCharts\\index.html"); Utility.copyTextFile("charts.css", false, "CollationCharts\\charts.css"); Utility.copyTextFile("help.html", true, "CollationCharts\\help.html"); indexFile = Utility.openPrintWriter("CollationCharts\\index_list.html"); Utility.appendFile("index_header.html", true, indexFile); /* indexFile.println("
"); indexFile.println("Help"); */ while (it.hasNext()) { Utility.dot(counter); Pair p = (Pair) it.next(); String sortKey = (String) p.first; String s = (String) p.second; int cp = UTF16.charAt(s,0); byte script = ucd.getScript(cp); // get first non-zero primary int primary = sortKey.charAt(0); if (sortKey.length() < 4) script = -3; else if (primary == 0) script = -2; else if (primary < variable) script = -1; else if (primary < high) script = COMMON_SCRIPT; else if (primary >= UCA.UNSUPPORTED_BASE) script = UNSUPPORTED; if (script == KATAKANA_SCRIPT) script = HIRAGANA_SCRIPT; else if ((script == INHERITED_SCRIPT || script == COMMON_SCRIPT) && oldScript >= 0) script = oldScript; if (script != oldScript // && (script != COMMON_SCRIPT && script != INHERITED_SCRIPT) ) { closeFile(output); output = null; oldScript = script; } if (output == null) { ++scriptCount[script+3]; if (scriptCount[script+3] > 1) { System.out.println("\t\tFAIL: " + scriptCount[script+3] + ", " + getChunkName(script) + ", " + ucd.getCodeAndName(s)); } output = openFile(scriptCount[script+3], script); } boolean firstPrimaryEquals = primary == lastSortKey.charAt(0); int strength = uca.strengthDifference(sortKey, lastSortKey); if (strength < 0) strength = -strength; lastSortKey = sortKey; // find out if this is an expansion: more than one primary weight int primaryCount = 0; for (int i = 0; i < sortKey.length(); ++i) { char w = sortKey.charAt(i); if (w == 0) break; ++ primaryCount; } String breaker = ""; if (columnCount > 10 || !firstPrimaryEquals) { if (!firstPrimaryEquals || script == UNSUPPORTED) breaker = "
Last Modified: " + new Date());
indexFile.println("
UCA Version: " + uca.getDataVersion());
indexFile.println("
UCD Version: " + ucd.getVersion());
indexFile.println("