jdk/test/sun/util/calendar/zi/Main.java
author sherman
Tue, 12 Feb 2013 09:25:43 -0800
changeset 15658 55b829ca2334
child 23010 6dadb192ad81
permissions -rw-r--r--
8007392: JSR 310: DateTime API Updates 8007520: Update date/time classes in j.util and j.sql packages 8007572: Replace existing jdk timezone data at <java.home>/lib/zi with JSR310's tzdb Summary: Integration of JSR310 Date/Time API for M7 Reviewed-by: darcy, alanb, naoto Contributed-by: scolebourne@joda.org, roger.riggs@oracle.com, masayoshi.okutsu@oracle.com, patrick.zhang@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15658
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
     1
/*
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
     2
 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
     4
 *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    10
 *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    15
 * accompanied this code).
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    16
 *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    20
 *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    23
 * questions.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    24
 */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    25
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    26
import java.util.ArrayList;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    27
import java.util.List;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    28
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    29
/**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    30
 * Main class for the javazic time zone data compiler.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    31
 *
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    32
 * @since 1.4
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    33
 */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    34
public class Main {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    35
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    36
    private static boolean verbose = false;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    37
    static boolean outputDoc = false;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    38
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    39
    private List<String> ziFiles = new ArrayList<String>();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    40
    private static String zoneNamesFile = null;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    41
    private static String versionName = "unknown";
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    42
    private static String outputDir = "zoneinfo";
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    43
    private static String mapFile = null;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    44
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    45
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    46
     * Parses the specified arguments and sets up the variables.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    47
     * @param argv the arguments
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    48
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    49
    void processArgs(String[] argv) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    50
        for (int i = 0; i < argv.length; i++) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    51
            String arg = argv[i];
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    52
            if (arg.startsWith("-h")) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    53
                usage();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    54
                System.exit(0);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    55
            } else if (arg.equals("-d")) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    56
                outputDir = argv[++i];
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    57
            } else if (arg.equals("-v")) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    58
                verbose = true;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    59
            } else if (arg.equals("-V")) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    60
                versionName = argv[++i];
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    61
            } else if (arg.equals("-doc")) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    62
                outputDoc = true;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    63
            } else if (arg.equals("-map")) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    64
                outputDoc = true;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    65
                mapFile = argv[++i];
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    66
            } else if (arg.equals("-f")) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    67
                zoneNamesFile = argv[++i];
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    68
            } else if (arg.equals("-S")) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    69
                try {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    70
                    Zoneinfo.setYear(Integer.parseInt(argv[++i]));
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    71
                } catch (Exception e) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    72
                    error("invalid year: " + argv[i]);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    73
                    usage();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    74
                    System.exit(1);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    75
                }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    76
            } else {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    77
                boolean isStartYear = arg.equals("-s");
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    78
                if (isStartYear || arg.equals("-e")) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    79
                    try {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    80
                        int year = Integer.parseInt(argv[++i]);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    81
                        if (isStartYear) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    82
                            Zoneinfo.setStartYear(year);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    83
                        } else {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    84
                            Zoneinfo.setEndYear(year);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    85
                        }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    86
                    } catch (Exception e) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    87
                        error("invalid year: " + argv[i]);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    88
                        usage();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    89
                        System.exit(1);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    90
                    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    91
                } else {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    92
                    // the rest of args are zoneinfo source files
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    93
                    while (i < argv.length) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    94
                        ziFiles.add(argv[i++]);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    95
                    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    96
                }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    97
            }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    98
        }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
    99
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   100
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   101
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   102
     * Parses zoneinfo source files
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   103
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   104
    int compile() {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   105
        int nFiles = ziFiles.size();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   106
        int status = 0;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   107
        Mappings maps = new Mappings();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   108
        BackEnd backend = BackEnd.getBackEnd();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   109
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   110
        for (int i = 0; i < nFiles; i++) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   111
            Zoneinfo frontend = Zoneinfo.parse(ziFiles.get(i));
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   112
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   113
            for (String key : frontend.getZones().keySet()) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   114
                info(key);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   115
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   116
                Timezone tz = frontend.phase2(key);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   117
                status |= backend.processZoneinfo(tz);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   118
            }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   119
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   120
            maps.add(frontend);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   121
        }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   122
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   123
        // special code for dealing with the conflicting name "MET"
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   124
        Zone.addMET();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   125
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   126
        maps.resolve();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   127
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   128
        status |= backend.generateSrc(maps);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   129
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   130
        return status;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   131
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   132
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   133
    public static void main(String[] argv) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   134
        Main zic = new Main();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   135
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   136
        /*
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   137
         * Parse args
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   138
         */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   139
        zic.processArgs(argv);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   140
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   141
        /*
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   142
         * Read target zone names
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   143
         */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   144
        if (zoneNamesFile != null) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   145
            Zone.readZoneNames(zoneNamesFile);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   146
        }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   147
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   148
        zic.compile();
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   149
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   150
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   151
    void usage() {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   152
        System.err.println("Usage: javazic [options] file...\n"+
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   153
                           "         -f namefile  file containing zone names\n"+
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   154
                           "                      to be generated (ie, generating subset)\n"+
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   155
                           "         -d dir       output directory\n"+
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   156
                           "         -v           verbose\n"+
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   157
                           "         -V datavers  specifies the tzdata version string\n"+
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   158
                           "                      (eg, \"tzdata2000g\")"+
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   159
                           "         -S year      output only SimleTimeZone data of that year\n"+
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   160
                           "         -s year      start year (default: 1900)\n"+
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   161
                           "         -e year      end year (default: 2037)\n"+
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   162
                           "         -doc         generates HTML documents\n"+
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   163
                           "         -map mapfile generates HTML documents with map information\n"+
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   164
                           "         file...      zoneinfo source file(s)");
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   165
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   166
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   167
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   168
     * @return the output directory path name
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   169
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   170
    static String getOutputDir() {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   171
        return outputDir;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   172
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   173
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   174
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   175
     * @return the map file's path and name
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   176
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   177
    static String getMapFile() {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   178
        return mapFile;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   179
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   180
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   181
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   182
     * Returns the time zone data version string specified by the -V
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   183
     * option. If it is not specified, "unknown" is returned.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   184
     * @return the time zone data version string
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   185
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   186
    static String getVersionName() {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   187
        return versionName;
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   188
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   189
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   190
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   191
     * Prints out the specified fatal error message and calls {@link
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   192
     * java.lang.System#exit System.exit(1)}.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   193
     * @param msg the fatal error message
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   194
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   195
    static void panic(String msg) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   196
        printMessage("fatal error", msg);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   197
        System.exit(1);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   198
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   199
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   200
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   201
     * Prints out the specified error message.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   202
     * @param msg the error message
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   203
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   204
    static void error(String msg) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   205
        printMessage("error", msg);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   206
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   207
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   208
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   209
     * Prints out the specified warning message.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   210
     * @param msg the warning message
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   211
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   212
    static void warning(String msg) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   213
        printMessage("warning", msg);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   214
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   215
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   216
    /**
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   217
     * Prints out the informative message.
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   218
     * @param msg the informative message
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   219
     */
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   220
    static void info(String msg) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   221
        if (verbose) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   222
            printMessage(null, msg);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   223
        }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   224
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   225
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   226
    private static void printMessage(String type, String msg) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   227
        if (type != null) {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   228
            type += ": ";
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   229
        } else {
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   230
            type = "";
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   231
        }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   232
        System.err.println("javazic: " + type + msg);
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   233
    }
55b829ca2334 8007392: JSR 310: DateTime API Updates
sherman
parents:
diff changeset
   234
}