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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
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
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
11 class Byte : Number {
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
12 public static const byte MIN_VALUE = byte.min;
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
13 public static const byte MAX_VALUE = byte.max;
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
14 private byte value;
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
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
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
34 super();
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
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
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
42 private static TypeInfo TYPE_;
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
43 public static TypeInfo TYPE(){
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
44 if( TYPE_ is null ){
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
45 TYPE_ = typeid(byte);
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
46 }
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
47 return TYPE_;
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
48 }
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
49
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
50 byte byteValue(){ return value; }
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
51 double doubleValue(){ return value; }
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
52 float floatValue(){ return value; }
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
53 int intValue(){ return value; }
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
54 long longValue(){ return value; }
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
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
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
59