1/* GENERATED SOURCE. DO NOT MODIFY. */
2// © 2016 and later: Unicode, Inc. and others.
3// License & terms of use: http://www.unicode.org/copyright.html#License
4/*
5 **********************************************************************
6 * Copyright (c) 2003-2010, International Business Machines
7 * Corporation and others.  All Rights Reserved.
8 **********************************************************************
9 * Author: Alan Liu
10 * Created: October 2 2003
11 * Since: ICU 2.8
12 **********************************************************************
13 */
14
15package android.icu.impl;
16import java.util.Date;
17
18import android.icu.util.TimeZone;
19
20/**
21 * <code>TimeZoneAdapter</code> wraps a android.icu.util.TimeZone
22 * subclass and inherits from java.util.TimeZone.
23 * Without this class, we would need to 'port' java.util.Date to
24 * android.icu.util as well, so that Date could interoperate properly
25 * with the android.icu.util TimeZone and Calendar classes.  With this
26 * class, we can use java.util.Date together with android.icu.util
27 * classes.
28 *
29 * @see android.icu.util.TimeZone#setDefault
30 * @author Alan Liu
31 * @hide Only a subset of ICU is exposed in Android
32 */
33public class TimeZoneAdapter extends java.util.TimeZone {
34
35    // Generated by serialver from JDK 1.4.1_01
36    static final long serialVersionUID = -2040072218820018557L;
37
38    /**
39     * The contained android.icu.util.TimeZone object.  Must not be null.
40     * We delegate all methods to this object.
41     */
42    private TimeZone zone;
43
44    /**
45     * Given a java.util.TimeZone, wrap it in the appropriate adapter
46     * subclass of android.icu.util.TimeZone and return the adapter.
47     */
48    public static java.util.TimeZone wrap(android.icu.util.TimeZone tz) {
49        return new TimeZoneAdapter(tz);
50    }
51
52    /**
53     * Return the java.util.TimeZone wrapped by this object.
54     */
55    public android.icu.util.TimeZone unwrap() {
56        return zone;
57    }
58
59    /**
60     * Constructs an adapter for a android.icu.util.TimeZone object.
61     */
62    public TimeZoneAdapter(TimeZone zone) {
63        this.zone = zone;
64        super.setID(zone.getID());
65    }
66
67    /**
68     * TimeZone API; calls through to wrapped time zone.
69     */
70    @Override
71    public void setID(String ID) {
72        super.setID(ID);
73        zone.setID(ID);
74    }
75
76    /**
77     * TimeZone API; calls through to wrapped time zone.
78     */
79    @Override
80    public boolean hasSameRules(java.util.TimeZone other) {
81        return other instanceof TimeZoneAdapter &&
82            zone.hasSameRules(((TimeZoneAdapter)other).zone);
83    }
84
85    /**
86     * TimeZone API; calls through to wrapped time zone.
87     */
88    @Override
89    public int getOffset(int era, int year, int month, int day, int dayOfWeek,
90                         int millis) {
91        return zone.getOffset(era, year, month, day, dayOfWeek, millis);
92    }
93
94    /**
95     * TimeZone API; calls through to wrapped time zone.
96     */
97    @Override
98    public int getRawOffset() {
99        return zone.getRawOffset();
100    }
101
102    /**
103     * TimeZone API; calls through to wrapped time zone.
104     */
105    @Override
106    public void setRawOffset(int offsetMillis) {
107        zone.setRawOffset(offsetMillis);
108    }
109
110    /**
111     * TimeZone API; calls through to wrapped time zone.
112     */
113    @Override
114    public boolean useDaylightTime() {
115        return zone.useDaylightTime();
116    }
117
118    /**
119     * TimeZone API; calls through to wrapped time zone.
120     */
121    @Override
122    public boolean inDaylightTime(Date date) {
123        return zone.inDaylightTime(date);
124    }
125
126    /**
127     * Boilerplate API; calls through to wrapped object.
128     */
129    @Override
130    public Object clone() {
131        return new TimeZoneAdapter((TimeZone)zone.clone());
132    }
133
134    /**
135     * Boilerplate API; calls through to wrapped object.
136     */
137    @Override
138    public synchronized int hashCode() {
139        return zone.hashCode();
140    }
141
142    /**
143     * Boilerplate API; calls through to wrapped object.
144     */
145    @Override
146    public boolean equals(Object obj) {
147        if (obj instanceof TimeZoneAdapter) {
148            obj = ((TimeZoneAdapter) obj).zone;
149        }
150        return zone.equals(obj);
151    }
152
153    /**
154     * Returns a string representation of this object.
155     * @return  a string representation of this object.
156     */
157    @Override
158    public String toString() {
159        return "TimeZoneAdapter: " + zone.toString();
160    }
161}
162