RE: [lang] Pre 2.0 StringUtils NPE changes
interesting problem... empty string has a very clear meaning in java, it is a non null String object of zero length. Does the entrenched user base merit retaining a non standard naming convention. or is Empty sufficiently entrenched to also mean null? (I don't think it is) I appreciate the dilemma but as a user would prefer it if the convention of empty stayed as and only . (but swallowing nulls and returning false id just the ticket) My 2 cents Matt -Original Message- From: Henning P. Schmiedehausen [mailto:[EMAIL PROTECTED] Sent: 18 July 2003 13:32 To: [EMAIL PROTECTED] Subject: Re: [lang] Pre 2.0 StringUtils NPE changes Howard M. Lewis Ship [EMAIL PROTECTED] writes: I must have missed this. What change to StringUtils.isEmpty() are you making. I like it just the way it it ... I had an identical method in Tapestry that I deprecated and pointed at StringUtils. I'm very much reliant on == null. I strongly agree here! We replaced lots and lots of if ((foo == null) || foo.equals()) with StringUtils.isEmpty() if ((foo != null) !foo.equals()) with StringUtils.isNotEmpty() in Turbine. If you change this behaviour, we would get _very_ upset... :-) Regards Henning -- Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH [EMAIL PROTECTED]+49 9131 50 654 0 http://www.intermeta.de/ Java, perl, Solaris, Linux, xSP Consulting, Web Services freelance consultant -- Jakarta Turbine Development -- hero for hire --- Quote of the week: It is pointless to tell people anything when you know that they won't process the message. --- Jonathan Revusky - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ** The information transmitted herewith is sensitive information intended only for use by the individual or entity to which it is addressed. If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/logging/src/test/org/apache/commons/logging LogTest.java LoadTest.java
rsitze 2003/07/18 07:11:45 Modified:logging/src/test/org/apache/commons/logging/log4j CustomConfigTestCase.java DefaultConfigTestCase.java logging/src/test/org/apache/commons/logging/jdk14 DefaultConfigTestCase.java CustomConfigTestCase.java logging/src/test/org/apache/commons/logging LogTest.java LoadTest.java Log: Cleanup imports some static method calls. Revision ChangesPath 1.4 +4 -7 jakarta-commons/logging/src/test/org/apache/commons/logging/log4j/CustomConfigTestCase.java Index: CustomConfigTestCase.java === RCS file: /home/cvs/jakarta-commons/logging/src/test/org/apache/commons/logging/log4j/CustomConfigTestCase.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- CustomConfigTestCase.java 10 Apr 2003 22:40:37 - 1.3 +++ CustomConfigTestCase.java 18 Jul 2003 14:11:45 - 1.4 @@ -68,11 +68,8 @@ import java.util.Properties; import junit.framework.Test; -import junit.framework.TestCase; import junit.framework.TestSuite; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PropertyConfigurator; 1.3 +7 -9 jakarta-commons/logging/src/test/org/apache/commons/logging/log4j/DefaultConfigTestCase.java Index: DefaultConfigTestCase.java === RCS file: /home/cvs/jakarta-commons/logging/src/test/org/apache/commons/logging/log4j/DefaultConfigTestCase.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DefaultConfigTestCase.java10 Apr 2003 22:40:37 - 1.2 +++ DefaultConfigTestCase.java18 Jul 2003 14:11:45 - 1.3 @@ -134,10 +134,8 @@ */ public void tearDown() { log = null; -if (factory != null) { -factory.releaseAll(); -factory = null; -} +factory = null; +LogFactory.releaseAll(); } @@ -190,7 +188,7 @@ // Set up log instance protected void setUpLog(String name) throws Exception { -log = factory.getLog(name); +log = LogFactory.getLog(name); } 1.4 +7 -9 jakarta-commons/logging/src/test/org/apache/commons/logging/jdk14/DefaultConfigTestCase.java Index: DefaultConfigTestCase.java === RCS file: /home/cvs/jakarta-commons/logging/src/test/org/apache/commons/logging/jdk14/DefaultConfigTestCase.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- DefaultConfigTestCase.java10 Apr 2003 22:40:37 - 1.3 +++ DefaultConfigTestCase.java18 Jul 2003 14:11:45 - 1.4 @@ -134,10 +134,8 @@ */ public void tearDown() { log = null; -if (factory != null) { -factory.releaseAll(); -factory = null; -} +factory = null; +LogFactory.releaseAll(); } @@ -190,7 +188,7 @@ // Set up log instance protected void setUpLog(String name) throws Exception { -log = factory.getLog(name); +log = LogFactory.getLog(name); } 1.5 +5 -9 jakarta-commons/logging/src/test/org/apache/commons/logging/jdk14/CustomConfigTestCase.java Index: CustomConfigTestCase.java === RCS file: /home/cvs/jakarta-commons/logging/src/test/org/apache/commons/logging/jdk14/CustomConfigTestCase.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- CustomConfigTestCase.java 10 Apr 2003 22:40:37 - 1.4 +++ CustomConfigTestCase.java 18 Jul 2003 14:11:45 - 1.5 @@ -66,16 +66,12 @@ import java.util.Iterator; import java.util.logging.Handler; import java.util.logging.Level; -import java.util.logging.Logger; import java.util.logging.LogManager; import java.util.logging.LogRecord; +import java.util.logging.Logger; import junit.framework.Test; -import junit.framework.TestCase; import junit.framework.TestSuite; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; /** 1.2 +2 -2 jakarta-commons/logging/src/test/org/apache/commons/logging/LogTest.java Index: LogTest.java === RCS file: /home/cvs/jakarta-commons/logging/src/test/org/apache/commons/logging/LogTest.java,v
cvs commit: jakarta-commons/logging/src/java/org/apache/commons/logging/impl Log4JCategoryLog.java Log4jFactory.java Log4JLogger.java
rsitze 2003/07/18 07:14:16 Modified:logging/src/java/org/apache/commons/logging/impl Log4JCategoryLog.java Log4jFactory.java Log4JLogger.java Log: Cleanup imports. Revision ChangesPath 1.11 +6 -6 jakarta-commons/logging/src/java/org/apache/commons/logging/impl/Log4JCategoryLog.java Index: Log4JCategoryLog.java === RCS file: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/impl/Log4JCategoryLog.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- Log4JCategoryLog.java 2 Apr 2003 01:29:38 - 1.10 +++ Log4JCategoryLog.java 18 Jul 2003 14:14:16 - 1.11 @@ -62,9 +62,9 @@ package org.apache.commons.logging.impl; -import org.apache.log4j.*; import org.apache.commons.logging.Log; -import java.util.Enumeration; +import org.apache.log4j.Category; +import org.apache.log4j.Priority; /** * pImplementation of [EMAIL PROTECTED] Log} that maps directly to a Log4J 1.5 +1 -4 jakarta-commons/logging/src/java/org/apache/commons/logging/impl/Log4jFactory.java Index: Log4jFactory.java === RCS file: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/impl/Log4jFactory.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Log4jFactory.java 2 Apr 2003 01:53:04 - 1.4 +++ Log4jFactory.java 18 Jul 2003 14:14:16 - 1.5 @@ -58,16 +58,13 @@ package org.apache.commons.logging.impl; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; import java.util.Enumeration; import java.util.Hashtable; import java.util.Vector; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogConfigurationException; import org.apache.commons.logging.LogFactory; -import org.apache.commons.logging.LogSource; - import org.apache.log4j.Logger; /** 1.4 +6 -6 jakarta-commons/logging/src/java/org/apache/commons/logging/impl/Log4JLogger.java Index: Log4JLogger.java === RCS file: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/impl/Log4JLogger.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Log4JLogger.java 2 Apr 2003 01:29:38 - 1.3 +++ Log4JLogger.java 18 Jul 2003 14:14:16 - 1.4 @@ -62,9 +62,9 @@ package org.apache.commons.logging.impl; -import org.apache.log4j.*; import org.apache.commons.logging.Log; -import java.util.Enumeration; +import org.apache.log4j.Logger; +import org.apache.log4j.Priority; /** * pImplementation of [EMAIL PROTECTED] Log} that maps directly to a Log4J - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/logging .cvsignore
rsitze 2003/07/18 07:15:50 Modified:logging .cvsignore Log: Revision ChangesPath 1.5 +3 -2 jakarta-commons/logging/.cvsignore Index: .cvsignore === RCS file: /home/cvs/jakarta-commons/logging/.cvsignore,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- .cvsignore1 Nov 2002 03:25:56 - 1.4 +++ .cvsignore18 Jul 2003 14:15:50 - 1.5 @@ -2,8 +2,9 @@ dist target logging.ipr -.project bin -.classpath maven.log velocity.log +.project +.classpath +.repositoryIndex - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[lang] 2.0RC SystemUtils.IS_OS_OS2's JavaDoc is wrong.
I found small mistake in Commons Lang 2.0RC1. (BSystemUtils.IS_OS_OS2's javadoc says "if this is Mac." (BIt should be "OS/2". (B (BRCS file: /home/cvspublic/jakarta-commons/lang/src/java/org/apache/commons/lang/ (BSystemUtils.java,v (Bretrieving revision 1.17 (Bdiff -u -r1.17 SystemUtils.java (B--- SystemUtils.java8 Jul 2003 05:59:58 - 1.17 (B+++ SystemUtils.java18 Jul 2003 15:03:21 - (B@@ -185,7 +185,7 @@ (B public static final boolean IS_OS_MAC_OSX = getOSMatches("Mac OS X"); (B (B /** (B- * pIs codetrue/code if this is Mac./p (B+ * pIs codetrue/code if this is OS/2./p (B * (B * pThe field will return codefalse/code if codeOS_NAME/code (Bis (B * codenull/code./p (B (B-- (BKANEUCHI Tetsuya (B (B (B- (BTo unsubscribe, e-mail: [EMAIL PROTECTED] (BFor additional commands, e-mail: [EMAIL PROTECTED]
[lang] StringUtils isEmpty change
Howard, Henning, Others, Can you confirm or deny if the method isEmptyOrNull() is an acceptably named replacement to isEmpty()? We are trying to be more explicit in naming. Otherwise can you find a word that means 'empty or null'? Perhaps we could have isBlank() as a synonym of isEmptyOrNull? Also, I should point out that the code you replaced in turbine (see below) is not identical to that in isEmpty()...which is part of the issue here. I also now think that deprecation may be necessary here. Stephen from:Henning P. Schmiedehausen [EMAIL PROTECTED] Howard M. Lewis Ship [EMAIL PROTECTED] writes: I must have missed this. What change to StringUtils.isEmpty() are you making. I like it just the way it it ... I had an identical method in Tapestry that I deprecated and pointed at StringUtils. I'm very much reliant on == null. I strongly agree here! We replaced lots and lots of if ((foo == null) || foo.equals()) with StringUtils.isEmpty() if ((foo != null) !foo.equals()) with StringUtils.isNotEmpty() in Turbine. If you change this behaviour, we would get _very_ upset... :-) Regards Henning -- Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH [EMAIL PROTECTED] 49 9131 50 654 0 http://www.intermeta.de/ Java, perl, Solaris, Linux, xSP Consulting, Web Services freelance consultant -- Jakarta Turbine Development -- hero for hire --- Quote of the week: It is pointless to tell people anything when you know that they won't process the message. --- Jonathan Revusky - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[Friday] General question on OO database design
Is there a standard spec on OO database modeling? Is there a project that facilitates OO database access layer in Commons? It would be so good if we can do something like getPerson(id) to a database directly instead of structured SQL queries. Thanks! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [lang] Pre 2.0 StringUtils NPE changes
On Fri, 2003-07-18 at 13:49, Hope, Matthew wrote: interesting problem... empty string has a very clear meaning in java, it is a non null String object of zero length. Does the entrenched user base merit retaining a non standard naming convention. or is Empty sufficiently entrenched to also mean null? (I don't think it is) I appreciate the dilemma but as a user would prefer it if the convention of empty stayed as and only . (but swallowing nulls and returning false id just the ticket) My 2 cents Matt This is the same as way I always interpret 'empty' in the context of a Java String object. A empty String is a zero length String, not a null object reference. I can easily see that equating a null to an empty String is convenient but I'd be happy to be explicit about this assumed equivalence in my code than have a method with a slightly misleading name. -Janek - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [lang] Pre 2.0 - StringUtils.isEmpty(), isNotEmpty() and stri ngsa with somespaces
What if you could instantiate StringUtils if you did not like the default behavior: new StringUtils(StringUtils.ALWAYS_TRIM, StringUtils.DISCARD_NULL); ? Just a random thought. Gary -Original Message- From: Lavandowska [mailto:[EMAIL PROTECTED] Sent: Friday, July 18, 2003 07:30 To: Jakarta Commons Developers List Subject: Re: [lang] Pre 2.0 - StringUtils.isEmpty(), isNotEmpty() and stri ngsa with somespaces I missed this one earlier, so I guess 2.0 would still work for me, though I find isEmptyTrimmedOrNull() extremely cumbersome. I'd likely just move to isEmpty( trim( str ) ) myself, rather than use the added method signatures. Lance --- Todd Jonker [EMAIL PROTECTED] wrote: On 7/15/03 8:12 PM, [EMAIL PROTECTED] wrote: Thus I propose: isEmpty(), true for , false for null isEmptyOrNull(), true for and null isEmptyTrimmed(), trim() then true for , false for null isEmptyTrimmedOrNull(), trim() then true for , true for null __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [Friday] General question on OO database design
On Fri, 2003-07-18 at 16:15, Yansheng Lin wrote: Is there a standard spec on OO database modeling? Is there a project that facilitates OO database access layer in Commons? It would be so good if we can do something like getPerson(id) to a database directly instead of structured SQL queries. Thanks! AFAIK there is no standard specification for mapping objects and object graphs to relational database tables. However there are many Object-to-relational mapping frameworks which will do it for you. ObJectRelationalBridge (OJB) is one, http://db.apache.org/ojb/. -Janek - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DO NOT REPLY [Bug 21715] New: - SystemUtils.IS_OS_OS2 Javadoc is wrong
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21715. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21715 SystemUtils.IS_OS_OS2 Javadoc is wrong Summary: SystemUtils.IS_OS_OS2 Javadoc is wrong Product: Commons Version: Nightly Builds Platform: Other OS/Version: Other Status: NEW Severity: Normal Priority: Other Component: Lang AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] The javadoc says Mac instead of OS/2. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang SystemUtils.java
ggregory2003/07/18 09:48:25 Modified:lang/src/java/org/apache/commons/lang SystemUtils.java Log: PR: 21715 Obtained from: commons-dev Submitted by: KANEUCHI Tetsuya [mailto:[EMAIL PROTECTED] Reviewed by: Gary Gregory Revision ChangesPath 1.18 +2 -2 jakarta-commons/lang/src/java/org/apache/commons/lang/SystemUtils.java Index: SystemUtils.java === RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/SystemUtils.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- SystemUtils.java 8 Jul 2003 05:59:58 - 1.17 +++ SystemUtils.java 18 Jul 2003 16:48:25 - 1.18 @@ -185,7 +185,7 @@ public static final boolean IS_OS_MAC_OSX = getOSMatches(Mac OS X); /** - * pIs codetrue/code if this is Mac./p + * pIs codetrue/code if this is OS/2./p * * pThe field will return codefalse/code if codeOS_NAME/code is * codenull/code./p - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DO NOT REPLY [Bug 21715] - SystemUtils.IS_OS_OS2 Javadoc is wrong
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21715. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21715 SystemUtils.IS_OS_OS2 Javadoc is wrong [EMAIL PROTECTED] changed: What|Removed |Added Status|NEW |RESOLVED Resolution||FIXED --- Additional Comments From [EMAIL PROTECTED] 2003-07-18 16:51 --- Source: -Original Message- From: KANEUCHI Tetsuya [mailto:[EMAIL PROTECTED] Sent: Friday, July 18, 2003 08:12 To: [EMAIL PROTECTED] Subject: [lang] 2.0RC SystemUtils.IS_OS_OS2's JavaDoc is wrong. I found small mistake in Commons Lang 2.0RC1. SystemUtils.IS_OS_OS2's javadoc says if this is Mac. It should be OS/2. RCS file: /home/cvspublic/jakarta-commons/lang/src/java/org/apache/commons/lang/ SystemUtils.java,v retrieving revision 1.17 diff -u -r1.17 SystemUtils.java --- SystemUtils.java8 Jul 2003 05:59:58 - 1.17 +++ SystemUtils.java18 Jul 2003 15:03:21 - @@ -185,7 +185,7 @@ public static final boolean IS_OS_MAC_OSX = getOSMatches(Mac OS X); /** - * pIs codetrue/code if this is Mac./p + * pIs codetrue/code if this is OS/2./p * * pThe field will return codefalse/code if codeOS_NAME/code is * codenull/code./p -- KANEUCHI Tetsuya - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [lang] Pre 2.0 - StringUtils.isEmpty(), isNotEmpty() and stri ngsa with somespaces
I think it would be easier to have different extensions or wrappers for StringUtils, such as: NullFriendlyStringUtils or TrimmedStringUtils Or, maybe a type of StringUtilsFactory that could take the params you suggested and return a corresponding instance. This situation seems so controversial, with multiple people needing/wanting different behaviors, it seems almost impossible for StringUtils to satisfy everyone. It seems better to keep it simple and let some extensions do the work, in that way, the possibilities could be unlimited. Thoughts? Gary Gregory wrote: What if you could instantiate StringUtils if you did not like the default behavior: new StringUtils(StringUtils.ALWAYS_TRIM, StringUtils.DISCARD_NULL); ? Just a random thought. Gary -Original Message- From: Lavandowska [mailto:[EMAIL PROTECTED] Sent: Friday, July 18, 2003 07:30 To: Jakarta Commons Developers List Subject: Re: [lang] Pre 2.0 - StringUtils.isEmpty(), isNotEmpty() and stri ngsa with somespaces I missed this one earlier, so I guess 2.0 would still work for me, though I find isEmptyTrimmedOrNull() extremely cumbersome. I'd likely just move to isEmpty( trim( str ) ) myself, rather than use the added method signatures. Lance --- Todd Jonker [EMAIL PROTECTED] wrote: On 7/15/03 8:12 PM, [EMAIL PROTECTED] wrote: Thus I propose: isEmpty(), true for , false for null isEmptyOrNull(), true for and null isEmptyTrimmed(), trim() then true for , false for null isEmptyTrimmedOrNull(), trim() then true for , true for null __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [lang] 2.0RC SystemUtils.IS_OS_OS2's JavaDoc is wrong.
Tetsuya, Patch applied and recorded here: http://issues.apache.org/bugzilla/show_bug.cgi?id=21715 Thank you, Gary -Original Message- From: KANEUCHI Tetsuya [mailto:[EMAIL PROTECTED] Sent: Friday, July 18, 2003 08:12 To: [EMAIL PROTECTED] Subject: [lang] 2.0RC SystemUtils.IS_OS_OS2's JavaDoc is wrong. I found small mistake in Commons Lang 2.0RC1. SystemUtils.IS_OS_OS2's javadoc says if this is Mac. It should be OS/2. RCS file: /home/cvspublic/jakarta-commons/lang/src/java/org/apache/commons/lang/ SystemUtils.java,v retrieving revision 1.17 diff -u -r1.17 SystemUtils.java --- SystemUtils.java8 Jul 2003 05:59:58 - 1.17 +++ SystemUtils.java18 Jul 2003 15:03:21 - @@ -185,7 +185,7 @@ public static final boolean IS_OS_MAC_OSX = getOSMatches(Mac OS X); /** - * pIs codetrue/code if this is Mac./p + * pIs codetrue/code if this is OS/2./p * * pThe field will return codefalse/code if codeOS_NAME/code is * codenull/code./p -- KANEUCHI Tetsuya - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang/time DurationFormatUtils.java
ggregory2003/07/18 10:04:31 Modified:lang/src/java/org/apache/commons/lang/time DurationFormatUtils.java Log: Added an ISO 8601 formatter for the date time extended format used in durations, with XML Schema durations particularly in mind. Note that this is still a package level class only. Revision ChangesPath 1.4 +79 -47 jakarta-commons/lang/src/java/org/apache/commons/lang/time/DurationFormatUtils.java Index: DurationFormatUtils.java === RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/time/DurationFormatUtils.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- DurationFormatUtils.java 14 Jul 2003 22:25:05 - 1.3 +++ DurationFormatUtils.java 18 Jul 2003 17:04:31 - 1.4 @@ -60,6 +60,7 @@ * @author a href=mailto:[EMAIL PROTECTED]Stephane Bailliez/a * @author a href=mailto:[EMAIL PROTECTED]Stefan Bodewig/a * @author Stephen Colebourne + * @author a href=mailto:[EMAIL PROTECTED]Gary Gregory/a * @since 2.0 * @version $Id$ */ @@ -67,12 +68,68 @@ // TODO: Make class public once methods can fully select which fields to output /** - * pDurationFormatUtils instances should NOT be constructed in standard programming./p - * - * pThis constructor is public to permit tools that require a JavaBean instance - * to operate./p + * pPattern used with codeFastDateFormat/code and codeSimpleDateFormat /code for the ISO8601 + * date time extended format used in durations./p + * + * @see org.apache.commons.lang.time.FastDateFormat + * @see java.text.SimpleDateFormat */ -public DurationFormatUtils() { +public static final String ISO_EXTENDED_FORMAT_PATTERN = 'P''Y'M'M'd'DT'H'H'm'M's.S'S'; + +/** + * pISO8601 formatter for the date time extended format used in durations, + * with XML Schema durations particularly in mind./p + * + * pThis format represents the Gregorian year, month, day, hour, minute, and second components defined + * in § 5.5.3.2 of ISO 8601, respectively. These components are ordered in their significance by their order + * of appearance i.e. as year, month, day, hour, minute, and second./p + * + * pThe ISO8601 extended format Pin/iYin/iMin/iDTin/iHin/iMin/iS, where in/iY + * represents the number of years, in/iM the number of months, in/iD the number of days, + * 'T' is the date/time separator, in/iH the number of hours, in/iM the number of minutes and + * in/iS the number of seconds. The number of seconds can include decimal digits to arbitrary precision./p + * + * @see #ISO_EXTENDED_FORMAT_PATTERN + * @see a href=http://www.w3.org/TR/xmlschema-2/#duration;http://www.w3.org/TR/xmlschema-2/#duration/a + */ +public static final FastDateFormat ISO_EXTENDED_FORMAT = +FastDateFormat.getInstance(ISO_EXTENDED_FORMAT_PATTERN); + +/** + * pGet the time gap as a string./p + * + * pThe format used is ISO8601-like: + * ihours/i:iminutes/i:iseconds/i.imilliseconds/i./p + * + * @param millis the duration to format + * @return the time as a String + */ +public static String formatISO(long millis) { +int hours, minutes, seconds, milliseconds; +hours = (int) (millis / DateUtils.MILLIS_IN_HOUR); +millis = millis - (hours * DateUtils.MILLIS_IN_HOUR); +minutes = (int) (millis / DateUtils.MILLIS_IN_MINUTE); +millis = millis - (minutes * DateUtils.MILLIS_IN_MINUTE); +seconds = (int) (millis / DateUtils.MILLIS_IN_SECOND); +millis = millis - (seconds * DateUtils.MILLIS_IN_SECOND); +milliseconds = (int) millis; + +StringBuffer buf = new StringBuffer(32); +buf.append(hours); +buf.append(':'); +buf.append((char) (minutes / 10 + '0')); +buf.append((char) (minutes % 10 + '0')); +buf.append(':'); +buf.append((char) (seconds / 10 + '0')); +buf.append((char) (seconds % 10 + '0')); +buf.append('.'); +if (milliseconds 10) { +buf.append('0').append('0'); +} else if (milliseconds 100) { +buf.append('0'); +} +buf.append(milliseconds); +return buf.toString(); } /** @@ -81,8 +138,8 @@ * seconds and has the following behavior./p * * ul - * liminutes are not displayed when code0/code. (ie: - * quot;45 secondsquot;)/li + * liminutes are not displayed when code0/code (ie: + * quot;45 secondsquot;)/li. * liseconds are always displayed in plural form (ie * quot;0 secondsquot;
cvs commit: jakarta-commons/lang/src/test/org/apache/commons/lang/time DurationFormatUtilsTest.java
ggregory2003/07/18 10:05:54 Modified:lang/src/test/org/apache/commons/lang/time DurationFormatUtilsTest.java Log: Added an ISO 8601 formatter for the date time extended format used in durations, with XML Schema durations particularly in mind. Note that the util class is still a package level class only. Revision ChangesPath 1.2 +26 -0 jakarta-commons/lang/src/test/org/apache/commons/lang/time/DurationFormatUtilsTest.java Index: DurationFormatUtilsTest.java === RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/time/DurationFormatUtilsTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- DurationFormatUtilsTest.java 8 Jun 2003 23:14:23 - 1.1 +++ DurationFormatUtilsTest.java 18 Jul 2003 17:05:54 - 1.2 @@ -53,6 +53,9 @@ */ package org.apache.commons.lang.time; +import java.util.Calendar; +import java.util.TimeZone; + import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; @@ -65,6 +68,7 @@ * @author a href=mailto:[EMAIL PROTECTED]Stephane Bailliez/a * @author a href=mailto:[EMAIL PROTECTED]Stefan Bodewig/a * @author Stephen Colebourne + * @author a href=mailto:[EMAIL PROTECTED]Gary Gregory/a */ public class DurationFormatUtilsTest extends TestCase { @@ -158,5 +162,27 @@ time = 12789 + 62 * 6; assertEquals(1:02:12.789, DurationFormatUtils.formatISO(time)); } + +public void testISODurationFormat(){ +TimeZone timeZone = TimeZone.getTimeZone(GMT-3); +Calendar cal = Calendar.getInstance(timeZone); +cal.set(2002, 1, 23, 9, 11, 12); +cal.set(Calendar.MILLISECOND, 1); +String text; +// repeat a test from testDateTimeISO to compare extended and not extended. +text = DateFormatUtils.ISO_DATETIME_TIMEZONE_FORMAT.format(cal); +assertEquals(2002-02-23T09:11:12-03:00, text); +// test fixture is the same as above, but now with extended format. +text = DurationFormatUtils.ISO_EXTENDED_FORMAT.format(cal); +assertEquals(P2002Y2M23DT9H11M12.1S, text); +// test fixture from example in http://www.w3.org/TR/xmlschema-2/#duration +cal.set(1, 1, 3, 10, 30, 0); +cal.set(Calendar.MILLISECOND, 0); +text = DurationFormatUtils.ISO_EXTENDED_FORMAT.format(cal); +assertEquals(P1Y2M3DT10H30M0.0S, text); +// want a way to say 'don't print the seconds in format()' or other fields for that matter: +//assertEquals(P1Y2M3DT10H30M, text); +} + } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [lang] StringUtils isEmpty change
When I read: StringUtils.isBlank(s) I translate that to: s.trim().length() == 0 Nulls are a separate beast to me. Gary -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, July 18, 2003 09:15 To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: [lang] StringUtils isEmpty change Howard, Henning, Others, Can you confirm or deny if the method isEmptyOrNull() is an acceptably named replacement to isEmpty()? We are trying to be more explicit in naming. Otherwise can you find a word that means 'empty or null'? Perhaps we could have isBlank() as a synonym of isEmptyOrNull? Also, I should point out that the code you replaced in turbine (see below) is not identical to that in isEmpty()...which is part of the issue here. I also now think that deprecation may be necessary here. Stephen from:Henning P. Schmiedehausen [EMAIL PROTECTED] Howard M. Lewis Ship [EMAIL PROTECTED] writes: I must have missed this. What change to StringUtils.isEmpty() are you making. I like it just the way it it ... I had an identical method in Tapestry that I deprecated and pointed at StringUtils. I'm very much reliant on == null. I strongly agree here! We replaced lots and lots of if ((foo == null) || foo.equals()) with StringUtils.isEmpty() if ((foo != null) !foo.equals()) with StringUtils.isNotEmpty() in Turbine. If you change this behaviour, we would get _very_ upset... :-) Regards Henning -- Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH [EMAIL PROTECTED] 49 9131 50 654 0 http://www.intermeta.de/ Java, perl, Solaris, Linux, xSP Consulting, Web Services freelance consultant -- Jakarta Turbine Development -- hero for hire --- Quote of the week: It is pointless to tell people anything when you know that they won't process the message. --- Jonathan Revusky - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[lang] build.xml fails in test.lang
Title: [lang] build.xml fails in test.lang I've got the latest from CVS and I get: test.lang: [echo] Running lang package tests ... [java] . [java] . [java] . [java] . [java] . [java] ...F.. [java] F. [java] ... [java] Time: 0.881 [java] There were 2 failures: [java] 1) testCenter(org.apache.commons.lang.StringUtilsTest)junit.framework.ComparisonFailure: expected:y... but was:... [java] at org.apache.commons.lang.StringUtilsTest.testCenter(StringUtilsTest.java:325) [java] 2) testPadFunctions(org.apache.commons.lang.StringUtilsTest)junit.framework.ComparisonFailure: expected:...-+ but was:... [java] at org.apache.commons.lang.StringUtilsTest.testPadFunctions(StringUtilsTest.java:476) [java] FAILURES!!! [java] Tests run: 322, Failures: 2, Errors: 0 BUILD FAILED file:C:/cvs-store/apache.org/jakarta/commons/lang/build.xml:114: Java returned: 1 Total time: 8 seconds C:\cvs-store\apache.org\jakarta\commons\langant dist test Buildfile: build.xml init: [echo] commons-lang 2.0-dev prepare: static: compile: javadoc: [javadoc] Generating Javadoc [javadoc] Javadoc execution [javadoc] Loading source files for package org.apache.commons.lang... [javadoc] Loading source files for package org.apache.commons.lang.builder... [javadoc] Loading source files for package org.apache.commons.lang.enum... [javadoc] Loading source files for package org.apache.commons.lang.exception... [javadoc] Loading source files for package org.apache.commons.lang.math... [javadoc] Loading source files for package org.apache.commons.lang.reflect... [javadoc] Loading source files for package org.apache.commons.lang.time... [javadoc] Loading source files for package org.apache.commons.lang.util... [javadoc] Constructing Javadoc information... [javadoc] Building tree for all the packages and classes... [javadoc] Building index for all the packages and classes... [javadoc] javadoc: warning - Tag @link: Class or Package not found: System#identityHashCode(java.lang.Object) [javadoc] javadoc: warning - org.apache.commons.lang.StringUtils.capitalise(String): Tag @link: can't find toTitleCase() in java.lang.Character [javadoc] javadoc: warning - Tag @link: Class or Package not found: java.lang.Math#random() [javadoc] javadoc: warning - Tag @link: Class or Package not found: java.lang.Math#random() [javadoc] javadoc: warning - org.apache.commons.lang.StringUtils.uncapitalise(String): Tag @link: can't find toLowerCase() in java.lang.Character [javadoc] Building index for all classes... [javadoc] javadoc: warning - Tag @link: Class or Package not found: java.lang.Math#random() [javadoc] javadoc: warning - Tag @link: Class or Package not found: java.lang.Math#random() [javadoc] javadoc: warning - org.apache.commons.lang.StringUtils.capitalise(String): Tag @link: can't find toTitleCase() in java.lang.Character [javadoc] javadoc: warning - org.apache.commons.lang.StringUtils.capitalise(String): Tag @link: can't find toTitleCase() in java.lang.Character [javadoc] javadoc: warning - org.apache.commons.lang.StringUtils.uncapitalise(String): Tag @link: can't find toLowerCase() in java.lang.Character [javadoc] javadoc: warning - org.apache.commons.lang.StringUtils.uncapitalise(String): Tag @link: can't find toLowerCase() in java.lang.Character [javadoc] javadoc: warning - org.apache.commons.lang.StringUtils.capitalise(String): Tag @link: can't find toTitleCase() in java.lang.Character [javadoc] javadoc: warning - org.apache.commons.lang.StringUtils.capitalise(String): Tag @link: can't find toTitleCase() in java.lang.Character [javadoc] javadoc: warning - org.apache.commons.lang.StringUtils.uncapitalise(String): Tag @link: can't find toLowerCase() in java.lang.Character [javadoc] javadoc: warning - org.apache.commons.lang.StringUtils.uncapitalise(String): Tag @link: can't find toLowerCase() in java.lang.Character [javadoc] javadoc: warning - Tag @link: Class or Package not found: System#identityHashCode(java.lang.Object) [javadoc] javadoc: warning - Tag @link: Class or Package not found: System#identityHashCode(java.lang.Object) [javadoc] javadoc: warning - Tag @link: Class or Package not found: System#identityHashCode(java.lang.Object) [javadoc] javadoc: warning - Tag @link: Class or Package not found: java.lang.Math#random() [javadoc] javadoc: warning - Tag @link: Class or Package not found: java.lang.Math#random() [javadoc] Generating C:\cvs-store\apache.org\jakarta\commons\lang\dist\docs\api\stylesheet.css... [javadoc] 20 warnings dist: init: [echo] commons-lang 2.0-dev
[Modeler] Next Release plan? (1.1?)
Yoav, others modeler-folks, Is there a date for 1.1 release of Modeler? Thanks, dims = Davanum Srinivas - http://webservices.apache.org/~dims/ __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [Modeler] Next Release plan? (1.1?)
Howdy, I was never given karma as a modeler (or commons) committer, so I was never able to go ahead with the release. It's still a bottleneck for tomcat 5 ;( I have no idea why this happened, as the vote took place and I emailed the requisite people (PMC etc.), but no luck ;( Yoav Shapira Millennium ChemInformatics -Original Message- From: Davanum Srinivas [mailto:[EMAIL PROTECTED] Sent: Friday, July 18, 2003 1:46 PM To: [EMAIL PROTECTED] Subject: [Modeler] Next Release plan? (1.1?) Yoav, others modeler-folks, Is there a date for 1.1 release of Modeler? Thanks, dims = Davanum Srinivas - http://webservices.apache.org/~dims/ __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [lang] StringUtils isEmpty change
I would prefer to keep it the way it is. If someone needs to explicitly check for null, let them. I missed the discussion about why this change is needed ... from my point of view, it looks like change for change's sake. -- Howard M. Lewis Ship Creator, Tapestry: Java Web Components http://jakarta.apache.org/tapestry -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, July 18, 2003 12:15 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: [lang] StringUtils isEmpty change Howard, Henning, Others, Can you confirm or deny if the method isEmptyOrNull() is an acceptably named replacement to isEmpty()? We are trying to be more explicit in naming. Otherwise can you find a word that means 'empty or null'? Perhaps we could have isBlank() as a synonym of isEmptyOrNull? Also, I should point out that the code you replaced in turbine (see below) is not identical to that in isEmpty()...which is part of the issue here. I also now think that deprecation may be necessary here. Stephen from:Henning P. Schmiedehausen [EMAIL PROTECTED] Howard M. Lewis Ship [EMAIL PROTECTED] writes: I must have missed this. What change to StringUtils.isEmpty() are you making. I like it just the way it it ... I had an identical method in Tapestry that I deprecated and pointed at StringUtils. I'm very much reliant on == null. I strongly agree here! We replaced lots and lots of if ((foo == null) || foo.equals()) with StringUtils.isEmpty() if ((foo != null) !foo.equals()) with StringUtils.isNotEmpty() in Turbine. If you change this behaviour, we would get _very_ upset... :-) Regards Henning -- Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH [EMAIL PROTECTED] 49 9131 50 654 0 http://www.intermeta.de/ Java, perl, Solaris, Linux, xSP Consulting, Web Services freelance consultant -- Jakarta Turbine Development -- hero for hire --- Quote of the week: It is pointless to tell people anything when you know that they won't process the message. --- Jonathan Revusky - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [lang] Pre 2.0 StringUtils NPE changes
I think (and my personal experience) is that the isEmpty() acts as a short-cut for has a value; where value is not a whitespace character and is not null (thus the trim - whitespaces are not 'valued'). This is so subjective though, I'm sure hasValue() would quickly be shot down ;-) --- Janek Bogucki [EMAIL PROTECTED] wrote: On Fri, 2003-07-18 at 13:49, Hope, Matthew wrote: interesting problem... empty string has a very clear meaning in java, it is a non null String object of zero length. Does the entrenched user base merit retaining a non standard naming convention. or is Empty sufficiently entrenched to also mean null? (I don't think it is) I appreciate the dilemma but as a user would prefer it if the convention of empty stayed as and only . (but swallowing nulls and returning false id just the ticket) My 2 cents Matt This is the same as way I always interpret 'empty' in the context of a Java String object. A empty String is a zero length String, not a null object reference. I can easily see that equating a null to an empty String is convenient but I'd be happy to be explicit about this assumed equivalence in my code than have a method with a slightly misleading name. -Janek = Lance Lavandowska Http://www.brainopolis.com/ __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/discovery/src/java/org/apache/commons/discovery/resource/names DiscoverServiceNames.java
rsitze 2003/07/18 13:53:51 Modified:discovery/src/java/org/apache/commons/discovery/resource/names DiscoverServiceNames.java Log: import cleanup Revision ChangesPath 1.3 +0 -1 jakarta-commons/discovery/src/java/org/apache/commons/discovery/resource/names/DiscoverServiceNames.java Index: DiscoverServiceNames.java === RCS file: /home/cvs/jakarta-commons/discovery/src/java/org/apache/commons/discovery/resource/names/DiscoverServiceNames.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DiscoverServiceNames.java 5 May 2003 14:22:45 - 1.2 +++ DiscoverServiceNames.java 18 Jul 2003 20:53:50 - 1.3 @@ -59,7 +59,6 @@ import org.apache.commons.discovery.ResourceDiscover; import org.apache.commons.discovery.ResourceNameDiscover; -import org.apache.commons.discovery.ResourceNameIterator; import org.apache.commons.discovery.resource.ClassLoaders; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [lang] Pre 2.0 StringUtils NPE changes
Actually, I like have both: isEmpty(s) which means 'is or not' and hasValue or isSomething which means 'is a not a white space string or null' Gary -Original Message- From: Lavandowska [mailto:[EMAIL PROTECTED] Sent: Friday, July 18, 2003 13:46 To: Jakarta Commons Developers List Subject: RE: [lang] Pre 2.0 StringUtils NPE changes I think (and my personal experience) is that the isEmpty() acts as a short-cut for has a value; where value is not a whitespace character and is not null (thus the trim - whitespaces are not 'valued'). This is so subjective though, I'm sure hasValue() would quickly be shot down ;-) --- Janek Bogucki [EMAIL PROTECTED] wrote: On Fri, 2003-07-18 at 13:49, Hope, Matthew wrote: interesting problem... empty string has a very clear meaning in java, it is a non null String object of zero length. Does the entrenched user base merit retaining a non standard naming convention. or is Empty sufficiently entrenched to also mean null? (I don't think it is) I appreciate the dilemma but as a user would prefer it if the convention of empty stayed as and only . (but swallowing nulls and returning false id just the ticket) My 2 cents Matt This is the same as way I always interpret 'empty' in the context of a Java String object. A empty String is a zero length String, not a null object reference. I can easily see that equating a null to an empty String is convenient but I'd be happy to be explicit about this assumed equivalence in my code than have a method with a slightly misleading name. -Janek = Lance Lavandowska Http://www.brainopolis.com/ __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Daemon Project; set_caps patch and Daemon interface bug notice.
Hi Commons - great work on the Daemon sandbox project. I just put it into production in my environment today. I thought I would give some feedback on a few issues I had: * I have no idea what set_caps() is for, but in my environment it was breaking everything. I just commented it out and now it's working find. Should there be an IFDEF added? My patch is available here: http://threebit.net/tutorials/jakarta-daemon/set_caps.patch The two boxes I tried it on are both: # cat /etc/issue; uname -a Debian GNU 3.0 Linux zedd.threebit.net 2.2.19 #1 Sat Jun 9 13:04:06 EST 2001 i686 unknown * org.apache.commons.daemon.Daemon.init() defines a DaemonContext, but DaemonLoader is looking for init(String[]). Which is correct? I got my stuff to work by defining my own interface (though, since reflection is used, I could have gotten away with no interface at all). http://threebit.net/tutorials/jakarta-daemon/src/net/threebit/daemonexample/DaemonFixed.java * Oh, and here's a miniscule example of a running service. http://threebit.net/tutorials/jakarta-daemon/src/net/threebit/daemonexample/SampleService.java Cheers! Kevin. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[lang] StringUtils isEmpty summary(2)
Well the position changes again, but the desire to release remains constant. Here's what we know now: Currently isEmpty() means trim, true for , or null Currently isNotEmpty() means not and not null (no trim) An incompatability on trim that we are trying to solve. a) Changing the current functionality of either isEmpty() or isNotEmpty() is not acceptable to the user base. Deprecation is the only way to change. b) The method 'isEmpty' is desired by different people to mean any of the three possibilities, - true for - true for or null - trim, true for , or null And of course trim is actually quite a bad method for stripping whitespace as it only strips chars = 32. c) The term 'empty' is defined by Sun to mean . d) The isXxxOrNull() naming is disliked as too long even though its clear. e) Similarly isEmptyTrimmed() naming is too long. f) More people want isEmpty() to be true for null than false. Please don't reply to this thread unless you disagree with one of the above. Stephen - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [lang] StringUtils isEmpty summary(2)
I disagree with items d) and e)... I don't think either method name is too long, and as you said, the meaning is clear. Stephen Colebourne wrote: Well the position changes again, but the desire to release remains constant. Here's what we know now: Currently isEmpty() means trim, true for , or null Currently isNotEmpty() means not and not null (no trim) An incompatability on trim that we are trying to solve. a) Changing the current functionality of either isEmpty() or isNotEmpty() is not acceptable to the user base. Deprecation is the only way to change. b) The method 'isEmpty' is desired by different people to mean any of the three possibilities, - true for - true for or null - trim, true for , or null And of course trim is actually quite a bad method for stripping whitespace as it only strips chars = 32. c) The term 'empty' is defined by Sun to mean . d) The isXxxOrNull() naming is disliked as too long even though its clear. e) Similarly isEmptyTrimmed() naming is too long. f) More people want isEmpty() to be true for null than false. Please don't reply to this thread unless you disagree with one of the above. Stephen - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java
scolebourne2003/07/18 16:57:43 Modified:lang/src/test/org/apache/commons/lang StringUtilsTest.java lang/src/java/org/apache/commons/lang StringUtils.java Log: Fixed leftPad() and rightPad() to correctly handle multi letter pad strings Revision ChangesPath 1.27 +3 -1 jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java Index: StringUtilsTest.java === RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- StringUtilsTest.java 18 Jul 2003 02:06:23 - 1.26 +++ StringUtilsTest.java 18 Jul 2003 23:57:43 - 1.27 @@ -315,6 +315,7 @@ assertEquals( ab , StringUtils.center(ab, 4)); assertEquals(abcd, StringUtils.center(abcd, 2)); assertEquals( a , StringUtils.center(a, 4)); +assertEquals( a , StringUtils.center(a, 5)); assertEquals(null, StringUtils.center(null, -1, )); assertEquals(null, StringUtils.center(null, 4, )); @@ -323,6 +324,7 @@ assertEquals(abcd, StringUtils.center(abcd, 2, )); assertEquals( a , StringUtils.center(a, 4, )); assertEquals(yayz, StringUtils.center(a, 4, yz)); +assertEquals(yzyayzy, StringUtils.center(a, 7, yz)); try { StringUtils.center(abc, 4, null); fail(); 1.63 +43 -16 jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java Index: StringUtils.java === RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v retrieving revision 1.62 retrieving revision 1.63 diff -u -r1.62 -r1.63 --- StringUtils.java 18 Jul 2003 02:06:24 - 1.62 +++ StringUtils.java 18 Jul 2003 23:57:43 - 1.63 @@ -1967,18 +1967,31 @@ if (str == null) { return null; } -if (padStr == null || padStr.length() == 0) { +int padLen; +if (padStr == null || (padLen = padStr.length()) == 0) { throw new IllegalArgumentException(Pad String must not be null or empty); } -if (padStr.length() == 1 size - str.length() = PAD_LIMIT) { - return rightPad(str, size, padStr.charAt(0)); +int strLen = str.length(); +int pads = size - strLen; +if (padLen == 1 pads = PAD_LIMIT) { +return rightPad(str, size, padStr.charAt(0)); } - -size = (size - str.length()) / padStr.length(); -if (size 0) { -str += repeat(padStr, size); + +if (pads = 0) { +return str; // returns original String when possible +} +if (pads == padLen) { +return str.concat(padStr); +} else if (pads padLen) { +return str.concat(padStr.substring(0, pads)); +} else { +char[] padding = new char[pads]; +char[] padChars = padStr.toCharArray(); +for (int i = 0; i pads; i++) { +padding[i] = padChars[i % padLen]; +} +return str.concat(new String(padding)); } -return str; } /** @@ -2041,7 +2054,7 @@ return str; // returns original String when possible } if (pads PAD_LIMIT) { -return leftPad(str, size, ' '); +return leftPad(str, size, String.valueOf(padChar)); } return padding(pads, padChar).concat(str); } @@ -2073,17 +2086,31 @@ if (str == null) { return null; } -if (padStr == null || padStr.length() == 0) { +int padLen; +if (padStr == null || (padLen = padStr.length()) == 0) { throw new IllegalArgumentException(Pad String must not be null or empty); } -if (padStr.length() == 1 size - str.length() = PAD_LIMIT) { +int strLen = str.length(); +int pads = size - strLen; +if (padLen == 1 pads = PAD_LIMIT) { return leftPad(str, size, padStr.charAt(0)); } -size = (size - str.length()) / padStr.length(); -if (size 0) { -str = repeat(padStr, size) + str; + +if (pads = 0) { +return str; // returns original String when possible +} +if (pads == padLen) { +return padStr.concat(str); +} else if (pads padLen) { +return padStr.substring(0, pads).concat(str); +} else { +char[] padding = new char[pads]; +char[] padChars =
[functor] Iterator and Generator
As far as I can tell, the role of generator is essentially that of an Iterator, it provides a mechanism for doing something to each element in a collection (not necessarily a Collection). The major differences being: * Generator has a close method (currently stop()). This is used for things that need to clean up after themselves a little bit, like closing files or sockets. EachLine was an example of this. * Generator has convenience methods for internal iteration (Algorithms.*) * Generator doesn't have a next() function, currently it only exposes the internal iteration methods like run(UnaryProcedure) It seems to me that it is possible to simplify and unify these two concepts with an implementation like the following: interface Generator extends Iterator { /** stops this Generator, freeing any associated resources */ void stop(); // the convenience methods, if desired at this level Generator apply(UnaryFunction f); boolean contains(UnaryPredicate p); Object detect(UnaryPredicate p); // etc. } abstract class BaseGenerator implements Generator { public abstract Object next(); public void remove() { throw new UnsupportedOperationException(); } public boolean hasNext() { return !(isStopped()); } public void stop() { closed = true; } // insert implementations of the convenience methods here, e.g., public void foreach(UnaryProcedure proc) { while(hasNext()) { proc.execute(next()); } } /** note this method is protected here */ protected boolean isStopped() { return closed; } protected void finalize() { if(!isStopped()) { stop(); } } private boolean closed = false; } Implementations of Generator would then look something like: /** * This one is infinite, if you don't call * stop(), it'll generate for ever. */ class RandomIntegers extends BaseGenerator { public Object next() { return new Integer(random.nextInt()); } private Random random = new Random(); } or, /** * This is finite and doesn't really need * to be manually stopped. It's really no * better than an Iterator, except it adds * the convenience methods like: * Elements.from(myArray).contains(myPredicate); */ class Elements extends BaseGenerator { public Elements(Object[] values) { this.values = values; this.next= 0; } public boolean hasNext() { return !isStopped() (next values.length); } public Object next() { return values[next++]; } public static Elements from(Object[] values) { return new Elements(values); } /** You could override stop() here if you want: */ public void stop() { values = null; super.stop(); } private int next; private Object[] values; } or, /** * This one actually needs to be stopped, * although the finalizer will protect * you a little bit. (And we call * stop() internally if you iterate all * the way to the end of the stream.) * * You can treat this as an Iterator * (i.e., pass it off to a method that * expects an Iterator), but you'll * have to follow the close what you open * strategy and call stop() yourself. */ class Lines extends BaseGenerator { public Lines(BufferedReader in) { this.in = in; } public boolean hasNext() { return !isStopped() (nextSet || setNext()); } public Object next() { if(hasNext()) { nextSet = false; return next; } else { throw new NoSucheElementException(); } } public void stop() { in.close(); in = null; next = null; super.stop(); } private boolean setNext() { next = in.readLine(); if(null == next) { stop(); nextSet = false; } else { nextSet = true; } return nextSet; } private boolean nextSet = false; private String next = null; private BufferedReader in; } etc. Is there a disadvantage to doing it this way that I'm missing? - Rod http://radio.weblogs.com/0122027/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java
scolebourne2003/07/18 17:22:51 Modified:lang/src/test/org/apache/commons/lang StringUtilsTest.java lang/src/java/org/apache/commons/lang StringUtils.java Log: Minor performance tweaks, and some extra tests Revision ChangesPath 1.28 +20 -1 jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java Index: StringUtilsTest.java === RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- StringUtilsTest.java 18 Jul 2003 23:57:43 - 1.27 +++ StringUtilsTest.java 19 Jul 2003 00:22:50 - 1.28 @@ -311,6 +311,9 @@ public void testCenter() { assertEquals(null, StringUtils.center(null, -1)); assertEquals(null, StringUtils.center(null, 4)); +assertEquals(ab, StringUtils.center(ab, 0)); +assertEquals(ab, StringUtils.center(ab, -1)); +assertEquals(ab, StringUtils.center(ab, 1)); assertEquals(, StringUtils.center(, 4)); assertEquals( ab , StringUtils.center(ab, 4)); assertEquals(abcd, StringUtils.center(abcd, 2)); @@ -319,6 +322,9 @@ assertEquals(null, StringUtils.center(null, -1, )); assertEquals(null, StringUtils.center(null, 4, )); +assertEquals(ab, StringUtils.center(ab, 0, )); +assertEquals(ab, StringUtils.center(ab, -1, )); +assertEquals(ab, StringUtils.center(ab, 1, )); assertEquals(, StringUtils.center(, 4, )); assertEquals( ab , StringUtils.center(ab, 4, )); assertEquals(abcd, StringUtils.center(abcd, 2, )); @@ -326,6 +332,11 @@ assertEquals(yayz, StringUtils.center(a, 4, yz)); assertEquals(yzyayzy, StringUtils.center(a, 7, yz)); try { +StringUtils.center(null, 4, null); +fail(); +} catch (IllegalArgumentException ex) { +} +try { StringUtils.center(abc, 4, null); fail(); } catch (IllegalArgumentException ex) { @@ -477,6 +488,10 @@ assertEquals(123456-+~, StringUtils.rightPad (123456, 9, -+~) ); assertEquals(123456-+, StringUtils.rightPad (123456, 8, -+~) ); try { +StringUtils.rightPad(null, 6, null); +fail(); +} catch (IllegalArgumentException ex) {} +try { StringUtils.rightPad(123456, 6, null); fail(); } catch (IllegalArgumentException ex) {} @@ -492,6 +507,10 @@ assertEquals(-+-+1234, StringUtils.leftPad(1234, 8, -+) ); assertEquals(-+~123456, StringUtils.leftPad(123456, 9, -+~) ); assertEquals(-+123456, StringUtils.leftPad(123456, 8, -+~) ); +try { +StringUtils.leftPad(null, 6, null); +fail(); +} catch (IllegalArgumentException ex) {} try { StringUtils.leftPad(123456, 6, null); fail(); 1.64 +67 -75 jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java Index: StringUtils.java === RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v retrieving revision 1.63 retrieving revision 1.64 diff -u -r1.63 -r1.64 --- StringUtils.java 18 Jul 2003 23:57:43 - 1.63 +++ StringUtils.java 19 Jul 2003 00:22:50 - 1.64 @@ -1954,6 +1954,7 @@ * StringUtils.rightPad(bat, -1, yz) = bat * StringUtils.rightPad(bat, 1, null) = IllegalArgumentException * StringUtils.rightPad(bat, 1, )= IllegalArgumentException + * StringUtils.rightPad(null, 1, ) = IllegalArgumentException * /pre * * @param str the String to pad out, may be null @@ -1964,13 +1965,13 @@ * @throws IllegalArgumentException if padStr is the empty String or null */ public static String rightPad(String str, int size, String padStr) { -if (str == null) { -return null; -} int padLen; if (padStr == null || (padLen = padStr.length()) == 0) { throw new IllegalArgumentException(Pad String must not be null or empty); } +if (str == null) { +return null; +} int strLen = str.length(); int pads = size - strLen; if (padLen == 1 pads = PAD_LIMIT) { @@ -2073,6 +2074,7 @@ * StringUtils.leftPad(bat, -1, yz) = bat * StringUtils.leftPad(bat, 1, null) = IllegalArgumentException * StringUtils.leftPad(bat, 1, )= IllegalArgumentException + * StringUtils.leftPad(null, 1, ) =
RE: [Modeler] Next Release plan? (1.1?)
Am trying to chase this down... Thanks, dims --- Shapira, Yoav [EMAIL PROTECTED] wrote: Howdy, I was never given karma as a modeler (or commons) committer, so I was never able to go ahead with the release. It's still a bottleneck for tomcat 5 ;( I have no idea why this happened, as the vote took place and I emailed the requisite people (PMC etc.), but no luck ;( Yoav Shapira Millennium ChemInformatics -Original Message- From: Davanum Srinivas [mailto:[EMAIL PROTECTED] Sent: Friday, July 18, 2003 1:46 PM To: [EMAIL PROTECTED] Subject: [Modeler] Next Release plan? (1.1?) Yoav, others modeler-folks, Is there a date for 1.1 release of Modeler? Thanks, dims = Davanum Srinivas - http://webservices.apache.org/~dims/ __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] = Davanum Srinivas - http://webservices.apache.org/~dims/ __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections CollectionUtils.java
scolebourne2003/07/18 17:30:08 Modified:collections/src/java/org/apache/commons/collections CollectionUtils.java Log: Javadoc improvement prompted by K.C. Baltz Revision ChangesPath 1.33 +5 -3 jakarta-commons/collections/src/java/org/apache/commons/collections/CollectionUtils.java Index: CollectionUtils.java === RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/CollectionUtils.java,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- CollectionUtils.java 11 May 2003 14:12:46 - 1.32 +++ CollectionUtils.java 19 Jul 2003 00:30:08 - 1.33 @@ -909,7 +909,9 @@ /** * Returns a predicated collection backed by the given collection. * Only objects that pass the test in the given predicate can be - * added to the collection. + * added to the collection. Throws an IllegalArgumentException on adding + * an element if it is invalid. + * p * It is important not to use the original collection after invoking this * method, as it is a backdoor for adding unvalidated objects. * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [lang] Proposal (2): isEmpty
I could live with #1, though I'd rather the current contract (the trim() functionality) didn't change (whine whine whine). Or #2 is fine also, but I'd suggest another name (StringTests connotes Unit tests to me), maybe StringChecks or CheckString? Lance --- Stephen Colebourne [EMAIL PROTECTED] wrote: Proposal for methods: - isEmpty() - true for or null - isNotEmpty() - opposite - isEmptyNN() - true for - isBlank() - trims - true for , or null - isNotBlank() - opposite - isBlankNN() - trims - true foror - isWhitespace() - true for all whitespace, or null - isNotWhitespace() - opposite - isWhitespaceNN() - true for all whitespace or Where NN means NotNull. This covers all the cases, and takes the working premise that more people want null to be true than false. Proposal for location: 1) In StringUtils. Incompatable change to isEmpty() (no longer trims) and isWhitespace() (null now true). 2) In StringTests (new class). Deprecate StringUtils isEmpty/isNotEmpty. = Lance Lavandowska Http://www.brainopolis.com/ __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [lang] StringUtils isEmpty summary(2)
I likewise disagree on d (I rather liked isNotNullOrEmpty - despite being long. Oops, isNotEmptyOrNull). Also, I wanted to clarify my position as depicted in b: not that all whitespace is removed, but as a String.trim() removes whitespace on either end. If the String is all whitespace, the result is a true empty String (). Thus my position that isEmpty() should trim. Lance --- __matthewHawthorne [EMAIL PROTECTED] wrote: I disagree with items d) and e)... I don't think either method name is too long, and as you said, the meaning is clear. Stephen Colebourne wrote: b) The method 'isEmpty' is desired by different people to mean any snip And of course trim is actually quite a bad method for stripping whitespace as it only strips chars = 32. __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang/builder CompareToBuilder.java
ggregory2003/07/18 20:25:39 Modified:lang/src/java/org/apache/commons/lang/builder CompareToBuilder.java Log: Severity Description ResourceIn Folder Location Creation Time The static method setAccessible(AccessibleObject[], boolean) from the type AccessibleObject should be accessed directly CompareToBuilder.java Apache Jakarta Commons/lang/src/java/org/apache/commons/lang/builderline 254July 18, 2003 7:11:22 PM Revision ChangesPath 1.17 +7 -6 jakarta-commons/lang/src/java/org/apache/commons/lang/builder/CompareToBuilder.java Index: CompareToBuilder.java === RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/builder/CompareToBuilder.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- CompareToBuilder.java 14 Jul 2003 22:25:03 - 1.16 +++ CompareToBuilder.java 19 Jul 2003 03:25:38 - 1.17 @@ -53,6 +53,7 @@ */ package org.apache.commons.lang.builder; +import java.lang.reflect.AccessibleObject; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.Comparator; @@ -91,7 +92,7 @@ * * pAlternatively, there is a method that uses reflection to determine * the fields to test. Because these fields are usually private, the method, - * codereflectionCompare/code, uses codeField.setAccessible/code to change + * codereflectionCompare/code, uses codeAccessibleObject.setAccessible/code to change * the visibility of the fields. This will fail under a security manager, * unless the appropriate permissions are set. It is also slower than testing * explicitly./p @@ -134,7 +135,7 @@ * pThis method uses reflection to determine the ordering between two * Objects./p * - * pIt uses codeField.setAccessible/code to gain access to private + * pIt uses codeAccessibleObject.setAccessible/code to gain access to private * fields. This means that it will throw a security exception if run under * a security manger, if the permissions are not set up correctly. It is * also not as efficient as testing explicitly./p @@ -161,7 +162,7 @@ * pThis method uses reflection to determine if the two Objects are * equal./p * - * pIt uses codeField.setAccessible/code to gain access to private + * pIt uses codeAccessibleObject.setAccessible/code to gain access to private * fields. This means that it will throw a security exception if run under * a security manger, if the permissions are not set up correctly. It is * also not as efficient as testing explicitly./p @@ -190,7 +191,7 @@ * pThis method uses reflection to determine if the two Objects are * equal./p * - * pIt uses codeField.setAccessible/code to gain access to private + * pIt uses codeAccessibleObject.setAccessible/code to gain access to private * fields. This means that it will throw a security exception if run under * a security manger, if the permissions are not set up correctly. It is * also not as efficient as testing explicitly./p @@ -251,7 +252,7 @@ CompareToBuilder builder, boolean useTransients) { Field[] fields = clazz.getDeclaredFields(); -Field.setAccessible(fields, true); +AccessibleObject.setAccessible(fields, true); for (int i = 0; i fields.length builder.comparison == 0; i++) { Field f = fields[i]; if ((f.getName().indexOf('$') == -1) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Daemon Project; set_caps patch and Daemon interface bug notice.
Kevin O'Donnell [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi Commons - great work on the Daemon sandbox project. I just put it into production in my environment today. I thought I would give some feedback on a few issues I had: * I have no idea what set_caps() is for, but in my environment it was breaking everything. I just commented it out and now it's working find. Should there be an IFDEF added? My patch is available here: http://threebit.net/tutorials/jakarta-daemon/set_caps.patch I don't have access to a Debian box to investigate further. If you could investigate (or at least post what goes wrong), it would be very helpful. At worst, we could change the configure scripts to detect Debian. The two boxes I tried it on are both: # cat /etc/issue; uname -a Debian GNU 3.0 Linux zedd.threebit.net 2.2.19 #1 Sat Jun 9 13:04:06 EST 2001 i686 unknown * org.apache.commons.daemon.Daemon.init() defines a DaemonContext, but DaemonLoader is looking for init(String[]). Which is correct? I got my stuff to work by defining my own interface (though, since reflection is used, I could have gotten away with no interface at all). http://threebit.net/tutorials/jakarta-daemon/src/net/threebit/daemonexample/ DaemonFixed.java A common problem with OS projects: The docs lag what it actually does. The daemon has been extended to support classes that don't implement Daemon (such as jakarta-tomcat-5) by calling init(String []) in this case. AFAIK, the DaemonContext call should work as well if the class implements Daemon (but since I use this for Tomcat mostly, I haven't tried recently). * Oh, and here's a miniscule example of a running service. http://threebit.net/tutorials/jakarta-daemon/src/net/threebit/daemonexample/ SampleService.java Cheers! Kevin. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [functor] Iterator and Generator
At first blush (and not having any experience actually using Generators directly) I guess the questionability for me lies in the issue of how often would someone want to create a Generator that is not an Iterator. -Mark Rodney Waldhoff wrote: As far as I can tell, the role of generator is essentially that of an Iterator, it provides a mechanism for doing something to each element in a collection (not necessarily a Collection). The major differences being: * Generator has a close method (currently stop()). This is used for things that need to clean up after themselves a little bit, like closing files or sockets. EachLine was an example of this. * Generator has convenience methods for internal iteration (Algorithms.*) * Generator doesn't have a next() function, currently it only exposes the internal iteration methods like run(UnaryProcedure) It seems to me that it is possible to simplify and unify these two concepts with an implementation like the following: interface Generator extends Iterator { /** stops this Generator, freeing any associated resources */ void stop(); // the convenience methods, if desired at this level Generator apply(UnaryFunction f); boolean contains(UnaryPredicate p); Object detect(UnaryPredicate p); // etc. } abstract class BaseGenerator implements Generator { public abstract Object next(); public void remove() { throw new UnsupportedOperationException(); } public boolean hasNext() { return !(isStopped()); } public void stop() { closed = true; } // insert implementations of the convenience methods here, e.g., public void foreach(UnaryProcedure proc) { while(hasNext()) { proc.execute(next()); } } /** note this method is protected here */ protected boolean isStopped() { return closed; } protected void finalize() { if(!isStopped()) { stop(); } } private boolean closed = false; } Implementations of Generator would then look something like: /** * This one is infinite, if you don't call * stop(), it'll generate for ever. */ class RandomIntegers extends BaseGenerator { public Object next() { return new Integer(random.nextInt()); } private Random random = new Random(); } or, /** * This is finite and doesn't really need * to be manually stopped. It's really no * better than an Iterator, except it adds * the convenience methods like: * Elements.from(myArray).contains(myPredicate); */ class Elements extends BaseGenerator { public Elements(Object[] values) { this.values = values; this.next= 0; } public boolean hasNext() { return !isStopped() (next values.length); } public Object next() { return values[next++]; } public static Elements from(Object[] values) { return new Elements(values); } /** You could override stop() here if you want: */ public void stop() { values = null; super.stop(); } private int next; private Object[] values; } or, /** * This one actually needs to be stopped, * although the finalizer will protect * you a little bit. (And we call * stop() internally if you iterate all * the way to the end of the stream.) * * You can treat this as an Iterator * (i.e., pass it off to a method that * expects an Iterator), but you'll * have to follow the close what you open * strategy and call stop() yourself. */ class Lines extends BaseGenerator { public Lines(BufferedReader in) { this.in = in; } public boolean hasNext() { return !isStopped() (nextSet || setNext()); } public Object next() { if(hasNext()) { nextSet = false; return next; } else { throw new NoSucheElementException(); } } public void stop() { in.close(); in = null; next = null; super.stop(); } private boolean setNext() { next = in.readLine(); if(null == next) { stop(); nextSet = false; } else { nextSet = true; } return nextSet; } private boolean nextSet = false; private String next = null; private BufferedReader in; } etc. Is there a disadvantage to doing it this way that I'm missing? - Rod http://radio.weblogs.com/0122027/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [lang] Proposal (2): isEmpty
The comments at http://raibledesigns.com/comments/rd/minimal/commons_lang_stringutils are a good reason for how surprisingly nice people find isEmpty. On Fri, 18 Jul 2003, Stephen Colebourne wrote: Proposal for methods: - isEmpty() - true for or null - isNotEmpty() - opposite - isEmptyNN() - true for +1. Especially +1 for isEmpty retaining much the same functionality. - isBlank() - trims - true for , or null - isNotBlank() - opposite - isBlankNN() - trims - true foror +1 I think this wording works. While I think people do expect isEmpty to be false for null, I don't think they expect it to go trimming on them usually. - isWhitespace() - true for all whitespace, or null - isNotWhitespace() - opposite - isWhitespaceNN() - true for all whitespace or +1 Where NN means NotNull. This covers all the cases, and takes the working premise that more people want null to be true than false. Proposal for location: 1) In StringUtils. Incompatable change to isEmpty() (no longer trims) and isWhitespace() (null now true). +1 2) In StringTests (new class). Deprecate StringUtils isEmpty/isNotEmpty. -1. I don't think we want to overly confuse the issue with this yet. Breaking StringUtils up is a 3.0 thing if desired I believe. I prefer the incompatable change #1. We are offering a simply named alternative. Also, some people already don't expect isEmpty to trim. And Tapestry and Turbine should both be OK. Agreed. Hen - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [lang] Proposal (2): isEmpty
On Fri, 18 Jul 2003, Lavandowska wrote: I could live with #1, though I'd rather the current contract (the trim() functionality) didn't change (whine whine whine). isBlank! Just think of the joy you'll have as you switch to it. It's such a sexier name. Or #2 is fine also, but I'd suggest another name (StringTests connotes Unit tests to me), maybe StringChecks or CheckString? 2004! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [lang] Proposal (2): isEmpty
On Fri, 18 Jul 2003, Gary Gregory wrote: I like #2. Boo! ;) Seriously for a moment. I think the usage of commons-lang is beginning to hit the up-curve. It's creeping into projects and people are starting to talk about it [along with other Commons things] outside of the usual circles. A 2.0 soon will really take off I believe. A clarification please: I do not see why any isWhitespace methods are needed since the isBlank methods trim()'s their arguments. isBlank(null) returns true isWS(null) returns true isBlank() returns true isWS() returns true isBlank( ) returns true isWS( ) returns true isBlank(\t\n) returns true isWS(\t\n) returns true isBlank( Hello ) returns false isWS( Hello ) returns false Am I missing something? Re-reading Stephen's suggestion, only thing I can see is that he suggests that isBlank(\t\n) would not be true. However a quick test shows that trim() removes all whitespace, so I'm a believer in Gary's point. Hen - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Downloading
Hi.. I am new to httpclient. I am developing a program that download a file. I've got the response using : InputStream bodyStream = postMethod.getResponseBodyAsStream(); When I write the bodyStream to a file, it write the whole response things. (I only want to save the file). Is there anyway I could get only the content of the file ? I attached my downloaded file. many thanks in advance. Cheers, quent Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month!- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: InputStream part source
David Sean Taylor wrote: This implies that I can't contribute the InputStreamPartSource to your codebase as is, since it will be coupled to my particular InputStream factory. Right, because the InputStreamPartSource can (by design) not fulfill the contract of the createInputStream method without buffering. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DO NOT REPLY [Bug 11240] - Cookies with ',' in the value string is not parsed correctly in some cases
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11240. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11240 Cookies with ',' in the value string is not parsed correctly in some cases --- Additional Comments From [EMAIL PROTECTED] 2003-07-18 08:10 --- Created an attachment (id=7363) Netscape spec patch (take 1) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DO NOT REPLY [Bug 19618] - URI class constructors need revision, optimization
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618 URI class constructors need revision, optimization --- Additional Comments From [EMAIL PROTECTED] 2003-07-18 08:55 --- Created an attachment (id=7366) Patch (take 1) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DO NOT REPLY [Bug 10957] - Change Header/HeaderElement to handle a list as the value
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10957. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10957 Change Header/HeaderElement to handle a list as the value [EMAIL PROTECTED] changed: What|Removed |Added Target Milestone|2.1 Final |3.0 Final - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DO NOT REPLY [Bug 10793] - User definable default headers support
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10793. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10793 User definable default headers support [EMAIL PROTECTED] changed: What|Removed |Added Target Milestone|2.1 Final |3.0 Final - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DO NOT REPLY [Bug 19618] - URI class constructors need revision, optimization
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618 URI class constructors need revision, optimization --- Additional Comments From [EMAIL PROTECTED] 2003-07-18 12:36 --- I think these are good changes. We should probably also change the URI(URI, String) constructor to boot. I think we might also want to create some tests for parsing unescaped URIs. I have no idea how well this functionality works. Mike - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DO NOT REPLY [Bug 19618] - URI class constructors need revision, optimization
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618 URI class constructors need revision, optimization --- Additional Comments From [EMAIL PROTECTED] 2003-07-18 12:38 --- Actually, I guess all of the constructors should be changed to add a boolean flag. Mike - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DO NOT REPLY [Bug 10792] - Plug-in authentication modules
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10792. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10792 Plug-in authentication modules [EMAIL PROTECTED] changed: What|Removed |Added CC||[EMAIL PROTECTED] Summary|Plug-in authentication |Plug-in authentication |modules |modules - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DO NOT REPLY [Bug 19618] - URI class constructors need revision, optimization
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618 URI class constructors need revision, optimization --- Additional Comments From [EMAIL PROTECTED] 2003-07-18 13:05 --- Good point. I'll revise the remaining URI constructors. As to test cases, I am afraid I do not possess the required detailed knowledge of the URI spec. Sung-Gu does not do test cases for free. So, I really do not know. Oleg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DO NOT REPLY [Bug 11240] - Cookies with ',' in the value string is not parsed correctly in some cases
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11240. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11240 Cookies with ',' in the value string is not parsed correctly in some cases --- Additional Comments From [EMAIL PROTECTED] 2003-07-18 13:11 --- Fair enough. I will provide a test case shortly Oleg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Downloading
Hi Odi, Thanks for your quick reply. I have already succeed uploading file using MultipartPostMethod. I have to download the file back for future reference. I have already tried downloading the file both using GetMethod and PostMethod, but again I get the whole response file (not the content). Thanks. Quent Ortwin_Glück [EMAIL PROTECTED] wrote: Quent, I guess you are trying to make a file upload with Multipart MIME encoded attachments. HttpClient can not parse such responses, but it can send such requests. Consider using the Commons FileUpload component for your problem. AFAIK the FileUpload guys have a release pending and the current code is stable. Odi Querent wrote: Hi.. I am new to httpclient. I am developing a program that download a file. I've got the response using : InputStream bodyStream = postMethod.getResponseBodyAsStream(); When I write the bodyStream to a file, it write the whole response things. (I only want to save the file). Is there anyway I could get only the content of the file ? I attached my downloaded file. Unfortunately attachments 100 KB get stripped by the list. many thanks in advance. Cheers, quent -- _ NOSE applied intelligence ag [www] http://www.nose.ch ortwin glück [email] [EMAIL PROTECTED] hardturmstrasse 171 [pgp key] 0x81CF3416 8005 zurich [office] +41-1-277 57 35 switzerland [fax] +41-1-277 57 12 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month!
Re: DO NOT REPLY [Bug 11240] - Cookies with ',' in the valuestring is not parsed correctly in some cases
Wow, all that without getting 5$ :-) [EMAIL PROTECTED] wrote: --- Additional Comments From [EMAIL PROTECTED] 2003-07-18 13:11 --- Fair enough. I will provide a test case shortly Oleg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Réf. : Re: Downloading
I have already tried downloading the file both using GetMethod and PostMethod, but again I get the whole response file (not the content). For me, get the content of downloaded file works fine with getResponseBodyAsStream() method (I use PostMethod) Headers can be accessed just with getResponseHeader() method ... Damien
Re: Downloading
Querent, let me put numbers in front of your actions (just for easier reference): 1. I have already succeed uploading file using MultipartPostMethod. 2. I have to download the file back for future reference. 3. I have already tried downloading the file both using GetMethod and PostMethod, but again I get the whole response file (not the content). So in 1 you upload file A to WHERE? I guess a servlet and then store it on the server. That's where you must use Commons FileUpload component to handle the Multipart MIME encoding and extract the uploaded file. What you see in 2 is --surprise, surprise-- only what you stored on the server. Check the file on the server to see what I mean. Any magic involved? Odi - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DO NOT REPLY [Bug 19618] - URI class constructors need revision, optimization
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618 URI class constructors need revision, optimization --- Additional Comments From [EMAIL PROTECTED] 2003-07-18 13:36 --- I will put some more test cases on my todo list. Mike - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Downloading
Quent, It sounds like the server is not processing the multi-part post and is just storing all bytes received as the file. Perhaps a multi-part message is not required. Have you tried just sending the file as the content of a plain PostMethod? Mike Querent wrote: Hi Odi, Thanks for your quick reply. I have already succeed uploading file using MultipartPostMethod. I have to download the file back for future reference. I have already tried downloading the file both using GetMethod and PostMethod, but again I get the whole response file (not the content). Thanks. Quent Ortwin_Glück [EMAIL PROTECTED] wrote: Quent, I guess you are trying to make a file upload with Multipart MIME encoded attachments. HttpClient can not parse such responses, but it can send such requests. Consider using the Commons FileUpload component for your problem. AFAIK the FileUpload guys have a release pending and the current code is stable. Odi Querent wrote: Hi.. I am new to httpclient. I am developing a program that download a file. I've got the response using : InputStream bodyStream = postMethod.getResponseBodyAsStream(); When I write the bodyStream to a file, it write the whole response things. (I only want to save the file). Is there anyway I could get only the content of the file ? I attached my downloaded file. Unfortunately attachments 100 KB get stripped by the list. many thanks in advance. Cheers, quent - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Documentation
The documentation about Encodings should include information on Cookies as well. Currently the Headers section says: The headers of a HTTP request or response must be in US-ASCII format. It is not possible to use non US-ASCII characters in the header of a request or response. Generally this is not an issue however, because the HTTP headers are designed to facilite the transfer of data rather than to actually transfer the data itself. We should incorporate the knowledge about cookies here (since cookies are headers). Unfortunately my cookie karma is low. Oleg, I guess you have most experience here. Is there anything we must mention? Odi -- _ NOSE applied intelligence ag [www] http://www.nose.ch ortwin glück [email] [EMAIL PROTECTED] hardturmstrasse 171 [pgp key] 0x81CF3416 8005 zurich [office] +41-1-277 57 35 switzerland [fax] +41-1-277 57 12 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DO NOT REPLY [Bug 19618] - URI class constructors need revision, optimization
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618 URI class constructors need revision, optimization --- Additional Comments From [EMAIL PROTECTED] 2003-07-18 15:13 --- Created an attachment (id=7374) Patch (take 2) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DO NOT REPLY [Bug 19618] - URI class constructors need revision, optimization
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618 URI class constructors need revision, optimization --- Additional Comments From [EMAIL PROTECTED] 2003-07-18 15:14 --- I guess it was bit more that I bargained for. I really have no idea whether those 'component' URI constructors expect escaped or unescaped strings as input. I tend to lean toward just letting them be for the moment. Oleg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Downloading
Odi, Just to clear things up. 1. Upload file to a servlet and store in the server. (no problem at all) 2. Download the file through a servlet as well with parameter to get specific file. The thing is I don't know how the server store it and I don't have access to check it. It all works well if I'm downloading using browsers. i guess the browser can encode the contenttype. Damien, When u're using getResponseBodyAsStream() method, do u get something like: --10585088040931058508804093 Content-type: application/octet-stream Content-disposition: attachment;filename=1.txt in the beginning of ur file ? They are not part of the headers. i tried to print the headers and it's not that. Mike, The uploding file works fine. I am having problem downloading the file using PostMethod Thank you all quent - Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month!
RE: Documentation
Odi, You are absolutely right. We have to mention in the encoding guide or/and cookie guide that cookies must conform to encoding requirements for the HTTP headers, that is, 'funny' non-US-ASCII characters will be lost. Oleg -Original Message- From: Ortwin Glück [mailto:[EMAIL PROTECTED] Sent: Friday, July 18, 2003 3:50 PM To: Commons HttpClient Project Subject: Documentation The documentation about Encodings should include information on Cookies as well. Currently the Headers section says: The headers of a HTTP request or response must be in US-ASCII format. It is not possible to use non US-ASCII characters in the header of a request or response. Generally this is not an issue however, because the HTTP headers are designed to facilite the transfer of data rather than to actually transfer the data itself. We should incorporate the knowledge about cookies here (since cookies are headers). Unfortunately my cookie karma is low. Oleg, I guess you have most experience here. Is there anything we must mention? Odi -- _ NOSE applied intelligence ag [www] http://www.nose.ch ortwin glück [email] [EMAIL PROTECTED] hardturmstrasse 171 [pgp key] 0x81CF3416 8005 zurich [office] +41-1-277 57 35 switzerland [fax] +41-1-277 57 12 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [httpclient][session][how to create a session]
Hi Vincent, If you want to know how to use the same connection for multiple requests, use the recycle method that should be available for the request method you're using. Just keep in mind that all attributes for the connection are cleared - except the host and authentication, if I remember correctly. So, if your next request is for the same path as the previous request, then you'll have to save it (getPath()), recycle the request, and then reset it (setPath()). Later. Dennis -Original Message- From: vincent chappuis To: [EMAIL PROTECTED] Sent: 7/18/03 11:39 AM Subject: [httpclient][session][how to create a session] Hi all, I'm a beginer in HttpClient. My problem is the next one : How to keep a session using HttpClient API ? Best regards
RE: [httpclient][session][how to create a session]
Vncent, Have a look at the HttpState class. You can keep an instance of HttpState class in order to preserve HTTP state information between method invocations. HttpState mystate = new HttpState(); HttpClient httpclient = new HttpClient(); Cookie mycookie = new Cookie(.foobar.com, mycookie, stuff, /, null, false); mystate.addCookie(mycookie); mystate.setCookiePolicy(CookiePolicy.RFC2109); httpclient.setState(mystate); Hope this helps Oleg -Original Message- From: vincent chappuis [mailto:[EMAIL PROTECTED] Sent: Friday, July 18, 2003 5:39 PM To: [EMAIL PROTECTED] Subject: [httpclient][session][how to create a session] Hi all, I'm a beginer in HttpClient. My problem is the next one : How to keep a session using HttpClient API ? Best regards - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [httpclient][session][how to create a session]
Hi Dennis. thanks very much for your response. I use 2 request for the same httpClient. a GetMethod and then a MultipartPostMethod. GetMethod connet to the serveur and do an authenitcation. The seveur application open a session and pull some information in it (like current user) Then, I execute the MultipartPostMethod. The pointed URL must get info in session like the current user. But it don't retrieve it. Because this second request does not found the session created by sending the first method (GetMethod) So I can not use the recycle method Do you have any idea about how to resolve this problem? Best regards Vincent - Original Message - From: Norrod, Dennis G Mr Veridian-MRJ [EMAIL PROTECTED] To: 'vincent chappuis ' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Friday, July 18, 2003 6:37 PM Subject: RE: [httpclient][session][how to create a session] Hi Vincent, If you want to know how to use the same connection for multiple requests, use the recycle method that should be available for the request method you're using. Just keep in mind that all attributes for the connection are cleared - except the host and authentication, if I remember correctly. So, if your next request is for the same path as the previous request, then you'll have to save it (getPath()), recycle the request, and then reset it (setPath()). Later. Dennis -Original Message- From: vincent chappuis To: [EMAIL PROTECTED] Sent: 7/18/03 11:39 AM Subject: [httpclient][session][how to create a session] Hi all, I'm a beginer in HttpClient. My problem is the next one : How to keep a session using HttpClient API ? Best regards - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [httpclient][session][how to create a session]
Hi Oleg, It works fine! thank you very much. Like that, I keep the session. Best regards Vincent - Original Message - From: Kalnichevski, Oleg [EMAIL PROTECTED] To: Commons HttpClient Project [EMAIL PROTECTED] Sent: Friday, July 18, 2003 6:44 PM Subject: RE: [httpclient][session][how to create a session] Vncent, Have a look at the HttpState class. You can keep an instance of HttpState class in order to preserve HTTP state information between method invocations. HttpState mystate = new HttpState(); HttpClient httpclient = new HttpClient(); Cookie mycookie = new Cookie(.foobar.com, mycookie, stuff, /, null, false); mystate.addCookie(mycookie); mystate.setCookiePolicy(CookiePolicy.RFC2109); httpclient.setState(mystate); Hope this helps Oleg -Original Message- From: vincent chappuis [mailto:[EMAIL PROTECTED] Sent: Friday, July 18, 2003 5:39 PM To: [EMAIL PROTECTED] Subject: [httpclient][session][how to create a session] Hi all, I'm a beginer in HttpClient. My problem is the next one : How to keep a session using HttpClient API ? Best regards - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DO NOT REPLY [Bug 11240] - Cookies with ',' in the value string is not parsed correctly in some cases
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11240. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11240 Cookies with ',' in the value string is not parsed correctly in some cases --- Additional Comments From [EMAIL PROTECTED] 2003-07-18 18:48 --- Looks good, though I haven't had a chance to run it yet (my up-to-date system is at home). One suggestion: add a comment or two describing the non-default behavior of this method such as comma handling, and maybe an @see that points to the relevant part of the Netscape cookie spec, assuming they actually documented this. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DO NOT REPLY [Bug 17947] - Need setURI() methods in HttpMethod interface
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17947. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17947 Need setURI() methods in HttpMethod interface --- Additional Comments From [EMAIL PROTECTED] 2003-07-18 18:55 --- Looks good, but I have one suggestion. If the URL is absolute, the patch always creates a new HostConfiguration. This could mess up applications that call both setURI and setHostConfiguration (though it's questionable why someone would call both). Maybe if the host/port part of the URL is the same as the current HostConfiguration's host/port, setURI should leave the HostConfiguration alone? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DO NOT REPLY [Bug 19618] - URI class constructors need revision, optimization
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618 URI class constructors need revision, optimization --- Additional Comments From [EMAIL PROTECTED] 2003-07-18 22:10 --- I find that URI(String) constructor is too ambiguous. Should the URI character sequence be assumed to be escaped or per default or the other way around? I just do not know. I do not mind leaving a plain URI(String) constructor undeprecated as long as we all agree on a reasonable default. Oleg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DO NOT REPLY [Bug 19618] - URI class constructors need revision, optimization
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618 URI class constructors need revision, optimization --- Additional Comments From [EMAIL PROTECTED] 2003-07-18 22:32 --- I just looked up java.net.URL and java.net.URI (in JDK 1.4). java.net.URI's single-String constructor expects the argument to be already-escaped. The JavaDoc for java.net.URL isn't explicit on this, but I know that it doesn't do automatic escaping for you. So if we keep a single-argument constructor in HttpClient, I think it should expect an escaped string. That's backwards from what I remembered before I looked it up, which shows how confusing this is (or how tired I am today). - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DO NOT REPLY [Bug 11240] - Cookies with ',' in the value string is not parsed correctly in some cases
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11240. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11240 Cookies with ',' in the value string is not parsed correctly in some cases --- Additional Comments From [EMAIL PROTECTED] 2003-07-18 22:33 --- Nice comment! :-) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DO NOT REPLY [Bug 19618] - URI class constructors need revision, optimization
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618 URI class constructors need revision, optimization --- Additional Comments From [EMAIL PROTECTED] 2003-07-18 22:33 --- I agree with Laura on this one. I see no reason to remove the String only constructors as long as they are well documented. They all currently assume the Strings are not escaped. I think we should keep this default behavior. Mike - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DO NOT REPLY [Bug 11240] - Cookies with ',' in the value string is not parsed correctly in some cases
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11240. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11240 Cookies with ',' in the value string is not parsed correctly in some cases --- Additional Comments From [EMAIL PROTECTED] 2003-07-18 22:36 --- Looks good to me. Mike - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [VOTE][RESULT] Add commons-codec as an HttpClient dependency
Mike, Also, since this code is not in a released version yet maven builds will require manually adding a current Codec build. We should request that a Codec snapshot is added to the maven repository if possible. We'll need to check with the Codec team and then log an issue in JIRA for the maven team to actually upload it. I wouldn't anticipate any problems with the process though, and that will allow HttpClient to continue to build out of the box with maven. Regards, Adrian Sutton. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DO NOT REPLY [Bug 19618] - URI class constructors need revision, optimization
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618 URI class constructors need revision, optimization --- Additional Comments From [EMAIL PROTECTED] 2003-07-18 23:25 --- Well, in the face of ambiguity I guess we should try to be as specific as possible. Normally I would keep the String constructor but this seems to be a special case. Forcing a choice with the boolean is the safest way to go. Mike - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]