String.java (CASE_INSENSITIVE_ORDER): New static field.

2000-09-13  Bryce McKinlay  <bryce@albatross.co.nz>

	* java/lang/String.java (CASE_INSENSITIVE_ORDER): New static field.
	Initialize with anonymous class.
	(compareToIgnoreCase): New method.

	* java/lang/ThreadGroup.java (had_uncaught_exception): New field.
	(uncaughtException): Set had_uncaught_exception.
	* prims.cc (JvRunMain): Check value of had_uncaught_exception and
	exit with error status if set.
	(_Jv_RunMain): Ditto.

From-SVN: r36385
This commit is contained in:
Bryce McKinlay 2000-09-13 06:36:25 +00:00 committed by Bryce McKinlay
parent bb07060a6a
commit 0f94c029e9
4 changed files with 42 additions and 5 deletions

View file

@ -10,6 +10,7 @@ package java.lang;
import java.io.UnsupportedEncodingException;
import java.io.Serializable;
import java.lang.Comparable;
import java.util.Comparator;
/**
* @author Per Bothner <bothner@cygnus.com>
@ -17,7 +18,7 @@ import java.lang.Comparable;
*/
/* Written using "Java Class Libraries", 2nd edition, plus online
* API docs for JDK 1.2 beta from http://www.javasoft.com.
* Status: Complete to 1.1, but see FIXMEs. Also see testsuite results.
* Status: Complete to 1.3.
*/
public final class String implements Serializable, Comparable
@ -30,6 +31,14 @@ public final class String implements Serializable, Comparable
// but it will avoid showing up as a discrepancy when comparing SUIDs.
private static final long serialVersionUID = -6849794470754667710L;
static Comparator CASE_INSENSITIVE_ORDER = new Comparator()
{
public int compare (Object o1, Object o2)
{
return ((String) o1).compareToIgnoreCase ((String) o2);
}
};
public String ()
{
init();
@ -182,6 +191,12 @@ public final class String implements Serializable, Comparable
{
return compareTo ((String)obj);
}
public int compareToIgnoreCase (String str)
{
return this.toUpperCase().toLowerCase().compareTo(
str.toUpperCase().toLowerCase());
}
public native boolean regionMatches (int toffset,
String other, int ooffset, int len);