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
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;
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
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
12 class Byte : Number {
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
13 public static const byte MIN_VALUE = byte.min;
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
14 public static const byte MAX_VALUE = byte.max;
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
15 private byte value;
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
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
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
35 super();
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
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
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
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
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
47 }
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
48 return TYPE_;
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
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
51 byte byteValue(){ return value; }
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
52 double doubleValue(){ return value; }
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
53 float floatValue(){ return value; }
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
54 int intValue(){ return value; }
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
55 long longValue(){ return value; }
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
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
fcf926c91ca4 Added base classes
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
60