# HG changeset patch # User Frank Benoit # Date 1236199278 -3600 # Node ID 712ffca654f363d3108f07f2cf990e492226fc24 # Parent 0e8eed4cac02ec09d9030ab7f9d79c71a5bfb65e Moved java classes to their correct location diff -r 0e8eed4cac02 -r 712ffca654f3 java/src/java/io/Reader.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/src/java/io/Reader.d Wed Mar 04 21:41:18 2009 +0100 @@ -0,0 +1,41 @@ +module java.io.Reader; + +import java.lang.util; + +class Reader{ + protected Object lock; + protected this(){ + implMissing(__FILE__,__LINE__); + } + protected this(Object lock){ + implMissing(__FILE__,__LINE__); + } + abstract void close(); + void mark(int readAheadLimit){ + implMissing(__FILE__,__LINE__); + } + bool markSupported(){ + implMissing(__FILE__,__LINE__); + return false; + } + int read(){ + implMissing(__FILE__,__LINE__); + return 0; + } + int read(char[] cbuf){ + implMissing(__FILE__,__LINE__); + return 0; + } + abstract int read(char[] cbuf, int off, int len); + bool ready(){ + implMissing(__FILE__,__LINE__); + return false; + } + void reset(){ + implMissing(__FILE__,__LINE__); + } + long skip(long n){ + implMissing(__FILE__,__LINE__); + return 0; + } +} diff -r 0e8eed4cac02 -r 712ffca654f3 java/src/java/io/Writer.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/src/java/io/Writer.d Wed Mar 04 21:41:18 2009 +0100 @@ -0,0 +1,5 @@ +module java.io.Writer; + +class Writer{ +} + diff -r 0e8eed4cac02 -r 712ffca654f3 java/src/java/lang/Byte.d --- a/java/src/java/lang/Byte.d Mon Mar 02 14:44:56 2009 +0100 +++ b/java/src/java/lang/Byte.d Wed Mar 04 21:41:18 2009 +0100 @@ -1,6 +1,7 @@ module java.lang.Byte; import java.lang.util; +import java.lang.exceptions; class Byte : ValueWrapperT!(byte) { public static byte parseByte( String s ){ diff -r 0e8eed4cac02 -r 712ffca654f3 java/src/java/lang/Character.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/src/java/lang/Character.d Wed Mar 04 21:41:18 2009 +0100 @@ -0,0 +1,50 @@ +module java.lang.Character; + +import java.lang.exceptions; +import java.lang.util; +import tango.text.Unicode; + +class Character { + public static bool isUpperCase( dchar c ){ + implMissing( __FILE__, __LINE__); + return false; + } + public static dchar toUpperCase( dchar c ){ + dchar[] r = tango.text.Unicode.toUpper( [c] ); + return r[0]; + } + public static dchar toLowerCase( dchar c ){ + dchar[] r = tango.text.Unicode.toLower( [c] ); + return r[0]; + } + public static bool isWhitespace( dchar c ){ + return tango.text.Unicode.isWhitespace( c ); + } + public static bool isDigit( dchar c ){ + return tango.text.Unicode.isDigit( c ); + } + public static bool isLetterOrDigit( dchar c ){ + return isDigit(c) || isLetter(c); + } + public static bool isUnicodeIdentifierPart(char ch){ + implMissing( __FILE__, __LINE__); + return false; + } + public static bool isUnicodeIdentifierStart(char ch){ + implMissing( __FILE__, __LINE__); + return false; + } + public static bool isIdentifierIgnorable(char ch){ + implMissing( __FILE__, __LINE__); + return false; + } + public static bool isJavaIdentifierPart(char ch){ + implMissing( __FILE__, __LINE__); + return false; + } + + this( char c ){ + // must be correct for container storage + implMissing( __FILE__, __LINE__); + } +} diff -r 0e8eed4cac02 -r 712ffca654f3 java/src/java/lang/Float.d --- a/java/src/java/lang/Float.d Mon Mar 02 14:44:56 2009 +0100 +++ b/java/src/java/lang/Float.d Wed Mar 04 21:41:18 2009 +0100 @@ -1,6 +1,7 @@ module java.lang.Float; import java.lang.util; +import java.lang.exceptions; class Float : ValueWrapperT!(float) { diff -r 0e8eed4cac02 -r 712ffca654f3 java/src/java/lang/Integer.d --- a/java/src/java/lang/Integer.d Mon Mar 02 14:44:56 2009 +0100 +++ b/java/src/java/lang/Integer.d Wed Mar 04 21:41:18 2009 +0100 @@ -1,6 +1,7 @@ module java.lang.Integer; import java.lang.util; +import java.lang.exceptions; class Integer : ValueWrapperT!(int) { diff -r 0e8eed4cac02 -r 712ffca654f3 java/src/java/lang/exceptions.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/src/java/lang/exceptions.d Wed Mar 04 21:41:18 2009 +0100 @@ -0,0 +1,77 @@ +module java.lang.exceptions; + +import java.lang.util; + +class ClassCastException : Exception { + this( String e = null ){ + super(e); + } +} + +class IllegalStateException : Exception { + this( String e = null ){ + super(e); + } + this( Exception e ){ + super(e.toString); + } +} + +class IndexOutOfBoundsException : Exception { + this( String e = null){ + super(e); + } +} + +class InterruptedException : Exception { + this( String e = null ){ + super(e); + } + this( Exception e ){ + super(e.toString); + } +} + +class NullPointerException : Exception { + this( String e = null ){ + super(e); + } + this( Exception e ){ + super(e.toString); + } +} + +class NumberFormatException : IllegalArgumentException { + this( String e ){ + super(e); + } + this( Exception e ){ + super(e.toString); + } +} + +class RuntimeException : Exception { + this( char[] file, long line, char[] msg = null){ + super( msg, file, line ); + } + this( String e = null){ + super(e); + } + this( Exception e ){ + super(e.toString); + next = e; + } + public Exception getCause() { + return next; + } +} + +class UnsupportedOperationException : RuntimeException { + this( String e = null){ + super(e); + } + this( Exception e ){ + super(e.toString); + } +} + diff -r 0e8eed4cac02 -r 712ffca654f3 java/src/java/lang/reflect/InvocationTargetException.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/src/java/lang/reflect/InvocationTargetException.d Wed Mar 04 21:41:18 2009 +0100 @@ -0,0 +1,17 @@ +module java.lang.reflect.InvocationTargetException; + +import java.lang.all; + +class InvocationTargetException : Exception { + Exception cause; + this( Exception e = null, String msg = null ){ + super(msg); + cause = e; + } + + alias getCause getTargetException; + Exception getCause(){ + return cause; + } +} + diff -r 0e8eed4cac02 -r 712ffca654f3 java/src/java/lang/util.d --- a/java/src/java/lang/util.d Mon Mar 02 14:44:56 2009 +0100 +++ b/java/src/java/lang/util.d Wed Mar 04 21:41:18 2009 +0100 @@ -399,100 +399,70 @@ return res; } -class Character { - public static bool isUpperCase( dchar c ){ - implMissing( __FILE__, __LINE__); - return false; - } - public static dchar toUpperCase( dchar c ){ - dchar[] r = tango.text.Unicode.toUpper( [c] ); - return r[0]; - } - public static dchar toLowerCase( dchar c ){ - dchar[] r = tango.text.Unicode.toLower( [c] ); - return r[0]; - } - public static bool isWhitespace( dchar c ){ - return tango.text.Unicode.isWhitespace( c ); - } - public static bool isDigit( dchar c ){ - return tango.text.Unicode.isDigit( c ); - } - public static bool isLetterOrDigit( dchar c ){ - return isDigit(c) || isLetter(c); - } - public static bool isUnicodeIdentifierPart(char ch){ - implMissing( __FILE__, __LINE__); - return false; - } - public static bool isUnicodeIdentifierStart(char ch){ - implMissing( __FILE__, __LINE__); - return false; - } - public static bool isIdentifierIgnorable(char ch){ - implMissing( __FILE__, __LINE__); - return false; - } - public static bool isJavaIdentifierPart(char ch){ - implMissing( __FILE__, __LINE__); - return false; - } - - this( char c ){ - // must be correct for container storage - implMissing( __FILE__, __LINE__); - } -} - String new_String( String cont, int offset, int len ){ return cont[ offset .. offset+len ].dup; } + String new_String( String cont ){ return cont.dup; } + String String_valueOf( bool v ){ return v ? "true" : "false"; } + String String_valueOf( int v ){ return tango.text.convert.Integer.toString(v); } + String String_valueOf( long v ){ return tango.text.convert.Integer.toString(v); } + String String_valueOf( float v ){ return tango.text.convert.Float.toString(v); } + String String_valueOf( double v ){ return tango.text.convert.Float.toString(v); } + String String_valueOf( dchar v ){ return dcharToString(v); } + String String_valueOf( char[] v ){ return v.dup; } + String String_valueOf( char[] v, int offset, int len ){ return v[ offset .. offset+len ].dup; } + String String_valueOf( Object v ){ return v is null ? "null" : v.toString(); } + bool CharacterIsDefined( dchar ch ){ return (ch in tango.text.UnicodeData.unicodeData) !is null; } + dchar CharacterFirstToLower( String str ){ int consumed; return CharacterFirstToLower( str, consumed ); } + dchar CharacterFirstToLower( String str, out int consumed ){ dchar[1] buf; buf[0] = firstCodePoint( str, consumed ); dchar[] r = tango.text.Unicode.toLower( buf ); return r[0]; } + int length( String str ){ return str.length; } + dchar CharacterToLower( dchar c ){ dchar[] r = tango.text.Unicode.toLower( [c] ); return r[0]; @@ -510,94 +480,120 @@ bool CharacterIsLetter( dchar c ){ return tango.text.Unicode.isLetter( c ); } + +/// Extension to String public String toUpperCase( String str ){ return tango.text.Unicode.toUpper( str ); } +/// Extension to String public String replaceFirst( String str, String regex, String replacement ){ implMissing(__FILE__,__LINE__); return str; } +/// Extension to String public int indexOf( String str, char searched ){ int res = tango.text.Util.locate( str, searched ); if( res is str.length ) res = -1; return res; } +/// Extension to String public int indexOf( String str, char searched, int startpos ){ int res = tango.text.Util.locate( str, searched, startpos ); if( res is str.length ) res = -1; return res; } +/// Extension to String public int indexOf(String str, String ch){ return indexOf( str, ch, 0 ); } +/// Extension to String public int indexOf(String str, String ch, int start){ int res = tango.text.Util.locatePattern( str, ch, start ); if( res is str.length ) res = -1; return res; } +/// Extension to String public int lastIndexOf(String str, char ch){ return lastIndexOf( str, ch, str.length ); } + +/// Extension to String public int lastIndexOf(String str, char ch, int formIndex){ int res = tango.text.Util.locatePrior( str, ch, formIndex ); if( res is str.length ) res = -1; return res; } + +/// Extension to String public int lastIndexOf(String str, String ch ){ return lastIndexOf( str, ch, str.length ); } + +/// Extension to String public int lastIndexOf(String str, String ch, int start ){ int res = tango.text.Util.locatePatternPrior( str, ch, start ); if( res is str.length ) res = -1; return res; } +/// Extension to String public String replaceAll( String str, String regex, String replacement ){ implMissing(__FILE__,__LINE__); return null; } + +/// Extension to String public String replace( String str, char from, char to ){ return tango.text.Util.replace( str.dup, from, to ); } +/// Extension to String public String substring( String str, int start ){ return str[ start .. $ ].dup; } +/// Extension to String public String substring( String str, int start, int end ){ return str[ start .. end ].dup; } +/// Extension to String public wchar[] substring( wchar[] str, int start ){ return str[ start .. $ ].dup; } +/// Extension to String public wchar[] substring( wchar[] str, int start, int end ){ return str[ start .. end ].dup; } +/// Extension to String public char charAt( String str, int pos ){ return str[ pos ]; } +/// Extension to String public void getChars( String src, int srcBegin, int srcEnd, String dst, int dstBegin){ dst[ dstBegin .. dstBegin + srcEnd - srcBegin ] = src[ srcBegin .. srcEnd ]; } +/// Extension to String public wchar[] toWCharArray( String str ){ return toString16(str); } +/// Extension to String public char[] toCharArray( String str ){ return str; } +/// Extension to String public bool endsWith( String src, String pattern ){ if( src.length < pattern.length ){ return false; @@ -605,21 +601,27 @@ return src[ $-pattern.length .. $ ] == pattern; } +/// Extension to String public bool equals( String src, String other ){ return src == other; } +/// Extension to String public bool equalsIgnoreCase( String src, String other ){ return tango.text.Unicode.toFold(src) == tango.text.Unicode.toFold(other); } +/// Extension to String public int compareToIgnoreCase( String src, String other ){ return compareTo( tango.text.Unicode.toFold(src), tango.text.Unicode.toFold(other)); } + +/// Extension to String public int compareTo( String src, String other ){ return typeid(String).compare( cast(void*)&src, cast(void*)&other ); } +/// Extension to String public bool startsWith( String src, String pattern ){ if( src.length < pattern.length ){ return false; @@ -627,17 +629,22 @@ return src[ 0 .. pattern.length ] == pattern; } +/// Extension to String public String toLowerCase( String src ){ return tango.text.Unicode.toLower( src ); } +/// Extension to String public hash_t toHash( String src ){ return typeid(String).getHash(&src); } +/// Extension to String public String trim( String str ){ return tango.text.Util.trim( str ).dup; } + +/// Extension to String public String intern( String str ){ return str; } @@ -670,100 +677,6 @@ "d" ); } -class RuntimeException : Exception { - this( char[] file, long line, char[] msg = null){ - super( msg, file, line ); - } - this( String e = null){ - super(e); - } - this( Exception e ){ - super(e.toString); - next = e; - } - public Exception getCause() { - return next; - } - -} -class IndexOutOfBoundsException : Exception { - this( String e = null){ - super(e); - } -} - -class UnsupportedOperationException : RuntimeException { - this( String e = null){ - super(e); - } - this( Exception e ){ - super(e.toString); - } -} -class NumberFormatException : IllegalArgumentException { - this( String e ){ - super(e); - } - this( Exception e ){ - super(e.toString); - } -} -class NullPointerException : Exception { - this( String e = null ){ - super(e); - } - this( Exception e ){ - super(e.toString); - } -} -class IllegalStateException : Exception { - this( String e = null ){ - super(e); - } - this( Exception e ){ - super(e.toString); - } -} -class InterruptedException : Exception { - this( String e = null ){ - super(e); - } - this( Exception e ){ - super(e.toString); - } -} -class InvocationTargetException : Exception { - Exception cause; - this( Exception e = null, String msg = null ){ - super(msg); - cause = e; - } - - alias getCause getTargetException; - Exception getCause(){ - return cause; - } -} -class MissingResourceException : Exception { - String classname; - String key; - this( String msg, String classname, String key ){ - super(msg); - this.classname = classname; - this.key = key; - } -} -class ParseException : Exception { - this( String e = null ){ - super(e); - } -} -class ClassCastException : Exception { - this( String e = null ){ - super(e); - } -} - interface Cloneable{ } @@ -773,26 +686,6 @@ interface Comparator { int compare(Object o1, Object o2); } -interface EventListener{ -} - -class EventObject { - protected Object source; - - public this(Object source) { - if (source is null) - throw new IllegalArgumentException( "null arg" ); - this.source = source; - } - - public Object getSource() { - return source; - } - - public override String toString() { - return this.classinfo.name ~ "[source=" ~ source.toString() ~ "]"; - } -} private struct GCStats { size_t poolsize; // total size of pool @@ -808,13 +701,17 @@ return s.poolsize; } +/// Extension to the D Exception String ExceptionGetLocalizedMessage( Exception e ){ return e.msg; } +/// Extension to the D Exception void ExceptionPrintStackTrace( Exception e ){ ExceptionPrintStackTrace( e, Stderr ); } + +/// Extension to the D Exception void ExceptionPrintStackTrace( Exception e, FormatOutput!(char) print ){ Exception exception = e; while( exception !is null ){ @@ -828,59 +725,6 @@ } } -class Reader{ - protected Object lock; - protected this(){ - implMissing(__FILE__,__LINE__); - } - protected this(Object lock){ - implMissing(__FILE__,__LINE__); - } - abstract void close(); - void mark(int readAheadLimit){ - implMissing(__FILE__,__LINE__); - } - bool markSupported(){ - implMissing(__FILE__,__LINE__); - return false; - } - int read(){ - implMissing(__FILE__,__LINE__); - return 0; - } - int read(char[] cbuf){ - implMissing(__FILE__,__LINE__); - return 0; - } - abstract int read(char[] cbuf, int off, int len); - bool ready(){ - implMissing(__FILE__,__LINE__); - return false; - } - void reset(){ - implMissing(__FILE__,__LINE__); - } - long skip(long n){ - implMissing(__FILE__,__LINE__); - return 0; - } -} -interface Writer{ -} - - -class Collator : Comparator { - public static Collator getInstance(){ - implMissing( __FILE__, __LINE__ ); - return null; - } - private this(){ - } - int compare(Object o1, Object o2){ - implMissing( __FILE__, __LINE__ ); - return 0; - } -} template arraycast(T) { T[] arraycast(U) (U[] u) { @@ -1053,6 +897,9 @@ String toString(); } +/++ + + String in java is implementing the interface CharSequence + +/ class StringCharSequence : CharSequence { private String str; this( String str ){ diff -r 0e8eed4cac02 -r 712ffca654f3 java/src/java/text/Collator.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/src/java/text/Collator.d Wed Mar 04 21:41:18 2009 +0100 @@ -0,0 +1,17 @@ +module java.text.Collator; + +import java.lang.all; + +class Collator : Comparator { + public static Collator getInstance(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + private this(){ + } + int compare(Object o1, Object o2){ + implMissing( __FILE__, __LINE__ ); + return 0; + } +} + diff -r 0e8eed4cac02 -r 712ffca654f3 java/src/java/text/ParseException.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/src/java/text/ParseException.d Wed Mar 04 21:41:18 2009 +0100 @@ -0,0 +1,10 @@ +module java.text.ParseException; + +import java.lang.all; + +class ParseException : Exception { + this( String e = null ){ + super(e); + } +} + diff -r 0e8eed4cac02 -r 712ffca654f3 java/src/java/util/EventListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/src/java/util/EventListener.d Wed Mar 04 21:41:18 2009 +0100 @@ -0,0 +1,6 @@ +module java.util.EventListener; + +interface EventListener{ +} + + diff -r 0e8eed4cac02 -r 712ffca654f3 java/src/java/util/EventObject.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/src/java/util/EventObject.d Wed Mar 04 21:41:18 2009 +0100 @@ -0,0 +1,22 @@ +module java.util.EventObject; + +import java.lang.all; + +class EventObject { + protected Object source; + + public this(Object source) { + if (source is null) + throw new IllegalArgumentException( "null arg" ); + this.source = source; + } + + public Object getSource() { + return source; + } + + public override String toString() { + return this.classinfo.name ~ "[source=" ~ source.toString() ~ "]"; + } +} + diff -r 0e8eed4cac02 -r 712ffca654f3 java/src/java/util/MissingResourceException.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/src/java/util/MissingResourceException.d Wed Mar 04 21:41:18 2009 +0100 @@ -0,0 +1,14 @@ +module java.util.MissingResourceException; + +import java.lang.all; + +class MissingResourceException : Exception { + String classname; + String key; + this( String msg, String classname, String key ){ + super(msg); + this.classname = classname; + this.key = key; + } +} + diff -r 0e8eed4cac02 -r 712ffca654f3 java/src/java/util/ResourceBundle.d --- a/java/src/java/util/ResourceBundle.d Mon Mar 02 14:44:56 2009 +0100 +++ b/java/src/java/util/ResourceBundle.d Wed Mar 04 21:41:18 2009 +0100 @@ -8,6 +8,8 @@ import java.lang.util; import java.lang.Integer; +import java.lang.exceptions; +import java.util.MissingResourceException; import tango.io.device.File; import tango.text.locale.Core;