/* * Copyright (c) 2001, 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>GenDoc</code> is one of back-end classes of javazic, and generates * index.html and other html files which prints the detailed time zone * information for each zone.
*/ class GenDoc extends BackEnd {
privatestaticfinal String docDir = "doc";
privatestaticfinal String header1 = "-//W3C//DTD HTML 4.0 Frameset//EN\"" + "\"http://www.w3.org/TR/REC-html40/frameset.dtd\">\n" + "\n\n\n\n" + "Java Platform, Standard Edition - TimeZone information based on "; privatestaticfinal String header3 = "-->\n\n" + "Java Platform, Standard Edition TimeZone - "; privatestaticfinal String header4 = "\n" + "\n\n";
// list of time zone name and zonefile name/real time zone name // e.g. // key (String) : value (String) // "America/Denver" : "America/Denver.html" (real time zone) // "America/Shiprock" : "America/Denver" (alias)
TreeMap<String,String> timezoneList = new TreeMap<String,String>();
// list of time zone's display name and time zone name // e.g. // key (String) : value (String) // "Tokyo, Asia" : "Asia/Tokyo" // "Marengo, Indiana, America" : "America/Indiana/Marengo" // (aliases included)
TreeMap<String,String> displayNameList = new TreeMap<String,String>();
// list of top level regions // e.g. // key (String) : value (String) // "America" : "America.html" // (including entries in America/Indiana/, America/Kentucky/, ...)
TreeMap<String,String> regionList = new TreeMap<String,String>();
// mapping list from zone name to latitude & longitude // This list is generated from zone.tab. // e.g. // key (String) : value (LatitudeAndLongitude object) // "Asia/Tokyo" : latitude=35.3916, longitude=13.9444 // (aliases not included)
HashMap<String,LatitudeAndLongitude> mapList = null;
// SortedMap of zone IDs sorted by their GMT offsets. If zone's GMT // offset will change in the future, its last known offset is // used.
SortedMap<Integer, Set<String>> zonesByOffset = new TreeMap<Integer, Set<String>>();
/** * Generates HTML document for each zone. * @param Timezone * @return 0 if no errors, or 1 if error occurred.
*/ int processZoneinfo(Timezone tz) { try { int size; int index;
String outputDir = Main.getOutputDir();
String zonename = tz.getName();
String zonefile = ZoneInfoFile.getFileName(zonename) + ".html";
List<RuleRec> stz = tz.getLastRules();
timezoneList.put(zonename, zonefile);
displayNameList.put(transform(zonename), zonename);
// 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<String>();
zonesByOffset.put(lastKnownOffset, set);
}
set.add(zonename);
/* If outputDir doesn't end with file-separator, adds it. */ if (!outputDir.endsWith(File.separator)) {
outputDir += File.separatorChar;
}
outputDir += docDir + File.separatorChar;
index = zonename.indexOf('/'); if (index != -1) {
regionList.put(zonename.substring(0, index),
zonename.substring(0, index) + ".html");
}
/* If zonefile includes file-separator, it's treated as part of * pathname. And make directory if necessary.
*/
index = zonefile.lastIndexOf('/'); if (index != -1) {
zonefile.replace('/', File.separatorChar);
outputDir += zonefile.substring(0, index+1);
}
File outD = new File(outputDir);
outD.mkdirs();
/* If mapfile is available, add a link to the appropriate map */ if ((mapList == null) && (Main.getMapFile() != null)) {
FileReader fr = new FileReader(Main.getMapFile());
BufferedReader in = new BufferedReader(fr);
mapList = new HashMap<String,LatitudeAndLongitude>();
String line; while ((line = in.readLine()) != null) { // skip blank and comment lines if (line.length() == 0 || line.charAt(0) == '#') { continue;
}
StringTokenizer tokens = new StringTokenizer(line);
String token = tokens.nextToken(); /* We don't use the first token. */
token = tokens.nextToken();
LatitudeAndLongitude location = new LatitudeAndLongitude(token);
token = tokens.nextToken();
mapList.put(token, location);
}
in.close();
}
/* Open zoneinfo file to write. */
FileWriter fw = new FileWriter(outputDir + zonefile.substring(index+1));
BufferedWriter out = new BufferedWriter(fw);
out.write(header1 + new Date() + header3 + zonename + header4);
out.write(body1 + "+2\">" + zonename + "");
LatitudeAndLongitude location = mapList.get(zonename); if (location != null) { int deg, min, sec;
\n"); for (int i = 0; i < size; i++) {
out.write("
#FFFFFF\">\n");
StringTokenizer st = new StringTokenizer(rule.get(i).getLine());
String s; if (st.hasMoreTokens()) { /* RULE - truncated */
st.nextToken();
} if (st.hasMoreTokens()) { /* NAME */
out.write("
" + st.nextToken() + "
");
} if (st.hasMoreTokens()) { /* FROM */
out.write("
" + st.nextToken() + "
");
} if (st.hasMoreTokens()) { /* TO */
s = st.nextToken(); if (s.equals("min") || s.equals("max")) {
out.write("
red\">" + s + "
");
} else {
out.write("
" + s + "
");
}
} if (st.hasMoreTokens()) { /* TYPE */
out.write("
" + st.nextToken() + "
");
} if (st.hasMoreTokens()) { /* IN */
out.write("
" + st.nextToken() + "
");
} if (st.hasMoreTokens()) { /* ON */
out.write("
" + st.nextToken() + "
");
} if (st.hasMoreTokens()) { /* AT */
out.write("
" + st.nextToken() + "
");
} if (st.hasMoreTokens()) { /* SAVE */
out.write("
" + st.nextToken() + "
");
} if (st.hasMoreTokens()) { /* LETTER/S */
out.write("
" + st.nextToken() + "
");
} if (st.hasMoreTokens()) { /* NOTES */
s = st.nextToken(); while (st.hasMoreTokens()) {
s += " " + st.nextToken();
}
index = s.indexOf('#');
out.write("
" + s.substring(index+1) + "
\n");
} else {
out.write("
\n");
}
out.write("
\n");
}
out.write("
\n
\n"
);
}
/* Output Zone records. */ if (zone != null) {
size = zone.size();
out.write("
\n"); for (int i = 0; i < size; i++) {
out.write("
\n");
StringTokenizer st = new StringTokenizer(zone.get(i).getLine());
String s = st.nextToken(); if (s.equals("Zone")) { /* NAME */
s = st.nextToken();
s = st.nextToken();
}
out.write("
");
} if (st.hasMoreTokens()) { /* FORMAT */
s = st.nextToken();
index = s.indexOf('#'); if (index != -1) { if (index != 0) {
out.write("
" + s.substring(0, index-1) + "
"); /* FORMAT */
s = s.substring(index+1);
} else {
out.write("
"); /* FORMAT */
} while (st.hasMoreTokens()) {
s += " " + st.nextToken();
}
out.write("
"); /* UNTIL */
out.write("
" + s + "
\n
\n"); /* NOTES */ continue;
} else {
out.write("
" + s + "
"); /* FORMAT */
}
}
if (st.hasMoreTokens()) { /* UNTIL */
s = st.nextToken(); while (st.hasMoreTokens()) {
s += " " + st.nextToken();
}
index = s.indexOf('#'); if (index != -1) { if (index != 0) {
out.write("
/** * Generates index.html and other top-level frame files. * @param Mappings * @return 0 if no errors, or 1 if error occurred.
*/ int generateSrc(Mappings map) { try { int len;
Object o[];
String outputDir = Main.getOutputDir();
FileWriter fw1, fw2;
BufferedWriter out1, out2;
/* Whether alias list exists or not. */
Map<String,String> a = map.getAliases(); if (a == null) {
Main.panic("Data not exist. (aliases)"); return 1;
}
timezoneList.putAll(a);
/* If outputDir doesn't end with file-separator, adds it. */ if (!outputDir.endsWith(File.separator)) {
outputDir += File.separatorChar;
}
outputDir += docDir + File.separatorChar;
File outD = new File(outputDir);
outD.mkdirs();
/* Creates index.html */
fw1 = new FileWriter(outputDir + "index.html", false);
out1 = new BufferedWriter(fw1);
+ "This document is designed to be viewed using the frames feature. If you see this\n" + "message, you are using a non-frame-capable web client.\n" + " \n" + "Link tooverview-summary.html\">Non-frame version.\n" + "\n" + footer);
out1.close();
fw1.close();
/* Creates overview-frame.html */
fw1 = new FileWriter(outputDir + "overview-frame.html", false);
out1 = new BufferedWriter(fw1);
List<Integer> roi = map.getRawOffsetsIndex();
List<Set<String>> roit = map.getRawOffsetsIndexTable();
int index = 0; for (Integer offset : zonesByOffset.keySet()) { int off = roi.get(index);
Set<String> perRO = zonesByOffset.get(offset); if (offset == off) { // Merge aliases into zonesByOffset
perRO.addAll(roit.get(index));
}
index++;
/* Creates allTimeZone-frame2.html (Sorted by zone names) */
fw1 = new FileWriter(outputDir + "allTimeZone-frame2.html", false);
out1 = new BufferedWriter(fw1);
out1.write(header1 + new Date() + header2 + Main.getVersionName() +
header4 + body1 + "+1\">Sorted by zone names\n" + " \n\n" + "
/* Creates allTimeZone-frame3.html (Sorted by city names) */
fw1 = new FileWriter(outputDir + "allTimeZone-frame3.html", false);
out1 = new BufferedWriter(fw1);
out1.write(header1 + new Date() + header2 + Main.getVersionName() +
header4 + body1 + "+1\">Sorted by city names\n" + " \n\n" + "
0\" WIDTH=\"100%\">\n" + "
\n
\n");
Set<String> aliasSet = a.keySet();
len = aliasSet.size();
String aliasNames[] = aliasSet.toArray(new String[0]); for (int i = 0; i < len; i++) {
displayNameList.put(transform(aliasNames[i]),
aliasNames[i]);
}
+
Main.getVersionName() + " for Java Platform, " + "Standard Edition. The source code can be obtained " + "from ftp site ftp://elsie.nci.nih.gov/pub/\">" + "ftp://elsie.nci.nih.gov/pub/. A total of " +
len + " time zones and aliases are supported " + "in this edition. For the " + "format of rules and zones, refer to the zic " + "(zoneinfo compiler) man page on " + "Solaris or Linux.\n" + "
Note that the time zone data is not "
+ "a public interface of the Java Platform. No " + "applications should rely on the time zone data of " + "this document. Time zone names and data " + "may change without any prior notice.\n" +
body2 + footer);
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.