Mercurial > projects > dwt2
annotate base/src/java/lang/Byte.d @ 84:fcf926c91ca4
Added base classes
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 18 Apr 2009 09:25:29 +0200 |
parents | 1bf55a6eb092 |
children | 9e0ab372d5d8 |
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; |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
6 |
21
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
7 version(Tango){ |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
8 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
|
9 } else { // Phobos |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
10 } |
84 | 11 class Byte : Number { |
12 public static const byte MIN_VALUE = byte.min; | |
13 public static const byte MAX_VALUE = byte.max; | |
14 private byte value; | |
15 | |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
16 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
|
17 version(Tango){ |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
18 try{ |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
19 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
|
20 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
|
21 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
|
22 } |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
23 return res; |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
24 } |
21
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
25 catch( IllegalArgumentException e ){ |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
26 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
|
27 } |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
28 } else { // Phobos |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
29 implMissing( __FILE__, __LINE__); |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
30 return 0; |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
31 } |
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 this( byte value ){ |
84 | 34 super(); |
35 this.value = value; | |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
36 } |
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 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
|
39 return String_valueOf(i); |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
40 } |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
41 |
84 | 42 private static TypeInfo TYPE_; |
43 public static TypeInfo TYPE(){ | |
44 if( TYPE_ is null ){ | |
45 TYPE_ = typeid(byte); | |
46 } | |
47 return TYPE_; | |
48 } | |
49 | |
50 byte byteValue(){ return value; } | |
51 double doubleValue(){ return value; } | |
52 float floatValue(){ return value; } | |
53 int intValue(){ return value; } | |
54 long longValue(){ return value; } | |
55 short shortValue(){ return value; } | |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
56 } |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
57 alias Byte ValueWrapperByte; |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
58 |
84 | 59 |