J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2005 Sun Microsystems, Inc. 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. Sun designates this |
| 8 | * particular file as subject to the "Classpath" exception as provided |
| 9 | * 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.util.calendar; |
| 27 | |
| 28 | import java.util.Locale; |
| 29 | import java.util.TimeZone; |
| 30 | |
| 31 | class ImmutableGregorianDate extends BaseCalendar.Date { |
| 32 | private final BaseCalendar.Date date; |
| 33 | |
| 34 | ImmutableGregorianDate(BaseCalendar.Date date) { |
| 35 | if (date == null) { |
| 36 | throw new NullPointerException(); |
| 37 | } |
| 38 | this.date = date; |
| 39 | } |
| 40 | |
| 41 | public Era getEra() { |
| 42 | return date.getEra(); |
| 43 | } |
| 44 | |
| 45 | public CalendarDate setEra(Era era) { |
| 46 | unsupported(); return this; |
| 47 | } |
| 48 | |
| 49 | public int getYear() { |
| 50 | return date.getYear(); |
| 51 | } |
| 52 | |
| 53 | public CalendarDate setYear(int year) { |
| 54 | unsupported(); return this; |
| 55 | } |
| 56 | |
| 57 | public CalendarDate addYear(int n) { |
| 58 | unsupported(); return this; |
| 59 | } |
| 60 | |
| 61 | public boolean isLeapYear() { |
| 62 | return date.isLeapYear(); |
| 63 | } |
| 64 | |
| 65 | void setLeapYear(boolean leapYear) { |
| 66 | unsupported(); |
| 67 | } |
| 68 | |
| 69 | public int getMonth() { |
| 70 | return date.getMonth(); |
| 71 | } |
| 72 | |
| 73 | public CalendarDate setMonth(int month) { |
| 74 | unsupported(); return this; |
| 75 | } |
| 76 | |
| 77 | public CalendarDate addMonth(int n) { |
| 78 | unsupported(); return this; |
| 79 | } |
| 80 | |
| 81 | public int getDayOfMonth() { |
| 82 | return date.getDayOfMonth(); |
| 83 | } |
| 84 | |
| 85 | public CalendarDate setDayOfMonth(int date) { |
| 86 | unsupported(); return this; |
| 87 | } |
| 88 | |
| 89 | public CalendarDate addDayOfMonth(int n) { |
| 90 | unsupported(); return this; |
| 91 | } |
| 92 | |
| 93 | public int getDayOfWeek() { |
| 94 | return date.getDayOfWeek(); |
| 95 | } |
| 96 | |
| 97 | public int getHours() { |
| 98 | return date.getHours(); |
| 99 | } |
| 100 | |
| 101 | public CalendarDate setHours(int hours) { |
| 102 | unsupported(); return this; |
| 103 | } |
| 104 | |
| 105 | public CalendarDate addHours(int n) { |
| 106 | unsupported(); return this; |
| 107 | } |
| 108 | |
| 109 | public int getMinutes() { |
| 110 | return date.getMinutes(); |
| 111 | } |
| 112 | |
| 113 | public CalendarDate setMinutes(int minutes) { |
| 114 | unsupported(); return this; |
| 115 | } |
| 116 | |
| 117 | public CalendarDate addMinutes(int n) { |
| 118 | unsupported(); return this; |
| 119 | } |
| 120 | |
| 121 | public int getSeconds() { |
| 122 | return date.getSeconds(); |
| 123 | } |
| 124 | |
| 125 | public CalendarDate setSeconds(int seconds) { |
| 126 | unsupported(); return this; |
| 127 | } |
| 128 | |
| 129 | public CalendarDate addSeconds(int n) { |
| 130 | unsupported(); return this; |
| 131 | } |
| 132 | |
| 133 | public int getMillis() { |
| 134 | return date.getMillis(); |
| 135 | } |
| 136 | |
| 137 | public CalendarDate setMillis(int millis) { |
| 138 | unsupported(); return this; |
| 139 | } |
| 140 | |
| 141 | public CalendarDate addMillis(int n) { |
| 142 | unsupported(); return this; |
| 143 | } |
| 144 | |
| 145 | public long getTimeOfDay() { |
| 146 | return date.getTimeOfDay(); |
| 147 | } |
| 148 | |
| 149 | public CalendarDate setDate(int year, int month, int dayOfMonth) { |
| 150 | unsupported(); return this; |
| 151 | } |
| 152 | |
| 153 | public CalendarDate addDate(int year, int month, int dayOfMonth) { |
| 154 | unsupported(); return this; |
| 155 | } |
| 156 | |
| 157 | public CalendarDate setTimeOfDay(int hours, int minutes, int seconds, int millis) { |
| 158 | unsupported(); return this; |
| 159 | } |
| 160 | |
| 161 | public CalendarDate addTimeOfDay(int hours, int minutes, int seconds, int millis) { |
| 162 | unsupported(); return this; |
| 163 | } |
| 164 | |
| 165 | protected void setTimeOfDay(long fraction) { |
| 166 | unsupported(); |
| 167 | } |
| 168 | |
| 169 | public boolean isNormalized() { |
| 170 | return date.isNormalized(); |
| 171 | } |
| 172 | |
| 173 | public boolean isStandardTime() { |
| 174 | return date.isStandardTime(); |
| 175 | } |
| 176 | |
| 177 | public void setStandardTime(boolean standardTime) { |
| 178 | unsupported(); |
| 179 | } |
| 180 | |
| 181 | public boolean isDaylightTime() { |
| 182 | return date.isDaylightTime(); |
| 183 | } |
| 184 | |
| 185 | protected void setLocale(Locale loc) { |
| 186 | unsupported(); |
| 187 | } |
| 188 | |
| 189 | public TimeZone getZone() { |
| 190 | return date.getZone(); |
| 191 | } |
| 192 | |
| 193 | public CalendarDate setZone(TimeZone zoneinfo) { |
| 194 | unsupported(); return this; |
| 195 | } |
| 196 | |
| 197 | public boolean isSameDate(CalendarDate date) { |
| 198 | return date.isSameDate(date); |
| 199 | } |
| 200 | |
| 201 | public boolean equals(Object obj) { |
| 202 | if (this == obj) { |
| 203 | return true; |
| 204 | } |
| 205 | if (!(obj instanceof ImmutableGregorianDate)) { |
| 206 | return false; |
| 207 | } |
| 208 | return date.equals(((ImmutableGregorianDate) obj).date); |
| 209 | } |
| 210 | |
| 211 | public int hashCode() { |
| 212 | return date.hashCode(); |
| 213 | } |
| 214 | |
| 215 | public Object clone() { |
| 216 | return super.clone(); |
| 217 | } |
| 218 | |
| 219 | public String toString() { |
| 220 | return date.toString(); |
| 221 | } |
| 222 | |
| 223 | protected void setDayOfWeek(int dayOfWeek) { |
| 224 | unsupported(); |
| 225 | } |
| 226 | |
| 227 | protected void setNormalized(boolean normalized) { |
| 228 | unsupported(); |
| 229 | } |
| 230 | |
| 231 | public int getZoneOffset() { |
| 232 | return date.getZoneOffset(); |
| 233 | } |
| 234 | |
| 235 | protected void setZoneOffset(int offset) { |
| 236 | unsupported(); |
| 237 | } |
| 238 | |
| 239 | public int getDaylightSaving() { |
| 240 | return date.getDaylightSaving(); |
| 241 | } |
| 242 | |
| 243 | protected void setDaylightSaving(int daylightSaving) { |
| 244 | unsupported(); |
| 245 | } |
| 246 | |
| 247 | public int getNormalizedYear() { |
| 248 | return date.getNormalizedYear(); |
| 249 | } |
| 250 | |
| 251 | public void setNormalizedYear(int normalizedYear) { |
| 252 | unsupported(); |
| 253 | } |
| 254 | |
| 255 | private void unsupported() { |
| 256 | throw new UnsupportedOperationException(); |
| 257 | } |
| 258 | } |