1/*
2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
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 * <code>BackEnd</code> is an abstract base class for a back-end of compiling
28 * Olson's zoneinfo database and generating Java zoneinfo database.
29 *
30 * @since 1.4
31 */
32abstract class BackEnd {
33
34    /**
35     * Receives each zone's TimeZone information which was created by
36     * {@link Zoneinfo#parse} in class <code>Zoneinfo</code>,
37     * and processes it.
38     *
39     * @param tz Timezone object for each zone
40     * @return 0 if no error occurred, otherwise 1.
41     */
42    abstract int processZoneinfo(Timezone tz);
43
44    /**
45     * Receives whole information which is generated by JavaZic's front-end
46     * in the form of Mapping object and generates all Java zone information
47     * files.
48     *
49     * @param m Mappings object which is generated by
50     *          {@link Main#compile() Main.compile()}.
51     * @return 0 if no error occurred, otherwise 1.
52     */
53    abstract int generateSrc(Mappings m);
54
55    /**
56     * Decides which backend class should be used and returns its instance.
57     * @return an instance of backend class
58     */
59    static BackEnd getBackEnd() {
60        if (Zoneinfo.isYearForTimeZoneDataSpecified) {
61            return new Simple();
62        } else if (Main.outputDoc) {
63            return new GenDoc();
64        } else {
65            return new Gen();
66        }
67    }
68}
69