1 Clazz.load (["java.lang.Comparable", "$.Number"], "java.lang.Short", null, function () {
2 java.lang.Short = Short = function () {
3 Clazz.instantialize (this, arguments);
5 Clazz.decorateAsType (Short, "Short", Number, Comparable, null, true);
6 Short.prototype.valueOf = function () { return 0; };
7 Short.toString = Short.prototype.toString = function () {
8 if (arguments.length != 0) {
9 return "" + arguments[0];
10 } else if (this === Short) {
11 return "class java.lang.Short"; // Short.class.toString
13 return "" + this.valueOf ();
15 Clazz.makeConstructor (Short,
17 this.valueOf = function () {
21 Clazz.makeConstructor (Short,
23 var v = Math.round (value) & 0xffffffff;
24 this.valueOf = function () {
28 Clazz.makeConstructor (Short,
30 var value = Short.parseShort (s, 10);
31 this.valueOf = function () {
35 Short.serialVersionUID = Short.prototype.serialVersionUID = 7515723908773894738;
36 Short.MIN_VALUE = Short.prototype.MIN_VALUE = -32768;
37 Short.MAX_VALUE = Short.prototype.MAX_VALUE = 32767;
38 Short.TYPE = Short.prototype.TYPE = Short;
40 Clazz.defineMethod (Short, "parseShort",
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 integer = parseInt (s, radix);
51 throw new NumberFormatException ("Not a Number : " + s);
55 Short.parseShort = Short.prototype.parseShort;
56 Clazz.defineMethod (Short, "parseShort",
58 return Short.parseShort (s, 10);
61 Short.parseShort = Short.prototype.parseShort;
63 Clazz.defineMethod (Short, "$valueOf",
65 return new Short(Short.parseShort (s, 10));
68 Clazz.defineMethod (Short, "$valueOf",
73 Clazz.defineMethod (Short, "$valueOf",
75 return new Short(Short.parseShort (s, r));
78 Short.$valueOf = Short.prototype.$valueOf;
79 Clazz.defineMethod (Short, "equals",
81 if(s == null || !Clazz.instanceOf(s, Short) ){
84 return s.valueOf() == this.valueOf();
86 Short.toHexString = Short.prototype.toHexString = function (i) {
87 return i.toString (16);
89 Short.toOctalString = Short.prototype.toOctalString = function (i) {
90 return i.toString (8);
92 Short.toBinaryString = Short.prototype.toBinaryString = function (i) {
93 return i.toString (2);
95 Short.decode = Clazz.defineMethod (Short, "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 = Short.$valueOf (nm.substring (index), radix);
116 result = negative ? new Short (-result.shortValue ()) : result;
118 if (Clazz.instanceOf (e, NumberFormatException)) {
119 var constant = negative ? String.instantialize ("-" + nm.substring (index)) : nm.substring (index);
120 result = Short.$valueOf (constant, radix);