/* * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
/** * <code>Simple</code> generates TimeZoneData, which had been used as internal * data of TimeZone before J2SDK1.3. * Since J2SDK1.4 doesn't need TimeZoneData, this class is for maintenance * of old JDK release.
*/ class Simple extends BackEnd {
/** * Zone records which are applied for given year.
*/ privatestatic Map<String,ZoneRec> lastZoneRecs = new HashMap<>();
/** * Rule records which are applied for given year.
*/ privatestatic Map<String,List<RuleRec>> lastRules = new TreeMap<>();
/** * zone IDs sorted by their GMT offsets. If zone's GMT * offset will change in the future, its last known offset is * used.
*/ private SortedMap<Integer, Set<String>> zonesByOffset = new TreeMap<>();
/** * Sets last Rule records and Zone records for given timezone to * each Map. * * @param tz Timezone object for each zone * @return always 0
*/ int processZoneinfo(Timezone tz) {
String zonename = tz.getName();
// Populate zonesByOffset. (Zones that will change their // GMT offsets are also added to zonesByOffset here.) int lastKnownOffset = tz.getRawOffset();
Set<String> set = zonesByOffset.get(lastKnownOffset); if (set == null) {
set = new TreeSet<>();
zonesByOffset.put(lastKnownOffset, set);
}
set.add(zonename);
return 0;
}
/** * Generates TimeZoneData to output SimpleTimeZone data. * @param map Mappings object which is generated by {@link Main#compile}. * @return 0 if no error occurred, otherwise 1.
*/ int generateSrc(Mappings map) { try {
File outD = new File(Main.getOutputDir());
outD.mkdirs();
FileWriter fw = new FileWriter(new File(outD, "TimeZoneData.java"), false);
BufferedWriter out = new BufferedWriter(fw);
Map<String,String> a = map.getAliases();
List<Integer> roi = map.getRawOffsetsIndex();
List<Set<String>> roit = map.getRawOffsetsIndexTable();
int index = 0; for (int offset : zonesByOffset.keySet()) { int o = roi.get(index);
Set<String> set = zonesByOffset.get(offset); if (offset == o) { // Merge aliases into zonesByOffset
set.addAll(roit.get(index));
}
index++;
for (String key : set) {
ZoneRec zrec;
String realname;
List<RuleRec> stz; if ((realname = a.get(key)) != null) { // if this alias is not targeted, ignore it. if (!Zone.isTargetZone(key)) { continue;
}
stz = lastRules.get(realname);
zrec = lastZoneRecs.get(realname);
} else {
stz = lastRules.get(key);
zrec = lastZoneRecs.get(key);
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.14Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.