You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2006/03/15 15:57:17 UTC

svn commit: r386087 [33/45] - in /incubator/harmony/enhanced/classlib/trunk: make/ make/patternsets/ modules/jndi/ modules/jndi/META-INF/ modules/jndi/make/ modules/jndi/make/common/ modules/jndi/src/ modules/jndi/src/main/ modules/jndi/src/main/java/ ...

Added: incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternTests.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternTests.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternTests.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,1549 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests.api.java.util.regex;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests simple Pattern compilation and Matcher methods
+ * 
+ */
+public class PatternTests extends TestCase {
+	public void testSimpleMatch() {
+		Pattern p;
+
+		try {
+			p = Pattern.compile("foo.*");
+
+			Matcher m1 = p.matcher("foo123");
+			assertTrue(m1.matches());
+			assertTrue(m1.find(0));
+			assertTrue(m1.lookingAt());
+
+			Matcher m2 = p.matcher("fox");
+			assertFalse(m2.matches());
+			assertFalse(m2.find(0));
+			assertFalse(m2.lookingAt());
+
+			assertTrue(Pattern.matches("foo.*", "foo123"));
+			assertFalse(Pattern.matches("foo.*", "fox"));
+
+			assertFalse(Pattern.matches("bar", "foobar"));
+
+			assertTrue(Pattern.matches("", ""));
+
+		} catch (PatternSyntaxException e) {
+			System.out.println(e.getMessage());
+			fail();
+		}
+	}
+
+	public void testCursors() {
+		Pattern p;
+		Matcher m;
+
+		try {
+			p = Pattern.compile("foo");
+
+			m = p.matcher("foobar");
+			assertTrue(m.find());
+			assertTrue(m.start() == 0);
+			assertTrue(m.end() == 3);
+			assertFalse(m.find());
+
+			// Note: also testing reset here
+			m.reset();
+			assertTrue(m.find());
+			assertTrue(m.start() == 0);
+			assertTrue(m.end() == 3);
+			assertFalse(m.find());
+
+			m.reset("barfoobar");
+			assertTrue(m.find());
+			assertTrue(m.start() == 3);
+			assertTrue(m.end() == 6);
+			assertFalse(m.find());
+
+			m.reset("barfoo");
+			assertTrue(m.find());
+			assertTrue(m.start() == 3);
+			assertTrue(m.end() == 6);
+			assertFalse(m.find());
+
+			m.reset("foobarfoobarfoo");
+			assertTrue(m.find());
+			assertTrue(m.start() == 0);
+			assertTrue(m.end() == 3);
+			assertTrue(m.find());
+			assertTrue(m.start() == 6);
+			assertTrue(m.end() == 9);
+			assertTrue(m.find());
+			assertTrue(m.start() == 12);
+			assertTrue(m.end() == 15);
+			assertFalse(m.find());
+			assertTrue(m.find(0));
+			assertTrue(m.start() == 0);
+			assertTrue(m.end() == 3);
+			assertTrue(m.find(4));
+			assertTrue(m.start() == 6);
+			assertTrue(m.end() == 9);
+		} catch (PatternSyntaxException e) {
+			System.out.println(e.getMessage());
+			fail();
+		}
+	}
+
+	public void testGroups() {
+		Pattern p;
+		Matcher m;
+
+		try {
+			p = Pattern.compile("(p[0-9]*)#?(q[0-9]*)");
+
+			m = p.matcher("p1#q3p2q42p5p71p63#q888");
+			assertTrue(m.find());
+			assertTrue(m.start() == 0);
+			assertTrue(m.end() == 5);
+			assertTrue(m.groupCount() == 2);
+			assertTrue(m.start(0) == 0);
+			assertTrue(m.end(0) == 5);
+			assertTrue(m.start(1) == 0);
+			assertTrue(m.end(1) == 2);
+			assertTrue(m.start(2) == 3);
+			assertTrue(m.end(2) == 5);
+			assertTrue(m.group().equals("p1#q3"));
+			assertTrue(m.group(0).equals("p1#q3"));
+			assertTrue(m.group(1).equals("p1"));
+			assertTrue(m.group(2).equals("q3"));
+
+			assertTrue(m.find());
+			assertTrue(m.start() == 5);
+			assertTrue(m.end() == 10);
+			assertTrue(m.groupCount() == 2);
+			assertTrue(m.end(0) == 10);
+			assertTrue(m.start(1) == 5);
+			assertTrue(m.end(1) == 7);
+			assertTrue(m.start(2) == 7);
+			assertTrue(m.end(2) == 10);
+			assertTrue(m.group().equals("p2q42"));
+			assertTrue(m.group(0).equals("p2q42"));
+			assertTrue(m.group(1).equals("p2"));
+			assertTrue(m.group(2).equals("q42"));
+
+			assertTrue(m.find());
+			assertTrue(m.start() == 15);
+			assertTrue(m.end() == 23);
+			assertTrue(m.groupCount() == 2);
+			assertTrue(m.start(0) == 15);
+			assertTrue(m.end(0) == 23);
+			assertTrue(m.start(1) == 15);
+			assertTrue(m.end(1) == 18);
+			assertTrue(m.start(2) == 19);
+			assertTrue(m.end(2) == 23);
+			assertTrue(m.group().equals("p63#q888"));
+			assertTrue(m.group(0).equals("p63#q888"));
+			assertTrue(m.group(1).equals("p63"));
+			assertTrue(m.group(2).equals("q888"));
+			assertFalse(m.find());
+		} catch (PatternSyntaxException e) {
+			System.out.println(e.getMessage());
+			fail();
+		}
+	}
+
+	public void testReplace() {
+		Pattern p;
+		Matcher m;
+
+		// Note: examples from book,
+		// Hitchens, Ron, 2002, "Java NIO", O'Reilly, page 171
+		try {
+			p = Pattern.compile("a*b");
+
+			m = p.matcher("aabfooaabfooabfoob");
+			assertTrue(m.replaceAll("-").equals("-foo-foo-foo-"));
+			assertTrue(m.replaceFirst("-").equals("-fooaabfooabfoob"));
+
+			/*
+			 * p = Pattern.compile ("\\p{Blank}");
+			 * 
+			 * m = p.matcher ("fee fie foe fum"); assertTrue
+			 * (m.replaceFirst("-").equals ("fee-fie foe fum")); assertTrue
+			 * (m.replaceAll("-").equals ("fee-fie-foe-fum"));
+			 */
+
+			p = Pattern.compile("([bB])yte");
+
+			m = p.matcher("Byte for byte");
+			assertTrue(m.replaceFirst("$1ite").equals("Bite for byte"));
+			assertTrue(m.replaceAll("$1ite").equals("Bite for bite"));
+
+			p = Pattern.compile("\\d\\d\\d\\d([- ])");
+
+			m = p.matcher("card #1234-5678-1234");
+			assertTrue(m.replaceFirst("xxxx$1").equals("card #xxxx-5678-1234"));
+			assertTrue(m.replaceAll("xxxx$1").equals("card #xxxx-xxxx-1234"));
+
+			p = Pattern.compile("(up|left)( *)(right|down)");
+
+			m = p.matcher("left right, up down");
+			assertTrue(m.replaceFirst("$3$2$1").equals("right left, up down"));
+			assertTrue(m.replaceAll("$3$2$1").equals("right left, down up"));
+
+			p = Pattern.compile("([CcPp][hl]e[ea]se)");
+
+			m = p.matcher("I want cheese. Please.");
+			assertTrue(m.replaceFirst("<b> $1 </b>").equals(
+					"I want <b> cheese </b>. Please."));
+			assertTrue(m.replaceAll("<b> $1 </b>").equals(
+					"I want <b> cheese </b>. <b> Please </b>."));
+		} catch (PatternSyntaxException e) {
+			System.out.println(e.getMessage());
+			fail();
+		}
+	}
+
+	public void testEscapes() {
+		Pattern p;
+		Matcher m;
+		boolean triggerError;
+
+		try {
+			// Test \\ sequence
+			p = Pattern.compile("([a-z]+)\\\\([a-z]+);");
+			m = p.matcher("fred\\ginger;abbott\\costello;jekell\\hyde;");
+			assertTrue(m.find());
+			assertTrue(m.group(1).equals("fred"));
+			assertTrue(m.group(2).equals("ginger"));
+			assertTrue(m.find());
+			assertTrue(m.group(1).equals("abbott"));
+			assertTrue(m.group(2).equals("costello"));
+			assertTrue(m.find());
+			assertTrue(m.group(1).equals("jekell"));
+			assertTrue(m.group(2).equals("hyde"));
+			assertFalse(m.find());
+
+			// Test \n, \t, \r, \f, \e, \a sequences
+			p = Pattern.compile("([a-z]+)[\\n\\t\\r\\f\\e\\a]+([a-z]+)");
+			m = p.matcher("aa\nbb;cc\u0009\rdd;ee\u000C\u001Bff;gg\n\u0007hh");
+			assertTrue(m.find());
+			assertTrue(m.group(1).equals("aa"));
+			assertTrue(m.group(2).equals("bb"));
+			assertTrue(m.find());
+			assertTrue(m.group(1).equals("cc"));
+			assertTrue(m.group(2).equals("dd"));
+			assertTrue(m.find());
+			assertTrue(m.group(1).equals("ee"));
+			assertTrue(m.group(2).equals("ff"));
+			assertTrue(m.find());
+			assertTrue(m.group(1).equals("gg"));
+			assertTrue(m.group(2).equals("hh"));
+			assertFalse(m.find());
+
+			// Test \\u and \\x sequences
+			p = Pattern.compile("([0-9]+)[\\u0020:\\x21];");
+			m = p.matcher("11:;22 ;33-;44!;");
+			assertTrue(m.find());
+			assertTrue(m.group(1).equals("11"));
+			assertTrue(m.find());
+			assertTrue(m.group(1).equals("22"));
+			assertTrue(m.find());
+			assertTrue(m.group(1).equals("44"));
+			assertFalse(m.find());
+
+			// Test invalid unicode sequences
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\u");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertTrue(triggerError);
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\u;");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertTrue(triggerError);
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\u002");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertTrue(triggerError);
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\u002;");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertTrue(triggerError);
+
+			// Test invalid hex sequences
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\x");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertTrue(triggerError);
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\x;");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertTrue(triggerError);
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\xa");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertTrue(triggerError);
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\xa;");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertTrue(triggerError);
+
+			// Test \0 (octal) sequences (1, 2 and 3 digit)
+			p = Pattern.compile("([0-9]+)[\\07\\040\\0160];");
+			m = p.matcher("11\u0007;22:;33 ;44p;");
+			assertTrue(m.find());
+			assertTrue(m.group(1).equals("11"));
+			assertTrue(m.find());
+			assertTrue(m.group(1).equals("33"));
+			assertTrue(m.find());
+			assertTrue(m.group(1).equals("44"));
+			assertFalse(m.find());
+
+			// Test invalid octal sequences
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\08");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertTrue(triggerError);
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\0477");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\0");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertTrue(triggerError);
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\0;");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertTrue(triggerError);
+
+			// Test \c (control character) sequence
+			p = Pattern.compile("([0-9]+)[\\cA\\cB\\cC\\cD];");
+			m = p.matcher("11\u0001;22:;33\u0002;44p;55\u0003;66\u0004;");
+			assertTrue(m.find());
+			assertTrue(m.group(1).equals("11"));
+			assertTrue(m.find());
+			assertTrue(m.group(1).equals("33"));
+			assertTrue(m.find());
+			assertTrue(m.group(1).equals("55"));
+			assertTrue(m.find());
+			assertTrue(m.group(1).equals("66"));
+			assertFalse(m.find());
+
+			// More thorough control escape test
+			// Ensure that each escape matches exactly the corresponding
+			// character
+			// code and no others (well, from 0-255 at least)
+			int i, j;
+			for (i = 0; i < 26; i++) {
+				p = Pattern.compile("\\c"
+						+ Character.toString((char) ('A' + i)));
+				int match_char = -1;
+				for (j = 0; j < 255; j++) {
+					m = p.matcher(Character.toString((char) j));
+					if (m.matches()) {
+						assertTrue(match_char == -1);
+						match_char = j;
+					}
+				}
+				assertTrue(match_char == i + 1);
+			}
+
+			// Test invalid control escapes
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\c");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertTrue(triggerError);
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\c;");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\ca;");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\c4;");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+		} catch (PatternSyntaxException e) {
+			System.out.println(e.getMessage());
+			fail();
+		}
+	}
+
+	public void testCharacterClasses() {
+		Pattern p;
+		Matcher m;
+		boolean triggerError;
+
+		try {
+			// Test one character range
+			p = Pattern.compile("[p].*[l]");
+			m = p.matcher("paul");
+			assertTrue(m.matches());
+			m = p.matcher("pool");
+			assertTrue(m.matches());
+			m = p.matcher("pong");
+			assertFalse(m.matches());
+			m = p.matcher("pl");
+			assertTrue(m.matches());
+
+			// Test two character range
+			p = Pattern.compile("[pm].*[lp]");
+			m = p.matcher("prop");
+			assertTrue(m.matches());
+			m = p.matcher("mall");
+			assertTrue(m.matches());
+			m = p.matcher("pong");
+			assertFalse(m.matches());
+			m = p.matcher("pill");
+			assertTrue(m.matches());
+
+			// Test range including [ and ]
+			p = Pattern.compile("[<\\[].*[\\]>]");
+			m = p.matcher("<foo>");
+			assertTrue(m.matches());
+			m = p.matcher("[bar]");
+			assertTrue(m.matches());
+			m = p.matcher("{foobar]");
+			assertFalse(m.matches());
+			m = p.matcher("<pill]");
+			assertTrue(m.matches());
+
+			// Test range using ^
+			p = Pattern.compile("[^bc][a-z]+[tr]");
+			m = p.matcher("pat");
+			assertTrue(m.matches());
+			m = p.matcher("liar");
+			assertTrue(m.matches());
+			m = p.matcher("car");
+			assertFalse(m.matches());
+			m = p.matcher("gnat");
+			assertTrue(m.matches());
+
+			// Test character range using -
+			p = Pattern.compile("[a-z]_+[a-zA-Z]-+[0-9p-z]");
+			m = p.matcher("d__F-8");
+			assertTrue(m.matches());
+			m = p.matcher("c_a-q");
+			assertTrue(m.matches());
+			m = p.matcher("a__R-a");
+			assertFalse(m.matches());
+			m = p.matcher("r_____d-----5");
+			assertTrue(m.matches());
+
+			// Test range using unicode characters and unicode and hex escapes
+			p = Pattern.compile("[\\u1234-\\u2345]_+[a-z]-+[\u0001-\\x11]");
+			m = p.matcher("\u2000_q-\u0007");
+			assertTrue(m.matches());
+			m = p.matcher("\u1234_z-\u0001");
+			assertTrue(m.matches());
+			m = p.matcher("r_p-q");
+			assertFalse(m.matches());
+			m = p.matcher("\u2345_____d-----\n");
+			assertTrue(m.matches());
+
+			// Test ranges including the "-" character
+			p = Pattern.compile("[\\*-/]_+[---]!+[--AP]");
+			m = p.matcher("-_-!!A");
+			assertTrue(m.matches());
+			m = p.matcher("\u002b_-!!!-");
+			assertTrue(m.matches());
+			m = p.matcher("!_-!@");
+			assertFalse(m.matches());
+			m = p.matcher(",______-!!!!!!!P");
+			assertTrue(m.matches());
+
+			// Test nested ranges
+			p = Pattern.compile("[pm[t]][a-z]+[[r]lp]");
+			m = p.matcher("prop");
+			assertTrue(m.matches());
+			m = p.matcher("tsar");
+			assertTrue(m.matches());
+			m = p.matcher("pong");
+			assertFalse(m.matches());
+			m = p.matcher("moor");
+			assertTrue(m.matches());
+
+			// Test character class intersection with &&
+			// TODO: figure out what x&&y or any class with a null intersection
+			// set (like [[a-c]&&[d-f]]) might mean. It doesn't mean "match
+			// nothing" and doesn't mean "match anything" so I'm stumped.
+			p = Pattern.compile("[[a-p]&&[g-z]]+-+[[a-z]&&q]-+[x&&[a-z]]-+");
+			m = p.matcher("h--q--x--");
+			assertTrue(m.matches());
+			m = p.matcher("hog--q-x-");
+			assertTrue(m.matches());
+			m = p.matcher("ape--q-x-");
+			assertFalse(m.matches());
+			m = p.matcher("mop--q-x----");
+			assertTrue(m.matches());
+
+			// Test error cases with &&
+			triggerError = false;
+			try {
+				p = Pattern.compile("[&&[xyz]]");
+				m = p.matcher("&");
+				// System.out.println(m.matches());
+				m = p.matcher("x");
+				// System.out.println(m.matches());
+				m = p.matcher("y");
+				// System.out.println(m.matches());
+				p = Pattern.compile("[[xyz]&[axy]]");
+				m = p.matcher("x");
+				// System.out.println(m.matches());
+				m = p.matcher("z");
+				// System.out.println(m.matches());
+				m = p.matcher("&");
+				// System.out.println(m.matches());
+				p = Pattern.compile("[abc[123]&&[345]def]");
+				m = p.matcher("a");
+				// System.out.println(m.matches());
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertFalse(triggerError);
+			triggerError = false;
+			try {
+				p = Pattern.compile("[[xyz]&&]");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertFalse(triggerError);
+			triggerError = false;
+			try {
+				p = Pattern.compile("[[abc]&]");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertFalse(triggerError);
+			triggerError = false;
+			try {
+				p = Pattern.compile("[[abc]&&");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertTrue(triggerError);
+			triggerError = false;
+			try {
+				p = Pattern.compile("[[abc]\\&&[xyz]]");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertFalse(triggerError);
+			triggerError = false;
+			try {
+				p = Pattern.compile("[[abc]&\\&[xyz]]");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertFalse(triggerError);
+
+			// Test 3-way intersection
+			p = Pattern.compile("[[a-p]&&[g-z]&&[d-k]]");
+			m = p.matcher("g");
+			assertTrue(m.matches());
+			m = p.matcher("m");
+			assertFalse(m.matches());
+
+			// Test nested intersection
+			p = Pattern.compile("[[[a-p]&&[g-z]]&&[d-k]]");
+			m = p.matcher("g");
+			assertTrue(m.matches());
+			m = p.matcher("m");
+			assertFalse(m.matches());
+
+			// Test character class subtraction with && and ^
+			p = Pattern.compile("[[a-z]&&[^aeiou]][aeiou][[^xyz]&&[a-z]]");
+			m = p.matcher("pop");
+			assertTrue(m.matches());
+			m = p.matcher("tag");
+			assertTrue(m.matches());
+			m = p.matcher("eat");
+			assertFalse(m.matches());
+			m = p.matcher("tax");
+			assertFalse(m.matches());
+			m = p.matcher("zip");
+			assertTrue(m.matches());
+
+			// Test . (DOT), with and without DOTALL
+			// Note: DOT not allowed in character classes
+			p = Pattern.compile(".+/x.z");
+			m = p.matcher("!$/xyz");
+			assertTrue(m.matches());
+			m = p.matcher("%\n\r/x\nz");
+			assertFalse(m.matches());
+			p = Pattern.compile(".+/x.z", Pattern.DOTALL);
+			m = p.matcher("%\n\r/x\nz");
+			assertTrue(m.matches());
+
+			// Test \d (digit)
+			p = Pattern.compile("\\d+[a-z][\\dx]");
+			m = p.matcher("42a6");
+			assertTrue(m.matches());
+			m = p.matcher("21zx");
+			assertTrue(m.matches());
+			m = p.matcher("ab6");
+			assertFalse(m.matches());
+			m = p.matcher("56912f9");
+			assertTrue(m.matches());
+
+			// Test \D (not a digit)
+			p = Pattern.compile("\\D+[a-z]-[\\D3]");
+			m = p.matcher("za-p");
+			assertTrue(m.matches());
+			m = p.matcher("%!e-3");
+			assertTrue(m.matches());
+			m = p.matcher("9a-x");
+			assertFalse(m.matches());
+			m = p.matcher("\u1234pp\ny-3");
+			assertTrue(m.matches());
+
+			// Test \s (whitespace)
+			p = Pattern.compile("<[a-zA-Z]+\\s+[0-9]+[\\sx][^\\s]>");
+			m = p.matcher("<cat \t1\fx>");
+			assertTrue(m.matches());
+			m = p.matcher("<cat \t1\f >");
+			assertFalse(m.matches());
+			m = p
+					.matcher("xyz <foo\n\r22 5> <pp \t\n\f\r \u000b41x\u1234><pp \nx7\rc> zzz");
+			assertTrue(m.find());
+			assertTrue(m.find());
+			assertFalse(m.find());
+
+			// Test \S (not whitespace)
+			p = Pattern.compile("<[a-z] \\S[0-9][\\S\n]+[^\\S]221>");
+			m = p.matcher("<f $0**\n** 221>");
+			assertTrue(m.matches());
+			m = p.matcher("<x 441\t221>");
+			assertTrue(m.matches());
+			m = p.matcher("<z \t9\ng 221>");
+			assertFalse(m.matches());
+			m = p.matcher("<z 60\ngg\u1234\f221>");
+			assertTrue(m.matches());
+			p = Pattern
+					.compile("<[a-z] \\S[0-9][\\S\n]+[^\\S]221[\\S&&[^abc]]>");
+			m = p.matcher("<f $0**\n** 221x>");
+			assertTrue(m.matches());
+			m = p.matcher("<x 441\t221z>");
+			assertTrue(m.matches());
+			m = p.matcher("<x 441\t221 >");
+			assertFalse(m.matches());
+			m = p.matcher("<x 441\t221c>");
+			assertFalse(m.matches());
+			m = p.matcher("<z \t9\ng 221x>");
+			assertFalse(m.matches());
+			m = p.matcher("<z 60\ngg\u1234\f221\u0001>");
+			assertTrue(m.matches());
+
+			// Test \w (ascii word)
+			p = Pattern.compile("<\\w+\\s[0-9]+;[^\\w]\\w+/[\\w$]+;");
+			m = p.matcher("<f1 99;!foo5/a$7;");
+			assertTrue(m.matches());
+			m = p.matcher("<f$ 99;!foo5/a$7;");
+			assertFalse(m.matches());
+			m = p
+					.matcher("<abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789 99;!foo5/a$7;");
+			assertTrue(m.matches());
+
+			// Test \W (not an ascii word)
+			p = Pattern.compile("<\\W\\w+\\s[0-9]+;[\\W_][^\\W]+\\s[0-9]+;");
+			m = p.matcher("<$foo3\n99;_bar\t0;");
+			assertTrue(m.matches());
+			m = p.matcher("<hh 99;_g 0;");
+			assertFalse(m.matches());
+			m = p.matcher("<*xx\t00;^zz\f11;");
+			assertTrue(m.matches());
+
+			// Test x|y pattern
+			// TODO
+		} catch (PatternSyntaxException e) {
+			System.out.println(e.getMessage());
+			fail();
+		}
+	}
+
+	public void testPOSIXGroups() {
+		Pattern p;
+		Matcher m;
+		boolean triggerError;
+
+		// Test POSIX groups using \p and \P (in the group and not in the group)
+		// Groups are Lower, Upper, ASCII, Alpha, Digit, XDigit, Alnum, Punct,
+		// Graph, Print, Blank, Space, Cntrl
+		try {
+			// Test \p{Lower}
+			/*
+			 * FIXME: Requires complex range processing
+			 * p = Pattern.compile("<\\p{Lower}\\d\\P{Lower}:[\\p{Lower}Z]\\s[^\\P{Lower}]>");
+			 * m = p.matcher("<a4P:g x>"); assertTrue(m.matches()); m =
+			 * p.matcher("<p4%:Z\tq>"); assertTrue(m.matches()); m =
+			 * p.matcher("<A6#:e e>"); assertFalse(m.matches());
+			 */
+			p = Pattern.compile("\\p{Lower}+");
+			m = p.matcher("abcdefghijklmnopqrstuvwxyz");
+			assertTrue(m.matches());
+
+			// Invalid uses of \p{Lower}
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\p");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertTrue(triggerError);
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\p;");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertTrue(triggerError);
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\p{");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertTrue(triggerError);
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\p{;");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertTrue(triggerError);
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\p{Lower");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertTrue(triggerError);
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\p{Lower;");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertTrue(triggerError);
+
+			// Test \p{Upper}
+			/*
+			 * FIXME: Requires complex range processing
+			 * p = Pattern.compile("<\\p{Upper}\\d\\P{Upper}:[\\p{Upper}z]\\s[^\\P{Upper}]>");
+			 * m = p.matcher("<A4p:G X>"); assertTrue(m.matches()); m =
+			 * p.matcher("<P4%:z\tQ>"); assertTrue(m.matches()); m =
+			 * p.matcher("<a6#:E E>"); assertFalse(m.matches());
+			 */
+			p = Pattern.compile("\\p{Upper}+");
+			m = p.matcher("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
+			assertTrue(m.matches());
+
+			// Invalid uses of \p{Upper}
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\p{Upper");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertTrue(triggerError);
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\p{Upper;");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertTrue(triggerError);
+
+			// Test \p{ASCII}
+			/*
+			 * FIXME: Requires complex range processing p = Pattern.compile("<\\p{ASCII}\\d\\P{ASCII}:[\\p{ASCII}\u1234]\\s[^\\P{ASCII}]>");
+			 * m = p.matcher("<A4\u0080:G X>"); assertTrue(m.matches()); m =
+			 * p.matcher("<P4\u00ff:\u1234\t\n>"); assertTrue(m.matches()); m =
+			 * p.matcher("<\u00846#:E E>"); assertFalse(m.matches())
+			 */;
+			int i;
+			p = Pattern.compile("\\p{ASCII}");
+			for (i = 0; i < 0x80; i++) {
+				m = p.matcher(Character.toString((char) i));
+				assertTrue(m.matches());
+			}
+			for (; i < 0xff; i++) {
+				m = p.matcher(Character.toString((char) i));
+				assertFalse(m.matches());
+			}
+
+			// Invalid uses of \p{ASCII}
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\p{ASCII");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertTrue(triggerError);
+			triggerError = false;
+			try {
+				p = Pattern.compile("\\p{ASCII;");
+			} catch (PatternSyntaxException e) {
+				triggerError = true;
+			}
+			assertTrue(triggerError);
+
+			// Test \p{Alpha}
+			// TODO
+
+			// Test \p{Digit}
+			// TODO
+
+			// Test \p{XDigit}
+			// TODO
+
+			// Test \p{Alnum}
+			// TODO
+
+			// Test \p{Punct}
+			// TODO
+
+			// Test \p{Graph}
+			// TODO
+
+			// Test \p{Print}
+			// TODO
+
+			// Test \p{Blank}
+			// TODO
+
+			// Test \p{Space}
+			// TODO
+
+			// Test \p{Cntrl}
+			// TODO
+		} catch (PatternSyntaxException e) {
+			System.out.println(e.getMessage());
+			fail();
+		}
+	}
+
+	public void testUnicodeCategories() {
+		// Test Unicode categories using \p and \P
+		// One letter codes: L, M, N, P, S, Z, C
+		// Two letter codes: Lu, Nd, Sc, Sm, ...
+		// See java.lang.Character and Unicode standard for complete list
+		// TODO
+		try {
+			// Test \p{L}
+			// TODO
+
+			// Test \p{N}
+			// TODO
+
+			// ... etc
+
+			// Test two letter codes:
+			// From unicode.org:
+			// Lu
+			// Ll
+			// Lt
+			// Lm
+			// Lo
+			// Mn
+			// Mc
+			// Me
+			// Nd
+			// Nl
+			// No
+			// Pc
+			// Pd
+			// Ps
+			// Pe
+			// Pi
+			// Pf
+			// Po
+			// Sm
+			// Sc
+			// Sk
+			// So
+			// Zs
+			// Zl
+			// Zp
+			// Cc
+			// Cf
+			// Cs
+			// Co
+			// Cn
+		} catch (PatternSyntaxException e) {
+			System.out.println(e.getMessage());
+			fail();
+		}
+	}
+
+	public void testUnicodeBlocks() {
+		Pattern p;
+		Matcher m;
+		int i, j;
+
+		// Test Unicode blocks using \p and \P
+		// FIXME:
+		// Note that LatinExtended-B and ArabicPresentations-B are unrecognized
+		// by the reference JDK.
+		try {
+			for (i = 0; i < UBlocks.length; i++) {
+				/*
+				 * p = Pattern.compile("\\p{"+UBlocks[i].name+"}");
+				 * 
+				 * if (UBlocks[i].low > 0) { m =
+				 * p.matcher(Character.toString((char)(UBlocks[i].low-1)));
+				 * assertFalse(m.matches()); } for (j=UBlocks[i].low; j <=
+				 * UBlocks[i].high; j++) { m =
+				 * p.matcher(Character.toString((char)j));
+				 * assertTrue(m.matches()); } if (UBlocks[i].high < 0xFFFF) { m =
+				 * p.matcher(Character.toString((char)(UBlocks[i].high+1)));
+				 * assertFalse(m.matches()); }
+				 * 
+				 * p = Pattern.compile("\\P{"+UBlocks[i].name+"}");
+				 * 
+				 * if (UBlocks[i].low > 0) { m =
+				 * p.matcher(Character.toString((char)(UBlocks[i].low-1)));
+				 * assertTrue(m.matches()); } for (j=UBlocks[i].low; j <
+				 * UBlocks[i].high; j++) { m =
+				 * p.matcher(Character.toString((char)j));
+				 * assertFalse(m.matches()); } if (UBlocks[i].high < 0xFFFF) { m =
+				 * p.matcher(Character.toString((char)(UBlocks[i].high+1)));
+				 * assertTrue(m.matches()); }
+				 */
+
+				p = Pattern.compile("\\p{In" + UBlocks[i].name + "}");
+
+				if (UBlocks[i].low > 0) {
+					m = p.matcher(Character
+							.toString((char) (UBlocks[i].low - 1)));
+					assertFalse(m.matches());
+				}
+				for (j = UBlocks[i].low; j <= UBlocks[i].high; j++) {
+					m = p.matcher(Character.toString((char) j));
+					assertTrue(m.matches());
+				}
+				if (UBlocks[i].high < 0xFFFF) {
+					m = p.matcher(Character
+							.toString((char) (UBlocks[i].high + 1)));
+					assertFalse(m.matches());
+				}
+
+				p = Pattern.compile("\\P{In" + UBlocks[i].name + "}");
+
+				if (UBlocks[i].low > 0) {
+					m = p.matcher(Character
+							.toString((char) (UBlocks[i].low - 1)));
+					assertTrue(m.matches());
+				}
+				for (j = UBlocks[i].low; j < UBlocks[i].high; j++) {
+					m = p.matcher(Character.toString((char) j));
+					assertFalse(m.matches());
+				}
+				if (UBlocks[i].high < 0xFFFF) {
+					m = p.matcher(Character
+							.toString((char) (UBlocks[i].high + 1)));
+					assertTrue(m.matches());
+				}
+			}
+		} catch (PatternSyntaxException e) {
+			System.out.println(e.getMessage());
+			fail();
+		}
+	}
+
+	public void testCapturingGroups() {
+		try {
+			// Test simple capturing groups
+			// TODO
+
+			// Test grouping without capture (?:...)
+			// TODO
+
+			// Test combination of grouping and capture
+			// TODO
+
+			// Test \<num> sequence with capturing and non-capturing groups
+			// TODO
+
+			// Test \<num> with <num> out of range
+			// TODO
+		} catch (PatternSyntaxException e) {
+			System.out.println(e.getMessage());
+			fail();
+		}
+	}
+
+	public void testRepeats() {
+		try {
+			// Test ?
+			// TODO
+
+			// Test *
+			// TODO
+
+			// Test +
+			// TODO
+
+			// Test {<num>}, including 0, 1 and more
+			// TODO
+
+			// Test {<num>,}, including 0, 1 and more
+			// TODO
+
+			// Test {<n1>,<n2>}, with n1 < n2, n1 = n2 and n1 > n2 (illegal?)
+			// TODO
+		} catch (PatternSyntaxException e) {
+			System.out.println(e.getMessage());
+			fail();
+		}
+	}
+
+	public void testAnchors() {
+		try {
+			// Test ^, default and MULTILINE
+			// TODO
+
+			// Test $, default and MULTILINE
+			// TODO
+
+			// Test \b (word boundary)
+			// TODO
+
+			// Test \B (not a word boundary)
+			// TODO
+
+			// Test \A (beginning of string)
+			// TODO
+
+			// Test \Z (end of string)
+			// TODO
+
+			// Test \z (end of string)
+			// TODO
+
+			// Test \G
+			// TODO
+
+			// Test positive lookahead using (?=...)
+			// TODO
+
+			// Test negative lookahead using (?!...)
+			// TODO
+
+			// Test positive lookbehind using (?<=...)
+			// TODO
+
+			// Test negative lookbehind using (?<!...)
+			// TODO
+		} catch (PatternSyntaxException e) {
+			System.out.println(e.getMessage());
+			fail();
+		}
+	}
+
+	public void testMisc() {
+		Pattern p;
+		Matcher m;
+
+		try {
+			// Test (?>...)
+			// TODO
+
+			// Test (?onflags-offflags)
+			// Valid flags are i,m,d,s,u,x
+			// TODO
+
+			// Test (?onflags-offflags:...)
+			// TODO
+
+			// Test \Q, \E
+			p = Pattern.compile("[a-z]+;\\Q[a-z]+;\\Q(foo.*);\\E[0-9]+");
+			m = p.matcher("abc;[a-z]+;\\Q(foo.*);411");
+			assertTrue(m.matches());
+			m = p.matcher("abc;def;foo42;555");
+			assertFalse(m.matches());
+			m = p.matcher("abc;\\Qdef;\\Qfoo99;\\E123");
+			assertFalse(m.matches());
+
+			p = Pattern.compile("[a-z]+;(foo[0-9]-\\Q(...)\\E);[0-9]+");
+			m = p.matcher("abc;foo5-(...);123");
+			assertTrue(m.matches());
+			assertTrue(m.group(1).equals("foo5-(...)"));
+			m = p.matcher("abc;foo9-(xxx);789");
+			assertFalse(m.matches());
+
+			p = Pattern.compile("[a-z]+;(bar[0-9]-[a-z\\Q$-\\E]+);[0-9]+");
+			m = p.matcher("abc;bar0-def$-;123");
+			assertTrue(m.matches());
+
+			// FIXME:
+			// This should work the same as the pattern above but fails with the
+			// the reference JDK
+			p = Pattern.compile("[a-z]+;(bar[0-9]-[a-z\\Q-$\\E]+);[0-9]+");
+			m = p.matcher("abc;bar0-def$-;123");
+			// assertTrue(m.matches());
+
+			// FIXME:
+			// This should work too .. it looks as if just about anything that
+			// has more
+			// than one character between \Q and \E is broken in the the reference JDK
+			p = Pattern.compile("[a-z]+;(bar[0-9]-[a-z\\Q[0-9]\\E]+);[0-9]+");
+			m = p.matcher("abc;bar0-def[99]-]0x[;123");
+			// assertTrue(m.matches());
+
+			// This is the same as above but with explicit escapes .. and this
+			// does work
+			// on the the reference JDK
+			p = Pattern.compile("[a-z]+;(bar[0-9]-[a-z\\[0\\-9\\]]+);[0-9]+");
+			m = p.matcher("abc;bar0-def[99]-]0x[;123");
+			assertTrue(m.matches());
+
+			// Test #<comment text>
+			// TODO
+		} catch (PatternSyntaxException e) {
+			System.out.println(e.getMessage());
+			fail();
+		}
+	}
+
+	public void testCompile1() {
+		try {
+			Pattern pattern = Pattern
+					.compile("[0-9A-Za-z][0-9A-Za-z\\x2e\\x3a\\x2d\\x5f]*");
+			String name = "iso-8859-1";
+			assertTrue(pattern.matcher(name).matches());
+		} catch (PatternSyntaxException e) {
+			System.out.println(e.getMessage());
+			fail();
+		}
+	}
+
+	public void testCompile2() {
+		String findString = "\\Qimport\\E";
+
+		try {
+			Pattern pattern = Pattern.compile(findString, 0);
+			Matcher matcher = pattern.matcher(new String(
+					"import a.A;\n\n import b.B;\nclass C {}"));
+
+			assertTrue(matcher.find(0));
+		} catch (PatternSyntaxException e) {
+			System.out.println(e.getMessage());
+			fail();
+		}
+	}
+
+	public void testCompile3() {
+		Pattern p;
+		Matcher m;
+		try {
+			p = Pattern.compile("a$");
+			m = p.matcher("a\n");
+			assertTrue(m.find());
+			assertTrue(m.group().equals("a"));
+			assertFalse(m.find());
+
+			p = Pattern.compile("(a$)");
+			m = p.matcher("a\n");
+			assertTrue(m.find());
+			assertTrue(m.group().equals("a"));
+			assertTrue(m.group(1).equals("a"));
+			assertFalse(m.find());
+
+			p = Pattern.compile("^.*$", Pattern.MULTILINE);
+
+			m = p.matcher("a\n");
+			assertTrue(m.find());
+			// System.out.println("["+m.group()+"]");
+			assertTrue(m.group().equals("a"));
+			assertFalse(m.find());
+
+			m = p.matcher("a\nb\n");
+			assertTrue(m.find());
+			// System.out.println("["+m.group()+"]");
+			assertTrue(m.group().equals("a"));
+			assertTrue(m.find());
+			// System.out.println("["+m.group()+"]");
+			assertTrue(m.group().equals("b"));
+			assertFalse(m.find());
+
+			m = p.matcher("a\nb");
+			assertTrue(m.find());
+			// System.out.println("["+m.group()+"]");
+			assertTrue(m.group().equals("a"));
+			assertTrue(m.find());
+			assertTrue(m.group().equals("b"));
+			assertFalse(m.find());
+
+			m = p.matcher("\naa\r\nbb\rcc\n\n");
+			assertTrue(m.find());
+			// System.out.println("["+m.group()+"]");
+			assertTrue(m.group().equals(""));
+			assertTrue(m.find());
+			// System.out.println("["+m.group()+"]");
+			assertTrue(m.group().equals("aa"));
+			assertTrue(m.find());
+			// System.out.println("["+m.group()+"]");
+			assertTrue(m.group().equals("bb"));
+			assertTrue(m.find());
+			// System.out.println("["+m.group()+"]");
+			assertTrue(m.group().equals("cc"));
+			assertTrue(m.find());
+			// System.out.println("["+m.group()+"]");
+			assertTrue(m.group().equals(""));
+			assertFalse(m.find());
+
+			m = p.matcher("a");
+			assertTrue(m.find());
+			assertTrue(m.group().equals("a"));
+			assertFalse(m.find());
+
+			m = p.matcher("");
+			// FIXME: This matches the reference behaviour but is
+			// inconsistent with matching "a" - ie. the end of the
+			// target string should match against $ always but this
+			// appears to work with the null string only when not in
+			// multiline mode (see below)
+			assertFalse(m.find());
+
+			p = Pattern.compile("^.*$");
+			m = p.matcher("");
+			assertTrue(m.find());
+			assertTrue(m.group().equals(""));
+			assertFalse(m.find());
+		} catch (PatternSyntaxException e) {
+			System.out.println(e.getMessage());
+			assertTrue(false);
+		}
+	}
+
+	public void testCompile4() {
+		String findString = "\\Qpublic\\E";
+		StringBuffer text = new StringBuffer("    public class Class {\n"
+				+ "    public class Class {");
+
+		Pattern pattern = Pattern.compile(findString, 0);
+		Matcher matcher = pattern.matcher(text);
+
+		boolean found = matcher.find();
+		assertTrue(found);
+		assertTrue(matcher.start() == 4);
+		if (found) {
+			// modify text
+			text.delete(0, text.length());
+			text.append("Text have been changed.");
+		}
+
+		found = matcher.find();
+		assertFalse(found);
+	}
+
+	public void testCompile5() {
+		Pattern p = Pattern.compile("^[0-9]");
+		String s[] = p.split("12", -1);
+		assertEquals("", s[0]);
+		assertEquals("2", s[1]);
+		assertEquals(2, s.length);
+	}
+
+	
+//	  public void testCompile6() {
+//		String regex = "[\\p{L}[\\p{Mn}[\\p{Pc}[\\p{Nd}[\\p{Nl}[\\p{Sc}]]]]]]+";
+//		String regex = "[\\p{L}\\p{Mn}\\p{Pc}\\p{Nd}\\p{Nl}\\p{Sc}]+";
+//		try {
+//			Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
+//			assertTrue(true);
+//		} catch (PatternSyntaxException e) {
+//			System.out.println(e.getMessage());
+//			assertTrue(false);
+//		}
+//	}
+
+
+	private static class UBInfo {
+		public UBInfo(int low, int high, String name) {
+			this.name = name;
+			this.low = low;
+			this.high = high;
+		}
+
+		public String name;
+
+		public int low, high;
+	}
+
+	// A table representing the unicode categories
+	//private static UBInfo[] UCategories = {
+	// Lu
+	// Ll
+	// Lt
+	// Lm
+	// Lo
+	// Mn
+	// Mc
+	// Me
+	// Nd
+	// Nl
+	// No
+	// Pc
+	// Pd
+	// Ps
+	// Pe
+	// Pi
+	// Pf
+	// Po
+	// Sm
+	// Sc
+	// Sk
+	// So
+	// Zs
+	// Zl
+	// Zp
+	// Cc
+	// Cf
+	// Cs
+	// Co
+	// Cn
+	//};
+
+	// A table representing the unicode character blocks
+	private static UBInfo[] UBlocks = {
+	/* 0000; 007F; Basic Latin */
+	new UBInfo(0x0000, 0x007F, "BasicLatin"), // Character.UnicodeBlock.BASIC_LATIN
+			/* 0080; 00FF; Latin-1 Supplement */
+			new UBInfo(0x0080, 0x00FF, "Latin-1Supplement"), // Character.UnicodeBlock.LATIN_1_SUPPLEMENT
+			/* 0100; 017F; Latin Extended-A */
+			new UBInfo(0x0100, 0x017F, "LatinExtended-A"), // Character.UnicodeBlock.LATIN_EXTENDED_A
+			/* 0180; 024F; Latin Extended-B */
+			// new UBInfo (0x0180,0x024F,"InLatinExtended-B"), //
+			// Character.UnicodeBlock.LATIN_EXTENDED_B
+			/* 0250; 02AF; IPA Extensions */
+			new UBInfo(0x0250, 0x02AF, "IPAExtensions"), // Character.UnicodeBlock.IPA_EXTENSIONS
+			/* 02B0; 02FF; Spacing Modifier Letters */
+			new UBInfo(0x02B0, 0x02FF, "SpacingModifierLetters"), // Character.UnicodeBlock.SPACING_MODIFIER_LETTERS
+			/* 0300; 036F; Combining Diacritical Marks */
+			new UBInfo(0x0300, 0x036F, "CombiningDiacriticalMarks"), // Character.UnicodeBlock.COMBINING_DIACRITICAL_MARKS
+			/* 0370; 03FF; Greek */
+			new UBInfo(0x0370, 0x03FF, "Greek"), // Character.UnicodeBlock.GREEK
+			/* 0400; 04FF; Cyrillic */
+			new UBInfo(0x0400, 0x04FF, "Cyrillic"), // Character.UnicodeBlock.CYRILLIC
+			/* 0530; 058F; Armenian */
+			new UBInfo(0x0530, 0x058F, "Armenian"), // Character.UnicodeBlock.ARMENIAN
+			/* 0590; 05FF; Hebrew */
+			new UBInfo(0x0590, 0x05FF, "Hebrew"), // Character.UnicodeBlock.HEBREW
+			/* 0600; 06FF; Arabic */
+			new UBInfo(0x0600, 0x06FF, "Arabic"), // Character.UnicodeBlock.ARABIC
+			/* 0700; 074F; Syriac */
+			new UBInfo(0x0700, 0x074F, "Syriac"), // Character.UnicodeBlock.SYRIAC
+			/* 0780; 07BF; Thaana */
+			new UBInfo(0x0780, 0x07BF, "Thaana"), // Character.UnicodeBlock.THAANA
+			/* 0900; 097F; Devanagari */
+			new UBInfo(0x0900, 0x097F, "Devanagari"), // Character.UnicodeBlock.DEVANAGARI
+			/* 0980; 09FF; Bengali */
+			new UBInfo(0x0980, 0x09FF, "Bengali"), // Character.UnicodeBlock.BENGALI
+			/* 0A00; 0A7F; Gurmukhi */
+			new UBInfo(0x0A00, 0x0A7F, "Gurmukhi"), // Character.UnicodeBlock.GURMUKHI
+			/* 0A80; 0AFF; Gujarati */
+			new UBInfo(0x0A80, 0x0AFF, "Gujarati"), // Character.UnicodeBlock.GUJARATI
+			/* 0B00; 0B7F; Oriya */
+			new UBInfo(0x0B00, 0x0B7F, "Oriya"), // Character.UnicodeBlock.ORIYA
+			/* 0B80; 0BFF; Tamil */
+			new UBInfo(0x0B80, 0x0BFF, "Tamil"), // Character.UnicodeBlock.TAMIL
+			/* 0C00; 0C7F; Telugu */
+			new UBInfo(0x0C00, 0x0C7F, "Telugu"), // Character.UnicodeBlock.TELUGU
+			/* 0C80; 0CFF; Kannada */
+			new UBInfo(0x0C80, 0x0CFF, "Kannada"), // Character.UnicodeBlock.KANNADA
+			/* 0D00; 0D7F; Malayalam */
+			new UBInfo(0x0D00, 0x0D7F, "Malayalam"), // Character.UnicodeBlock.MALAYALAM
+			/* 0D80; 0DFF; Sinhala */
+			new UBInfo(0x0D80, 0x0DFF, "Sinhala"), // Character.UnicodeBlock.SINHALA
+			/* 0E00; 0E7F; Thai */
+			new UBInfo(0x0E00, 0x0E7F, "Thai"), // Character.UnicodeBlock.THAI
+			/* 0E80; 0EFF; Lao */
+			new UBInfo(0x0E80, 0x0EFF, "Lao"), // Character.UnicodeBlock.LAO
+			/* 0F00; 0FFF; Tibetan */
+			new UBInfo(0x0F00, 0x0FFF, "Tibetan"), // Character.UnicodeBlock.TIBETAN
+			/* 1000; 109F; Myanmar */
+			new UBInfo(0x1000, 0x109F, "Myanmar"), // Character.UnicodeBlock.MYANMAR
+			/* 10A0; 10FF; Georgian */
+			new UBInfo(0x10A0, 0x10FF, "Georgian"), // Character.UnicodeBlock.GEORGIAN
+			/* 1100; 11FF; Hangul Jamo */
+			new UBInfo(0x1100, 0x11FF, "HangulJamo"), // Character.UnicodeBlock.HANGUL_JAMO
+			/* 1200; 137F; Ethiopic */
+			new UBInfo(0x1200, 0x137F, "Ethiopic"), // Character.UnicodeBlock.ETHIOPIC
+			/* 13A0; 13FF; Cherokee */
+			new UBInfo(0x13A0, 0x13FF, "Cherokee"), // Character.UnicodeBlock.CHEROKEE
+			/* 1400; 167F; Unified Canadian Aboriginal Syllabics */
+			new UBInfo(0x1400, 0x167F, "UnifiedCanadianAboriginalSyllabics"), // Character.UnicodeBlock.UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS
+			/* 1680; 169F; Ogham */
+			new UBInfo(0x1680, 0x169F, "Ogham"), // Character.UnicodeBlock.OGHAM
+			/* 16A0; 16FF; Runic */
+			new UBInfo(0x16A0, 0x16FF, "Runic"), // Character.UnicodeBlock.RUNIC
+			/* 1780; 17FF; Khmer */
+			new UBInfo(0x1780, 0x17FF, "Khmer"), // Character.UnicodeBlock.KHMER
+			/* 1800; 18AF; Mongolian */
+			new UBInfo(0x1800, 0x18AF, "Mongolian"), // Character.UnicodeBlock.MONGOLIAN
+			/* 1E00; 1EFF; Latin Extended Additional */
+			new UBInfo(0x1E00, 0x1EFF, "LatinExtendedAdditional"), // Character.UnicodeBlock.LATIN_EXTENDED_ADDITIONAL
+			/* 1F00; 1FFF; Greek Extended */
+			new UBInfo(0x1F00, 0x1FFF, "GreekExtended"), // Character.UnicodeBlock.GREEK_EXTENDED
+			/* 2000; 206F; General Punctuation */
+			new UBInfo(0x2000, 0x206F, "GeneralPunctuation"), // Character.UnicodeBlock.GENERAL_PUNCTUATION
+			/* 2070; 209F; Superscripts and Subscripts */
+			new UBInfo(0x2070, 0x209F, "SuperscriptsandSubscripts"), // Character.UnicodeBlock.SUPERSCRIPTS_AND_SUBSCRIPTS
+			/* 20A0; 20CF; Currency Symbols */
+			new UBInfo(0x20A0, 0x20CF, "CurrencySymbols"), // Character.UnicodeBlock.CURRENCY_SYMBOLS
+			/* 20D0; 20FF; Combining Marks for Symbols */
+			new UBInfo(0x20D0, 0x20FF, "CombiningMarksforSymbols"), // Character.UnicodeBlock.COMBINING_MARKS_FOR_SYMBOLS
+			/* 2100; 214F; Letterlike Symbols */
+			new UBInfo(0x2100, 0x214F, "LetterlikeSymbols"), // Character.UnicodeBlock.LETTERLIKE_SYMBOLS
+			/* 2150; 218F; Number Forms */
+			new UBInfo(0x2150, 0x218F, "NumberForms"), // Character.UnicodeBlock.NUMBER_FORMS
+			/* 2190; 21FF; Arrows */
+			new UBInfo(0x2190, 0x21FF, "Arrows"), // Character.UnicodeBlock.ARROWS
+			/* 2200; 22FF; Mathematical Operators */
+			new UBInfo(0x2200, 0x22FF, "MathematicalOperators"), // Character.UnicodeBlock.MATHEMATICAL_OPERATORS
+			/* 2300; 23FF; Miscellaneous Technical */
+			new UBInfo(0x2300, 0x23FF, "MiscellaneousTechnical"), // Character.UnicodeBlock.MISCELLANEOUS_TECHNICAL
+			/* 2400; 243F; Control Pictures */
+			new UBInfo(0x2400, 0x243F, "ControlPictures"), // Character.UnicodeBlock.CONTROL_PICTURES
+			/* 2440; 245F; Optical Character Recognition */
+			new UBInfo(0x2440, 0x245F, "OpticalCharacterRecognition"), // Character.UnicodeBlock.OPTICAL_CHARACTER_RECOGNITION
+			/* 2460; 24FF; Enclosed Alphanumerics */
+			new UBInfo(0x2460, 0x24FF, "EnclosedAlphanumerics"), // Character.UnicodeBlock.ENCLOSED_ALPHANUMERICS
+			/* 2500; 257F; Box Drawing */
+			new UBInfo(0x2500, 0x257F, "BoxDrawing"), // Character.UnicodeBlock.BOX_DRAWING
+			/* 2580; 259F; Block Elements */
+			new UBInfo(0x2580, 0x259F, "BlockElements"), // Character.UnicodeBlock.BLOCK_ELEMENTS
+			/* 25A0; 25FF; Geometric Shapes */
+			new UBInfo(0x25A0, 0x25FF, "GeometricShapes"), // Character.UnicodeBlock.GEOMETRIC_SHAPES
+			/* 2600; 26FF; Miscellaneous Symbols */
+			new UBInfo(0x2600, 0x26FF, "MiscellaneousSymbols"), // Character.UnicodeBlock.MISCELLANEOUS_SYMBOLS
+			/* 2700; 27BF; Dingbats */
+			new UBInfo(0x2700, 0x27BF, "Dingbats"), // Character.UnicodeBlock.DINGBATS
+			/* 2800; 28FF; Braille Patterns */
+			new UBInfo(0x2800, 0x28FF, "BraillePatterns"), // Character.UnicodeBlock.BRAILLE_PATTERNS
+			/* 2E80; 2EFF; CJK Radicals Supplement */
+			new UBInfo(0x2E80, 0x2EFF, "CJKRadicalsSupplement"), // Character.UnicodeBlock.CJK_RADICALS_SUPPLEMENT
+			/* 2F00; 2FDF; Kangxi Radicals */
+			new UBInfo(0x2F00, 0x2FDF, "KangxiRadicals"), // Character.UnicodeBlock.KANGXI_RADICALS
+			/* 2FF0; 2FFF; Ideographic Description Characters */
+			new UBInfo(0x2FF0, 0x2FFF, "IdeographicDescriptionCharacters"), // Character.UnicodeBlock.IDEOGRAPHIC_DESCRIPTION_CHARACTERS
+			/* 3000; 303F; CJK Symbols and Punctuation */
+			new UBInfo(0x3000, 0x303F, "CJKSymbolsandPunctuation"), // Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
+			/* 3040; 309F; Hiragana */
+			new UBInfo(0x3040, 0x309F, "Hiragana"), // Character.UnicodeBlock.HIRAGANA
+			/* 30A0; 30FF; Katakana */
+			new UBInfo(0x30A0, 0x30FF, "Katakana"), // Character.UnicodeBlock.KATAKANA
+			/* 3100; 312F; Bopomofo */
+			new UBInfo(0x3100, 0x312F, "Bopomofo"), // Character.UnicodeBlock.BOPOMOFO
+			/* 3130; 318F; Hangul Compatibility Jamo */
+			new UBInfo(0x3130, 0x318F, "HangulCompatibilityJamo"), // Character.UnicodeBlock.HANGUL_COMPATIBILITY_JAMO
+			/* 3190; 319F; Kanbun */
+			new UBInfo(0x3190, 0x319F, "Kanbun"), // Character.UnicodeBlock.KANBUN
+			/* 31A0; 31BF; Bopomofo Extended */
+			new UBInfo(0x31A0, 0x31BF, "BopomofoExtended"), // Character.UnicodeBlock.BOPOMOFO_EXTENDED
+			/* 3200; 32FF; Enclosed CJK Letters and Months */
+			new UBInfo(0x3200, 0x32FF, "EnclosedCJKLettersandMonths"), // Character.UnicodeBlock.ENCLOSED_CJK_LETTERS_AND_MONTHS
+			/* 3300; 33FF; CJK Compatibility */
+			new UBInfo(0x3300, 0x33FF, "CJKCompatibility"), // Character.UnicodeBlock.CJK_COMPATIBILITY
+			/* 3400; 4DB5; CJK Unified Ideographs Extension A */
+			new UBInfo(0x3400, 0x4DB5, "CJKUnifiedIdeographsExtensionA"), // Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
+			/* 4E00; 9FFF; CJK Unified Ideographs */
+			new UBInfo(0x4E00, 0x9FFF, "CJKUnifiedIdeographs"), // Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
+			/* A000; A48F; Yi Syllables */
+			new UBInfo(0xA000, 0xA48F, "YiSyllables"), // Character.UnicodeBlock.YI_SYLLABLES
+			/* A490; A4CF; Yi Radicals */
+			new UBInfo(0xA490, 0xA4CF, "YiRadicals"), // Character.UnicodeBlock.YI_RADICALS
+			/* AC00; D7A3; Hangul Syllables */
+			new UBInfo(0xAC00, 0xD7A3, "HangulSyllables"), // Character.UnicodeBlock.HANGUL_SYLLABLES
+			/* D800; DB7F; High Surrogates */
+			/* DB80; DBFF; High Private Use Surrogates */
+			/* DC00; DFFF; Low Surrogates */
+			/* E000; F8FF; Private Use */
+			/* F900; FAFF; CJK Compatibility Ideographs */
+			new UBInfo(0xF900, 0xFAFF, "CJKCompatibilityIdeographs"), // Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
+			/* FB00; FB4F; Alphabetic Presentation Forms */
+			new UBInfo(0xFB00, 0xFB4F, "AlphabeticPresentationForms"), // Character.UnicodeBlock.ALPHABETIC_PRESENTATION_FORMS
+			/* FB50; FDFF; Arabic Presentation Forms-A */
+			new UBInfo(0xFB50, 0xFDFF, "ArabicPresentationForms-A"), // Character.UnicodeBlock.ARABIC_PRESENTATION_FORMS_A
+			/* FE20; FE2F; Combining Half Marks */
+			new UBInfo(0xFE20, 0xFE2F, "CombiningHalfMarks"), // Character.UnicodeBlock.COMBINING_HALF_MARKS
+			/* FE30; FE4F; CJK Compatibility Forms */
+			new UBInfo(0xFE30, 0xFE4F, "CJKCompatibilityForms"), // Character.UnicodeBlock.CJK_COMPATIBILITY_FORMS
+			/* FE50; FE6F; Small Form Variants */
+			new UBInfo(0xFE50, 0xFE6F, "SmallFormVariants"), // Character.UnicodeBlock.SMALL_FORM_VARIANTS
+			/* FE70; FEFE; Arabic Presentation Forms-B */
+			// new UBInfo (0xFE70,0xFEFE,"InArabicPresentationForms-B"), //
+			// Character.UnicodeBlock.ARABIC_PRESENTATION_FORMS_B
+			/* FEFF; FEFF; Specials */
+			new UBInfo(0xFEFF, 0xFEFF, "Specials"), // Character.UnicodeBlock.SPECIALS
+			/* FF00; FFEF; Halfwidth and Fullwidth Forms */
+			new UBInfo(0xFF00, 0xFFEF, "HalfwidthandFullwidthForms"), // Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS
+			/* FFF0; FFFD; Specials */
+			new UBInfo(0xFFF0, 0xFFFD, "Specials") // Character.UnicodeBlock.SPECIALS
+	};
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/ReplaceTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/ReplaceTests.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/ReplaceTests.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/ReplaceTests.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,101 @@
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests.api.java.util.regex;
+
+import junit.framework.TestCase;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+import java.util.regex.PatternSyntaxException;
+
+public class ReplaceTests extends TestCase {
+	
+	public void testSimpleReplace() {
+		String target, pattern, repl, s;
+		Pattern p = null;
+		Matcher m;
+
+		target = "foobarfobarfoofo1";
+		pattern = "fo[^o]";
+		repl = "xxx";
+		try {
+			p = Pattern.compile(pattern);
+		} catch (PatternSyntaxException e) {
+			System.out.println(e.getMessage());
+			fail();
+		}
+		m = p.matcher(target);
+		s = m.replaceFirst(repl);
+		assertTrue(s.equals("foobarxxxarfoofo1"));
+		s = m.replaceAll(repl);
+		assertTrue(s.equals("foobarxxxarfooxxx"));
+	}
+
+	public void testCaptureReplace() {
+		String target, pattern, repl, s;
+		Pattern p = null;
+		Matcher m;
+
+		target = "[31]foo;bar[42];[99]xyz";
+		pattern = "\\[([0-9]+)\\]([a-z]+)";
+		repl = "$2[$1]";
+		try {
+			p = Pattern.compile(pattern);
+		} catch (PatternSyntaxException e) {
+			System.out.println(e.getMessage());
+			fail();
+		}
+		m = p.matcher(target);
+		s = m.replaceFirst(repl);
+		assertTrue(s.equals("foo[31];bar[42];[99]xyz"));
+		s = m.replaceAll(repl);
+		assertTrue(s.equals("foo[31];bar[42];xyz[99]"));
+
+		target = "[31]foo(42)bar{63}zoo;[12]abc(34)def{56}ghi;{99}xyz[88]xyz(77)xyz;";
+		pattern = "\\[([0-9]+)\\]([a-z]+)\\(([0-9]+)\\)([a-z]+)\\{([0-9]+)\\}([a-z]+)";
+		repl = "[$5]$6($3)$4{$1}$2";
+		try {
+			p = Pattern.compile(pattern);
+		} catch (PatternSyntaxException e) {
+			System.out.println(e.getMessage());
+			fail();
+		}
+		m = p.matcher(target);
+		s = m.replaceFirst(repl);
+		// System.out.println(s);
+		assertTrue(s
+				.equals("[63]zoo(42)bar{31}foo;[12]abc(34)def{56}ghi;{99}xyz[88]xyz(77)xyz;"));
+		s = m.replaceAll(repl);
+		// System.out.println(s);
+		assertTrue(s
+				.equals("[63]zoo(42)bar{31}foo;[56]ghi(34)def{12}abc;{99}xyz[88]xyz(77)xyz;"));
+	}
+
+	public void testEscapeReplace() {
+		String target, pattern, repl, s;
+
+		target = "foo'bar''foo";
+		pattern = "'";
+		repl = "\\'";
+		s = target.replaceAll(pattern, repl);
+		assertTrue(s.equals("foo'bar''foo"));
+		repl = "\\\\'";
+		s = target.replaceAll(pattern, repl);
+		assertTrue(s.equals("foo\\'bar\\'\\'foo"));
+		repl = "\\$3";
+		s = target.replaceAll(pattern, repl);
+		assertTrue(s.equals("foo$3bar$3$3foo"));
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/SplitTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/SplitTests.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/SplitTests.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/SplitTests.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,178 @@
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests.api.java.util.regex;
+
+import junit.framework.TestCase;
+import java.util.regex.*;
+
+/**
+ * TODO Type description
+ * 
+ */
+public class SplitTests extends TestCase {
+	
+	public void testSimple() {
+		Pattern p = Pattern.compile("/");
+		String[] results = p.split("have/you/done/it/right");
+		String[] expected = new String[] { "have", "you", "done", "it", "right" };
+		assertEquals(expected.length, results.length);
+		for (int i = 0; i < expected.length; i++) {
+			assertEquals(results[i], expected[i]);
+		}
+	}
+
+	public void testSplit1() {
+		Pattern p = null;
+
+		// This set of tests comes from the O'Reilly NIO book, page 160
+		try {
+			p = Pattern.compile(" ");
+		} catch (PatternSyntaxException e) {
+			fail();
+		}
+
+		String input = "poodle zoo";
+		String tokens[];
+
+		tokens = p.split(input, 1);
+		assertTrue(tokens.length == 1);
+		assertTrue(tokens[0].equals(input));
+		tokens = p.split(input, 2);
+		assertTrue(tokens.length == 2);
+		assertTrue(tokens[0].equals("poodle"));
+		assertTrue(tokens[1].equals("zoo"));
+		tokens = p.split(input, 5);
+		assertTrue(tokens.length == 2);
+		assertTrue(tokens[0].equals("poodle"));
+		assertTrue(tokens[1].equals("zoo"));
+		tokens = p.split(input, -2);
+		assertTrue(tokens.length == 2);
+		assertTrue(tokens[0].equals("poodle"));
+		assertTrue(tokens[1].equals("zoo"));
+		tokens = p.split(input, 0);
+		assertTrue(tokens.length == 2);
+		assertTrue(tokens[0].equals("poodle"));
+		assertTrue(tokens[1].equals("zoo"));
+		tokens = p.split(input);
+		assertTrue(tokens.length == 2);
+		assertTrue(tokens[0].equals("poodle"));
+		assertTrue(tokens[1].equals("zoo"));
+
+		try {
+			p = Pattern.compile("d");
+		} catch (PatternSyntaxException e) {
+			fail();
+			return;
+		}
+
+		tokens = p.split(input, 1);
+		assertTrue(tokens.length == 1);
+		assertTrue(tokens[0].equals(input));
+		tokens = p.split(input, 2);
+		assertTrue(tokens.length == 2);
+		assertTrue(tokens[0].equals("poo"));
+		assertTrue(tokens[1].equals("le zoo"));
+		tokens = p.split(input, 5);
+		assertTrue(tokens.length == 2);
+		assertTrue(tokens[0].equals("poo"));
+		assertTrue(tokens[1].equals("le zoo"));
+		tokens = p.split(input, -2);
+		assertTrue(tokens.length == 2);
+		assertTrue(tokens[0].equals("poo"));
+		assertTrue(tokens[1].equals("le zoo"));
+		tokens = p.split(input, 0);
+		assertTrue(tokens.length == 2);
+		assertTrue(tokens[0].equals("poo"));
+		assertTrue(tokens[1].equals("le zoo"));
+		tokens = p.split(input);
+		assertTrue(tokens.length == 2);
+		assertTrue(tokens[0].equals("poo"));
+		assertTrue(tokens[1].equals("le zoo"));
+
+		try {
+			p = Pattern.compile("o");
+		} catch (PatternSyntaxException e) {
+			fail();
+		}
+
+		tokens = p.split(input, 1);
+		assertTrue(tokens.length == 1);
+		assertTrue(tokens[0].equals(input));
+		tokens = p.split(input, 2);
+		assertTrue(tokens.length == 2);
+		assertTrue(tokens[0].equals("p"));
+		assertTrue(tokens[1].equals("odle zoo"));
+		tokens = p.split(input, 5);
+		assertTrue(tokens.length == 5);
+		assertTrue(tokens[0].equals("p"));
+		assertTrue(tokens[1].equals(""));
+		assertTrue(tokens[2].equals("dle z"));
+		assertTrue(tokens[3].equals(""));
+		assertTrue(tokens[4].equals(""));
+		tokens = p.split(input, -2);
+		assertTrue(tokens.length == 5);
+		assertTrue(tokens[0].equals("p"));
+		assertTrue(tokens[1].equals(""));
+		assertTrue(tokens[2].equals("dle z"));
+		assertTrue(tokens[3].equals(""));
+		assertTrue(tokens[4].equals(""));
+		tokens = p.split(input, 0);
+		assertTrue(tokens.length == 3);
+		assertTrue(tokens[0].equals("p"));
+		assertTrue(tokens[1].equals(""));
+		assertTrue(tokens[2].equals("dle z"));
+		tokens = p.split(input);
+		assertTrue(tokens.length == 3);
+		assertTrue(tokens[0].equals("p"));
+		assertTrue(tokens[1].equals(""));
+		assertTrue(tokens[2].equals("dle z"));
+	}
+
+	public void testSplit2() {
+		Pattern p = Pattern.compile("");
+		String s[];
+		s = p.split("a", -1);
+		assertEquals(3, s.length);
+		assertEquals("", s[0]);
+		assertEquals("a", s[1]);
+		assertEquals("", s[2]);
+
+		s = p.split("", -1);
+		assertEquals(1, s.length);
+		assertEquals("", s[0]);
+
+		s = p.split("abcd", -1);
+		assertEquals(6, s.length);
+		assertEquals("", s[0]);
+		assertEquals("a", s[1]);
+		assertEquals("b", s[2]);
+		assertEquals("c", s[3]);
+		assertEquals("d", s[4]);
+		assertEquals("", s[5]);
+
+		// Match with a surrogate pair .. strangely splits the surrogate pair. I
+		// would have expected
+		// the third matched string to be "\ud869\uded6" (aka \u2a6d6)
+		s = p.split("a\ud869\uded6b", -1);
+		assertEquals(6, s.length);
+		assertEquals("", s[0]);
+		assertEquals("a", s[1]);
+		assertEquals("\ud869", s[2]);
+		assertEquals("\uded6", s[3]);
+		assertEquals("b", s[4]);
+		assertEquals("", s[5]);
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/regex/AllTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/regex/AllTests.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/regex/AllTests.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/regex/AllTests.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,37 @@
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests.regex;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Test suite that includes all tests for the Regex project.
+ */
+public class AllTests {
+
+	public static void main(String[] args) {
+		junit.textui.TestRunner.run(AllTests.suite());
+	}
+
+	public static Test suite() {
+		TestSuite suite = new TestSuite("All Regex test suites");
+		// $JUnit-BEGIN$
+		suite.addTest(tests.api.java.util.regex.AllTests.suite());
+		// $JUnit-END$
+		return suite;
+	}
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/sql/META-INF/MANIFEST.MF?rev=386087&r1=386086&r2=386087&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/META-INF/MANIFEST.MF (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/META-INF/MANIFEST.MF Wed Mar 15 06:55:38 2006
@@ -5,5 +5,19 @@
 Bundle-Version: 1.0.0
 Bundle-ClassPath: .
 Eclipse-JREBundle: true
-Export-Package: java.sql
-Import-Package: java.lang
+Export-Package: java.sql,
+ javax.sql,
+ javax.sql.rowset,
+ javax.sql.rowset.serial,
+ javax.sql.rowset.spi,
+ javax.transaction,
+ javax.transaction.xa
+Import-Package: java.lang,
+ java.util,
+ java.io,
+ com.ibm.oti.vm,
+ java.security,
+ java.math,
+ java.net,
+ java.text,
+ java.rmi

Added: incubator/harmony/enhanced/classlib/trunk/modules/sql/make/build.xml
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/sql/make/build.xml?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/make/build.xml (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/make/build.xml Wed Mar 15 06:55:38 2006
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+  
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+  
+       http://www.apache.org/licenses/LICENSE-2.0
+  
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<project name="SQL Build" default="build" basedir="..">
+	<description>Build for SQL component</description>
+
+	<!-- set global properties for this build. -->
+	<xmlproperty file="make/common/hyproperties.xml" semanticAttributes="true"/>
+	<property environment="env"/>
+
+	<!-- Determine the (normalized) operating system family -->
+	<condition property="if.win">
+		<os family="Windows" />
+	</condition>
+	<condition property="hy.os_family" value="windows">
+		<isset property="if.win"/>
+	</condition>
+
+	<condition property="if.linux">
+		<and>
+			<os name="linux" />
+			<os family="unix" />
+		</and>
+	</condition>
+	<condition property="hy.os_family" value="linux">
+		<isset property="if.linux"/>
+	</condition>
+
+
+	<!-- Determine the (normalized) processor family -->
+	<condition property="if.x86_64">
+		<contains string="${os.arch}" substring="x86_64"/>
+	</condition>
+	<condition property="hy.cpu_family" value="x86_64">
+		<isset property="if.x86_64"/>
+	</condition>
+	
+	<condition property="if.x86">
+		<and>
+			<contains string="${os.arch}" substring="86"/>
+			<not>
+				<isset property="if.x86_64"/>
+			</not>
+		</and>
+	</condition>
+	<condition property="hy.cpu_family" value="x86">
+		<isset property="if.x86"/>
+	</condition>
+	
+	<condition property="if.ipf">
+		<contains string="${os.arch}" substring="ia64"/>
+	</condition>
+	<condition property="hy.cpu_family" value="ipf">
+		<isset property="if.ipf"/>
+	</condition>
+
+	<!-- Define the platform property dependant upon the OS and platform -->
+	<property name="hy.platform" value="${hy.os_family}.${hy.cpu_family}"/>
+
+	<!-- Set the java compiler to be the Eclipse Java compiler -->
+	<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter" />
+
+
+	<target name="init">
+		<tstamp>
+			<format property="build-date" pattern="yyyyMMdd" locale="en" />
+		</tstamp>
+		<tstamp>
+			<format property="build-time" pattern="yyyyMMdd_HHmm" />
+		</tstamp>
+		<echo message="build-date=${build-date}" />
+		<echo message="build-time=${build-time}" />
+		<echo message="on platform=${os.name} version=${os.version} arch=${os.arch}" />
+
+		<property name="java.debug.option" value="on" />
+		<property name="native.debug.option" value="on" />
+
+		<property name="source.ver" value="1.4" />
+	</target>
+	
+	<!-- SQL TARGETS -->
+
+	<target name="build" depends="init">
+		<ant dir="make/common" target="compile.java" />
+		<ant dir="make/common" target="build.jar" />
+	<!--	<ant dir="make/platform/${hy.platform}" target="compile.native" /> -->
+		<ant dir="make/common" target="copy.resources" />
+	</target>
+
+
+	<target name="test" depends="build">
+		<ant dir="make/common" target="compile.tests" />
+		<ant dir="make/common" target="run.tests" />
+	</target>
+
+	<target name="clean">
+		<delete dir="${hy.sql.bin.main}"/>
+		<delete dir="${hy.sql.bin.test}"/>
+	</target>
+
+</project>

Added: incubator/harmony/enhanced/classlib/trunk/modules/sql/make/common/build.xml
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/sql/make/common/build.xml?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/make/common/build.xml (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/make/common/build.xml Wed Mar 15 06:55:38 2006
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+  
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+  
+       http://www.apache.org/licenses/LICENSE-2.0
+  
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<project name="Common_SQL_Build">
+	
+	<target name="compile.java" description="Compile SQL java code">
+		<echo message="Compiling SQL classes from ${hy.sql.src.main.java}" />
+		
+		<mkdir dir="${hy.sql.bin.main}" />
+
+		<javac sourcepath=""
+			srcdir="${hy.sql.src.main.java}"
+			destdir="${hy.sql.bin.main}"
+			source="${source.ver}"
+			debug="${java.debug.option}">
+
+			<bootclasspath>
+				<fileset dir="${hy.target}/jre/lib/boot">
+					<include name="*.jar" />
+				</fileset>
+			</bootclasspath>
+                        <exclude name="**/InvalidTransactionException.java" />
+                        <exclude name="**/TransactionRequiredException.java" />
+                        <exclude name="**/TransactionRolledbackException.java" />
+		</javac>
+	</target>
+	
+	<target name="build.jar">
+		<jar destfile="${hy.target}/jre/lib/boot/sql.jar"
+			manifest="${hy.sql}/META-INF/MANIFEST.MF">
+			<fileset dir="${hy.sql.bin.main}" />
+		</jar>
+	</target>
+
+	
+	<target name="compile.tests">
+		<echo message="Compiling SQL tests from ${hy.sql.src.test.java}" />
+
+		<mkdir dir="${hy.sql.bin.test}" />
+
+		<javac srcdir="${hy.sql.src.test.java}"
+			destdir="${hy.sql.bin.test}"
+			sourcepath=""
+			source="${source.ver}"
+			debug="${java.debug.option}">
+
+			<bootclasspath>
+				<fileset dir="${hy.target}/jre/lib/boot">
+					<include name="*.jar" />
+				</fileset>
+			</bootclasspath>
+                        <classpath location="../../../../build/tests" />
+                        <exclude name="**/InvalidTransactionExceptionTest.java" />
+                        <exclude name="**/TransactionRequiredExceptionTest.java" />
+                        <exclude name="**/TransactionRolledbackExceptionTest.java" />
+		</javac>
+	</target>
+
+
+	<target name="run.tests">
+		
+	        <mkdir dir="${hy.tests.reports}" />
+
+	        <junit fork="yes"
+			forkmode="once"
+			printsummary="withOutAndErr"
+			errorproperty="test.error"
+			showoutput="on"
+			dir="${hy.sql.bin.test}"
+			jvm="${hy.target}/jre/bin/java">
+
+			<jvmarg value="-showversion"/>
+
+			<env key="JAVA_HOME" value="${hy.target}/jre"/>
+
+			<classpath>
+				<pathelement path="${hy.sql.bin.test}"/>
+			</classpath>
+                        <classpath location="../../../../build/tests" />
+
+			<formatter type="xml" />
+
+			<batchtest todir="${hy.tests.reports}" haltonfailure="no">
+				<fileset dir="${hy.sql.src.test.java}">
+					<include name="**/*Test.java"/>
+                                        <exclude name="**/ArrayTest.java" />
+                                        <exclude name="**/DriverManagerTest.java" />
+                                        <exclude name="**/InvalidTransactionExceptionTest.java" />
+                                        <exclude name="**/TransactionRequiredExceptionTest.java" />
+                                        <exclude name="**/TransactionRolledbackExceptionTest.java" />
+				</fileset>
+			</batchtest>
+		</junit>
+	</target>
+	
+	
+	<target name="copy.resources">
+		<!-- Nothing for SQL -->
+	</target>
+</project>
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/sql/make/common/hyproperties.xml
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/sql/make/common/hyproperties.xml?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/make/common/hyproperties.xml (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/make/common/hyproperties.xml Wed Mar 15 06:55:38 2006
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+  
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+  
+       http://www.apache.org/licenses/LICENSE-2.0
+  
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<hy>
+   <sql location=".">
+      <src>
+         <main>
+            <java location="src/main/java" />
+        	<resources location="src/main/resources" />
+         </main>
+         <test>
+            <java location="src/test/java" />
+            <resources location="src/main/resources" />
+         </test>
+         <natives location="src/natives" />
+      </src>
+      <bin>
+        <main location="bin/main" />
+        <test location="bin/test" />
+      </bin>
+      <packaging>
+      </packaging>
+   </sql>
+
+   <target location="../../deploy" />
+
+   <tests>
+      <reports location="../../build/test_report" />
+   </tests>
+</hy>

Added: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/com/ibm/common/ClassUtils.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/com/ibm/common/ClassUtils.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/com/ibm/common/ClassUtils.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/com/ibm/common/ClassUtils.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,61 @@
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package com.ibm.common;
+
+/**
+ * A class containing sets of utility functions relating to Classes, ClassLoaders and associated
+ * aspects of Java
+ * 
+ */
+public class ClassUtils {
+
+	/**
+	 * Gets the ClassLoader of method that called the method which called this method.
+	 * ie if C2.m2() calls this method, and C1.m1() calls C2.m2(), this method returns the
+	 * ClassLoader for class C1.
+	 * @return The ClassLoader of the caller's caller.
+	 * TODO - needs completing
+	 */
+	public static ClassLoader getCallerClassLoader() {
+		return null;
+	} // end method getCallerClassLoader
+	
+	/**
+	 * Finds if a supplied Object belongs to the given ClassLoader.
+	 * @param theObject the object to check
+	 * @param theClassLoader the ClassLoader 
+	 * @return true if the Object does belong to the ClassLoader, false otherwise
+	 */
+	public static boolean isClassFromClassLoader( Object theObject, ClassLoader theClassLoader ) {
+		
+		if( (theObject == null) || (theClassLoader == null) ) return false;
+		
+		Class objectClass = theObject.getClass();
+		
+		try {
+			Class checkClass = Class.forName(objectClass.getName(), true, theClassLoader);
+			if( checkClass == objectClass ) return true;
+		} catch ( Throwable t ) {
+			
+		} // end try
+		
+		return false;
+	} // end method isClassFromClassLoader( Object, ClassLoader )
+	
+} // end class ClassUtils
+
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Array.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Array.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Array.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Array.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,131 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.sql;
+
+import java.util.Map;
+
+/**
+ * A Java representation of the SQL ARRAY type.
+ * 
+ */
+public interface Array {
+
+	/**
+	 * Retrieves the contents of the SQL ARRAY value as a Java array object.
+	 * 
+	 * @return A Java array containing the elements of this Array
+	 * @throws SQLException
+	 */
+	public Object getArray() throws SQLException;
+
+	/**
+	 * Returns part of the SQL ARRAY associated with this Array, starting at a
+	 * particular index and comprising up to count successive elements of the
+	 * SQL array.
+	 * 
+	 * @param index
+	 * @param count
+	 * @return A Java array containing the subportion of elements of this Array
+	 * @throws SQLException
+	 */
+	public Object getArray(long index, int count) throws SQLException;
+
+	/**
+	 * Returns part of the SQL ARRAY associated with this Array, starting at a
+	 * particular index and comprising up to count successive elements of the
+	 * SQL array.
+	 * 
+	 * @param index
+	 * @param count
+	 * @param map
+	 * @return A Java array containing the subportion of elements of this Array
+	 * @throws SQLException
+	 */
+	public Object getArray(long index, int count, Map map) throws SQLException;
+
+	/**
+	 * Returns the SQL ARRAY associated with this Array.
+	 * 
+	 * @param map
+	 * @return A Java array containing the elements of this Array
+	 * @throws SQLException
+	 */
+	public Object getArray(Map map) throws SQLException;
+
+	/**
+	 * Returns the JDBC type of the entries in this Array's associated array.
+	 * 
+	 * @return An integer constant from the java.sql.Types class
+	 * @throws SQLException
+	 */
+	public int getBaseType() throws SQLException;
+
+	/**
+	 * Returns the SQL type name of the entries in the array associated with
+	 * this Array.
+	 * 
+	 * @return The database specific name or a fully-qualified SQL type name.
+	 * @throws SQLException
+	 */
+	public String getBaseTypeName() throws SQLException;
+
+	/**
+	 * Returns a ResultSet object which holds the entries of the SQL ARRAY
+	 * associated with this Array.
+	 * 
+	 * @return the ResultSet
+	 * @throws SQLException
+	 */
+	public ResultSet getResultSet() throws SQLException;
+
+	/**
+	 * Returns a ResultSet object that holds the entries of a subarray,
+	 * beginning at a particular index and comprising up to count successive
+	 * entries.
+	 * 
+	 * @param index
+	 * @param count
+	 * @return the ResultSet
+	 * @throws SQLException
+	 */
+	public ResultSet getResultSet(long index, int count) throws SQLException;
+
+	/**
+	 * Returns a ResultSet object that holds the entries of a subarray,
+	 * beginning at a particular index and comprising up to count successive
+	 * entries.
+	 * 
+	 * @param index
+	 * @param count
+	 * @param map
+	 * @return the ResultSet
+	 * @throws SQLException
+	 */
+	public ResultSet getResultSet(long index, int count, Map map)
+			throws SQLException;
+
+	/**
+	 * Returns a ResultSet object which holds the entries of the SQL ARRAY
+	 * associated with this Array.
+	 * 
+	 * @param map
+	 * @return the ResultSet
+	 * @throws SQLException
+	 */
+	public ResultSet getResultSet(Map map) throws SQLException;
+
+} // end interface Array
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/BatchUpdateException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/BatchUpdateException.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/BatchUpdateException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/BatchUpdateException.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,147 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.sql;
+
+import java.io.Serializable;
+
+/**
+ * An exception thrown if a problem occurs during a batch update operation.
+ * <p>
+ * A BatchUpdateException provides additional information about the problem that
+ * occurred, compared with a standard SQLException. It supplies update counts
+ * for successful commands that executed within the batch update, but before the
+ * exception was encountered.
+ * <p>
+ * The element order in the array of update counts matches the order that the
+ * commands were added to the batch operation.
+ * <p>
+ * Once a batch update command fails and a BatchUpdateException is thrown, the
+ * JDBC driver may continue processing the remaining commands in the batch. If
+ * the driver does process more commands after the problem occurs, the array
+ * returned by BatchUpdateException.getUpdateCounts has an element for every
+ * command in the batch, not only those that executed successfully. In this
+ * case, the array element for any command which encountered a problem is set to
+ * Statement.EXECUTE_FAILED.
+ * 
+ */
+public class BatchUpdateException extends SQLException implements Serializable {
+
+	private static final long serialVersionUID = 5977529877145521757L;
+
+	private int[] theUpdateCounts = null;
+
+	/**
+	 * Creates a BatchUpdateException with the Reason, SQLState, and Update
+	 * Counts set to null and a Vendor Code of 0.
+	 */
+	public BatchUpdateException() {
+		super();
+	} // end method BatchUpdateException()
+
+	/**
+	 * Creates a BatchUpdateException with the Update Counts set to the supplied
+	 * value and the Reason, SQLState set to null and a Vendor Code of 0.
+	 * 
+	 * @param updateCounts
+	 *            the array of Update Counts to use in initialization
+	 */
+	public BatchUpdateException(int[] updateCounts) {
+		super();
+		this.theUpdateCounts = updateCounts;
+	} // end method BatchUpdateException(
+
+	/**
+	 * Creates a BatchUpdateException with the Update Counts set to the supplied
+	 * value, the Reason set to the supplied value and SQLState set to null and
+	 * a Vendor Code of 0.
+	 * 
+	 * @param reason
+	 *            the initialization value for Reason
+	 * @param updateCounts
+	 *            the array of Update Counts to set
+	 */
+	public BatchUpdateException(String reason, int[] updateCounts) {
+		super(reason);
+		this.theUpdateCounts = updateCounts;
+	} // end method BatchUpdateException(
+
+	/**
+	 * Creates a BatchUpdateException with the Update Counts set to the supplied
+	 * value, the Reason set to the supplied value, the SQLState initialized to
+	 * the supplied value and the Vendor Code initialized to 0.
+	 * 
+	 * @param reason
+	 *            the value to use for the Reason
+	 * @param SQLState
+	 *            the X/OPEN value to use for the SQLState
+	 * @param updateCounts
+	 *            the array of Update Counts to set
+	 */
+	public BatchUpdateException(String reason, String SQLState,
+			int[] updateCounts) {
+		super(reason, SQLState);
+		this.theUpdateCounts = updateCounts;
+	} // end method BatchUpdateException(
+
+	/**
+	 * Creates a BatchUpdateException with the Update Counts set to the supplied
+	 * value, the Reason set to the supplied value, the SQLState initialized to
+	 * the supplied value and the Vendor Code set to the supplied value.
+	 * 
+	 * @param reason
+	 *            the value to use for the Reason
+	 * @param SQLState
+	 *            the X/OPEN value to use for the SQLState
+	 * @param vendorCode
+	 *            the value to use for the vendor error code
+	 * @param updateCounts
+	 *            the array of Update Counts to set
+	 */
+	public BatchUpdateException(String reason, String SQLState, int vendorCode,
+			int[] updateCounts) {
+		super(reason, SQLState, vendorCode);
+		this.theUpdateCounts = updateCounts;
+	} // end method BatchUpdateException(
+
+	/**
+	 * Gets the Update Counts array.
+	 * <p>
+	 * If a batch update command fails and a BatchUpdateException is thrown, the
+	 * JDBC driver may continue processing the remaining commands in the batch.
+	 * If the driver does process more commands after the problem occurs, the
+	 * array returned by <code>BatchUpdateException.getUpdateCounts</code> has
+	 * an element for every command in the batch, not only those that executed
+	 * successfully. In this case, the array element for any command which
+	 * encountered a problem is set to Statement.EXECUTE_FAILED.
+	 * 
+	 * @return an array that contains the successful update counts, before this
+	 *         exception. Alternatively, if the driver continues to process
+	 *         commands following an error, one of these listed items for every
+	 *         command the batch contains:
+	 *         <ol>
+	 *         <li>an count of the updates</li>
+	 *         <li><code>Statement.SUCCESS_NO_INFO</code> indicating that the
+	 *         command completed successfully, but the amount of altered rows is
+	 *         not known.</li>
+	 *         <li><code>Statement.EXECUTE_FAILED</code> indicating that the
+	 *         command was unsuccessful.
+	 *         </ol>
+	 */
+	public int[] getUpdateCounts() {
+		return theUpdateCounts;
+	} // end method getUpdateCounts()
+} // end class BatchUpdateException
+