3af1bcfe0cf020dec5efebfa8e4fbf4b0e87c0e8
[jalviewjs.git] / site / j2s / jssun / util / calendar / Era.js
1 Clazz.declarePackage ("jssun.util.calendar");\r
2 Clazz.load (null, "jssun.util.calendar.Era", ["java.lang.StringBuilder", "jssun.util.calendar.CalendarSystem", "$.ImmutableGregorianDate"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.name = null;\r
5 this.abbr = null;\r
6 this.since = 0;\r
7 this.sinceDate = null;\r
8 this.localTime = false;\r
9 this.hash = 0;\r
10 Clazz.instantialize (this, arguments);\r
11 }, jssun.util.calendar, "Era");\r
12 Clazz.makeConstructor (c$, \r
13 function (name, abbr, since, localTime) {\r
14 this.name = name;\r
15 this.abbr = abbr;\r
16 this.since = since;\r
17 this.localTime = localTime;\r
18 var gcal = jssun.util.calendar.CalendarSystem.getGregorianCalendar ();\r
19 var d = gcal.newCalendarDate (null);\r
20 gcal.getCalendarDate (since, d);\r
21 this.sinceDate =  new jssun.util.calendar.ImmutableGregorianDate (d);\r
22 }, "~S,~S,~N,~B");\r
23 Clazz.defineMethod (c$, "getName", \r
24 function () {\r
25 return this.name;\r
26 });\r
27 Clazz.defineMethod (c$, "getDisplayName", \r
28 function (locale) {\r
29 return this.name;\r
30 }, "java.util.Locale");\r
31 Clazz.defineMethod (c$, "getAbbreviation", \r
32 function () {\r
33 return this.abbr;\r
34 });\r
35 Clazz.defineMethod (c$, "getDiaplayAbbreviation", \r
36 function (locale) {\r
37 return this.abbr;\r
38 }, "java.util.Locale");\r
39 Clazz.defineMethod (c$, "getSince", \r
40 function (zone) {\r
41 if (zone == null || !this.localTime) {\r
42 return this.since;\r
43 }var offset = zone.getOffset (this.since);\r
44 return this.since - offset;\r
45 }, "java.util.TimeZone");\r
46 Clazz.defineMethod (c$, "getSinceDate", \r
47 function () {\r
48 return this.sinceDate;\r
49 });\r
50 Clazz.defineMethod (c$, "isLocalTime", \r
51 function () {\r
52 return this.localTime;\r
53 });\r
54 Clazz.overrideMethod (c$, "equals", \r
55 function (o) {\r
56 if (!(Clazz.instanceOf (o, jssun.util.calendar.Era))) {\r
57 return false;\r
58 }var that = o;\r
59 return this.name.equals (that.name) && this.abbr.equals (that.abbr) && this.since == that.since && this.localTime == that.localTime;\r
60 }, "~O");\r
61 Clazz.overrideMethod (c$, "hashCode", \r
62 function () {\r
63 if (this.hash == 0) {\r
64 this.hash = this.name.hashCode () ^ this.abbr.hashCode () ^ this.since ^ (this.since >> 32) ^ (this.localTime ? 1 : 0);\r
65 }return this.hash;\r
66 });\r
67 Clazz.overrideMethod (c$, "toString", \r
68 function () {\r
69 var sb =  new StringBuilder ();\r
70 sb.append ('[');\r
71 sb.append (this.getName ()).append (" (");\r
72 sb.append (this.getAbbreviation ()).append (')');\r
73 sb.append (" since ").append (this.getSinceDate ());\r
74 if (this.localTime) {\r
75 sb.setLength (sb.length () - 1);\r
76 sb.append (" local time");\r
77 }sb.append (']');\r
78 return sb.toString ();\r
79 });\r
80 });\r