1 Clazz.load (["java.lang.Comparable", "$.Number"], "java.lang.Byte", null, function () {
2 java.lang.Byte = Byte = function () {
3 Clazz.instantialize (this, arguments);
5 Clazz.decorateAsType (Byte, "Byte", Number, Comparable, null, true);
6 Byte.prototype.valueOf = function () { return 0; };
7 Byte.toString = Byte.prototype.toString = function () {
8 if (arguments.length != 0) {
9 return "" + arguments[0];
10 } else if (this === Byte) {
11 return "class java.lang.Byte"; // Byte.class.toString
13 return "" + this.valueOf ();
15 Clazz.makeConstructor (Byte,
17 this.valueOf = function () {
21 Clazz.makeConstructor (Byte,
23 var v = Math.round (value) & 0xffffffff;
24 this.valueOf = function () {
28 Clazz.makeConstructor (Byte,
30 var value = Byte.parseByte (s, 10);
31 this.valueOf = function () {
35 Byte.serialVersionUID = Byte.prototype.serialVersionUID = -7183698231559129828;
36 Byte.MIN_VALUE = Byte.prototype.MIN_VALUE = -128;
37 Byte.MAX_VALUE = Byte.prototype.MAX_VALUE = 127;
38 Byte.SIZE = Byte.prototype.SIZE = 8;
39 Byte.TYPE = Byte.prototype.TYPE = Byte;
41 Clazz.defineMethod (Byte, "parseByte",
44 throw new NumberFormatException ("null");
46 throw new NumberFormatException ("radix " + radix + " less than Character.MIN_RADIX");
48 throw new NumberFormatException ("radix " + radix + " greater than Character.MAX_RADIX");
50 var integer = parseInt (s, radix);
52 throw new NumberFormatException ("Not a Number : " + s);
56 Byte.parseByte = Byte.prototype.parseByte;
57 Clazz.defineMethod (Byte, "parseByte",
59 return Byte.parseByte (s, 10);
62 Byte.parseByte = Byte.prototype.parseByte;
64 Clazz.defineMethod (Byte, "$valueOf",
66 return new Byte(Byte.parseByte (s, 10));
69 Clazz.defineMethod (Byte, "$valueOf",
74 Clazz.defineMethod (Byte, "$valueOf",
76 return new Byte(Byte.parseByte (s, r));
79 Byte.$valueOf = Byte.prototype.$valueOf;
80 Clazz.overrideMethod(Byte, "equals",
82 if(s == null || !Clazz.instanceOf(s, Byte) ){
85 return s.valueOf() == this.valueOf();
87 Byte.toHexString = Byte.prototype.toHexString = function (i) {
88 return i.toString (16);
90 Byte.toOctalString = Byte.prototype.toOctalString = function (i) {
91 return i.toString (8);
93 Byte.toBinaryString = Byte.prototype.toBinaryString = function (i) {
94 return i.toString (2);
96 Byte.decode = Clazz.defineMethod (Byte, "decode",
100 var negative = false;
102 if (nm.startsWith ("-")) {
105 }if (nm.startsWith ("0x", index) || nm.startsWith ("0X", index)) {
108 } else if (nm.startsWith ("#", index)) {
111 } else if (nm.startsWith ("0", index) && nm.length > 1 + index) {
114 }if (nm.startsWith ("-", index)) throw new NumberFormatException ("Negative sign in wrong position");
116 result = Byte.$valueOf (nm.substring (index), radix);
117 result = negative ? new Byte (-result.byteValue ()) : result;
119 if (Clazz.instanceOf (e, NumberFormatException)) {
120 var constant = negative ? String.instantialize ("-" + nm.substring (index)) : nm.substring (index);
121 result = Byte.$valueOf (constant, radix);