01: /*
02: * Copyright 2000-2004 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04: *
05: * This code is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU General Public License version 2 only, as
07: * published by the Free Software Foundation. Sun designates this
08: * particular file as subject to the "Classpath" exception as provided
09: * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22: * CA 95054 USA or visit www.sun.com if you need additional information or
23: * have any questions.
24: */
25:
26: package sun.tools.javazic;
27:
28: /**
29: * <code>BackEnd</code> is an abstract base class for a back-end of compiling
30: * Olson's zoneinfo database and generating Java zoneinfo database.
31: *
32: * @since 1.4
33: */
34: abstract class BackEnd {
35:
36: /**
37: * Receives each zone's TimeZone information which was created by
38: * {@link Zoneinfo#parse} in class <code>Zoneinfo</code>,
39: * and processes it.
40: *
41: * @param tz Timezone object for each zone
42: * @return 0 if no error occurred, otherwise 1.
43: */
44: abstract int processZoneinfo(Timezone tz);
45:
46: /**
47: * Receives whole information which is generated by JavaZic's front-end
48: * in the form of Mapping object and generates all Java zone information
49: * files.
50: *
51: * @param m Mappings object which is generated by
52: * {@link Main#compile() Main.compile()}.
53: * @return 0 if no error occurred, otherwise 1.
54: */
55: abstract int generateSrc(Mappings m);
56:
57: /**
58: * Decides which backend class should be used and returns its instance.
59: * @return an instance of backend class
60: */
61: static BackEnd getBackEnd() {
62: if (Zoneinfo.isYearForTimeZoneDataSpecified) {
63: return new Simple();
64: } else if (Main.outputDoc) {
65: return new GenDoc();
66: } else {
67: return new Gen();
68: }
69: }
70: }
|