Mercurial > projects > dwt2
diff java/src/java/lang/Integer.d @ 0:6dd524f61e62
add dwt win and basic java stuff
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 02 Mar 2009 14:44:16 +0100 |
parents | |
children | 712ffca654f3 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/src/java/lang/Integer.d Mon Mar 02 14:44:16 2009 +0100 @@ -0,0 +1,115 @@ +module java.lang.Integer; + +import java.lang.util; + +class Integer : ValueWrapperT!(int) { + + public static const int MIN_VALUE = 0x80000000; + public static const int MAX_VALUE = 0x7fffffff; + public static const int SIZE = 32; + + public this ( int value ){ + super( value ); + } + + public this ( String s ){ + super(parseInt(s)); + } + + public static String toString( int i, int radix ){ + switch( radix ){ + case 2: + return toBinaryString(i); + case 8: + return toOctalString(i); + case 10: + return toString(i); + case 16: + return toHexString(i); + default: + implMissing( __FILE__, __LINE__ ); + return null; + } + } + + public static String toHexString( int i ){ + return tango.text.convert.Integer.toString(i, "x" ); + } + + public static String toOctalString( int i ){ + return tango.text.convert.Integer.toString(i, "o" ); + } + + public static String toBinaryString( int i ){ + return tango.text.convert.Integer.toString(i, "b" ); + } + + public static String toString( int i ){ + return tango.text.convert.Integer.toString(i); + } + + public static int parseInt( String s, int radix ){ + try{ + return tango.text.convert.Integer.toLong( s, radix ); + } + catch( IllegalArgumentException e ){ + throw new NumberFormatException( e ); + } + } + + public static int parseInt( String s ){ + try{ + return tango.text.convert.Integer.toLong( s ); + } + catch( IllegalArgumentException e ){ + throw new NumberFormatException( e ); + } + } + + public static Integer valueOf( String s, int radix ){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + public static Integer valueOf( String s ){ + return valueOf( parseInt(s)); + } + + public static Integer valueOf( int i ){ + return new Integer(i); + } + + public byte byteValue(){ + return cast(byte)value; + } + + public short shortValue(){ + return cast(short)value; + } + + public int intValue(){ + return value; + } + + public long longValue(){ + return cast(long)value; + } + + public float floatValue(){ + return cast(float)value; + } + + public double doubleValue(){ + return cast(double)value; + } + + public override hash_t toHash(){ + return intValue(); + } + + public override String toString(){ + return tango.text.convert.Integer.toString( value ); + } +} +alias Integer ValueWrapperInt; +