1 Clazz.load (["java.lang.Comparable", "$.Number"], "java.lang.Long", null, function () {
2 java.lang.Long = Long = function () {
3 Clazz.instantialize (this, arguments);
5 Clazz.decorateAsType (Long, "Long", Number, Comparable, null, true);
6 Long.prototype.valueOf = function () { return 0; };
7 Long.toString = Long.prototype.toString = function () {
8 if (arguments.length != 0) {
9 return "" + arguments[0];
10 } else if (this === Long) {
11 return "class java.lang.Long"; // Long.class.toString
13 return "" + this.valueOf ();
15 Clazz.makeConstructor (Long,
17 this.valueOf = function () {
21 Clazz.makeConstructor (Long,
23 var v = Math.round (value);
24 this.valueOf = function () {
28 Clazz.makeConstructor (Long,
30 var value = Long.parseLong (s, 10);
31 this.valueOf = function () {
35 Long.serialVersionUID = Long.prototype.serialVersionUID = 4290774380558885855;
36 Long.MIN_VALUE = Long.prototype.MIN_VALUE = -0x8000000000000000;
37 Long.MAX_VALUE = Long.prototype.MAX_VALUE = 0x7fffffffffffffff;
38 Long.TYPE = Long.prototype.TYPE = Long;
40 Clazz.defineMethod (Long, "parseLong",
43 throw new NumberFormatException ("null");
45 throw new NumberFormatException ("radix " + radix + " less than Character.MIN_RADIX");
47 throw new NumberFormatException ("radix " + radix + " greater than Character.MAX_RADIX");
49 var longVal = parseInt (s, radix);
51 throw new NumberFormatException ("Not a Number : " + s);
56 Clazz.defineMethod (Long, "parseLong",
58 return Long.parseLong (s, 10);
61 Long.parseLong = Long.prototype.parseLong;
63 Clazz.defineMethod (Long, "$valueOf",
65 return new Long(Long.parseLong (s, 10));
68 Clazz.defineMethod (Long, "$valueOf",
73 Clazz.defineMethod (Long, "$valueOf",
75 return new Long(Long.parseLong (s, r));
78 Long.$valueOf = Long.prototype.$valueOf;
79 Clazz.defineMethod (Long, "equals",
81 if(s == null || !Clazz.instanceOf(s, Long) ){
84 return s.valueOf() == this.valueOf();
86 Long.toHexString = Long.prototype.toHexString = function (i) {
87 return i.toString (16);
89 Long.toOctalString = Long.prototype.toOctalString = function (i) {
90 return i.toString (8);
92 Long.toBinaryString = Long.prototype.toBinaryString = function (i) {
93 return i.toString (2);
95 Long.decode = Clazz.defineMethod (Long, "decode",
101 if (nm.startsWith ("-")) {
104 }if (nm.startsWith ("0x", index) || nm.startsWith ("0X", index)) {
107 } else if (nm.startsWith ("#", index)) {
110 } else if (nm.startsWith ("0", index) && nm.length > 1 + index) {
113 }if (nm.startsWith ("-", index)) throw new NumberFormatException ("Negative sign in wrong position");
115 result = Long.$valueOf (nm.substring (index), radix);
116 result = negative ? new Long (-result.longValue ()) : result;
118 if (Clazz.instanceOf (e, NumberFormatException)) {
119 var constant = negative ? String.instantialize ("-" + nm.substring (index)) : nm.substring (index);
120 result = Long.$valueOf (constant, radix);