classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

java.text.MessageFormat parsing


From: Tom Dunstan
Subject: java.text.MessageFormat parsing
Date: Sat, 4 Jun 2005 01:01:31 +0930

Hi folks

Before I begin, major kudos to all involved in the free java world,
it's been wonderful to see it come so far!

I have some code which depends on certain behaviour of the
java.text.MessageFormat class when parsing strings (using the
parse(String) method). Basically if I'm trying to match a pattern
"/foo/{0}" with the string "/foo/bar", then I expect to get back "bar"
as parameter zero. This works with the Sun MessageFormat class (tested
with 1.4.2 and 1.5). Classpath, however, returns an empty string. I
would hazard a guess that Classpath is settling for the first String
that matches rather than the largest one that does so, but I'm no
expert in parsing theory so I'll let someone else do a proper
diagnosis.
 
Below is a mauve patch exhibiting the problem which succeeds for the
Sun JDKs but fails for gcj/gij/jamvm with classpath. I've just done a
cvs diff -u on the file that I modified; is there a preferred
way/place to post such things?

Cheers

Tom



Index: gnu/testlet/java/text/MessageFormat/parse.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/text/MessageFormat/parse.java,v
retrieving revision 1.1
diff -u -r1.1 parse.java
--- gnu/testlet/java/text/MessageFormat/parse.java      12 Mar 1999
11:50:43 -0000      1.1
+++ gnu/testlet/java/text/MessageFormat/parse.java      3 Jun 2005
15:08:36 -0000
@@ -72,5 +72,16 @@
       harness.check (val.length, 1);
       harness.check (val[0] instanceof Number);
       harness.check (((Number) (val[0])).longValue (), 23);
+
+      harness.checkPoint ("greedy string matching at end");
+      mf.applyPattern ("/foo/{0}");
+
+      pp.setIndex(0);
+      val = mf.parse ("/foo/bar", pp);
+      harness.check (val.length, 1);
+      harness.check (val[0] instanceof String);
+      harness.check (val[0], "bar");
+
+
     }
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]