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