1 module java.lang.Byte; 2 3 import java.lang.util; 4 import java.lang.exceptions; 5 import java.lang.Number; 6 import java.lang.Class; 7 import java.lang.String; 8 9 version(Tango){ 10 static import tango.text.convert.Integer; 11 } else { // Phobos 12 static import std.conv; 13 } 14 class Byte : Number { 15 public static const byte MIN_VALUE = byte.min; 16 public static const byte MAX_VALUE = byte.max; 17 private byte value; 18 19 public static byte parseByte( String s ){ 20 version(Tango){ 21 try{ 22 int res = tango.text.convert.Integer.parse( s ); 23 if( res < byte.min || res > byte.max ){ 24 throw new NumberFormatException( "out of range" ); 25 } 26 return res; 27 } 28 catch( IllegalArgumentException e ){ 29 throw new NumberFormatException( e ); 30 } 31 } else { // Phobos 32 try{ 33 return std.conv.to!(byte)(s); 34 } 35 catch( std.conv.ConvException e ){ 36 throw new NumberFormatException( e ); 37 } 38 } 39 } 40 this( byte value ){ 41 super(); 42 this.value = value; 43 } 44 45 public static String toString( byte i ){ 46 return String_valueOf(i); 47 } 48 49 private static Class TYPE_; 50 public static Class TYPE(){ 51 if( TYPE_ is null ){ 52 TYPE_ = Class.fromType!(byte); 53 } 54 return TYPE_; 55 } 56 57 override 58 byte byteValue(){ return value; } 59 override 60 double doubleValue(){ return value; } 61 override 62 float floatValue(){ return value; } 63 override 64 int intValue(){ return value; } 65 override 66 long longValue(){ return value; } 67 override 68 short shortValue(){ return value; } 69 } 70 alias Byte ValueWrapperByte; 71 72