[kaffe] CVS kaffe (dalibor): Replaced java/util/regex with implementation from GNU Classpath

Kaffe CVS cvs-commits at kaffe.org
Wed Mar 17 12:42:01 PST 2004


PatchSet 4534 
Date: 2004/03/17 20:23:06
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Replaced java/util/regex with implementation from GNU Classpath

2004-03-17  Dalibor Topic <robilad at kaffe.org>

        * libraries/javalib/java/util/regex/Matcher.java,
        libraries/javalib/java/util/regex/Pattern.java,
        libraries/javalib/java/util/regex/PatternSyntaxException.java:
        Replaced by implementation from GNU Classpath.

Members: 
	ChangeLog:1.2112->1.2113 
	libraries/javalib/java/util/regex/Matcher.java:1.4->1.5 
	libraries/javalib/java/util/regex/Pattern.java:1.4->1.5 
	libraries/javalib/java/util/regex/PatternSyntaxException.java:1.2->1.3 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2112 kaffe/ChangeLog:1.2113
--- kaffe/ChangeLog:1.2112	Wed Mar 17 19:27:59 2004
+++ kaffe/ChangeLog	Wed Mar 17 20:23:06 2004
@@ -1,5 +1,12 @@
 2004-03-17  Dalibor Topic <robilad at kaffe.org>
 
+        * libraries/javalib/java/util/regex/Matcher.java,
+        libraries/javalib/java/util/regex/Pattern.java,
+        libraries/javalib/java/util/regex/PatternSyntaxException.java:
+	Replaced by implementation from GNU Classpath.
+
+2004-03-17  Dalibor Topic <robilad at kaffe.org>
+
         * libraries/javalib/gnu/regexp/REException.java,
         libraries/javalib/gnu/regexp/REFilterInputStream.java,
         libraries/javalib/gnu/regexp/REMatch.java,
Index: kaffe/libraries/javalib/java/util/regex/Matcher.java
diff -u kaffe/libraries/javalib/java/util/regex/Matcher.java:1.4 kaffe/libraries/javalib/java/util/regex/Matcher.java:1.5
--- kaffe/libraries/javalib/java/util/regex/Matcher.java:1.4	Sat Jan 10 19:38:14 2004
+++ kaffe/libraries/javalib/java/util/regex/Matcher.java	Wed Mar 17 20:23:08 2004
@@ -1,141 +1,293 @@
+/* Matcher.java -- Instance of a regular expression applied to a char sequence.
+   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
 package java.util.regex;
+
 import gnu.regexp.RE;
 import gnu.regexp.REMatch;
 
-public final class Matcher {
-    private Pattern pattern;
-    private CharSequence input;
-    private int position;
-    private int appendPosition;
-    private REMatch match;
-
-    public Pattern pattern() {
-	return pattern;
-    }
-
-    Matcher(Pattern pattern, CharSequence input) {
-	this.pattern = pattern;
-	this.input = input;
-    }
-
-    public boolean matches() {
-	return find(0);
-    }
-
-    public boolean lookingAt() {
-	match = pattern.getRE().getMatch(input, 0);
-	if (match != null) {
-	    if (match.getStartIndex() == 0) {
-		return true;
-	    }
+/**
+ * Instance of a regular expression applied to a char sequence.
+ *
+ * @since 1.4
+ */
+public class Matcher
+{
+  private Pattern pattern;
+  private CharSequence input;
+  private int position;
+  private int appendPosition;
+  private REMatch match;
+
+  Matcher(Pattern pattern, CharSequence input)
+  {
+    this.pattern = pattern;
+    this.input = input;
+  }
+  
+  /**
+   * @param sb The target string buffer
+   * @param replacement The replacement string
+   *
+   * @exception IllegalStateException If no match has yet been attempted,
+   * or if the previous match operation failed
+   * @exception IndexOutOfBoundsException If the replacement string refers
+   * to a capturing group that does not exist in the pattern
+   */
+  public Matcher appendReplacement (StringBuffer sb, String replacement)
+    throws IllegalStateException
+  {
+    assertMatchOp();
+    sb.append(input.subSequence(appendPosition,
+				match.getStartIndex()).toString());
+    sb.append(match.substituteInto(replacement));
+    appendPosition = match.getEndIndex();
+    return this;
+  }
+
+  /**
+   * @param sb The target string buffer
+   */
+  public StringBuffer appendTail (StringBuffer sb)
+  {
+    sb.append(input.subSequence(appendPosition, input.length()).toString());
+    return sb;
+  }
+ 
+  /**
+   * @exception IllegalStateException If no match has yet been attempted,
+   * or if the previous match operation failed
+   */
+  public int end ()
+    throws IllegalStateException
+  {
+    assertMatchOp();
+    return match.getEndIndex();
+  }
+  
+  /**
+   * @param group The index of a capturing group in this matcher's pattern
+   *
+   * @exception IllegalStateException If no match has yet been attempted,
+   * or if the previous match operation failed
+   * @exception IndexOutOfBoundsException If the replacement string refers
+   * to a capturing group that does not exist in the pattern
+   */
+  public int end (int group)
+    throws IllegalStateException
+  {
+    assertMatchOp();
+    return match.getEndIndex(group);
+  }
+ 
+  public boolean find ()
+  {
+    boolean first = (match == null);
+    match = pattern.getRE().getMatch(input, position);
+    if (match != null)
+      {
+	int endIndex = match.getEndIndex();
+	// Are we stuck at the same position?
+	if (!first && endIndex == position)
+	  {
 	    match = null;
-	}
-	return false;
-    }
-
-    public boolean find() {
-	boolean first = (match == null);
-	match = pattern.getRE().getMatch(input, position);
-	if (match != null) {
-	    int endIndex = match.getEndIndex();
-	    // Are we stuck at the same position?
-	    if (!first && endIndex == position) {
-		match = null;
-		// Not at the end of the input yet?
-		if (position < input.length() - 1) {
-		    position++;
-		    return find(position);
-		} else {
-		    return false;
-		}
-	    }
-	    position = endIndex;
-	    return true;
-	}
-	return false;
-    }
-
-    public boolean find(int start) {
-	match = pattern.getRE().getMatch(input, start);
-	if (match != null) {
-	    position = match.getEndIndex();
-	    return true;
-	}
-	return false;
-    }
-
-    private void assertMatchOp() {
-	if (match == null) throw new IllegalStateException();
-    }
-
-    public int start() {
-	assertMatchOp();
-	return match.getStartIndex();
-    }
-
-    public int start(int group) {
-	assertMatchOp();
-	return match.getStartIndex(group);
-    }
-
-    public int end() {
-	assertMatchOp();
-	return match.getEndIndex();
-    }
-
-    public int end(int group) {
-	assertMatchOp();
-	return match.getEndIndex(group);
-    }
-    
-    public String group() {
-	assertMatchOp();
-	return match.toString();
-    }
-
-    public String group(int group) {
-	assertMatchOp();
-	return match.toString(group);
-    }
-
-    public int groupCount() {
-	return pattern.getRE().getNumSubs();
-    }
-
-    public Matcher appendReplacement(StringBuffer sb, String replacement) {
-	assertMatchOp();
-	sb.append(input.subSequence(appendPosition, match.getStartIndex()).toString());
-	sb.append(match.substituteInto(replacement));
-	appendPosition = match.getEndIndex();
-
-	return this;
-    }
-
-    public StringBuffer appendTail(StringBuffer sb) {
-	sb.append(input.subSequence(appendPosition, input.length()).toString());
-	return sb;
-    }
-
-    public String replaceAll(String replacement) {
-	reset();
-	return pattern.getRE().substituteAll(input, replacement, position);
-    }
-
-    public String replaceFirst(String replacement) {
-	reset();
-	// Semantics might not quite match
-	return pattern.getRE().substitute(input, replacement, position);
-    }
-
-    public Matcher reset() {
-	position = 0;
+	    // Not at the end of the input yet?
+	    if (position < input.length() - 1)
+	      {
+		position++;
+		return find(position);
+	      }
+	    else
+	      return false;
+	  }
+	position = endIndex;
+	return true;
+      }
+    return false;
+  } 
+
+  /**
+   * @param start The index to start the new pattern matching
+   *
+   * @exception IndexOutOfBoundsException If the replacement string refers
+   * to a capturing group that does not exist in the pattern
+   */
+  public boolean find (int start)
+  {
+    match = pattern.getRE().getMatch(input, start);
+    if (match != null)
+      {
+	position = match.getEndIndex();
+	return true;
+      }
+    return false;
+  }
+ 
+  /**
+   * @exception IllegalStateException If no match has yet been attempted,
+   * or if the previous match operation failed
+   */
+  public String group ()
+  {
+    assertMatchOp();
+    return match.toString();
+  }
+  
+  /**
+   * @param group The index of a capturing group in this matcher's pattern
+   *
+   * @exception IllegalStateException If no match has yet been attempted,
+   * or if the previous match operation failed
+   * @exception IndexOutOfBoundsException If the replacement string refers
+   * to a capturing group that does not exist in the pattern
+   */
+  public String group (int group)
+    throws IllegalStateException
+  {
+    assertMatchOp();
+    return match.toString(group);
+  }
+
+  /**
+   * @param replacement The replacement string
+   */
+  public String replaceFirst (String replacement)
+  {
+    reset();
+    // Semantics might not quite match
+    return pattern.getRE().substitute(input, replacement, position);
+  }
+
+  /**
+   * @param replacement The replacement string
+   */
+  public String replaceAll (String replacement)
+  {
+    reset();
+    return pattern.getRE().substituteAll(input, replacement, position);
+  }
+  
+  public int groupCount ()
+  {
+    return pattern.getRE().getNumSubs();
+  }
+ 
+  public boolean lookingAt ()
+  {
+    match = pattern.getRE().getMatch(input, 0);
+    if (match != null)
+      {
+	if (match.getStartIndex() == 0)
+	  return true;
 	match = null;
-	return this;
-    }
-
-    public Matcher reset(CharSequence input) {
-	this.input = input;
-	reset();
-	return this;
-    }
+      }
+    return false;
+  }
+  
+  /**
+   * Attempts to match the entire input sequence against the pattern. 
+   *
+   * If the match succeeds then more information can be obtained via the
+   * start, end, and group methods.
+   *
+   * @see #start
+   * @see #end
+   * @see #group
+   */
+  public boolean matches ()
+  {
+    return find(0);
+  }
+  
+  /**
+   * Returns the Pattern that is interpreted by this Matcher
+   */
+  public Pattern pattern ()
+  {
+    return pattern;
+  }
+  
+  public Matcher reset ()
+  {
+    position = 0;
+    match = null;
+    return this;
+  }
+  
+  /**
+   * @param input The new input character sequence
+   */
+  public Matcher reset (CharSequence input)
+  {
+    this.input = input;
+    return reset();
+  }
+  
+  /**
+   * @param group The index of a capturing group in this matcher's pattern
+   *
+   * @exception IllegalStateException If no match has yet been attempted,
+   * or if the previous match operation failed
+   */
+  public int start ()
+    throws IllegalStateException
+  {
+    assertMatchOp();
+    return match.getStartIndex();
+  }
+
+  /**
+   * @param group The index of a capturing group in this matcher's pattern
+   *
+   * @exception IllegalStateException If no match has yet been attempted,
+   * or if the previous match operation failed
+   * @exception IndexOutOfBoundsException If the replacement string refers
+   * to a capturing group that does not exist in the pattern
+   */
+  public int start (int group)
+    throws IllegalStateException
+  {
+    assertMatchOp();
+    return match.getStartIndex(group);
+  }
+
+  private void assertMatchOp()
+  {
+    if (match == null) throw new IllegalStateException();
+  }
 }
Index: kaffe/libraries/javalib/java/util/regex/Pattern.java
diff -u kaffe/libraries/javalib/java/util/regex/Pattern.java:1.4 kaffe/libraries/javalib/java/util/regex/Pattern.java:1.5
--- kaffe/libraries/javalib/java/util/regex/Pattern.java:1.4	Sat Jan 10 19:38:14 2004
+++ kaffe/libraries/javalib/java/util/regex/Pattern.java	Wed Mar 17 20:23:08 2004
@@ -1,142 +1,254 @@
+/* Pattern.java -- Compiled regular expression ready to be applied.
+   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
 package java.util.regex;
-import java.io.Serializable;
+
 import gnu.regexp.RE;
 import gnu.regexp.RESyntax;
 import gnu.regexp.REException;
-import java.util.ArrayList;
 
-public final class Pattern implements Serializable {
+import java.io.Serializable;
+import java.util.ArrayList;
 
-    public static final int UNIX_LINES = 1;
-    public static final int CASE_INSENSITIVE = 2;
-    public static final int COMMENTS = 4;
-    public static final int MULTILINE = 8;
-    public static final int DOTALL = 32;
-    public static final int UNICODE_CASE = 64;
-    public static final int CANON_EQ = 128;
 
-    private String pattern;
-    private int flags;
+/**
+ * Compiled regular expression ready to be applied. 
+ *
+ * @since 1.4
+ */
+public class Pattern implements Serializable
+{
+  private static final long serialVersionUID = 5073258162644648461L;
+  
+  public static final int CANON_EQ = 128;
+  public static final int CASE_INSENSITIVE = 2;
+  public static final int COMMENTS = 4;
+  public static final int DOTALL = 32;
+  public static final int MULTILINE = 8;
+  public static final int UNICODE_CASE = 64;
+  public static final int UNIX_LINES = 1;
+  
+  private final String regex;
+  private final int flags;
+
+  private final RE re;
+
+  private Pattern (String regex)
+    throws PatternSyntaxException
+  {
+    this (regex, 0);
+  }
+
+  private Pattern (String regex, int flags)
+    throws PatternSyntaxException
+  {
+    this.regex = regex;
+    this.flags = flags;
+
+    int gnuFlags = 0;
+    if ((flags & CASE_INSENSITIVE) != 0)
+      gnuFlags |= RE.REG_ICASE;
+    if ((flags & MULTILINE) != 0)
+      gnuFlags |= RE.REG_MULTILINE;
+    if ((flags & DOTALL) != 0)
+      gnuFlags |= RE.REG_DOT_NEWLINE;
+    // not yet supported:
+    // if ((flags & UNICODE_CASE) != 0) gnuFlags =
+    // if ((flags & CANON_EQ) != 0) gnuFlags =
+
+    // Eventually there will be such a thing as JDK 1_4 syntax
+    RESyntax syntax = RESyntax.RE_SYNTAX_PERL5;
+    if ((flags & UNIX_LINES) != 0)
+      {
+	// Use a syntax set with \n for linefeeds?
+	syntax = new RESyntax(syntax);
+	syntax.setLineSeparator("\n");
+      }
+
+    if ((flags & COMMENTS) != 0)
+      {
+	// Use a syntax with support for comments?
+      }
+
+    try
+      {
+	this.re = new RE(regex, gnuFlags, syntax);
+      }
+    catch (REException e)
+      {
+	throw new PatternSyntaxException(e.getMessage(),
+					 regex, e.getPosition());
+      }
+  }
+ 
+  // package private accessor method
+  RE getRE()
+  {
+    return re;
+  }
+
+  /**
+   * @param regex The regular expression
+   *
+   * @exception PatternSyntaxException If the expression's syntax is invalid
+   */
+  public static Pattern compile (String regex)
+    throws PatternSyntaxException
+  {
+    return compile(regex, 0);
+  }
+  
+  /**
+   * @param regex The regular expression
+   * @param flags The match flags, a bit mask
+   *
+   * @exception PatternSyntaxException If the expression's syntax is invalid
+   * @exception IllegalArgumentException If bit values other than those
+   * corresponding to the defined match flags are set in flags
+   */
+  public static Pattern compile (String regex, int flags)
+    throws PatternSyntaxException
+  {
+    // FIXME: check which flags are really accepted
+    if ((flags & ~0xEF) != 0)
+      throw new IllegalArgumentException ();
     
-    private RE re;
-    RE getRE() { return re; }
-
-    private Pattern(String pattern, int flags) throws PatternSyntaxException {
-	this.pattern = pattern;
-	this.flags = flags;
-
-	int gnuFlags = 0;
-	if ((flags & CASE_INSENSITIVE) != 0) gnuFlags |= RE.REG_ICASE;
-	if ((flags & MULTILINE) != 0) gnuFlags |= RE.REG_MULTILINE;
-	if ((flags & DOTALL) != 0) gnuFlags |= RE.REG_DOT_NEWLINE;
-	// not yet supported:
-	// if ((flags & UNICODE_CASE) != 0) gnuFlags =
-	// if ((flags & CANON_EQ) != 0) gnuFlags =
-
-	// Eventually there will be such a thing as JDK 1_4 syntax
-	RESyntax syntax = RESyntax.RE_SYNTAX_PERL5;
-	if ((flags & UNIX_LINES) != 0) {
-	    // Use a syntax set with \n for linefeeds?
-	    syntax = new RESyntax(syntax);
-	    syntax.setLineSeparator("\n");
-	}
-
-	if ((flags & COMMENTS) != 0) {
-	    // Use a syntax with support for comments?
-	}
-
-	try {
-	    this.re = new RE(pattern, gnuFlags, syntax);
-	} catch (REException e) {
-	    throw new PatternSyntaxException(e.getMessage(),
-					     pattern, e.getPosition());
-	}
-    }
+    return new Pattern (regex, flags); 
+  }
+  
+  public int flags ()
+  {
+    return this.flags;
+  }
+  
+  /**
+   * @param regex The regular expression
+   * @param input The character sequence to be matched
+   *
+   * @exception PatternSyntaxException If the expression's syntax is invalid
+   */
+  public static boolean matches (String regex, CharSequence input) 
+  {
+    return compile(regex).matcher(input).matches();
+  }
+  
+  /**
+   * @param input The character sequence to be matched
+   */
+  public Matcher matcher (CharSequence input)
+  {
+    return new Matcher(this, input);
+  }
+  
+  /**
+   * @param input The character sequence to be matched
+   */
+  public String[] split (CharSequence input)
+  {
+    return split(input, 0);
+  }
+  
+  /**
+   * @param input The character sequence to be matched
+   * @param limit The result threshold
+   */
+  public String[] split (CharSequence input, int limit)
+  {
+    Matcher matcher = new Matcher(this, input);
+    ArrayList list = new ArrayList();
+    int empties = 0;
+    int count = 0;
+    int start = 0;
+    int end;
+    boolean matched;
+
+    while (matched = matcher.find() && (limit <= 0 || count < limit - 1))
+      {
+	++count;
+	end = matcher.start();
+	if (start == end)
+	  empties++;
+	else
+	  {
+	    while (empties-- > 0)
+	      list.add("");
+
+	    String text = input.subSequence(start, end).toString();
+	    list.add(text);
+	  }
+	start = matcher.end();
+      }
+
+    // We matched nothing.
+    if (!matched && count == 0)
+      return new String[] { input.toString() };
     
-    public static Pattern compile(String regex) throws PatternSyntaxException {
-	return compile(regex, 0);
-    }
-
-    public static Pattern compile(String regex, int flags) throws PatternSyntaxException {
-	return new Pattern(regex, flags);
-    }
-
-    public static boolean matches(String regex, CharSequence input) throws PatternSyntaxException {
-	return compile(regex).matcher(input).matches();
-    }
-
-    public String pattern() {
-	return pattern;
-    }
-
-    public int flags() {
-	return flags;
-    }
-
-    public Matcher matcher(CharSequence input) {
-	return new Matcher(this, input);
-    }
-
-    public String[] split(CharSequence input) {
-	return split(input, 0);
-    }
-
-    private static final String[] modelArray = new String [0];
-
-    public String[] split(CharSequence input, int limit) {
-	Matcher matcher = new Matcher(this, input);
-	ArrayList list = new ArrayList();
-	int empties = 0;
-	int count = 0;
-	int start = 0;
-	int end;
-	boolean matched;
-	while (matched = matcher.find() && (limit <= 0 || count < limit - 1)) {
-	    ++count;
-	    end = matcher.start();
-	    if (start == end) {
-		empties++;
-	    } else {
-		while (empties-- > 0) {
-		    list.add("");
-		}
-		String text = input.subSequence(start, end).toString();
-		list.add(text);
-	    }
-	    start = matcher.end();
-	}
-
-	// We matched nothing.
-	if (!matched && count == 0) {
-		return new String[] { input.toString() };
-	}
-
-	// Is the last token empty?
-	boolean emptyLast = (start == input.length());
-
-	// Can/Must we add empties or an extra last token at the end?
-	if (list.size() < limit || limit < 0 || (limit == 0 && !emptyLast)) {
-	    if (limit > list.size()) {
-		int max = limit - list.size();
-		empties = (empties > max) ? max : empties;
-	    }
-	    while (empties-- > 0) {
-		list.add("");
-	    }
-	}
-
-	// last token at end
-	if (limit != 0 || (limit == 0 && !emptyLast)) {
-	    String t = input.subSequence(start, input.length()).toString();
-	    if ("".equals(t) && limit == 0) {
-		// Don't add.
-	    } else {
-		list.add(t);
-	    }
-	}
-
-	String[] output = new String [list.size()];
-	list.toArray(output);
-	return output;
-    }
+    // Is the last token empty?
+    boolean emptyLast = (start == input.length());
+
+    // Can/Must we add empties or an extra last token at the end?
+    if (list.size() < limit || limit < 0 || (limit == 0 && !emptyLast))
+      {
+	if (limit > list.size())
+	  {
+	    int max = limit - list.size();
+	    empties = (empties > max) ? max : empties;
+	  }
+	while (empties-- > 0)
+	  list.add("");
+      }
+
+    // last token at end
+    if (limit != 0 || (limit == 0 && !emptyLast))
+      {
+	String t = input.subSequence(start, input.length()).toString();
+	if ("".equals(t) && limit == 0)
+	  ; // Don't add.
+	else
+	  list.add(t);
+      }
+
+    String[] output = new String [list.size()];
+    list.toArray(output);
+    return output;
+  }
+  
+  public String pattern ()
+  {
+    return regex;
+  }
 }
Index: kaffe/libraries/javalib/java/util/regex/PatternSyntaxException.java
diff -u kaffe/libraries/javalib/java/util/regex/PatternSyntaxException.java:1.2 kaffe/libraries/javalib/java/util/regex/PatternSyntaxException.java:1.3
--- kaffe/libraries/javalib/java/util/regex/PatternSyntaxException.java:1.2	Mon Oct 13 03:10:04 2003
+++ kaffe/libraries/javalib/java/util/regex/PatternSyntaxException.java	Wed Mar 17 20:23:08 2004
@@ -1,29 +1,132 @@
+/* PatternSyntaxException - Indicates illegal pattern for regular expression.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
 package java.util.regex;
 
-public class PatternSyntaxException extends IllegalArgumentException {
-    protected String description;
-    protected String pattern;
-    protected int index;
-
-    public PatternSyntaxException(String description, String pattern, int index) {
-	this.description = description;
-	this.pattern = pattern;
-	this.index = index;
-    }
-
-    public String getDescription() {
-	return description;
-    }
-
-    public String getPattern() {
-	return pattern;
-    }
-
-    public int getIndex() {
-	return index;
-    }
-
-    public String getMessage() {
-	return description; // XXX
-    }
+/**
+ * Indicates illegal pattern for regular expression.
+ * Includes state to inspect the pattern and what and where the expression
+ * was not valid regular expression.
+ */
+public class PatternSyntaxException extends IllegalArgumentException
+{
+  private static final long serialVersionUID = -3864639126226059218L;
+
+  /**
+   * Human readable escription of the syntax error.
+   */
+  private final String desc;
+
+  /**
+   * The original pattern that contained the syntax error.
+   */
+  private final String pattern;
+  
+  /**
+   * Index of the first character in the String that was probably invalid,
+   * or -1 when unknown.
+   */
+  private final int index;
+
+  /**
+   * Creates a new PatternSyntaxException.
+   *
+   * @param description Human readable escription of the syntax error.
+   * @param pattern The original pattern that contained the syntax error.
+   * @param index Index of the first character in the String that was
+   *        probably invalid, or -1 when unknown.
+   */
+  public PatternSyntaxException(String description,
+		                String pattern,
+				int index)
+  {
+    super(description);
+    this.desc = description;
+    this.pattern = pattern;
+    this.index = index;
+  }
+
+  /**
+   * Returns a human readable escription of the syntax error.
+   */
+  public String getDescription()
+  {
+    return desc;
+  }
+
+  /**
+   * Returns the original pattern that contained the syntax error.
+   */
+  public String getPattern()
+  {
+    return pattern;
+  }
+
+  /**
+   * Returns the index of the first character in the String that was probably
+   * invalid, or -1 when unknown.
+   */
+  public int getIndex()
+  {
+    return index;
+  }
+
+  /**

*** Patch too long, truncated ***




More information about the kaffe mailing list