/* * 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>Gen</code> is one of back-end classes of javazic, and generates * ZoneInfoMappings and zone-specific file for each zone.
*/ class Gen extends BackEnd {
/** * Generates datafile in binary TLV format for each time zone. * Regarding contents of output files, see {@link ZoneInfoFile}. * * @param Timezone * @return 0 if no errors, or 1 if error occurred.
*/ int processZoneinfo(Timezone tz) { try { int size;
String outputDir = Main.getOutputDir();
String zonefile = ZoneInfoFile.getFileName(tz.getName());
/* If outputDir doesn't end with file-separator, adds it. */ if (!outputDir.endsWith(File.separator)) {
outputDir += File.separatorChar;
}
/* If zonefile includes file-separator, it's treated as part of * pathname. And make directory if necessary.
*/ int index = zonefile.lastIndexOf(File.separatorChar); if (index != -1) {
outputDir += zonefile.substring(0, index+1);
}
File outD = new File(outputDir);
outD.mkdirs();
FileOutputStream fos = new FileOutputStream(outputDir + zonefile.substring(index+1));
DataOutputStream dos = new DataOutputStream(fos);
if ((dstOffsets == null && offsets != null) ||
(dstOffsets != null && offsets == null)) {
Main.panic("Data not exist. (dstOffsets or offsets)"); return 1;
}
/* Output Transition records */
dos.writeByte(ZoneInfoFile.TAG_Transition);
size = transitions.size();
dos.writeShort((size * 8) & 0xFFFF); int dstoffset; for (int i = 0; i < size; i++) { /* if DST offset is 0, this means DST isn't used. * (NOT: offset's index is 0.)
*/ if ((dstoffset = dstOffsets.get(i).intValue()) == -1) {
dstoffset = 0;
}
/** * Generates ZoneInfoMappings in binary TLV format for each zone. * Regarding contents of output files, see {@link ZoneInfoFile}. * * @param Mappings * @return 0 if no errors, or 1 if error occurred.
*/ int generateSrc(Mappings map) { try { int index; int block_size; int roi_size; long fp;
String outputDir = Main.getOutputDir();
/* If outputDir doesn't end with file-separator, adds it. */ if (!outputDir.endsWith(File.separator)) {
outputDir += File.separatorChar;
}
File outD = new File(outputDir);
outD.mkdirs();
/* Open ZoneInfoMapping file to write. */
RandomAccessFile raf = new RandomAccessFile(outputDir + ZoneInfoFile.JAVAZM_FILE_NAME, "rw");
/* Whether rawOffsetIndex list exists or not. */
List<Integer> roi = map.getRawOffsetsIndex(); if (roi == null) {
Main.panic("Data not exist. (rawOffsetsIndex)"); return 1;
}
roi_size = roi.size();
/* Whether rawOffsetIndexTable list exists or not. */
List<Set<String>> roit = map.getRawOffsetsIndexTable(); if (roit == null || roit.size() != roi_size) {
Main.panic("Data not exist. (rawOffsetsIndexTable) Otherwise, Invalid size"); return 1;
}
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.