You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Henri Yandell <fl...@gmail.com> on 2006/08/01 08:30:12 UTC
Re: [lang] VariableFormatter - pre 2.2
On 7/23/06, Stephen Colebourne <sc...@btopenworld.com> wrote:
> I have reworked the VariableFormatter class along the lines that I was thinking. I have committed it as StrSubstitutor so it doesn't clash for the moment and so it can be easiy reviewed.
>
> This version does not have a separate parser class, but still supports escaping, and matchers for prefix/suffix (which can now be set by users). The new class should perform better as a result.
>
> I have removed the edge cases wrt resolving Objects, as they were rather ill-defined.
>
> Otherwise, the basic functionality it supported, and the test case is slightly enlarged. I still want to break out the resolver as a public abstract class before release.
>
> Opinions
Oliver, Gary, Tom?
Looking to get Lang 2.2 moving out the door and this is the only blocker.
Hen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] ExceptionUtilsTestCase should not depend on Java 1.4.x
Posted by Henri Yandell <fl...@gmail.com>.
Just got to get a working 1.3 so I can confirm :) Pretty sad when the
Sun 1.3 Linux dist fails to work due to glibc incompatibility of some
kind.
Hen
On 8/7/06, Gary Gregory <gg...@seagullsoftware.com> wrote:
> Hi All:
>
> When I have the compiler set to Java 1.3.1, I get:
>
> Severity and Description Path Resource Location
> Creation Time Id
> The method getCause() is undefined for the type Throwable Apache
> Jakarta Commons
> trunks-proper/lang/src/test/org/apache/commons/lang/exception
> ExceptionUtilsTestCase.java line 135 1153767000812 14290961
> The method getCause() is undefined for the type Throwable Apache
> Jakarta Commons
> trunks-proper/lang/src/test/org/apache/commons/lang/exception
> ExceptionUtilsTestCase.java line 136 1153767000812 14290965
> The method getCause() is undefined for the type Throwable Apache
> Jakarta Commons
> trunks-proper/lang/src/test/org/apache/commons/lang/exception
> ExceptionUtilsTestCase.java line 169 1153767000812 14290993
> The method getCause() is undefined for the type Throwable Apache
> Jakarta Commons
> trunks-proper/lang/src/test/org/apache/commons/lang/exception
> ExceptionUtilsTestCase.java line 269 1153767000812 14291025
> The method getCause() is undefined for the type Throwable Apache
> Jakarta Commons
> trunks-proper/lang/src/test/org/apache/commons/lang/exception
> ExceptionUtilsTestCase.java line 316 1153767000812 14291026
>
> Gary
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[lang] ExceptionUtilsTestCase should not depend on Java 1.4.x
Posted by Gary Gregory <gg...@seagullsoftware.com>.
Hi All:
When I have the compiler set to Java 1.3.1, I get:
Severity and Description Path Resource Location
Creation Time Id
The method getCause() is undefined for the type Throwable Apache
Jakarta Commons
trunks-proper/lang/src/test/org/apache/commons/lang/exception
ExceptionUtilsTestCase.java line 135 1153767000812 14290961
The method getCause() is undefined for the type Throwable Apache
Jakarta Commons
trunks-proper/lang/src/test/org/apache/commons/lang/exception
ExceptionUtilsTestCase.java line 136 1153767000812 14290965
The method getCause() is undefined for the type Throwable Apache
Jakarta Commons
trunks-proper/lang/src/test/org/apache/commons/lang/exception
ExceptionUtilsTestCase.java line 169 1153767000812 14290993
The method getCause() is undefined for the type Throwable Apache
Jakarta Commons
trunks-proper/lang/src/test/org/apache/commons/lang/exception
ExceptionUtilsTestCase.java line 269 1153767000812 14291025
The method getCause() is undefined for the type Throwable Apache
Jakarta Commons
trunks-proper/lang/src/test/org/apache/commons/lang/exception
ExceptionUtilsTestCase.java line 316 1153767000812 14291026
Gary
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] VariableFormatter - pre 2.2
Posted by Stephen Colebourne <sc...@btopenworld.com>.
Henri Yandell wrote:
> On 8/2/06, Gary Gregory <gg...@seagullsoftware.com> wrote:
> I think in some places it was to avoid clash with JDK 1.5.
> StringBuilder I presume being the one.
(I sent a mail earlier, but its not arrived)
But yes, this is the key point. StrBuilder is a pre JDK5 version of
StringBuilder - except that it has many many more features :-)
Hence the rest of the classes are named in sympathy.
Stephen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] VariableFormatter - pre 2.2
Posted by Henri Yandell <fl...@gmail.com>.
On 8/2/06, Gary Gregory <gg...@seagullsoftware.com> wrote:
> Hello All:
>
> I think the argument for the name change I am hearing is: we are not
> formatting a la printf but we are replacing markers with values (and not
> formatting those values). Is that right? If that is the case, a
> "Substitutor" name is better.
>
> As a general rule, I do not like or use abbreviations in class or method
> names (acronyms are OK by me). So I would say that StringSubstitutor is
> better. After all, we have "StringUtils", "StringEscapeUtils" and many
> others, not "StrUtils", "StrEscapeUtils". So I would ask that we use
> "StringFoo" for all of these classes.
I think in some places it was to avoid clash with JDK 1.5.
StringBuilder I presume being the one.
Hen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] 2.2?
Posted by Antonio Gallardo <ag...@agssa.net>.
Henri Yandell escribió:
> Wish I could get JDK 1.3 to work on a Linux box. Both my Debian Sarge
> (hardly a new distro) and Ubuntu laptop have glibc errors. Must grab
> the IBM version and see how it goes.
Hi Henri,
I had similar problems in Fedora, I needed to install a "compat-glibc*"
packages in order to runJDK 1.3.
Best Regards,
Antonio Gallardo.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] 2.2?
Posted by Henri Yandell <fl...@gmail.com>.
On 8/21/06, Henri Yandell <fl...@gmail.com> wrote:
> On 8/21/06, Henri Yandell <fl...@gmail.com> wrote:
> > On 8/16/06, Henri Yandell <fl...@gmail.com> wrote:
> > > On 8/16/06, Gary Gregory <gg...@seagullsoftware.com> wrote:
> > > > FWIW, here are some test results for test.time I have:
> > > >
> > > > Compiled with Sun Java 1.4.2_12:
> > > >
> > > > - test.time has 1 failure with Sun Java 1.3.1_15
> > > > - test.time passes with Sun Java 1.4.2_12
> > > > - test.time passes with Sun Java 1.5.0_08
> > > >
> > > > Doing the same above with the code compiled with Sun Java 1.3.1_15 yield
> > > > the same results. This is all on Windows XP SP2 and Ant 1.6.5.
> > >
> > > Wish I could get JDK 1.3 to work on a Linux box. Both my Debian Sarge
> > > (hardly a new distro) and Ubuntu laptop have glibc errors. Must grab
> > > the IBM version and see how it goes.
> >
> > Grabbed the IBM SDK for 1.3 ....
>
> Compiling under 1.4.x and 1.5 and then running ant test gives:
>
> test.builder:
> [junit] Running org.apache.commons.lang.builder.BuilderTestSuite
> [junit] Tests run: 261, Failures: 8, Errors: 0, Time elapsed: 0.131 sec
> [junit] Test org.apache.commons.lang.builder.BuilderTestSuite FAI
>
> test.time:
> [junit] Running org.apache.commons.lang.time.TimeTestSuite
> [junit] Some date rounding tests not run since the current version is 1.3.1
> [junit] Tests run: 55, Failures: 10, Errors: 0, Time elapsed: 5.255 sec
> [junit] Test org.apache.commons.lang.time.TimeTestSuite FAILED
Running 'ant test' under the 1.3 IBM JVM (missed that important snippet).
Hen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] 2.2?
Posted by Henri Yandell <fl...@gmail.com>.
On 8/21/06, Henri Yandell <fl...@gmail.com> wrote:
> On 8/21/06, Henri Yandell <fl...@gmail.com> wrote:
> > On 8/16/06, Henri Yandell <fl...@gmail.com> wrote:
> > > On 8/16/06, Gary Gregory <gg...@seagullsoftware.com> wrote:
> > > > FWIW, here are some test results for test.time I have:
> > > >
> > > > Compiled with Sun Java 1.4.2_12:
> > > >
> > > > - test.time has 1 failure with Sun Java 1.3.1_15
> > > > - test.time passes with Sun Java 1.4.2_12
> > > > - test.time passes with Sun Java 1.5.0_08
> > > >
> > > > Doing the same above with the code compiled with Sun Java 1.3.1_15 yield
> > > > the same results. This is all on Windows XP SP2 and Ant 1.6.5.
> > >
> > > Wish I could get JDK 1.3 to work on a Linux box. Both my Debian Sarge
> > > (hardly a new distro) and Ubuntu laptop have glibc errors. Must grab
> > > the IBM version and see how it goes.
> >
> > Grabbed the IBM SDK for 1.3 ....
>
> Compiling under 1.4.x and 1.5 and then running ant test gives:
>
> test.builder:
> [junit] Running org.apache.commons.lang.builder.BuilderTestSuite
> [junit] Tests run: 261, Failures: 8, Errors: 0, Time elapsed: 0.131 sec
> [junit] Test org.apache.commons.lang.builder.BuilderTestSuite FAI
>
> test.time:
> [junit] Running org.apache.commons.lang.time.TimeTestSuite
> [junit] Some date rounding tests not run since the current version is 1.3.1
> [junit] Tests run: 55, Failures: 10, Errors: 0, Time elapsed: 5.255 sec
> [junit] Test org.apache.commons.lang.time.TimeTestSuite FAILED
Digging into these 1.3 runtime bugs:
One of the time ones is the one you reported Gary. It's to do with
http://issues.apache.org/jira/browse/LANG-59 and is linked to what we
think is a bug within the JDK (really ought to try that out with Java
6 and see if it's still there). Looks like things were worse in the
1.3 JVM.
The other failures within the time package are a timezone problem in
the DateUtilsTest assertDate method. I'm 7 hours off of GMT, so the
values are 7 hours off. Probably not a problem when running under GMT.
The IBM date code is probably the same as the Sun code.
The Builder package errors are linked to two types of error. A bunch
of HashCodeBuilder errors in which the hashcode created is not the
same as we expect; and the second set are to do with ToStringBuilder
returning object attributes in a different order than expected. Both
are explained if the reflection libraries are returning things in a
different order than the Sun libraries.
So a whole bunch of bugs, but I don't see much we can do about any of
them. Maybe we could add alphabetical sorting to the attribute names
for the builder classes if that turns out to be the case. Not sure we
care if hashcodes and toStrings are different between JVMs.
Hen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] 2.2?
Posted by Henri Yandell <fl...@gmail.com>.
On 8/21/06, Henri Yandell <fl...@gmail.com> wrote:
> On 8/16/06, Henri Yandell <fl...@gmail.com> wrote:
> > On 8/16/06, Gary Gregory <gg...@seagullsoftware.com> wrote:
> > > FWIW, here are some test results for test.time I have:
> > >
> > > Compiled with Sun Java 1.4.2_12:
> > >
> > > - test.time has 1 failure with Sun Java 1.3.1_15
> > > - test.time passes with Sun Java 1.4.2_12
> > > - test.time passes with Sun Java 1.5.0_08
> > >
> > > Doing the same above with the code compiled with Sun Java 1.3.1_15 yield
> > > the same results. This is all on Windows XP SP2 and Ant 1.6.5.
> >
> > Wish I could get JDK 1.3 to work on a Linux box. Both my Debian Sarge
> > (hardly a new distro) and Ubuntu laptop have glibc errors. Must grab
> > the IBM version and see how it goes.
>
> Grabbed the IBM SDK for 1.3 ....
Compiling under 1.4.x and 1.5 and then running ant test gives:
test.builder:
[junit] Running org.apache.commons.lang.builder.BuilderTestSuite
[junit] Tests run: 261, Failures: 8, Errors: 0, Time elapsed: 0.131 sec
[junit] Test org.apache.commons.lang.builder.BuilderTestSuite FAI
test.time:
[junit] Running org.apache.commons.lang.time.TimeTestSuite
[junit] Some date rounding tests not run since the current version is 1.3.1
[junit] Tests run: 55, Failures: 10, Errors: 0, Time elapsed: 5.255 sec
[junit] Test org.apache.commons.lang.time.TimeTestSuite FAILED
Much fun.
Hen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] 2.2?
Posted by Henri Yandell <fl...@gmail.com>.
On 8/16/06, Henri Yandell <fl...@gmail.com> wrote:
> On 8/16/06, Gary Gregory <gg...@seagullsoftware.com> wrote:
> > FWIW, here are some test results for test.time I have:
> >
> > Compiled with Sun Java 1.4.2_12:
> >
> > - test.time has 1 failure with Sun Java 1.3.1_15
> > - test.time passes with Sun Java 1.4.2_12
> > - test.time passes with Sun Java 1.5.0_08
> >
> > Doing the same above with the code compiled with Sun Java 1.3.1_15 yield
> > the same results. This is all on Windows XP SP2 and Ant 1.6.5.
>
> Wish I could get JDK 1.3 to work on a Linux box. Both my Debian Sarge
> (hardly a new distro) and Ubuntu laptop have glibc errors. Must grab
> the IBM version and see how it goes.
Grabbed the IBM SDK for 1.3 and when running Ant I get compile time
errors. Lovely:
[javac] error: The encoding null is not supported
[javac] /home/hen/apache/jakarta-commons-proper/lang/src/java/org/apache/commons/lang/StringEscapeUtils.java:494:
cannot resolve symbol
[javac] symbol : variable HTML40
[javac] location: class org.apache.commons.lang.Entities
[javac] Entities.HTML40.escape(writer, string);
(and a bunch more of the same type of error within Entities).
Hen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] 2.2?
Posted by Henri Yandell <fl...@gmail.com>.
On 8/16/06, Henri Yandell <fl...@gmail.com> wrote:
> Wish I could get JDK 1.3 to work on a Linux box. Both my Debian Sarge
> (hardly a new distro) and Ubuntu laptop have glibc errors. Must grab
> the IBM version and see how it goes.
Surprised I've not noticed this before. Been on OS X for too long I guess:
http://sources.redhat.com/ml/libc-alpha/2002-04/msg00143.html
Sun's JDK 1.2 and JDK 1.3 on modern glibc's won't be working. OS X
doesn't ship with 1.2. So I guess I need to switch to Windows if I'm
going to make a stab at building Lang under 1.2.
Hen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
RE: [lang] 2.2?
Posted by Gary Gregory <gg...@seagullsoftware.com>.
Henri:
Here the failure:
junit.framework.ComparisonFailure: Check 00:00:00.000
expected:<...0:00:00.000 MD...> but was:<...6:00:00.000 GM...>
at junit.framework.Assert.assertEquals(Assert.java:81)
at
org.apache.commons.lang.time.DateUtilsTest.testTruncateLang59(DateUtilsT
est.java:905)
at java.lang.reflect.Method.invoke(Native Method)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUn
it3TestReference.java:128)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.ja
va:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
ner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
nner.java:196)
> -----Original Message-----
> From: Henri Yandell [mailto:flamefew@gmail.com]
> Sent: Wednesday, August 16, 2006 8:43 PM
> To: Jakarta Commons Developers List
> Subject: Re: [lang] 2.2?
>
> On 8/16/06, Gary Gregory <gg...@seagullsoftware.com> wrote:
> > FWIW, here are some test results for test.time I have:
> >
> > Compiled with Sun Java 1.4.2_12:
> >
> > - test.time has 1 failure with Sun Java 1.3.1_15
> > - test.time passes with Sun Java 1.4.2_12
> > - test.time passes with Sun Java 1.5.0_08
> >
> > Doing the same above with the code compiled with Sun Java 1.3.1_15
yield
> > the same results. This is all on Windows XP SP2 and Ant 1.6.5.
>
> Wish I could get JDK 1.3 to work on a Linux box. Both my Debian Sarge
> (hardly a new distro) and Ubuntu laptop have glibc errors. Must grab
> the IBM version and see how it goes.
>
> Which one is the test.time failure?
>
> Hen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] 2.2?
Posted by Henri Yandell <fl...@gmail.com>.
On 8/16/06, Gary Gregory <gg...@seagullsoftware.com> wrote:
> FWIW, here are some test results for test.time I have:
>
> Compiled with Sun Java 1.4.2_12:
>
> - test.time has 1 failure with Sun Java 1.3.1_15
> - test.time passes with Sun Java 1.4.2_12
> - test.time passes with Sun Java 1.5.0_08
>
> Doing the same above with the code compiled with Sun Java 1.3.1_15 yield
> the same results. This is all on Windows XP SP2 and Ant 1.6.5.
Wish I could get JDK 1.3 to work on a Linux box. Both my Debian Sarge
(hardly a new distro) and Ubuntu laptop have glibc errors. Must grab
the IBM version and see how it goes.
Which one is the test.time failure?
Hen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] 2.2?
Posted by Stephen Colebourne <sc...@btopenworld.com>.
Henri Yandell wrote:
> If the VariableFormatter stuff is happily resolved (at least the 2.2
> aspects of it), then the only issue I know of is the recent failed
> nightly build of Lang. It implies we have a bugfix that is still
> failing on some time-based yet random-appearing event.
>
> I hadn't pushed on Lang 2.2 in the last couple of weeks due to being a
> bit tied up; things are lighter again now though and unless anyone
> wants to jump in I'll get things in motion.
I was starting to look at the Enum issues, so I'm generally done with
the mandatory 2.2 issues.
Stephen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
RE: [lang] 2.2?
Posted by Gary Gregory <gg...@seagullsoftware.com>.
FWIW, here are some test results for test.time I have:
Compiled with Sun Java 1.4.2_12:
- test.time has 1 failure with Sun Java 1.3.1_15
- test.time passes with Sun Java 1.4.2_12
- test.time passes with Sun Java 1.5.0_08
Doing the same above with the code compiled with Sun Java 1.3.1_15 yield
the same results. This is all on Windows XP SP2 and Ant 1.6.5.
Gary
> -----Original Message-----
> From: Henri Yandell [mailto:flamefew@gmail.com]
> Sent: Wednesday, August 16, 2006 12:17 PM
> To: Jakarta Commons Developers List
> Subject: Re: [lang] 2.2?
>
> If the VariableFormatter stuff is happily resolved (at least the 2.2
> aspects of it), then the only issue I know of is the recent failed
> nightly build of Lang. It implies we have a bugfix that is still
> failing on some time-based yet random-appearing event.
>
> I hadn't pushed on Lang 2.2 in the last couple of weeks due to being a
> bit tied up; things are lighter again now though and unless anyone
> wants to jump in I'll get things in motion.
>
> Hen
>
> On 8/16/06, Gary Gregory <gg...@seagullsoftware.com> wrote:
> > Hi All:
> >
> > How close are we to an Alpha/Beta for 2.2?
> >
> > Gary
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] 2.2?
Posted by Henri Yandell <fl...@gmail.com>.
If the VariableFormatter stuff is happily resolved (at least the 2.2
aspects of it), then the only issue I know of is the recent failed
nightly build of Lang. It implies we have a bugfix that is still
failing on some time-based yet random-appearing event.
I hadn't pushed on Lang 2.2 in the last couple of weeks due to being a
bit tied up; things are lighter again now though and unless anyone
wants to jump in I'll get things in motion.
Hen
On 8/16/06, Gary Gregory <gg...@seagullsoftware.com> wrote:
> Hi All:
>
> How close are we to an Alpha/Beta for 2.2?
>
> Gary
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] 2.2?
Posted by Henri Yandell <fl...@gmail.com>.
I still need to GPG things (keys at home):
http://people.apache.org/~bayard/commons-lang/
Once I get the GPG I'll announce an rc1, but feel free to complain.
Hen
On 9/19/06, Stephen Colebourne <sc...@btopenworld.com> wrote:
> ----- Original Message ----
> From: Henri Yandell <fl...@gmail.com>
> > I'll probably build the jar/dist etc under
> > 1.3 rather than 1.2 for the first RC, so there will be a known
> > issue of 'build needs to be under 1.2' still to resolve.
>
> Despite my previous protestations, I believe that releasing using 1.3 is acceptable. The troublesome StringBuffer.append(StringBuffer) method was added in JDK1.4, and I've never heard of any similar JDK level issues between 1.2 and 1.3. 1.2 is also almost impossible to get running on most systems these days.
>
> For Joda-Time I use the phrase "We now recommend JDK 1.3 or later, and have performed no testing on earlier JDKs." That would cover us.
>
> Stephen
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] 2.2?
Posted by Stephen Colebourne <sc...@btopenworld.com>.
----- Original Message ----
From: Henri Yandell <fl...@gmail.com>
> I'll probably build the jar/dist etc under
> 1.3 rather than 1.2 for the first RC, so there will be a known
> issue of 'build needs to be under 1.2' still to resolve.
Despite my previous protestations, I believe that releasing using 1.3 is acceptable. The troublesome StringBuffer.append(StringBuffer) method was added in JDK1.4, and I've never heard of any similar JDK level issues between 1.2 and 1.3. 1.2 is also almost impossible to get running on most systems these days.
For Joda-Time I use the phrase "We now recommend JDK 1.3 or later, and have performed no testing on earlier JDKs." That would cover us.
Stephen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] 2.2?
Posted by Henri Yandell <fl...@gmail.com>.
On 8/16/06, Gary Gregory <gg...@seagullsoftware.com> wrote:
> Hi All:
>
> How close are we to an Alpha/Beta for 2.2?
Replying to this again - I think it's pretty close.
I just added an 'at least 1.4' check to the failing 1.3 test (we
already have a bunch of these for similar types of tests in
DateUtilsTest). The site is pretty close to the minimal requirements
for a release, though always more that could be done.
So next up I need to run through the release process and build an RC.
Tempted to do so tomorrow. I'll probably build the jar/dist etc under
1.3 rather than 1.2 for the first RC, so there will be a known issue
of 'build needs to be under 1.2' still to resolve.
Hen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] EnumUtils new method?
Posted by Stephen Colebourne <sc...@btopenworld.com>.
Gary Gregory wrote:
> In EnumUtils we have:
> public static Enum getEnum(Class enumClass, String name)
> What I need to ask a List of Enum classes for an Enum:
> public static Enum getEnum(List enumClassList, String name)
> Is this too odd a case? Should I keep my utility method in my own code?
Sounds pretty odd to me. Each enum is intended to be a separate isolated
unit, which share code because we're pre JDK1.5. It wasn't intended that
there would be what amounts to groups of enum classes.
Stephen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[lang] EnumUtils new method?
Posted by Gary Gregory <gg...@seagullsoftware.com>.
Hello:
In EnumUtils we have:
public static Enum getEnum(Class enumClass, String name)
What I need to ask a List of Enum classes for an Enum:
public static Enum getEnum(List enumClassList, String name)
Is this too odd a case? Should I keep my utility method in my own code?
Your thoughts please...
Thank you,
Gary
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[lang] 2.2?
Posted by Gary Gregory <gg...@seagullsoftware.com>.
Hi All:
How close are we to an Alpha/Beta for 2.2?
Gary
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] VariableFormatter - pre 2.2
Posted by Stephen Colebourne <sc...@btopenworld.com>.
Almost done on text package - StrSubstitutor needs replace methods
taking a StringBuffer (as adding them later causes overloading issues as
per StringBuffer itself from JDK1.3 to 1.4)
Stephen
Henri Yandell wrote:
> On 8/4/06, Stephen Colebourne <sc...@btopenworld.com> wrote:
>
>> Henri Yandell wrote:
>> > On 8/2/06, Tom Schindl <li...@bestsolution.at> wrote:
>> >
>> >> Well I'd love to see this method in 2.2 because I think it does
>> make any
>> >> API visible to the user and doesn't bloat the
>> >> interface with too many new methods.
>> >>
>> >> Any other thoughts?
>> >
>> >
>> > Just that now that Attributes 2.2 is out, I'm ready to start cutting
>> > Lang 2.2 release candidates and want to put this one to bed :)
>>
>> I'm away next two weekends.
>>
>> VariableFormatter needs to be extracted as an abstract class StrLookup -
>> like StrMatcher.
>>
>> And the resolveVariable method needs altering to have a more subclass
>> friendly API (see other thread).
>>
>> So, if you feel like coding...
>
>
> Before 2.2? Or for what Tom wants?
>
> Hen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] VariableFormatter - pre 2.2
Posted by Henri Yandell <fl...@gmail.com>.
On 8/4/06, Stephen Colebourne <sc...@btopenworld.com> wrote:
> Henri Yandell wrote:
> > On 8/2/06, Tom Schindl <li...@bestsolution.at> wrote:
> >
> >> Well I'd love to see this method in 2.2 because I think it does make any
> >> API visible to the user and doesn't bloat the
> >> interface with too many new methods.
> >>
> >> Any other thoughts?
> >
> >
> > Just that now that Attributes 2.2 is out, I'm ready to start cutting
> > Lang 2.2 release candidates and want to put this one to bed :)
>
> I'm away next two weekends.
>
> VariableFormatter needs to be extracted as an abstract class StrLookup -
> like StrMatcher.
>
> And the resolveVariable method needs altering to have a more subclass
> friendly API (see other thread).
>
> So, if you feel like coding...
Before 2.2? Or for what Tom wants?
Hen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] VariableFormatter - pre 2.2
Posted by Stephen Colebourne <sc...@btopenworld.com>.
Henri Yandell wrote:
> On 8/2/06, Tom Schindl <li...@bestsolution.at> wrote:
>
>> Well I'd love to see this method in 2.2 because I think it does make any
>> API visible to the user and doesn't bloat the
>> interface with too many new methods.
>>
>> Any other thoughts?
>
>
> Just that now that Attributes 2.2 is out, I'm ready to start cutting
> Lang 2.2 release candidates and want to put this one to bed :)
I'm away next two weekends.
VariableFormatter needs to be extracted as an abstract class StrLookup -
like StrMatcher.
And the resolveVariable method needs altering to have a more subclass
friendly API (see other thread).
So, if you feel like coding...
Stephen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] VariableFormatter - pre 2.2
Posted by Tom Schindl <li...@bestsolution.at>.
Henri Yandell schrieb:
> On 8/2/06, Tom Schindl <li...@bestsolution.at> wrote:
>> Well I'd love to see this method in 2.2 because I think it does make any
>> API visible to the user and doesn't bloat the
>> interface with too many new methods.
>>
>> Any other thoughts?
>
> Just that now that Attributes 2.2 is out, I'm ready to start cutting
> Lang 2.2 release candidates and want to put this one to bed :)
>
> Hen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Well no problem from my side. I'll create a Jira-Entry.
Tom
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] VariableFormatter - pre 2.2
Posted by Henri Yandell <fl...@gmail.com>.
On 8/2/06, Tom Schindl <li...@bestsolution.at> wrote:
> Well I'd love to see this method in 2.2 because I think it does make any
> API visible to the user and doesn't bloat the
> interface with too many new methods.
>
> Any other thoughts?
Just that now that Attributes 2.2 is out, I'm ready to start cutting
Lang 2.2 release candidates and want to put this one to bed :)
Hen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] VariableFormatter - pre 2.2
Posted by Tom Schindl <li...@bestsolution.at>.
Well I'd love to see this method in 2.2 because I think it does make any
API visible to the user and doesn't bloat the
interface with too many new methods.
Any other thoughts?
Tom
Henri Yandell wrote:
> Make a new one - unless you're arguing for the change to be in 2.2;
> then keep it going on this thread.
>
> Hen
>
> On 8/2/06, Tom Schindl <li...@bestsolution.at> wrote:
>
>> Where should I put my feature request should I:
>> - append it to VariableFormatter's-Jira-Entry
>> - create a new Jira-Entry for StrSubstitutor
>>
>> Tom
>>
>> Tom Schindl schrieb:
>> > Hi,
>> >
>> > Looks good to me. Maybe for 2.3 this patch could provide
>> > MessageFormatting like proposed before without bloating the API. Does
>> > this now mean that VariableFormatter is gone? I like the nameing
>> > StrSubstitutor better.
>> >
>> > Tom
>> >
>> > Henri Yandell schrieb:
>> >> On 7/23/06, Stephen Colebourne <sc...@btopenworld.com> wrote:
>> >>> I have reworked the VariableFormatter class along the lines that I
>> >>> was thinking. I have committed it as StrSubstitutor so it doesn't
>> >>> clash for the moment and so it can be easiy reviewed.
>> >>>
>> >>> This version does not have a separate parser class, but still
>> >>> supports escaping, and matchers for prefix/suffix (which can now be
>> >>> set by users). The new class should perform better as a result.
>> >>>
>> >>> I have removed the edge cases wrt resolving Objects, as they were
>> >>> rather ill-defined.
>> >>>
>> >>> Otherwise, the basic functionality it supported, and the test case
>> >>> is slightly enlarged. I still want to break out the resolver as a
>> >>> public abstract class before release.
>> >>>
>> >>> Opinions
>> >> Oliver, Gary, Tom?
>> >>
>> >> Looking to get Lang 2.2 moving out the door and this is the only
>> blocker.
>> >>
>> >> Hen
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>> >> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>> >>
>> >>
>> >
>> >
>> >
>> ------------------------------------------------------------------------
>> >
>> > Index:
>> /home.local/tom/projects/eclipse-ws/bidi-forms/jakarta-commons-lang/src/java/org/apache/commons/lang/text/StrSubstitutor.java
>>
>> > ===================================================================
>> > ---
>> /home.local/tom/projects/eclipse-ws/bidi-forms/jakarta-commons-lang/src/java/org/apache/commons/lang/text/StrSubstitutor.java
>> (revision 427468)
>> > +++
>> /home.local/tom/projects/eclipse-ws/bidi-forms/jakarta-commons-lang/src/java/org/apache/commons/lang/text/StrSubstitutor.java
>> (working copy)
>> > @@ -16,6 +16,7 @@
>> >
>> > package org.apache.commons.lang.text;
>> >
>> > +import java.text.MessageFormat;
>> > import java.util.ArrayList;
>> > import java.util.List;
>> > import java.util.Map;
>> > @@ -725,5 +726,84 @@
>> > return obj.toString();
>> > }
>> > }
>> > +
>> > + /**
>> > + * Looks up a string value by name using a {@link Map} and can
>> use format
>> > + * expressions known from {@link MessageFormat}
>> > + */
>> > + static class MapVariableResolverFormat extends
>> MapVariableResolver {
>> > +
>> > + MapVariableResolverFormat(Map map) {
>> > + super(map);
>> > + }
>> > +
>> > + public String resolveVariable(String varName) {
>> > + int index;
>> > +
>> > + if (map != null && (index =
>> varName.indexOf(",")) != -1) {
>> > + return MessageFormat.format("{0" +
>> varName.substring(index)
>> > + + "}", new Object[] { map.get(
>> > +
>> varName.substring(0, index)) });
>> > + } else {
>> > + return super.resolveVariable(varName);
>> > + }
>> > + }
>> > + }
>> > +
>> > + /**
>> > + * Substitutes variables by value and allows to use the
>> formats known from
>> > + * {@link MessageFormat}:
>> > + * <p>
>> > + * The following example demonstrates this:
>> > + * </p>
>> > + * <pre>
>> > + * Map map = new HashMap();
>> > + * map.put("num",new Double(1000.103));
>> > + * map.put("date", new
>> SimpleDateFormat("yyyy-MM-dd").parse("1970-01-01"));
>> > + *
>> > + * StrSubstitutor.Format.replace("Number:
>> ${num,number,integer}, Date: ${date,date,yyyy-MM-dd}", map)
>> > + * </pre>
>> > + * yielding in Locale.US
>> > + * <pre>
>> > + * Number: 1,000, Date: 1970-01-01
>> > + * </pre>
>> > + */
>> > + public static class Format {
>> > + private Format() {}
>> > +
>> > + /**
>> > + * Replaces all the occurrences of variables in the given
>> source object with
>> > + * their matching values from the map.
>> > + *
>> > + * @param source the source text containing the variables
>> to substitute
>> > + * @param valueMap the map with the values
>> > + * @return the result of the replace operation
>> > + */
>> > + public static String replace(Object source, Map valueMap) {
>> > + StrSubstitutor tmp = new StrSubstitutor();
>> > + tmp.setVariableResolver(new
>> MapVariableResolverFormat(valueMap));
>> > +
>> > + return tmp.replace(source);
>> > + }
>> >
>> > + /**
>> > + * Replaces all the occurrences of variables in the given
>> source object with
>> > + * their matching values from the map. This method allows
>> to specifiy a
>> > + * custom variable prefix and suffix
>> > + *
>> > + * @param source the source text containing the variables
>> to substitute
>> > + * @param valueMap the map with the values
>> > + * @param prefix the prefix of variables
>> > + * @param suffix the suffix of variables
>> > + * @return the result of the replace operation
>> > + */
>> > + public static String replace(Object source, Map valueMap,
>> String prefix, String suffix) {
>> > + StrSubstitutor tmp = new StrSubstitutor();
>> > + tmp.setVariablePrefix(prefix);
>> > + tmp.setVariableSuffix(suffix);
>> > + tmp.setVariableResolver(new
>> MapVariableResolverFormat(valueMap));
>> > +
>> > + return tmp.replace(source);
>> > + }
>> > + }
>> > }
>> > Index:
>> /home.local/tom/projects/eclipse-ws/bidi-forms/jakarta-commons-lang/src/test/org/apache/commons/lang/text/StrSubstitutorTest.java
>>
>> > ===================================================================
>> > ---
>> /home.local/tom/projects/eclipse-ws/bidi-forms/jakarta-commons-lang/src/test/org/apache/commons/lang/text/StrSubstitutorTest.java
>> (revision 427468)
>> > +++
>> /home.local/tom/projects/eclipse-ws/bidi-forms/jakarta-commons-lang/src/test/org/apache/commons/lang/text/StrSubstitutorTest.java
>> (working copy)
>> > @@ -16,7 +16,10 @@
>> >
>> > package org.apache.commons.lang.text;
>> >
>> > +import java.text.ParseException;
>> > +import java.text.SimpleDateFormat;
>> > import java.util.HashMap;
>> > +import java.util.Locale;
>> > import java.util.Map;
>> >
>> > import junit.framework.Test;
>> > @@ -24,8 +27,6 @@
>> > import junit.framework.TestSuite;
>> > import junit.textui.TestRunner;
>> >
>> > -import
>> org.apache.commons.lang.text.StrSubstitutor.MapVariableResolver;
>> > -
>> > /**
>> > * Test class for StrSubstitutor.
>> > *
>> > @@ -332,6 +333,26 @@
>> > }
>> > }
>> >
>> > + public void testWithFormating() {
>> > + Locale tmp = Locale.getDefault();
>> > +
>> > + try {
>> > + Map map = new HashMap();
>> > + map.put("num",new Double(1000.103));
>> > + map.put("date", new
>> SimpleDateFormat("yyyy-MM-dd").parse("1970-01-01"));
>> > +
>> > + Locale.setDefault(Locale.US);
>> > +
>> > + String value = StrSubstitutor.Format.replace("Number:
>> ${num,number,integer}, Date: ${date,date,yyyy-MM-dd}", map);
>> > + assertEquals("Number: 1,000, Date: 1970-01-01", value);
>> > +
>> > + } catch (ParseException e) {
>> > + fail("Parsing failed");
>> > + } finally {
>> > + Locale.setDefault(tmp);
>> > + }
>> > + }
>> > +
>> > /**
>> > * Tests interpolation with weird boundary patterns.
>> > */
>> >
>> >
>> >
>> >
>> ------------------------------------------------------------------------
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] VariableFormatter - pre 2.2
Posted by Henri Yandell <fl...@gmail.com>.
Make a new one - unless you're arguing for the change to be in 2.2;
then keep it going on this thread.
Hen
On 8/2/06, Tom Schindl <li...@bestsolution.at> wrote:
> Where should I put my feature request should I:
> - append it to VariableFormatter's-Jira-Entry
> - create a new Jira-Entry for StrSubstitutor
>
> Tom
>
> Tom Schindl schrieb:
> > Hi,
> >
> > Looks good to me. Maybe for 2.3 this patch could provide
> > MessageFormatting like proposed before without bloating the API. Does
> > this now mean that VariableFormatter is gone? I like the nameing
> > StrSubstitutor better.
> >
> > Tom
> >
> > Henri Yandell schrieb:
> >> On 7/23/06, Stephen Colebourne <sc...@btopenworld.com> wrote:
> >>> I have reworked the VariableFormatter class along the lines that I
> >>> was thinking. I have committed it as StrSubstitutor so it doesn't
> >>> clash for the moment and so it can be easiy reviewed.
> >>>
> >>> This version does not have a separate parser class, but still
> >>> supports escaping, and matchers for prefix/suffix (which can now be
> >>> set by users). The new class should perform better as a result.
> >>>
> >>> I have removed the edge cases wrt resolving Objects, as they were
> >>> rather ill-defined.
> >>>
> >>> Otherwise, the basic functionality it supported, and the test case
> >>> is slightly enlarged. I still want to break out the resolver as a
> >>> public abstract class before release.
> >>>
> >>> Opinions
> >> Oliver, Gary, Tom?
> >>
> >> Looking to get Lang 2.2 moving out the door and this is the only blocker.
> >>
> >> Hen
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >>
> >>
> >
> >
> > ------------------------------------------------------------------------
> >
> > Index: /home.local/tom/projects/eclipse-ws/bidi-forms/jakarta-commons-lang/src/java/org/apache/commons/lang/text/StrSubstitutor.java
> > ===================================================================
> > --- /home.local/tom/projects/eclipse-ws/bidi-forms/jakarta-commons-lang/src/java/org/apache/commons/lang/text/StrSubstitutor.java (revision 427468)
> > +++ /home.local/tom/projects/eclipse-ws/bidi-forms/jakarta-commons-lang/src/java/org/apache/commons/lang/text/StrSubstitutor.java (working copy)
> > @@ -16,6 +16,7 @@
> >
> > package org.apache.commons.lang.text;
> >
> > +import java.text.MessageFormat;
> > import java.util.ArrayList;
> > import java.util.List;
> > import java.util.Map;
> > @@ -725,5 +726,84 @@
> > return obj.toString();
> > }
> > }
> > +
> > + /**
> > + * Looks up a string value by name using a {@link Map} and can use format
> > + * expressions known from {@link MessageFormat}
> > + */
> > + static class MapVariableResolverFormat extends MapVariableResolver {
> > +
> > + MapVariableResolverFormat(Map map) {
> > + super(map);
> > + }
> > +
> > + public String resolveVariable(String varName) {
> > + int index;
> > +
> > + if (map != null && (index = varName.indexOf(",")) != -1) {
> > + return MessageFormat.format("{0" + varName.substring(index)
> > + + "}", new Object[] { map.get(
> > + varName.substring(0, index)) });
> > + } else {
> > + return super.resolveVariable(varName);
> > + }
> > + }
> > + }
> > +
> > + /**
> > + * Substitutes variables by value and allows to use the formats known from
> > + * {@link MessageFormat}:
> > + * <p>
> > + * The following example demonstrates this:
> > + * </p>
> > + * <pre>
> > + * Map map = new HashMap();
> > + * map.put("num",new Double(1000.103));
> > + * map.put("date", new SimpleDateFormat("yyyy-MM-dd").parse("1970-01-01"));
> > + *
> > + * StrSubstitutor.Format.replace("Number: ${num,number,integer}, Date: ${date,date,yyyy-MM-dd}", map)
> > + * </pre>
> > + * yielding in Locale.US
> > + * <pre>
> > + * Number: 1,000, Date: 1970-01-01
> > + * </pre>
> > + */
> > + public static class Format {
> > + private Format() {}
> > +
> > + /**
> > + * Replaces all the occurrences of variables in the given source object with
> > + * their matching values from the map.
> > + *
> > + * @param source the source text containing the variables to substitute
> > + * @param valueMap the map with the values
> > + * @return the result of the replace operation
> > + */
> > + public static String replace(Object source, Map valueMap) {
> > + StrSubstitutor tmp = new StrSubstitutor();
> > + tmp.setVariableResolver(new MapVariableResolverFormat(valueMap));
> > +
> > + return tmp.replace(source);
> > + }
> >
> > + /**
> > + * Replaces all the occurrences of variables in the given source object with
> > + * their matching values from the map. This method allows to specifiy a
> > + * custom variable prefix and suffix
> > + *
> > + * @param source the source text containing the variables to substitute
> > + * @param valueMap the map with the values
> > + * @param prefix the prefix of variables
> > + * @param suffix the suffix of variables
> > + * @return the result of the replace operation
> > + */
> > + public static String replace(Object source, Map valueMap, String prefix, String suffix) {
> > + StrSubstitutor tmp = new StrSubstitutor();
> > + tmp.setVariablePrefix(prefix);
> > + tmp.setVariableSuffix(suffix);
> > + tmp.setVariableResolver(new MapVariableResolverFormat(valueMap));
> > +
> > + return tmp.replace(source);
> > + }
> > + }
> > }
> > Index: /home.local/tom/projects/eclipse-ws/bidi-forms/jakarta-commons-lang/src/test/org/apache/commons/lang/text/StrSubstitutorTest.java
> > ===================================================================
> > --- /home.local/tom/projects/eclipse-ws/bidi-forms/jakarta-commons-lang/src/test/org/apache/commons/lang/text/StrSubstitutorTest.java (revision 427468)
> > +++ /home.local/tom/projects/eclipse-ws/bidi-forms/jakarta-commons-lang/src/test/org/apache/commons/lang/text/StrSubstitutorTest.java (working copy)
> > @@ -16,7 +16,10 @@
> >
> > package org.apache.commons.lang.text;
> >
> > +import java.text.ParseException;
> > +import java.text.SimpleDateFormat;
> > import java.util.HashMap;
> > +import java.util.Locale;
> > import java.util.Map;
> >
> > import junit.framework.Test;
> > @@ -24,8 +27,6 @@
> > import junit.framework.TestSuite;
> > import junit.textui.TestRunner;
> >
> > -import org.apache.commons.lang.text.StrSubstitutor.MapVariableResolver;
> > -
> > /**
> > * Test class for StrSubstitutor.
> > *
> > @@ -332,6 +333,26 @@
> > }
> > }
> >
> > + public void testWithFormating() {
> > + Locale tmp = Locale.getDefault();
> > +
> > + try {
> > + Map map = new HashMap();
> > + map.put("num",new Double(1000.103));
> > + map.put("date", new SimpleDateFormat("yyyy-MM-dd").parse("1970-01-01"));
> > +
> > + Locale.setDefault(Locale.US);
> > +
> > + String value = StrSubstitutor.Format.replace("Number: ${num,number,integer}, Date: ${date,date,yyyy-MM-dd}", map);
> > + assertEquals("Number: 1,000, Date: 1970-01-01", value);
> > +
> > + } catch (ParseException e) {
> > + fail("Parsing failed");
> > + } finally {
> > + Locale.setDefault(tmp);
> > + }
> > + }
> > +
> > /**
> > * Tests interpolation with weird boundary patterns.
> > */
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] VariableFormatter - pre 2.2
Posted by Tom Schindl <li...@bestsolution.at>.
Where should I put my feature request should I:
- append it to VariableFormatter's-Jira-Entry
- create a new Jira-Entry for StrSubstitutor
Tom
Tom Schindl schrieb:
> Hi,
>
> Looks good to me. Maybe for 2.3 this patch could provide
> MessageFormatting like proposed before without bloating the API. Does
> this now mean that VariableFormatter is gone? I like the nameing
> StrSubstitutor better.
>
> Tom
>
> Henri Yandell schrieb:
>> On 7/23/06, Stephen Colebourne <sc...@btopenworld.com> wrote:
>>> I have reworked the VariableFormatter class along the lines that I
>>> was thinking. I have committed it as StrSubstitutor so it doesn't
>>> clash for the moment and so it can be easiy reviewed.
>>>
>>> This version does not have a separate parser class, but still
>>> supports escaping, and matchers for prefix/suffix (which can now be
>>> set by users). The new class should perform better as a result.
>>>
>>> I have removed the edge cases wrt resolving Objects, as they were
>>> rather ill-defined.
>>>
>>> Otherwise, the basic functionality it supported, and the test case
>>> is slightly enlarged. I still want to break out the resolver as a
>>> public abstract class before release.
>>>
>>> Opinions
>> Oliver, Gary, Tom?
>>
>> Looking to get Lang 2.2 moving out the door and this is the only blocker.
>>
>> Hen
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>
>>
>
>
> ------------------------------------------------------------------------
>
> Index: /home.local/tom/projects/eclipse-ws/bidi-forms/jakarta-commons-lang/src/java/org/apache/commons/lang/text/StrSubstitutor.java
> ===================================================================
> --- /home.local/tom/projects/eclipse-ws/bidi-forms/jakarta-commons-lang/src/java/org/apache/commons/lang/text/StrSubstitutor.java (revision 427468)
> +++ /home.local/tom/projects/eclipse-ws/bidi-forms/jakarta-commons-lang/src/java/org/apache/commons/lang/text/StrSubstitutor.java (working copy)
> @@ -16,6 +16,7 @@
>
> package org.apache.commons.lang.text;
>
> +import java.text.MessageFormat;
> import java.util.ArrayList;
> import java.util.List;
> import java.util.Map;
> @@ -725,5 +726,84 @@
> return obj.toString();
> }
> }
> +
> + /**
> + * Looks up a string value by name using a {@link Map} and can use format
> + * expressions known from {@link MessageFormat}
> + */
> + static class MapVariableResolverFormat extends MapVariableResolver {
> +
> + MapVariableResolverFormat(Map map) {
> + super(map);
> + }
> +
> + public String resolveVariable(String varName) {
> + int index;
> +
> + if (map != null && (index = varName.indexOf(",")) != -1) {
> + return MessageFormat.format("{0" + varName.substring(index)
> + + "}", new Object[] { map.get(
> + varName.substring(0, index)) });
> + } else {
> + return super.resolveVariable(varName);
> + }
> + }
> + }
> +
> + /**
> + * Substitutes variables by value and allows to use the formats known from
> + * {@link MessageFormat}:
> + * <p>
> + * The following example demonstrates this:
> + * </p>
> + * <pre>
> + * Map map = new HashMap();
> + * map.put("num",new Double(1000.103));
> + * map.put("date", new SimpleDateFormat("yyyy-MM-dd").parse("1970-01-01"));
> + *
> + * StrSubstitutor.Format.replace("Number: ${num,number,integer}, Date: ${date,date,yyyy-MM-dd}", map)
> + * </pre>
> + * yielding in Locale.US
> + * <pre>
> + * Number: 1,000, Date: 1970-01-01
> + * </pre>
> + */
> + public static class Format {
> + private Format() {}
> +
> + /**
> + * Replaces all the occurrences of variables in the given source object with
> + * their matching values from the map.
> + *
> + * @param source the source text containing the variables to substitute
> + * @param valueMap the map with the values
> + * @return the result of the replace operation
> + */
> + public static String replace(Object source, Map valueMap) {
> + StrSubstitutor tmp = new StrSubstitutor();
> + tmp.setVariableResolver(new MapVariableResolverFormat(valueMap));
> +
> + return tmp.replace(source);
> + }
>
> + /**
> + * Replaces all the occurrences of variables in the given source object with
> + * their matching values from the map. This method allows to specifiy a
> + * custom variable prefix and suffix
> + *
> + * @param source the source text containing the variables to substitute
> + * @param valueMap the map with the values
> + * @param prefix the prefix of variables
> + * @param suffix the suffix of variables
> + * @return the result of the replace operation
> + */
> + public static String replace(Object source, Map valueMap, String prefix, String suffix) {
> + StrSubstitutor tmp = new StrSubstitutor();
> + tmp.setVariablePrefix(prefix);
> + tmp.setVariableSuffix(suffix);
> + tmp.setVariableResolver(new MapVariableResolverFormat(valueMap));
> +
> + return tmp.replace(source);
> + }
> + }
> }
> Index: /home.local/tom/projects/eclipse-ws/bidi-forms/jakarta-commons-lang/src/test/org/apache/commons/lang/text/StrSubstitutorTest.java
> ===================================================================
> --- /home.local/tom/projects/eclipse-ws/bidi-forms/jakarta-commons-lang/src/test/org/apache/commons/lang/text/StrSubstitutorTest.java (revision 427468)
> +++ /home.local/tom/projects/eclipse-ws/bidi-forms/jakarta-commons-lang/src/test/org/apache/commons/lang/text/StrSubstitutorTest.java (working copy)
> @@ -16,7 +16,10 @@
>
> package org.apache.commons.lang.text;
>
> +import java.text.ParseException;
> +import java.text.SimpleDateFormat;
> import java.util.HashMap;
> +import java.util.Locale;
> import java.util.Map;
>
> import junit.framework.Test;
> @@ -24,8 +27,6 @@
> import junit.framework.TestSuite;
> import junit.textui.TestRunner;
>
> -import org.apache.commons.lang.text.StrSubstitutor.MapVariableResolver;
> -
> /**
> * Test class for StrSubstitutor.
> *
> @@ -332,6 +333,26 @@
> }
> }
>
> + public void testWithFormating() {
> + Locale tmp = Locale.getDefault();
> +
> + try {
> + Map map = new HashMap();
> + map.put("num",new Double(1000.103));
> + map.put("date", new SimpleDateFormat("yyyy-MM-dd").parse("1970-01-01"));
> +
> + Locale.setDefault(Locale.US);
> +
> + String value = StrSubstitutor.Format.replace("Number: ${num,number,integer}, Date: ${date,date,yyyy-MM-dd}", map);
> + assertEquals("Number: 1,000, Date: 1970-01-01", value);
> +
> + } catch (ParseException e) {
> + fail("Parsing failed");
> + } finally {
> + Locale.setDefault(tmp);
> + }
> + }
> +
> /**
> * Tests interpolation with weird boundary patterns.
> */
>
>
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] VariableFormatter - pre 2.2
Posted by Tom Schindl <li...@bestsolution.at>.
Hi,
Looks good to me. Maybe for 2.3 this patch could provide
MessageFormatting like proposed before without bloating the API. Does
this now mean that VariableFormatter is gone? I like the nameing
StrSubstitutor better.
Tom
Henri Yandell schrieb:
> On 7/23/06, Stephen Colebourne <sc...@btopenworld.com> wrote:
>> I have reworked the VariableFormatter class along the lines that I
>> was thinking. I have committed it as StrSubstitutor so it doesn't
>> clash for the moment and so it can be easiy reviewed.
>>
>> This version does not have a separate parser class, but still
>> supports escaping, and matchers for prefix/suffix (which can now be
>> set by users). The new class should perform better as a result.
>>
>> I have removed the edge cases wrt resolving Objects, as they were
>> rather ill-defined.
>>
>> Otherwise, the basic functionality it supported, and the test case
>> is slightly enlarged. I still want to break out the resolver as a
>> public abstract class before release.
>>
>> Opinions
>
> Oliver, Gary, Tom?
>
> Looking to get Lang 2.2 moving out the door and this is the only blocker.
>
> Hen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
Re: [lang] VariableFormatter - pre 2.2
Posted by Henri Yandell <fl...@gmail.com>.
For my part....
On 8/1/06, Oliver Heger <ol...@oliver-heger.de> wrote:
>
> +1 for the name StrSubstitutor.
I'm ambivalent on the name. I've always called this introspecting, but
we killed that name a while back so I'll take anything.
> Well, I guess I have no chance to convince you to get back to Object as
> result type for the resolver interface? Hm, for [configuration] I can
> probably live with this, but it may cause unnecessary conversions.
I can't see Objects working well in string substitution unless you add
the concept of formatting, and that takes us one step further down the
road to a full on velocity clone or some such.
${date:"hh:dd:mm"} or whatever.
Something to consider adding in a later release, but the basic
substitution is probably a good start.
Hen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] VariableFormatter - pre 2.2
Posted by Oliver Heger <ol...@oliver-heger.de>.
Stephen Colebourne wrote:
>>> For example "There were ${number} characters", would return the
>>> object matching the ${number} substitution, and dropping the rest of
>>> the text!
>>>
>>> Perhaps you can point to an exact use case?
>>>
> Oliver Heger wrote:
>> Your analysis is correct. The idea was that you can have specialized
>> resolver implementations that inherently work on objects, e.g.
>>
>> - a constant resolver, which interprets the variable name as a name of
>> a static field of a class, e.g.
>> ${my.package.MyClass.MY_CONSTANT} would return the value of the
>> constant field.
>>
>> - an expression resolver, which could be passed an expression in a
>> language like JEXL and would calculate the result.
>>
>> Of course if the string passed to the substitutor contains other text
>> elements or variables, you have no choice than converting the result
>> to text. But if only a single variable is to be processed, the result
>> can be an arbitrary type.
>
> Sounds a bit [configuration] specific to me.
>
> However, we could add a singleVariableName(String) method which would
> check for the special case where the whole string was a variable.
>
> We could also have a variableNames(String) method which returns the top
> level variable names in the string.
>
> Not sure how useful either of these would really be though.
>
> What might be more useful, would be to change the method signature of
> resolveVariable() to take the StrBuilder start pos and current variable
> start and end. That would effectively provide subclasses with much more
> detailed events about the variables.
>
> So, pre 2.2 - I'd suggest
> a) alter resolveVariable()
> b) extract VariableFormatter interface to be StrLookup abstract class
> c) agree class name (is anyone not OK with StrSubstitutor?)
>
> Stephen
>
a) and b) is fine with me. The discussion about the class name I will
leave to you native speakers ;-)
Oliver
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] VariableFormatter - pre 2.2
Posted by Stephen Colebourne <sc...@btopenworld.com>.
>> For example "There were ${number} characters", would return the object
>> matching the ${number} substitution, and dropping the rest of the text!
>>
>> Perhaps you can point to an exact use case?
>>
Oliver Heger wrote:
> Your analysis is correct. The idea was that you can have specialized
> resolver implementations that inherently work on objects, e.g.
>
> - a constant resolver, which interprets the variable name as a name of a
> static field of a class, e.g.
> ${my.package.MyClass.MY_CONSTANT} would return the value of the constant
> field.
>
> - an expression resolver, which could be passed an expression in a
> language like JEXL and would calculate the result.
>
> Of course if the string passed to the substitutor contains other text
> elements or variables, you have no choice than converting the result to
> text. But if only a single variable is to be processed, the result can
> be an arbitrary type.
Sounds a bit [configuration] specific to me.
However, we could add a singleVariableName(String) method which would
check for the special case where the whole string was a variable.
We could also have a variableNames(String) method which returns the top
level variable names in the string.
Not sure how useful either of these would really be though.
What might be more useful, would be to change the method signature of
resolveVariable() to take the StrBuilder start pos and current variable
start and end. That would effectively provide subclasses with much more
detailed events about the variables.
So, pre 2.2 - I'd suggest
a) alter resolveVariable()
b) extract VariableFormatter interface to be StrLookup abstract class
c) agree class name (is anyone not OK with StrSubstitutor?)
Stephen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] VariableFormatter - pre 2.2
Posted by Oliver Heger <ol...@oliver-heger.de>.
Stephen Colebourne wrote:
> Oliver Heger wrote:
>> +1 for the name StrSubstitutor.
> :-)
>
>> Well, I guess I have no chance to convince you to get back to Object
>> as result type for the resolver interface? Hm, for [configuration] I
>> can probably live with this, but it may cause unnecessary conversions.
>
> My review of the original code seemed to show that if there was one
> substitution then the input object was returned, but if none or two
> substitutions then the string was returned. This just seems like a plain
> weird API.
>
> For example "There were ${number} characters", would return the object
> matching the ${number} substitution, and dropping the rest of the text!
>
> Perhaps you can point to an exact use case?
>
> Stephen
>
Your analysis is correct. The idea was that you can have specialized
resolver implementations that inherently work on objects, e.g.
- a constant resolver, which interprets the variable name as a name of a
static field of a class, e.g.
${my.package.MyClass.MY_CONSTANT} would return the value of the constant
field.
- an expression resolver, which could be passed an expression in a
language like JEXL and would calculate the result.
Of course if the string passed to the substitutor contains other text
elements or variables, you have no choice than converting the result to
text. But if only a single variable is to be processed, the result can
be an arbitrary type.
But maybe you are right and this concept is not really stringent.
Oliver
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] VariableFormatter - pre 2.2
Posted by Stephen Colebourne <sc...@btopenworld.com>.
Oliver Heger wrote:
> +1 for the name StrSubstitutor.
:-)
> Well, I guess I have no chance to convince you to get back to Object as
> result type for the resolver interface? Hm, for [configuration] I can
> probably live with this, but it may cause unnecessary conversions.
My review of the original code seemed to show that if there was one
substitution then the input object was returned, but if none or two
substitutions then the string was returned. This just seems like a plain
weird API.
For example "There were ${number} characters", would return the object
matching the ${number} substitution, and dropping the rest of the text!
Perhaps you can point to an exact use case?
Stephen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] VariableFormatter - pre 2.2
Posted by Oliver Heger <ol...@oliver-heger.de>.
Henri Yandell wrote:
> On 7/23/06, Stephen Colebourne <sc...@btopenworld.com> wrote:
>> I have reworked the VariableFormatter class along the lines that I
>> was thinking. I have committed it as StrSubstitutor so it doesn't
>> clash for the moment and so it can be easiy reviewed.
>>
>> This version does not have a separate parser class, but still
>> supports escaping, and matchers for prefix/suffix (which can now be
>> set by users). The new class should perform better as a result.
>>
>> I have removed the edge cases wrt resolving Objects, as they were
>> rather ill-defined.
>>
>> Otherwise, the basic functionality it supported, and the test case
>> is slightly enlarged. I still want to break out the resolver as a
>> public abstract class before release.
>>
>> Opinions
>
> Oliver, Gary, Tom?
>
> Looking to get Lang 2.2 moving out the door and this is the only blocker.
>
> Hen
>
+1 for the name StrSubstitutor.
Well, I guess I have no chance to convince you to get back to Object as
result type for the resolver interface? Hm, for [configuration] I can
probably live with this, but it may cause unnecessary conversions.
I don't want to block the release.
Oliver
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
RE: [lang] VariableFormatter - pre 2.2
Posted by Gary Gregory <gg...@seagullsoftware.com>.
Hello All:
I think the argument for the name change I am hearing is: we are not
formatting a la printf but we are replacing markers with values (and not
formatting those values). Is that right? If that is the case, a
"Substitutor" name is better.
As a general rule, I do not like or use abbreviations in class or method
names (acronyms are OK by me). So I would say that StringSubstitutor is
better. After all, we have "StringUtils", "StringEscapeUtils" and many
others, not "StrUtils", "StrEscapeUtils". So I would ask that we use
"StringFoo" for all of these classes.
Gary
> -----Original Message-----
> From: Henri Yandell [mailto:flamefew@gmail.com]
> Sent: Monday, July 31, 2006 11:30 PM
> To: Jakarta Commons Developers List; Stephen Colebourne
> Subject: Re: [lang] VariableFormatter - pre 2.2
>
> On 7/23/06, Stephen Colebourne <sc...@btopenworld.com> wrote:
> > I have reworked the VariableFormatter class along the lines that I
was thinking.
> I have committed it as StrSubstitutor so it doesn't clash for the
moment and so it
> can be easiy reviewed.
> >
> > This version does not have a separate parser class, but still
supports escaping,
> and matchers for prefix/suffix (which can now be set by users). The
new class
> should perform better as a result.
> >
> > I have removed the edge cases wrt resolving Objects, as they were
rather ill-
> defined.
> >
> > Otherwise, the basic functionality it supported, and the test case
is slightly
> enlarged. I still want to break out the resolver as a public abstract
class before
> release.
> >
> > Opinions
>
> Oliver, Gary, Tom?
>
> Looking to get Lang 2.2 moving out the door and this is the only
blocker.
>
> Hen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org