< prev index next >

make/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java

Print this page




  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 
  27 package build.tools.tzdb;
  28 
  29 import java.io.IOException;
  30 import java.nio.charset.StandardCharsets;
  31 import java.nio.file.Files;
  32 import java.nio.file.Path;
  33 import java.nio.file.Paths;
  34 import java.util.ArrayList;
  35 import java.util.Collections;

  36 import java.util.HashMap;
  37 import java.util.HashSet;
  38 import java.util.List;
  39 import java.util.Map;
  40 import java.util.Map.Entry;
  41 import java.util.NavigableMap;
  42 import java.util.Objects;
  43 import java.util.Set;
  44 import java.util.TreeMap;
  45 import java.util.TreeSet;
  46 import java.util.concurrent.ConcurrentHashMap;
  47 import java.time.*;
  48 import java.time.Year;
  49 import java.time.chrono.IsoChronology;
  50 import java.time.temporal.TemporalAdjusters;
  51 import java.time.zone.ZoneOffsetTransition;
  52 import java.time.zone.ZoneOffsetTransitionRule;
  53 import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition;
  54 import java.time.zone.ZoneRulesException;
  55 


 134     private final Map<String, Object> zones = new ConcurrentHashMap<>();
 135 
 136     /**
 137      * compatibility list
 138      */
 139     private static HashSet<String> excludedZones;
 140     static {
 141         // (1) exclude EST, HST and MST. They are supported
 142         //     via the short-id mapping
 143         // (2) remove UTC and GMT
 144         // (3) remove ROC, which is not supported in j.u.tz
 145         excludedZones = new HashSet<>(10);
 146         excludedZones.add("EST");
 147         excludedZones.add("HST");
 148         excludedZones.add("MST");
 149         excludedZones.add("GMT+0");
 150         excludedZones.add("GMT-0");
 151         excludedZones.add("ROC");
 152     }
 153 
 154     private Map<String, String> links = new HashMap<>(150);
 155     private Map<String, List<RuleLine>> rules = new HashMap<>(500);
 156 
 157     private void load(List<Path> files) throws IOException {
 158 
 159         for (Path file : files) {
 160             List<ZoneLine> openZone = null;
 161             try {
 162                 for (String line : Files.readAllLines(file, StandardCharsets.ISO_8859_1)) {
 163                     if (line.length() == 0 || line.charAt(0) == '#') {
 164                         continue;
 165                     }
 166                     //StringIterator itr = new StringIterator(line);
 167                     String[] tokens = split(line);
 168                     if (openZone != null &&               // continuing zone line
 169                         Character.isWhitespace(line.charAt(0)) &&
 170                         tokens.length > 0) {
 171                         ZoneLine zLine = new ZoneLine();
 172                         openZone.add(zLine);
 173                         if (zLine.parse(tokens, 0)) {
 174                             openZone = null;




  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 
  27 package build.tools.tzdb;
  28 
  29 import java.io.IOException;
  30 import java.nio.charset.StandardCharsets;
  31 import java.nio.file.Files;
  32 import java.nio.file.Path;
  33 import java.nio.file.Paths;
  34 import java.util.ArrayList;
  35 import java.util.Collections;
  36 import java.util.LinkedHashMap;
  37 import java.util.HashMap;
  38 import java.util.HashSet;
  39 import java.util.List;
  40 import java.util.Map;
  41 import java.util.Map.Entry;
  42 import java.util.NavigableMap;
  43 import java.util.Objects;
  44 import java.util.Set;
  45 import java.util.TreeMap;
  46 import java.util.TreeSet;
  47 import java.util.concurrent.ConcurrentHashMap;
  48 import java.time.*;
  49 import java.time.Year;
  50 import java.time.chrono.IsoChronology;
  51 import java.time.temporal.TemporalAdjusters;
  52 import java.time.zone.ZoneOffsetTransition;
  53 import java.time.zone.ZoneOffsetTransitionRule;
  54 import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition;
  55 import java.time.zone.ZoneRulesException;
  56 


 135     private final Map<String, Object> zones = new ConcurrentHashMap<>();
 136 
 137     /**
 138      * compatibility list
 139      */
 140     private static HashSet<String> excludedZones;
 141     static {
 142         // (1) exclude EST, HST and MST. They are supported
 143         //     via the short-id mapping
 144         // (2) remove UTC and GMT
 145         // (3) remove ROC, which is not supported in j.u.tz
 146         excludedZones = new HashSet<>(10);
 147         excludedZones.add("EST");
 148         excludedZones.add("HST");
 149         excludedZones.add("MST");
 150         excludedZones.add("GMT+0");
 151         excludedZones.add("GMT-0");
 152         excludedZones.add("ROC");
 153     }
 154 
 155     private Map<String, String> links = new LinkedHashMap<>(150);
 156     private Map<String, List<RuleLine>> rules = new HashMap<>(500);
 157 
 158     private void load(List<Path> files) throws IOException {
 159 
 160         for (Path file : files) {
 161             List<ZoneLine> openZone = null;
 162             try {
 163                 for (String line : Files.readAllLines(file, StandardCharsets.ISO_8859_1)) {
 164                     if (line.length() == 0 || line.charAt(0) == '#') {
 165                         continue;
 166                     }
 167                     //StringIterator itr = new StringIterator(line);
 168                     String[] tokens = split(line);
 169                     if (openZone != null &&               // continuing zone line
 170                         Character.isWhitespace(line.charAt(0)) &&
 171                         tokens.length > 0) {
 172                         ZoneLine zLine = new ZoneLine();
 173                         openZone.add(zLine);
 174                         if (zLine.parse(tokens, 0)) {
 175                             openZone = null;


< prev index next >