File tree Expand file tree Collapse file tree 4 files changed +67
-10
lines changed
sources/net.sf.j2s.java.core/src/java/lang Expand file tree Collapse file tree 4 files changed +67
-10
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ this.valueOf = function () {
2121} , "Number" ) ;
2222Clazz . makeConstructor ( Double ,
2323function ( s ) {
24- var value = Double . parseDouble ( s , 10 ) ;
24+ var value = Double . parseDouble ( s ) ;
2525this . valueOf = function ( ) {
2626 return value ;
2727} ;
@@ -53,9 +53,21 @@ var doubleVal = parseFloat (s);
5353if ( isNaN ( doubleVal ) ) {
5454throw new NumberFormatException ( "Not a Number : " + s ) ;
5555}
56- return new Double ( doubleVal ) ;
56+ return doubleVal ;
5757} , "String" ) ;
58- Double . $valueOf = Double . parseDouble = Double . prototype . parseDouble ;
58+ Double . parseDouble = Double . prototype . parseDouble ;
59+
60+ Clazz . defineMethod ( Double , "$valueOf" ,
61+ function ( s ) {
62+ return new Double ( this . parseDouble ( s ) ) ;
63+ } , "String" ) ;
64+
65+ Clazz . defineMethod ( Double , "$valueOf" ,
66+ function ( v ) {
67+ return new Double ( v ) ;
68+ } , "Number" ) ;
69+
70+ Double . $valueOf = Double . prototype . $valueOf ;
5971
6072Clazz . defineMethod ( Double , "equals" ,
6173function ( s ) {
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ Clazz.makeConstructor (Float,
2323function ( s ) {
2424var value = null ;
2525if ( s != null ) {
26- value = Float . parseFloat ( s , 10 ) ;
26+ value = Float . parseFloat ( s ) ;
2727} else {
2828 value = 0 ;
2929}
@@ -47,9 +47,21 @@ var floatVal = parseFloat (s);
4747if ( isNaN ( floatVal ) ) {
4848throw new NumberFormatException ( "Not a Number : " + s ) ;
4949}
50- return new Float ( floatVal ) ;
50+ return floatVal ;
5151} , "String" ) ;
52- Float . $valueOf = Float . parseFloat = Float . prototype . parseFloat ;
52+ Float . parseFloat = Float . prototype . parseFloat ;
53+
54+ Clazz . defineMethod ( Float , "$valueOf" ,
55+ function ( s ) {
56+ return new Float ( Float . parseFloat ( s , 10 ) ) ;
57+ } , "String" ) ;
58+
59+ Clazz . defineMethod ( Float , "$valueOf" ,
60+ function ( s ) {
61+ return new Float ( s ) ;
62+ } , "Number" ) ;
63+
64+ Float . $valueOf = Float . prototype . $valueOf ;
5365Clazz . defineMethod ( Float , "isNaN" ,
5466function ( num ) {
5567return isNaN ( num ) ;
Original file line number Diff line number Diff line change @@ -44,16 +44,32 @@ var integer = parseInt (s, radix);
4444if ( isNaN ( integer ) ) {
4545throw new NumberFormatException ( "Not a Number : " + s ) ;
4646}
47- return new Integer ( integer ) ;
47+ return integer ;
4848} , "String, Number" ) ;
4949Integer . parseInt = Integer . prototype . parseInt ;
5050Clazz . defineMethod ( Integer , "parseInt" ,
5151function ( s ) {
5252return Integer . parseInt ( s , 10 ) ;
5353} , "String" ) ;
5454
55- Integer . $valueOf = Integer . parseInt = Integer . prototype . parseInt ;
55+ Integer . parseInt = Integer . prototype . parseInt ;
56+
57+ Clazz . defineMethod ( Integer , "$valueOf" ,
58+ function ( s ) {
59+ return new Integer ( Integer . parseInt ( s , 10 ) ) ;
60+ } , "String" ) ;
61+
62+ Clazz . defineMethod ( Integer , "$valueOf" ,
63+ function ( s ) {
64+ return new Integer ( s ) ;
65+ } , "Number" ) ;
66+
67+ Clazz . defineMethod ( Integer , "$valueOf" ,
68+ function ( s , r ) {
69+ return new Integer ( Integer . parseInt ( s , r ) ) ;
70+ } , "String, Number" ) ;
5671
72+ Integer . $valueOf = Integer . prototype . $valueOf ;
5773Clazz . defineMethod ( Integer , "equals" ,
5874function ( s ) {
5975if ( s == null || ! Clazz . instanceOf ( s , Integer ) ) {
Original file line number Diff line number Diff line change @@ -44,15 +44,32 @@ var longVal = parseInt (s, radix);
4444if ( isNaN ( longVal ) ) {
4545throw new NumberFormatException ( "Not a Number : " + s ) ;
4646}
47- return new Long ( longVal ) ;
47+ return longVal ;
4848} , "String, Number" ) ;
49- Long . $valueOf = Long . parseLong = Long . prototype . parseLong ;
49+
5050Clazz . defineMethod ( Long , "parseLong" ,
5151function ( s ) {
5252return Long . parseLong ( s , 10 ) ;
5353} , "String" ) ;
54+
5455Long . parseLong = Long . prototype . parseLong ;
5556
57+ Clazz . defineMethod ( Long , "$valueOf" ,
58+ function ( s ) {
59+ return new Long ( Long . parseLong ( s , 10 ) ) ;
60+ } , "String" ) ;
61+
62+ Clazz . defineMethod ( Long , "$valueOf" ,
63+ function ( s ) {
64+ return new Long ( s ) ;
65+ } , "Number" ) ;
66+
67+ Clazz . defineMethod ( Long , "$valueOf" ,
68+ function ( s , r ) {
69+ return new Long ( Long . parseLong ( s , r ) ) ;
70+ } , "String, Number" ) ;
71+
72+ Long . $valueOf = Long . prototype . $valueOf ;
5673Clazz . defineMethod ( Long , "equals" ,
5774function ( s ) {
5875if ( s == null || ! Clazz . instanceOf ( s , Long ) ) {
You can’t perform that action at this time.
0 commit comments