@@ -12,6 +12,7 @@ Integer.toString = Integer.prototype.toString = function () {
1212 }
1313 return "" + this . valueOf ( ) ;
1414} ;
15+ /*
1516Clazz.makeConstructor (Integer,
1617function () {
1718this.valueOf = function () {
@@ -32,13 +33,31 @@ this.valueOf = function () {
3233 return value;
3334};
3435}, "String");
36+ // */
37+ Clazz . makeConstructor ( Integer ,
38+ function ( s ) {
39+ var v = 0 ;
40+ if ( arguments . length > 0 ) {
41+ if ( typeof s == "string" ) {
42+ v = Integer . parseInt ( s , 10 ) ;
43+ } else {
44+ v = s ;
45+ }
46+ }
47+ this . valueOf = function ( ) {
48+ return v ;
49+ } ;
50+ } , "Object" ) ;
3551Integer . serialVersionUID = Integer . prototype . serialVersionUID = 1360826667806852920 ;
3652Integer . MIN_VALUE = Integer . prototype . MIN_VALUE = - 0x80000000 ;
3753Integer . MAX_VALUE = Integer . prototype . MAX_VALUE = 0x7fffffff ;
3854Integer . TYPE = Integer . prototype . TYPE = Integer ;
3955
4056Clazz . defineMethod ( Integer , "parseInt" ,
4157function ( s , radix ) {
58+ if ( arguments . length < 2 || radix == null ) {
59+ radix = 10 ;
60+ }
4261if ( s == null ) {
4362throw new NumberFormatException ( "null" ) ;
4463} if ( radix < 2 ) {
@@ -52,18 +71,20 @@ throw new NumberFormatException ("Not a Number : " + s);
5271}
5372return integer ;
5473} , "String, Number" ) ;
74+ /*
5575Integer.parseInt = Integer.prototype.parseInt;
5676Clazz.defineMethod (Integer, "parseInt",
5777function (s) {
5878return Integer.parseInt (s, 10);
5979}, "String");
60-
80+ // */
6181Integer . parseInt = Integer . prototype . parseInt ;
6282
83+ /*
6384Clazz.defineMethod (Integer, "$valueOf",
64- function ( s ) {
85+ function (s, r ) {
6586return new Integer(Integer.parseInt (s, 10));
66- } , "String" ) ;
87+ }, "String");
6788
6889Clazz.defineMethod (Integer, "$valueOf",
6990function (s) {
@@ -75,8 +96,20 @@ function (s, r) {
7596return new Integer(Integer.parseInt (s, r));
7697}, "String, Number");
7798
78- Integer . $valueOf = Integer . prototype . $valueOf ;
79- Clazz . defineMethod ( Integer , "equals" ,
99+ Integer.$valueOf = Integer.prototype.$valueOf;
100+ // */
101+
102+ Integer . $valueOf = Integer . prototype . $valueOf = function ( s , r ) {
103+ if ( arguments . length == 2 ) { // String, Number
104+ return new Integer ( Integer . parseInt ( s , r ) ) ;
105+ } else if ( typeof s == "string" ) { // String
106+ return new Integer ( Integer . parseInt ( s , 10 ) ) ;
107+ } else { // Number
108+ return new Integer ( s ) ;
109+ }
110+ } ;
111+
112+ Clazz . overrideMethod ( Integer , "equals" ,
80113function ( s ) {
81114if ( s == null || ! Clazz . instanceOf ( s , Integer ) ) {
82115 return false ;
@@ -85,15 +118,15 @@ return s.valueOf() == this.valueOf();
85118} , "Object" ) ;
86119Integer . toHexString = Integer . prototype . toHexString = function ( d ) {
87120 if ( d . valueOf ) d = d . valueOf ( ) ;
88- return d . _numberToString ( 16 ) ;
121+ return d . to$tring ( 16 ) ;
89122} ;
90123Integer . toOctalString = Integer . prototype . toOctalString = function ( d ) {
91124 if ( d . valueOf ) d = d . valueOf ( ) ;
92- return d . _numberToString ( 8 ) ;
125+ return d . to$tring ( 8 ) ;
93126} ;
94127Integer . toBinaryString = Integer . prototype . toBinaryString = function ( d ) {
95128 if ( d . valueOf ) d = d . valueOf ( ) ;
96- return d . _numberToString ( 2 ) ;
129+ return d . to$tring ( 2 ) ;
97130} ;
98131Integer . decode = Clazz . defineMethod ( Integer , "decode" ,
99132function ( nm ) {
0 commit comments