diff --git a/icu4j/src/com/ibm/icu/dev/tool/cldr/LDML2ICUConverter.java b/icu4j/src/com/ibm/icu/dev/tool/cldr/LDML2ICUConverter.java index b19fb5f29a..989d2b095e 100644 --- a/icu4j/src/com/ibm/icu/dev/tool/cldr/LDML2ICUConverter.java +++ b/icu4j/src/com/ibm/icu/dev/tool/cldr/LDML2ICUConverter.java @@ -1388,7 +1388,6 @@ public class LDML2ICUConverter { }else if( name.equals(LDMLConstants.ERA)){ map.put(type, val); }else{ - System.err.println("Encountered unknown element: "+name); System.exit(-1); } diff --git a/icu4j/src/com/ibm/icu/dev/tool/cldr/LDMLComparator.java b/icu4j/src/com/ibm/icu/dev/tool/cldr/LDMLComparator.java index a9ba6be869..12b9078fc0 100644 --- a/icu4j/src/com/ibm/icu/dev/tool/cldr/LDMLComparator.java +++ b/icu4j/src/com/ibm/icu/dev/tool/cldr/LDMLComparator.java @@ -17,29 +17,13 @@ import java.io.*; import java.util.*; import java.io.PrintWriter; import java.io.File; -import java.io.FileReader; -import java.io.BufferedReader; import java.util.Calendar; -//import java.util.Locale; // DOM imports -import org.w3c.dom.Attr; import org.w3c.dom.Document; -import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.NodeList; -import org.w3c.dom.Text; - -// Needed JAXP classes -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -// SAX2 imports -import org.xml.sax.ErrorHandler; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; import com.ibm.icu.text.Normalizer; import com.ibm.icu.util.ULocale; @@ -52,21 +36,24 @@ public class LDMLComparator { * conforming to localeElements.dtd and produces an xml file file * in the format */ - private static final short OPT_SUN_JDK = 0x001; /*2exp0*/ - private static final short OPT_IBM_JDK = 0x002; /*2exp1*/ - private static final short OPT_WINDOWS = 0x004; /*2exp2*/ - private static final short OPT_HP_UX = 0x008; /*2exp3*/ - private static final short OPT_SOLARIS = 0x010; /*2exp4*/ - private static final short OPT_IBM_TOR = 0x020; /*2exp5*/ - private static final short OPT_APPLE = 0x040; /*2exp6*/ - private static final short OPT_ICU = 0x080; /*2exp7*/ - private static final short OPT_OTHER = 0x100; /*2exp8*/ - private static final short OPT_SOURCE = 0x200; /*2exp9*/ - private static final short OPT_DEST = 0x400; /*2exp10*/ - private static final short OPT_LINUX = 0x800; /*2exp11*/ - private static final short OPT_AIX = 0x1000; /*2exp12*/ - private static final short OPT_COMMON = 0x2000; /*2exp13*/ - private static final short OPT_UNKNOWN = 0x4000; /*2exp15*/ + private static final int OPT_SUN_JDK = 0x001; /*2exp0*/ + private static final int OPT_IBM_JDK = 0x002; /*2exp1*/ + private static final int OPT_WINDOWS = 0x004; /*2exp2*/ + private static final int OPT_HP_UX = 0x008; /*2exp3*/ + private static final int OPT_SOLARIS = 0x010; /*2exp4*/ + private static final int OPT_IBM_TOR = 0x020; /*2exp5*/ + private static final int OPT_APPLE = 0x040; /*2exp6*/ + private static final int OPT_ICU = 0x080; /*2exp7*/ + private static final int OPT_OTHER = 0x100; /*2exp8*/ + private static final int OPT_SOURCE = 0x200; /*2exp9*/ + private static final int OPT_DEST = 0x400; /*2exp10*/ + private static final int OPT_LINUX = 0x800; /*2exp11*/ + private static final int OPT_AIX = 0x1000; /*2exp12*/ + private static final int OPT_COMMON = 0x2000; /*2exp13*/ + private static final int OPT_DIFF = 0x4000; /*2exp15*/ //PN + private static final int OPT_DIFF_REF_COMMON = 0x8000; /*2exp16*/ //PN + private static final int OPT_BULK = 0x00010000; //PN + private static final int OPT_UNKNOWN = 0x00020000; //2**17 PN private static final String COMMON = "common"; private static final String ICU = "icu"; @@ -81,6 +68,10 @@ public class LDMLComparator { private static final String AIX = "aix"; private static final String LINUX = "linux"; + //PN added + private static final String DIFF = "diff"; + private static final String DIFF_REF_COMMON = "diff_ref_common"; + private static final String BULK = "bulk"; private static final String[] PLATFORM_PRINT_ORDER ={ COMMON, ICU, @@ -111,6 +102,9 @@ public class LDMLComparator { "-"+LINUX, "-s", "-d", + "-" + DIFF, //PN added, indicates that only differing elements/attributes to be written to html + "-" + DIFF_REF_COMMON, //PN added, same as diff only common is excluded from diff but gets printed to html for reference purposes + "-" + BULK, //do a bulk comparison of folder contents }; @@ -139,13 +133,48 @@ public class LDMLComparator { private String encoding = "UTF-8"; // default encoding - private class CompareElement{ + //PN added + private Vector m_PlatformVect = new Vector(); //holds names of platforms + private Vector m_PlatformFolderVect = new Vector(); //holds names of folders containing locale data for each platform + private int m_iOptions; + // key = element id, data = AccumulateDifferences instance + private TreeMap m_AccumulatedResultsMap = new TreeMap(); + private int m_iTotalConflictingElements = 0; + private int m_iTotalNonConflictingElements = 0; + private TreeMap m_LocaleSummaryDataMap = new TreeMap (); //key = localename, data = summary info + + private class CompareElement + { String node; String index; String parentNode; + String type; Hashtable platformData = new Hashtable(); } + + //PN added + //used for bulk comparisons + //holds the locales where the element identified by node,index and parentNode conflict + //for at least 2 of the platforms tested + //holds the locales where the element identified by node,index and parentNode don't + //for at all the platforms tested + private class AccumulatedResults + { + String node; + String index; + String parentNode; + String type; + Vector localeVectDiff = new Vector(); //holds loccales where a conflict in data was found + Vector localeVectSame = new Vector(); //holds loccales where a no conflict in data was found + } + private class SummaryData + { + String m_szPlatforms ; + int m_iNumConflictingElements; + } + + LDMLComparator(){ //initialize the color hash colorHash.put( COMMON, "#AD989D"); @@ -174,89 +203,142 @@ public class LDMLComparator { - private void processArgs(String[] args){ - short options = identifyOptions(args); - if ((args.length < 2) || ((options & OPT_UNKNOWN) != 0)) { + private void processArgs(String[] args) + { + m_iOptions = identifyOptions(args); + if ((args.length < 2) || ((m_iOptions & OPT_UNKNOWN) != 0)) + { printUsage(); return; } boolean warning[] = new boolean[1]; warning[0] = false; - Enumeration enum = optionTable.keys(); + Enumeration en = optionTable.keys(); - try{ - - localeStr = goldFileName.substring(goldFileName.lastIndexOf(File.separatorChar)+1,goldFileName.indexOf('.')); - - String fileName = destFolder+File.separator+localeStr+".html"; - OutputStreamWriter os = new OutputStreamWriter(new FileOutputStream(fileName),encoding); - String curDir = System.getProperty("user.dir"); - System.out.println("INFO: Creating file named: " + fileName +" in directory: " + curDir); - - addToCompareMap(goldFileName, goldKey); - for(;enum.hasMoreElements();){ - String key = (String)enum.nextElement(); - String compFile = (String) optionTable.get(key); - addToCompareMap(compFile,key); - + try + { + //check for bulk operation + if ((m_iOptions & OPT_BULK) != 0) + { + doBulkComparison(); } - PrintWriter writer = new PrintWriter(os); - printHTML(writer, localeStr); - }catch(Exception e){ + else + { + localeStr = goldFileName.substring(goldFileName.lastIndexOf(File.separatorChar)+1,goldFileName.indexOf('.')); + + String fileName = destFolder+File.separator+localeStr+".html"; + OutputStreamWriter os = new OutputStreamWriter(new FileOutputStream(fileName),encoding); + System.out.println("INFO: Creating file named: " + fileName); + + addToCompareMap(goldFileName, goldKey); + for(;en.hasMoreElements();) + { + String key = (String)en.nextElement(); + String compFile = (String) optionTable.get(key); + addToCompareMap(compFile,key); + + } + PrintWriter writer = new PrintWriter(os); + printHTML(writer, localeStr); + } + }catch(Exception e) + { e.printStackTrace(); } - - } - + + } private void printUsage() { - System.err.println("Usage: XMLComparator [