Mercurial > projects > dwt2
annotate base/src/java/lang/Short.d @ 115:b31c27b8e86d
Added Phobos implementation of java.lang.String.firstCodePoint.
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 17 Apr 2011 16:53:26 +0200 |
parents | 9e0ab372d5d8 |
children | 536e43f63c81 |
rev | line source |
---|---|
84 | 1 module java.lang.Short; |
2 | |
3 import java.lang.util; | |
4 import java.lang.exceptions; | |
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; |
84 | 7 |
8 version(Tango){ | |
9 static import tango.text.convert.Integer; | |
10 } else { // Phobos | |
11 } | |
12 class Short : Number { | |
13 public static const short MIN_VALUE = short.min; | |
14 public static const short MAX_VALUE = short.max; | |
15 private short value; | |
16 public static byte parseShort( String s ){ | |
17 version(Tango){ | |
18 try{ | |
19 int res = tango.text.convert.Integer.parse( s ); | |
20 if( res < byte.min || res > byte.max ){ | |
21 throw new NumberFormatException( "out of range" ); | |
22 } | |
23 return res; | |
24 } | |
25 catch( IllegalArgumentException e ){ | |
26 throw new NumberFormatException( e ); | |
27 } | |
28 } else { // Phobos | |
29 implMissing( __FILE__, __LINE__); | |
30 return 0; | |
31 } | |
32 } | |
33 this( short value ){ | |
34 super(); | |
35 this.value = value; | |
36 } | |
37 | |
38 public static String toString( short i ){ | |
39 return String_valueOf(i); | |
40 } | |
41 | |
88
9e0ab372d5d8
Revert from TypeInfo/ClassInfo to java.lang.Class
Frank Benoit <benoit@tionex.de>
parents:
84
diff
changeset
|
42 private static Class TYPE_; |
9e0ab372d5d8
Revert from TypeInfo/ClassInfo to java.lang.Class
Frank Benoit <benoit@tionex.de>
parents:
84
diff
changeset
|
43 public static Class TYPE(){ |
84 | 44 if( TYPE_ is null ){ |
88
9e0ab372d5d8
Revert from TypeInfo/ClassInfo to java.lang.Class
Frank Benoit <benoit@tionex.de>
parents:
84
diff
changeset
|
45 TYPE_ = Class.fromType!(short); |
84 | 46 } |
47 return TYPE_; | |
48 } | |
49 | |
50 byte byteValue(){ return cast(byte)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; } | |
56 } | |
57 alias Short ValueWrapperShort; | |
58 |