diff options
author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2008-02-21 12:55:11 +0000 |
---|---|---|
committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2008-02-21 12:55:11 +0000 |
commit | 1821fe846af2d215082094bed4be60b187d3bbb7 (patch) | |
tree | 241404f9a8c6bc8787a95b7cb1c5e1f6f258e0de | |
parent | 5ee1d4c0605785a702583765c4ea4afc064fdd93 (diff) | |
download | classpath-1821fe846af2d215082094bed4be60b187d3bbb7.tar.gz |
2008-02-21 Andrew John Hughes <gnu_andrew@member.fsf.org>
* gnu/java/util/regex/REException.java:
(REException(String,Throwable,int,int)): Added
constructor which also includes the cause.
* gnu/java/util/regex/RETokenNamedProperty.java:
(getHandler(String)): Add support for \p{javaX}.
(JavaCategoryHandler): New class.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | gnu/java/util/regex/REException.java | 6 | ||||
-rw-r--r-- | gnu/java/util/regex/RETokenNamedProperty.java | 50 |
3 files changed, 65 insertions, 0 deletions
@@ -1,5 +1,14 @@ 2008-02-21 Andrew John Hughes <gnu_andrew@member.fsf.org> + * gnu/java/util/regex/REException.java: + (REException(String,Throwable,int,int)): Added + constructor which also includes the cause. + * gnu/java/util/regex/RETokenNamedProperty.java: + (getHandler(String)): Add support for \p{javaX}. + (JavaCategoryHandler): New class. + +2008-02-21 Andrew John Hughes <gnu_andrew@member.fsf.org> + PR classpath/35274: * m4/acinclude.m4: Increase maximum heap size to 768mb. diff --git a/gnu/java/util/regex/REException.java b/gnu/java/util/regex/REException.java index 4104fbcd8..7a277ca3a 100644 --- a/gnu/java/util/regex/REException.java +++ b/gnu/java/util/regex/REException.java @@ -147,6 +147,12 @@ public class REException extends Exception { this.pos = position; } + REException(String msg, Throwable cause, int type, int position) { + super(msg, cause); + this.type = type; + this.pos = position; + } + /** * Returns the type of the exception, one of the constants listed above. */ diff --git a/gnu/java/util/regex/RETokenNamedProperty.java b/gnu/java/util/regex/RETokenNamedProperty.java index aec27583a..0051f1643 100644 --- a/gnu/java/util/regex/RETokenNamedProperty.java +++ b/gnu/java/util/regex/RETokenNamedProperty.java @@ -38,6 +38,9 @@ exception statement from your version. */ package gnu.java.util.regex; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + final class RETokenNamedProperty extends REToken { String name; boolean insens; @@ -268,6 +271,20 @@ final class RETokenNamedProperty extends REToken { return true; } }; + if (name.startsWith("java")) + { + try + { + Method m = Character.class.getMethod("is" + name.substring(4), + Character.TYPE); + return new JavaCategoryHandler(m); + } + catch (NoSuchMethodException e) + { + throw new REException("Unsupported Java handler: " + name, e, + REException.REG_ESCAPE, 0); + } + } throw new REException("unsupported name " + name, REException.REG_ESCAPE, 0); } @@ -320,4 +337,37 @@ final class RETokenNamedProperty extends REToken { } } + /** + * Handle the Java-specific extensions \p{javaX} where X + * is a method from Character of the form isX + * + * @author Andrew John Hughes (gnu_andrew@member.fsf.org) + */ + private static class JavaCategoryHandler + extends Handler + { + private Method method; + + public JavaCategoryHandler(Method m) + { + this.method = m; + } + + public boolean includes(char c) + { + try + { + return (Boolean) method.invoke(null, c); + } + catch (IllegalAccessException e) + { + throw new InternalError("Unable to access method " + method); + } + catch (InvocationTargetException e) + { + throw new InternalError("Error invoking " + method); + } + } + } + } |