Mercurial > projects > dwt2
annotate base/src/java/lang/Byte.d @ 88:9e0ab372d5d8
Revert from TypeInfo/ClassInfo to java.lang.Class
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 19 Apr 2009 11:10:09 +0200 |
parents | fcf926c91ca4 |
children | 536e43f63c81 |
rev | line source |
---|---|
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1 module java.lang.Byte; |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2 |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3 import java.lang.util; |
2
712ffca654f3
Moved java classes to their correct location
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
4 import java.lang.exceptions; |
84 | 5 import java.lang.Number; |
88
9e0ab372d5d8
Revert from TypeInfo/ClassInfo to java.lang.Class
Frank Benoit <benoit@tionex.de>
parents:
84
diff
changeset
|
6 import java.lang.Class; |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
7 |
21
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
8 version(Tango){ |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
9 static import tango.text.convert.Integer; |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
10 } else { // Phobos |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
11 } |
84 | 12 class Byte : Number { |
13 public static const byte MIN_VALUE = byte.min; | |
14 public static const byte MAX_VALUE = byte.max; | |
15 private byte value; | |
16 | |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
17 public static byte parseByte( String s ){ |
21
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
18 version(Tango){ |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
19 try{ |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
20 int res = tango.text.convert.Integer.parse( s ); |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
21 if( res < byte.min || res > byte.max ){ |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
22 throw new NumberFormatException( "out of range" ); |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
23 } |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
24 return res; |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
25 } |
21
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
26 catch( IllegalArgumentException e ){ |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
27 throw new NumberFormatException( e ); |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
28 } |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
29 } else { // Phobos |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
30 implMissing( __FILE__, __LINE__); |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
31 return 0; |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
32 } |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
33 } |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
34 this( byte value ){ |
84 | 35 super(); |
36 this.value = value; | |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
37 } |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
38 |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
39 public static String toString( byte i ){ |
21
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
40 return String_valueOf(i); |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
41 } |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
42 |
88
9e0ab372d5d8
Revert from TypeInfo/ClassInfo to java.lang.Class
Frank Benoit <benoit@tionex.de>
parents:
84
diff
changeset
|
43 private static Class TYPE_; |
9e0ab372d5d8
Revert from TypeInfo/ClassInfo to java.lang.Class
Frank Benoit <benoit@tionex.de>
parents:
84
diff
changeset
|
44 public static Class TYPE(){ |
84 | 45 if( TYPE_ is null ){ |
88
9e0ab372d5d8
Revert from TypeInfo/ClassInfo to java.lang.Class
Frank Benoit <benoit@tionex.de>
parents:
84
diff
changeset
|
46 TYPE_ = Class.fromType!(byte); |
84 | 47 } |
48 return TYPE_; | |
49 } | |
50 | |
51 byte byteValue(){ return value; } | |
52 double doubleValue(){ return value; } | |
53 float floatValue(){ return value; } | |
54 int intValue(){ return value; } | |
55 long longValue(){ return value; } | |
56 short shortValue(){ return value; } | |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
57 } |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
58 alias Byte ValueWrapperByte; |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
59 |
84 | 60 |