make/jdk/src/classes/build/tools/cldrconverter/MetaZonesParseHandler.java
changeset 49574 6a6ee36037ac
parent 47216 71c04702a3d5
child 49904 cadca99d52e7
equal deleted inserted replaced
49573:6b46983d6fbe 49574:6a6ee36037ac
     1 /*
     1 /*
     2  * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    25 
    25 
    26 package build.tools.cldrconverter;
    26 package build.tools.cldrconverter;
    27 
    27 
    28 import java.io.File;
    28 import java.io.File;
    29 import java.io.IOException;
    29 import java.io.IOException;
       
    30 import java.util.*;
       
    31 import java.util.stream.*;
       
    32 
    30 import org.xml.sax.Attributes;
    33 import org.xml.sax.Attributes;
    31 import org.xml.sax.InputSource;
    34 import org.xml.sax.InputSource;
    32 import org.xml.sax.SAXException;
    35 import org.xml.sax.SAXException;
    33 
    36 
    34 class MetaZonesParseHandler extends AbstractLDMLHandler<String> {
    37 class MetaZonesParseHandler extends AbstractLDMLHandler<String> {
    35     private String tzid, metazone;
    38     private String tzid, metazone;
       
    39 
       
    40     // for java.time.format.ZoneNames.java
       
    41     private List<String> mzoneMapEntryList = new ArrayList<>();
       
    42     private Map<String, String> zones = new HashMap<>();
    36 
    43 
    37     MetaZonesParseHandler() {
    44     MetaZonesParseHandler() {
    38     }
    45     }
    39 
    46 
    40     @Override
    47     @Override
    62                 metazone = attributes.getValue("mzone");
    69                 metazone = attributes.getValue("mzone");
    63             }
    70             }
    64             pushIgnoredContainer(qName);
    71             pushIgnoredContainer(qName);
    65             break;
    72             break;
    66 
    73 
       
    74         case "mapZone":
       
    75             String territory = attributes.getValue("territory");
       
    76             if (territory.equals("001")) {
       
    77                 zones.put(attributes.getValue("other"), attributes.getValue("type"));
       
    78             } else {
       
    79                 mzoneMapEntryList.add(String.format("        \"%s\", \"%s\", \"%s\",",
       
    80                     attributes.getValue("other"),
       
    81                     territory,
       
    82                     attributes.getValue("type")));
       
    83             }
       
    84             pushIgnoredContainer(qName);
       
    85             break;
       
    86 
    67         case "version":
    87         case "version":
    68         case "generation":
    88         case "generation":
    69             pushIgnoredContainer(qName);
    89             pushIgnoredContainer(qName);
    70             break;
    90             break;
    71 
    91 
    87             put(tzid, metazone);
   107             put(tzid, metazone);
    88             break;
   108             break;
    89         }
   109         }
    90         currentContainer = currentContainer.getParent();
   110         currentContainer = currentContainer.getParent();
    91     }
   111     }
       
   112 
       
   113     public Map<String, String> zidMap() {
       
   114         return zones;
       
   115     }
       
   116 
       
   117     public Stream<String> mzoneMapEntry() {
       
   118         return mzoneMapEntryList.stream();
       
   119     }
    92 }
   120 }