DO NOT REPLY [Bug 30032] New: - [PATCH][DbUtils] protected prepareConnection()

2004-07-11 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://issues.apache.org/bugzilla/show_bug.cgi?id=30032.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=30032

[PATCH][DbUtils] protected prepareConnection()

   Summary: [PATCH][DbUtils] protected prepareConnection()
   Product: Commons
   Version: unspecified
  Platform: All
OS/Version: All
Status: NEW
  Severity: Enhancement
  Priority: Other
 Component: DbUtils
AssignedTo: [EMAIL PROTECTED]
ReportedBy: [EMAIL PROTECTED]


This patch contains protected prepareConnection() method for the QueryRunner.
Also all this.ds.getConnection() calls were replaced with prepareConnection() 
calls.

Additionaly I added a few missed JavaDocs. Look at the patch for details.
===

Index: QueryRunner.java
===
RCS file: /home/cvspublic/jakarta-
commons/dbutils/src/java/org/apache/commons/dbutils/QueryRunner.java,v
retrieving revision 1.11
diff -u -r1.11 QueryRunner.java
--- QueryRunner.java6 Jun 2004 14:35:39 -   1.11
+++ QueryRunner.java11 Jul 2004 08:09:58 -
@@ -107,7 +107,7 @@
  * @since DbUtils 1.1
  */
 public int[] batch(String sql, Object[][] params) throws SQLException {
-Connection conn = this.ds.getConnection();
+Connection conn = prepareConnection();
 
 try {
 return this.batch(conn, sql, params);
@@ -142,6 +142,7 @@
 
 /**
  * Returns the codeDataSource/code this runner is using.
+ * @return codeDataSource/code this runner is using.
  */
 public DataSource getDataSource() {
 return this.ds;
@@ -166,6 +167,20 @@
 
 return conn.prepareStatement(sql);
 }
+
+/**
+ * Factory method that retrieves a codeConnection/code object.
+ * It called from all methods that don't receive codeConnection/code 
as one
+ * of parameters.
+ * This implementation uses codeDataSource/code to get a connection.
+ * @return retrieved codeConnection/code.
+ * @throws SQLException
+ * @since DbUtils 1.1
+ */
+protected Connection prepareConnection()
+   throws SQLException {
+   return ds.getConnection();
+}
 
 /**
  * Execute an SQL SELECT query with a single replacement parameter.  The
@@ -285,7 +300,7 @@
 public Object query(String sql, Object[] params, ResultSetHandler rsh)
 throws SQLException {
 
-Connection conn = this.ds.getConnection();
+Connection conn = prepareConnection();
 
 try {
 return this.query(conn, sql, params, rsh);
@@ -461,7 +476,7 @@
  * @return The number of rows updated.
  */
 public int update(String sql, Object[] params) throws SQLException {
-Connection conn = this.ds.getConnection();
+Connection conn = prepareConnection();
 
 try {
 return this.update(conn, sql, params);
@@ -499,6 +514,8 @@
  * Close a codeConnection/code.  This implementation avoids closing if 
  * null and does strongnot/strong suppress any exceptions.  Subclasses
  * can override to provide special handling like logging.
+ * @param conn codeConnection/code to close.
+ * @throws SQLException
  * @since DbUtils 1.1
  */
 protected void close(Connection conn) throws SQLException {
@@ -509,6 +526,8 @@
  * Close a codeStatement/code.  This implementation avoids closing if 
  * null and does strongnot/strong suppress any exceptions.  Subclasses
  * can override to provide special handling like logging.
+ * @param stmt codeStatement/code to close.
+ * @throws SQLException
  * @since DbUtils 1.1
  */
 protected void close(Statement stmt) throws SQLException {
@@ -519,6 +538,8 @@
  * Close a codeResultSet/code.  This implementation avoids closing if 
  * null and does strongnot/strong suppress any exceptions.  Subclasses
  * can override to provide special handling like logging.
+ * @param rs codeResultSet/code to close.
+ * @throws SQLException
  * @since DbUtils 1.1
  */
 protected void close(ResultSet rs) throws SQLException {

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Bug report for Commons [2004/07/11]

2004-07-11 Thread bugzilla
+---+
| Bugzilla Bug ID   |
| +-+
| | Status: UNC=Unconfirmed NEW=New ASS=Assigned|
| | OPN=ReopenedVER=Verified(Skipped Closed/Resolved)   |
| |   +-+
| |   | Severity: BLK=Blocker CRI=CriticalMAJ=Major |
| |   |   MIN=Minor   NOR=Normal  ENH=Enhancement   |
| |   |   +-+
| |   |   | Date Posted |
| |   |   |  +--+
| |   |   |  | Description  |
| |   |   |  |  |
| 6508|Ass|Enh|2002-02-17|HttpClient now supports proxyHost and proxyPort - |
| 6826|Ass|Enh|2002-03-04|Need to have xml files validated against DTDs as p|
| 6829|Ass|Enh|2002-03-04|Allow easier way of user specified tests  |
| 7069|Ass|Enh|2002-03-13|DTD and DOM Validators|
| 7135|Opn|Enh|2002-03-14|[beanutils] Misleading error message when beaninfo|
| 7226|Opn|Enh|2002-03-19|Nested Bean Collection|
| 7367|New|Nor|2002-03-22|[unspecified] ServiceManager not actually serializ|
| 7465|New|Nor|2002-03-25|Need better 'dist' build  |
| 7981|Ver|Nor|2002-04-11|[codec][PATCH] add 2 new methods for encoding stri|
| 8140|Ver|Nor|2002-04-16|Incorrect credentials loop infinitely |
|10319|New|Enh|2002-06-28|Instantiate property if null in form bean |
|10543|Ass|Enh|2002-07-08|generate ant task automatically from CLI  |
|10793|New|Enh|2002-07-15|User definable default headers support|
|10810|New|Enh|2002-07-15|Response handlers |
|10813|New|Enh|2002-07-15|RFC 2965 Support (Port sensitive cookies) |
|10815|New|Enh|2002-07-15|Instrumentation for Timings   |
|10957|New|Nor|2002-07-18|Change Header/HeaderElement to handle a list as th|
|12807|New|Nor|2002-09-19|[PATCH] x 2 Update build.xml to use commons-loggin|
|13031|New|Enh|2002-09-26|Use regular expression (regex) pattern matching fo|
|13390|New|Nor|2002-10-07|ResponseHeaderHandler and ResponseHeaderValidator |
|13426|New|Enh|2002-10-08|[PATCH] xml-reference.xml responseHeader addition |
|13743|Opn|Enh|2002-10-17|Need getPropertyType(Class theClass, String propNa|
|14036|New|Enh|2002-10-29|MultipartPostMethod does not check for error messa|
|14262|Opn|Maj|2002-11-05|SAXBeanWriter produces invalid XML|
|14394|Ver|Nor|2002-11-08|Excessive exceptions log under security manager   |
|14471|Opn|Enh|2002-11-12|validator-rules.xml JavaScript fails when field no|
|14667|Ver|Maj|2002-11-19|PropertyUtils.copyProperties does not copy to Dyna|
|15082|Ass|Enh|2002-12-04|[lang] elapsed time formatting utility method |
|15451|Opn|Enh|2002-12-17|Multiple mapped properties not possible / Direct m|
|15519|Ver|Maj|2002-12-19|PropertyUtils.getPropertyType() for java.util.Coll|
|15534|New|Nor|2002-12-19|Inadequate HTTP proxy server support in HttpClient|
|15744|New|Nor|2002-12-31|[unspecified] Scaffold ResultSet used after statem|
|15895|Unc|Nor|2003-01-08|In BeanMap all properties are writable (some with |
|16038|Opn|Enh|2003-01-13|[beanutils] LocaleBeanUtils.copyProperties() does |
|16132|New|Maj|2003-01-15|[Jelly] core:file convert html to lt;htmlgt;  |
|16394|New|Enh|2003-01-24|Enhance the IndexedListProperty to handle nested l|
|16525|Opn|Enh|2003-01-29|BeanUtils.setProperty is over-zealous at convertin|
|16600|New|Nor|2003-01-30|JUnitTestAdapter throws SAXException because no DT|
|16859|New|Nor|2003-02-06|[unspecified] Can't supply a javax.mail.Session to|
|16873|New|Enh|2003-02-07|Specifying a different latka.properties file  |
|16907|New|Enh|2003-02-08|Introduce Aspect oriented programming |
|16920|Opn|Enh|2003-02-10|Declaration of Locale (language/country) in valida|
|17002|Opn|Enh|2003-02-12|Problem with index property   |
|17102|New|Enh|2003-02-15|Can't embed  characters in paramValue data.   |
|17306|Opn|Enh|2003-02-22|extend field tag with forward attribute for er|
|17416|New|Enh|2003-02-26|Send InputStreams instead of files in MultipartPos|
|17501|New|Enh|2003-02-27|Add dynamic discovery of mapped properties to Prop|
|17619|New|Nor|2003-03-03|[jelly] ClassLoader Problems with XMLParser and XM|
|17650|New|Nor|2003-03-04|[unspecified] Make Messages pay attention to retur|
|17662|New|Nor|2003-03-05|unknown options are ignored instead of throwing Un|
|17682|New|Nor|2003-03-05|HelpFormatter does not wrap lines correctly after |

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2004-07-11 Thread stevencaswell
stevencaswell2004/07/11 09:48:32

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  http://issues.apache.org/bugzilla/show_bug.cgi?id=22692 :
  - added new splitPreserveAllTokens methods to mirror the split functionality, 
preserving empty tokens indicated by adjacent tokens;
  - refactored logic of existing split method into splitWorker for sharing by new 
splitPreserveAllTokens methods
  
  Revision  ChangesPath
  1.131 +219 -28   
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.130
  retrieving revision 1.131
  diff -u -r1.130 -r1.131
  --- StringUtils.java  24 May 2004 20:15:44 -  1.130
  +++ StringUtils.java  11 Jul 2004 16:48:31 -  1.131
  @@ -1994,6 +1994,150 @@
* @since 2.0
*/
   public static String[] split(String str, char separatorChar) {
  +return splitWorker(str, separatorChar, false);
  +}
  +
  +/**
  + * pSplits the provided text into an array, separators specified.
  + * This is an alternative to using StringTokenizer./p
  + *
  + * pThe separator is not included in the returned String array.
  + * Adjacent separators are treated as one separator.
  + * For more control over the split use the Tokenizer class./p
  + *
  + * pA codenull/code input String returns codenull/code.
  + * A codenull/code separatorChars splits on whitespace./p
  + *
  + * pre
  + * StringUtils.split(null, *) = null
  + * StringUtils.split(, *)   = []
  + * StringUtils.split(abc def, null) = [abc, def]
  + * StringUtils.split(abc def,  )  = [abc, def]
  + * StringUtils.split(abc  def,  ) = [abc, def]
  + * StringUtils.split(ab:cd:ef, :) = [ab, cd, ef]
  + * /pre
  + *
  + * @param str  the String to parse, may be null
  + * @param separatorChars  the characters used as the delimiters,
  + *  codenull/code splits on whitespace
  + * @return an array of parsed Strings, codenull/code if null String input
  + */
  +public static String[] split(String str, String separatorChars) {
  +return splitWorker(str, separatorChars, -1, false);
  +}
  +
  +/**
  + * pSplits the provided text into an array with a maximum length,
  + * separators specified./p
  + *
  + * pThe separator is not included in the returned String array.
  + * Adjacent separators are treated as one separator./p
  + *
  + * pA codenull/code input String returns codenull/code.
  + * A codenull/code separatorChars splits on whitespace./p
  + *
  + * pIf more than codemax/code delimited substrings are found, the last
  + * returned string includes all characters after the first codemax - 1/code
  + * returned strings (including separator characters)./p
  + *
  + * pre
  + * StringUtils.split(null, *, *)= null
  + * StringUtils.split(, *, *)  = []
  + * StringUtils.split(ab de fg, null, 0)   = [ab, cd, ef]
  + * StringUtils.split(ab   de fg, null, 0) = [ab, cd, ef]
  + * StringUtils.split(ab:cd:ef, :, 0)= [ab, cd, ef]
  + * StringUtils.split(ab:cd:ef, :, 2)= [ab, cd:ef]
  + * /pre
  + *
  + * @param str  the String to parse, may be null
  + * @param separatorChars  the characters used as the delimiters,
  + *  codenull/code splits on whitespace
  + * @param max  the maximum number of elements to include in the
  + *  array. A zero or negative value implies no limit
  + * @return an array of parsed Strings, codenull/code if null String input
  + */
  +public static String[] split(String str, String separatorChars, int max) {
  +return splitWorker(str, separatorChars, max, false);
  +}
  +
  +//---
  +/**
  + * pSplits the provided text into an array, using whitespace as the
  + * separator, preserving all tokens, including empty tokens created by 
  + * adjacent separators. This is an alternative to using StringTokenizer.
  + * Whitespace is defined by [EMAIL PROTECTED] Character#isWhitespace(char)}./p
  + *
  + * pThe separator is not included in the returned String array.
  + * Adjacent separators are treated as separators for empty tokens.
  + * For more control over the split use the Tokenizer class./p
  + *
  + * pA codenull/code input String returns codenull/code./p
  + *
  + * pre
  + * StringUtils.splitPreserveAllTokens(null)   = null
  + * StringUtils.splitPreserveAllTokens() = []
  + * StringUtils.splitPreserveAllTokens(abc def)  = [abc, def]
  + * 

cvs commit: jakarta-commons/lang/src/test/org/apache/commons/lang StringUtilsTest.java

2004-07-11 Thread stevencaswell
stevencaswell2004/07/11 09:49:07

  Modified:lang/src/test/org/apache/commons/lang StringUtilsTest.java
  Log:
  added tests for new splitPreserveAllTokens methods 
(http://issues.apache.org/bugzilla/show_bug.cgi?id=22692)
  
  Revision  ChangesPath
  1.60  +314 -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.59
  retrieving revision 1.60
  diff -u -r1.59 -r1.60
  --- StringUtilsTest.java  10 Mar 2004 23:54:48 -  1.59
  +++ StringUtilsTest.java  11 Jul 2004 16:49:07 -  1.60
  @@ -360,6 +360,319 @@
   assertEquals(msg, str.substring(2), res[1]);
   }
   
  +public void testSplitPreserveAllTokens_String() {
  +assertEquals(null, StringUtils.splitPreserveAllTokens(null));
  +assertEquals(0, StringUtils.splitPreserveAllTokens().length);
  +
  +String str = a b .c;
  +String[] res = StringUtils.splitPreserveAllTokens(str);
  +assertEquals(3, res.length);
  +assertEquals(a, res[0]);
  +assertEquals(b, res[1]);
  +assertEquals(.c, res[2]);
  +
  +str =  a b .c;
  +res = StringUtils.splitPreserveAllTokens(str);
  +assertEquals(4, res.length);
  +assertEquals(, res[0]);
  +assertEquals(a, res[1]);
  +assertEquals(b, res[2]);
  +assertEquals(.c, res[3]);
  +
  +str = a  b  .c;
  +res = StringUtils.splitPreserveAllTokens(str);
  +assertEquals(5, res.length);
  +assertEquals(a, res[0]);
  +assertEquals(, res[1]);
  +assertEquals(b, res[2]);
  +assertEquals(, res[3]);
  +assertEquals(.c, res[4]);
  +
  +str =  a  ;
  +res = StringUtils.splitPreserveAllTokens(str);
  +assertEquals(4, res.length);
  +assertEquals(, res[0]);
  +assertEquals(a, res[1]);
  +assertEquals(, res[2]);
  +assertEquals(, res[3]);
  +
  +str =  a  b;
  +res = StringUtils.splitPreserveAllTokens(str);
  +assertEquals(4, res.length);
  +assertEquals(, res[0]);
  +assertEquals(a, res[1]);
  +assertEquals(, res[2]);
  +assertEquals(b, res[3]);
  +
  +str = a + WHITESPACE + b + NON_WHITESPACE + c;
  +res = StringUtils.splitPreserveAllTokens(str);
  +assertEquals(WHITESPACE.length() + 1, res.length);
  +assertEquals(a, res[0]);
  +for(int i = 1; i  WHITESPACE.length()-1; i++)
  +{
  +  assertEquals(, res[i]);
  +}
  +assertEquals(b + NON_WHITESPACE + c, res[WHITESPACE.length()]); 
  
  +}
  +
  +public void testSplitPreserveAllTokens_StringChar() {
  +assertEquals(null, StringUtils.splitPreserveAllTokens(null, '.'));
  +assertEquals(0, StringUtils.splitPreserveAllTokens(, '.').length);
  +
  +String str = a.b. c;
  +String[] res = StringUtils.splitPreserveAllTokens(str, '.');
  +assertEquals(3, res.length);
  +assertEquals(a, res[0]);
  +assertEquals(b, res[1]);
  +assertEquals( c, res[2]);
  +
  +str = a.b.. c;
  +res = StringUtils.splitPreserveAllTokens(str, '.');
  +assertEquals(4, res.length);
  +assertEquals(a, res[0]);
  +assertEquals(b, res[1]);
  +assertEquals(, res[2]);
  +assertEquals( c, res[3]);
  +
  +str = .a.;
  +res = StringUtils.splitPreserveAllTokens(str, '.');
  +assertEquals(3, res.length);
  +assertEquals(, res[0]);
  +assertEquals(a, res[1]);
  +assertEquals(, res[2]);
  +   
  +str = .a..;
  +res = StringUtils.splitPreserveAllTokens(str, '.');
  +assertEquals(4, res.length);
  +assertEquals(, res[0]);
  +assertEquals(a, res[1]);
  +assertEquals(, res[2]);
  +assertEquals(, res[3]);
  +
  +str = ..a.;
  +res = StringUtils.splitPreserveAllTokens(str, '.');
  +assertEquals(4, res.length);
  +assertEquals(, res[0]);
  +assertEquals(, res[1]);
  +assertEquals(a, res[2]);
  +assertEquals(, res[3]);
  +
  +str = ..a;
  +res = StringUtils.splitPreserveAllTokens(str, '.');
  +assertEquals(3, res.length);
  +assertEquals(, res[0]);
  +assertEquals(, res[1]);
  +assertEquals(a, res[2]);
  +
  +str = a b c;
  +res = StringUtils.splitPreserveAllTokens(str,' ');
  +assertEquals(3, res.length);
  +assertEquals(a, res[0]);
  +assertEquals(b, res[1]);
  +assertEquals(c, res[2]);
  +
  +str = a  b  

cvs commit: jakarta-commons/dbcp/src/java/org/apache/commons/dbcp BasicDataSource.java

2004-07-11 Thread dirkv
dirkv   2004/07/11 09:51:34

  Modified:dbcp/src/java/org/apache/commons/dbcp BasicDataSource.java
  Log:
  Bugzilla Bug 29963: BasicDataSource does not work with getConnection(String, String)
  - fail fast (throw UnsupportedOperationException)
  - update javadoc
  
  Revision  ChangesPath
  1.38  +7 -2  
jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/BasicDataSource.java
  
  Index: BasicDataSource.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/BasicDataSource.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- BasicDataSource.java  9 Jun 2004 18:21:23 -   1.37
  +++ BasicDataSource.java  11 Jul 2004 16:51:34 -  1.38
  @@ -543,6 +543,8 @@
   
   /**
* Create (if necessary) and return a connection to the database.
  + * 
  + * pstrongBasicDataSource does NOT support this method./strong/p
*
* @param username Database user on whose behalf the Connection
*   is being made
  @@ -551,7 +553,10 @@
* @exception SQLException if a database access error occurs
*/
   public Connection getConnection(String username, String password) throws 
SQLException {
  -return createDataSource().getConnection(username, password);
  +// This method isn't supported by the PoolingDataSource returned by
  +// the createDataSource
  +throw new UnsupportedOperationException(Not supported by BasicDataSource);
  +// return createDataSource().getConnection(username, password);
   }
   
   
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [lang] StringUtils.split ignores empty items (Bugzilla bug# 22692)

2004-07-11 Thread Steven Caswell
I went ahead and named it splitPreserveAllTokens, since that seemed to be
the closest concensus. It would be good if someone could review.


Steven Caswell
Sun Certified Java Programmer
[EMAIL PROTECTED]
War is an ugly thing, but not the ugliest of things. The decayed and
degraded state of moral and patriotic feeling that thinks that nothing is
worth war is much worse. The person who has nothing for which he is willing
to fight, nothing which is more important than his own personal safety, is a
miserable creature and has no chance of being free unless made and kept so
by the exertions of better men than himself.  John Stuart Mill.


 -Original Message-
 From: Stephen Colebourne [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, July 07, 2004 2:35 PM
 To: Jakarta Commons Developers List
 Subject: Re: [lang] StringUtils.split ignores empty items 
 (Bugzilla bug# 22692)
 
 
 of splitPreserveTokens and splitPreserveAllTokens I prefer 
 the former, but am OK with the latter.
 
 Stephen
 
 - Original Message -
 From: Gary Gregory [EMAIL PROTECTED]
  So how about splitPreserveAllTokens. That might be a bit 
 verbose, but
 it
  does convey exactly what the method does.
 
 Seems fine to me.
 
 Gary
 
 -
 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]
 
 
 
 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



DO NOT REPLY [Bug 25560] - DateUtils.truncate() is off by one hour when using a date in DST switch 'zone'

2004-07-11 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://issues.apache.org/bugzilla/show_bug.cgi?id=25560.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=25560

DateUtils.truncate() is off by one hour when using a date in DST switch 'zone'

[EMAIL PROTECTED] changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED



--- Additional Comments From [EMAIL PROTECTED]  2004-07-11 17:04 ---
The truncate/round logic was adding a negative value to the current hours (using
Calendar.add) to move the hours back to zero. When this is done across the
beginning of daylight saving time, it has the affect of moving to 23:00 of the
previous day, because the hour skipped when daylight saving time doesn't exist.
For example, if daylight saving time begins at 02:00, and -5 is added to 05:00,
the result is 23:00 of yesterday, because the hour between 02:00 and 03:00
doesn't exist. The fix was to do the calculation in the truncate/round code, and
use Calendar.set to set the new hour value.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[Jakarta Commons Wiki] Updated: Lang

2004-07-11 Thread commons-dev
   Date: 2004-07-11T10:07:01
   Editor: 67.33.111.186 
   Wiki: Jakarta Commons Wiki
   Page: Lang
   URL: http://wiki.apache.org/jakarta-commons/Lang

   no comment

Change Log:

--
@@ -16,11 +16,10 @@
  1. [http://issues.apache.org/bugzilla/show_bug.cgi?id=20015 20015][lang] Make 
Entities public and unit test - '''Entities. Needs finishing.'''
  1. [http://issues.apache.org/bugzilla/show_bug.cgi?id=21333 21333]Add 
TimeoutController - '''Class in HttpClient. Needs evaluating. '''
  1. [http://issues.apache.org/bugzilla/show_bug.cgi?id=21333 21333]  Support 
HttpClient's DateParser class.
- 1. [http://issues.apache.org/bugzilla/show_bug.cgi?id=22692 22692]
StringUtils.split ignores empty items - '''new splitPreserve{Empty}Tokens being added 
- Steven'''
+ 1. [http://issues.apache.org/bugzilla/show_bug.cgi?id=22692 22692]
StringUtils.split ignores empty items - '''new splitPreserveAllTokens Needs to be 
reviewed.'''
  1. [http://issues.apache.org/bugzilla/show_bug.cgi?id=24910 24910]new 
StringUtils.split methods that split on the whole separator string - '''method 
signature issue''' 
  1. [http://issues.apache.org/bugzilla/show_bug.cgi?id=26297 26297][lang] 
BitSetUtils class, toIndexArray and fromIndexArray - '''DONE - Gary to confirm, looks 
like primitive overloads are still needed'''
  1. [http://issues.apache.org/bugzilla/show_bug.cgi?id=22172 22172][lang] 
DateUtils.parseCVS behavior parsing h:mm z - '''To be deleted. Code possibly to be 
placed in sandbox - Steven'''
- 1. [http://issues.apache.org/bugzilla/show_bug.cgi?id=25560 25560]
DateUtils.truncate() is off by one hour when using a date in DST switch 'zone'
  1. [http://issues.apache.org/bugzilla/show_bug.cgi?id=26922 26922][lang] public 
static boolean DateUtils.equals(Date dt1, Date dt2)
  1. [http://issues.apache.org/bugzilla/show_bug.cgi?id=15082 15082][lang] elapsed 
time formatting utility method - '''DurationFormatUtils. Needs finishing.'''
  1. [http://issues.apache.org/bugzilla/show_bug.cgi?id=29794 29794]Add 
convenience format(long) methods to FastDateFormat - '''Needs improvement'''
@@ -49,6 +48,7 @@
  1. [http://issues.apache.org/bugzilla/show_bug.cgi?id=26056 26056][lang] Add 
methods to ArrayUtils: add at end and insert-like ops - '''DONE'''
  1. StringUtils.ordinalIndexOf() - '''Appears to be DONE'''
  1. [http://issues.apache.org/bugzilla/show_bug.cgi?id=29673 29673][lang] 
ExceptionUtils: new getCause() methodname (for tomcat-exception) - '''DONE'''
+ 1. [http://issues.apache.org/bugzilla/show_bug.cgi?id=25560 25560]
DateUtils.truncate() is off by one hour when using a date in DST switch 'zone' - 
'''DONE'''
 
  Seeking opinions 
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons-sandbox/lang/src/java/org/apache/commons/lang DateFormatter.java

2004-07-11 Thread stevencaswell
stevencaswell2004/07/11 10:53:31

  Added:   lang/src/java/org/apache/commons/lang DateFormatter.java
  Log:
  Moved to the sandbox from comment-out code in DateUtils
  PR: http://issues.apache.org/bugzilla/show_bug.cgi?id=22172
  Submitted by: Serge Knystautas [EMAIL PROTECTED]
  CVS: --
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  ChangesPath
  1.1  
jakarta-commons-sandbox/lang/src/java/org/apache/commons/lang/DateFormatter.java
  
  Index: DateFormatter.java
  ===
  package org.apache.commons.lang;
  
  import java.text.DateFormat;
  import java.text.DateFormatSymbols;
  import java.text.ParseException;
  import java.util.Calendar;
  import java.util.Date;
  import java.util.Locale;
  
  public class DateFormatter {
  
  /*
   * pParses a date string formatted in CVS format./p
   * 
   * @param dateStr  the date to parse
   * @return the parsed date
   * @throws IllegalArgumentException if the date cannot be parsed
   */
  public static Calendar parseCVS(String dateStr) {
  if (dateStr == null) {
  throw new IllegalArgumentException(The date must not be null);
  }
  //Get the symbol names
  DateFormatSymbols symbols = new DateFormatSymbols(Locale.ENGLISH);
  
  DateFormat[] dateFormats = new DateFormat[0];
  
  //Prep the string to parse
  String value = dateStr.toLowerCase().trim();
  
  //Get the current date/time
  Calendar now = Calendar.getInstance();
  if (value.endsWith( ago)) {
  //If this was a date that was ago the current time...
  //Strip out the ' ago' part
  value = value.substring(0, value.length() - 4);
  
  //Split the value and unit
  int start = value.indexOf( );
  if (start  0) {
  throw new IllegalArgumentException(Could not find space in between 
value and unit);
  }
  String unit = value.substring(start + 1);
  value = value.substring(0, start);
  //We support a week, so we need to parse the value as a
  int val = 0;
  if (value.equals(a) || value.equals(an)) {
  val = 1;
  } else {
  val = Integer.parseInt(value);
  }
  
  //Determine the unit
  if (unit.equals(milliseconds) || unit.equals(millisecond)) {
  now.add(Calendar.MILLISECOND, -val);
  } else if (unit.equals(seconds) || unit.equals(second)) {
  now.add(Calendar.SECOND, -val);
  } else if (unit.equals(minutes) || unit.equals(minute)) {
  now.add(Calendar.MINUTE, -val);
  } else if (unit.equals(hours) || unit.equals(hour)) {
  now.add(Calendar.HOUR, -val);
  } else if (unit.equals(days) || unit.equals(day)) {
  now.add(Calendar.DATE, -val);
  } else if (unit.equals(weeks) || unit.equals(week)) {
  now.add(Calendar.DATE, -val * 7);
  } else if (unit.equals(fortnights) || unit.equals(fortnight)) {
  now.add(Calendar.DATE, -val * 14);
  } else if (unit.equals(months) || unit.equals(month)) {
  now.add(Calendar.MONTH, -val);
  } else if (unit.equals(years) || unit.equals(year)) {
  now.add(Calendar.YEAR, -val);
  } else {
  throw new IllegalArgumentException(We do not understand that many 
units ago);
  }
  return now;
  } else if (value.startsWith(last )) {
  //If this was the last time a certain field was met
  //Strip out the 'last ' part
  value = value.substring(5);
  //Get the current date/time
  String[] strings = symbols.getWeekdays();
  for (int i = 0; i  strings.length; i++) {
  if (value.equalsIgnoreCase(strings[i])) {
  //How many days after Sunday
  int daysAgo = 

cvs commit: jakarta-commons-sandbox/lang/src/java/org/apache/commons/lang DateFormatter.java

2004-07-11 Thread stevencaswell
stevencaswell2004/07/11 10:56:33

  Modified:lang/src/java/org/apache/commons/lang DateFormatter.java
  Log:
  Oops, forgot the license header
  
  Revision  ChangesPath
  1.2   +15 -0 
jakarta-commons-sandbox/lang/src/java/org/apache/commons/lang/DateFormatter.java
  
  Index: DateFormatter.java
  ===
  RCS file: 
/home/cvs/jakarta-commons-sandbox/lang/src/java/org/apache/commons/lang/DateFormatter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DateFormatter.java11 Jul 2004 17:53:31 -  1.1
  +++ DateFormatter.java11 Jul 2004 17:56:33 -  1.2
  @@ -1,4 +1,19 @@
   package org.apache.commons.lang;
  +/*
  + * Copyright 2002,2004 The Apache Software Foundation.
  + * 
  + * Licensed under the Apache License, Version 2.0 (the License);
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + * 
  + *  http://www.apache.org/licenses/LICENSE-2.0
  + * 
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an AS IS BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
   
   import java.text.DateFormat;
   import java.text.DateFormatSymbols;
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons-sandbox/lang/src/java/org/apache/commons/lang DateFormatter.java

2004-07-11 Thread stevencaswell
stevencaswell2004/07/11 11:13:24

  Modified:lang/src/java/org/apache/commons/lang DateFormatter.java
  Log:
  added further explanation of class source and purpose, with pointers to the bugzilla 
issue and mailing list discussion
  
  Revision  ChangesPath
  1.3   +11 -1 
jakarta-commons-sandbox/lang/src/java/org/apache/commons/lang/DateFormatter.java
  
  Index: DateFormatter.java
  ===
  RCS file: 
/home/cvs/jakarta-commons-sandbox/lang/src/java/org/apache/commons/lang/DateFormatter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DateFormatter.java11 Jul 2004 17:56:33 -  1.2
  +++ DateFormatter.java11 Jul 2004 18:13:24 -  1.3
  @@ -22,9 +22,19 @@
   import java.util.Date;
   import java.util.Locale;
   
  +/*
  + * This class was created to hold the parseCVS method extracted from DateUtils in 
commons-lang.
  + * The code was originally submitted by Serge Knystautas [EMAIL PROTECTED] It was 
never
  + * fully implemented, and has been moved to the sandbox for further development. 
Recent discussion
  + * from the commons-dev mailing list:
  + * http://marc.theaimsgroup.com/?l=jakarta-commons-devm=108904098032038w=2
  + * Moving the code to the sandbox satisfies bug is a temporary solution to
  + * http://issues.apache.org/bugzilla/show_bug.cgi?id=22172 but this issue needs to 
be considered
  + * when the class/method is further developed.
  + */
   public class DateFormatter {
   
  -/*
  +/**
* pParses a date string formatted in CVS format./p
* 
* @param dateStr  the date to parse
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons-sandbox/lang/src/test/org/apache/commons/lang DateFormatterTest.java

2004-07-11 Thread stevencaswell
stevencaswell2004/07/11 11:36:32

  Added:   lang/src/test/org/apache/commons/lang DateFormatterTest.java
  Log:
  Moved to sandbox from commons-lang DateUtilsTest
  PR: http://issues.apache.org/bugzilla/show_bug.cgi?id=22172
  Submitted by: Serge Knystautas [EMAIL PROTECTED]
  
  Revision  ChangesPath
  1.1  
jakarta-commons-sandbox/lang/src/test/org/apache/commons/lang/DateFormatterTest.java
  
  Index: DateFormatterTest.java
  ===
  package org.apache.commons.lang;
  /*
   * Copyright 2002,2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the License);
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *  http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an AS IS BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  import java.text.SimpleDateFormat;
  import java.util.Calendar;
  import java.util.Date;
  import junit.framework.AssertionFailedError;
  import junit.framework.TestCase;
  
  /*
   * This class was created to hold test cases for the parseCVS method extracted from 
DateUtilsTest in commons-lang.
   * The code was originally submitted by Serge Knystautas [EMAIL PROTECTED] It was 
never
   * fully implemented, and has been moved to the sandbox for further development. 
Recent discussion
   * from the commons-dev mailing list:
   * http://marc.theaimsgroup.com/?l=jakarta-commons-devm=108904098032038w=2
   * Moving the code to the sandbox satisfies bug is a temporary solution to
   * http://issues.apache.org/bugzilla/show_bug.cgi?id=22172 but this issue needs to 
be considered
   * when the class/method is further developed.
   */
  public class DateFormatterTest extends TestCase {
  
  /*
   * Tests the parse method, which is supposed to handle various strings
   * as flexibly as CVS supports.
   */
  public void testParseCVS() throws Exception {
  try {
  DateFormatter.parseCVS(null);
  fail();
  } catch (IllegalArgumentException ex) {}
  try {
  DateFormatter.parseCVS(gobbledegook);
  fail();
  } catch (IllegalArgumentException ex) {}
  try {
  DateFormatter.parseCVS(ago);
  fail();
  } catch (IllegalArgumentException ex) {}
  try {
  DateFormatter.parseCVS(1 junk ago);
  fail();
  } catch (IllegalArgumentException ex) {}
  try {
  DateFormatter.parseCVS(1month ago);
  fail();
  } catch (IllegalArgumentException ex) {}
  try {
  DateFormatter.parseCVS(last month);
  fail();
  } catch (IllegalArgumentException ex) {}
  
  
  //This is difficult to test since the now used in the
  //  parse function cannot be controlled.  We could possibly control
  //  it by trying before and after and making sure the value we expect
  //  is between the two values calculated.
  //For now we're just using the custom assertEquals that takes a delta
  
  Calendar now = null;
  
  // M/dd/yy H:mm:ss z
  now = Calendar.getInstance();
  now.set(Calendar.MILLISECOND, 0);
  assertEquals(parseCVS format M/dd/yy H:mm:ss z,
now, DateFormatter.parseCVS(new SimpleDateFormat(M/dd/yy H:mm:ss 
z).format(now.getTime())), 50);
  // MMM d,  h:mm a
  now = Calendar.getInstance();
  now.set(Calendar.MILLISECOND, 0);
  now.set(Calendar.SECOND, 0);
  assertEquals(parseCVS format MMM d,  h:mm a,
now, DateFormatter.parseCVS(new SimpleDateFormat(MMM d,  h:mm 
a).format(now.getTime())), 50);
  // h:mm z
  //
  // This format is difficult to test using the current time because the
  // parseCVS method applies the default date of January 1, 1970 to the
  // parsed time. The most straightforward way to test the parse is to
  // pass in a known value, and test the output against this know value.
  // 
  now = Calendar.getInstance();
  now.setTime(new SimpleDateFormat(h:mm z).parse(16:30 GMT));
  assertEquals(parseCVS format h:mm z 16:30 GMT, 
now, DateFormatter.parseCVS(16:30 GMT), 50);
  now = Calendar.getInstance();
  now.setTime(new SimpleDateFormat(h:mm z).parse(16:30 EST));
  assertEquals(parseCVS format h:mm z 16:30 EST, 
now, DateFormatter.parseCVS(16:30 EST), 50);
  now = 

cvs commit: jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/moment Variance.java

2004-07-11 Thread psteitz
psteitz 2004/07/11 11:38:12

  Modified:math/src/java/org/apache/commons/math/stat/univariate/moment
Variance.java
  Log:
  Added missing method for computing variance from mean with no subarray specified.
  
  Revision  ChangesPath
  1.26  +26 -1 
jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/moment/Variance.java
  
  Index: Variance.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/moment/Variance.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- Variance.java 10 Jul 2004 17:09:08 -  1.25
  +++ Variance.java 11 Jul 2004 18:38:12 -  1.26
  @@ -211,5 +211,30 @@
   }
   return var;
   }
  +
  +/**
  + * Returns the variance of the entries in the input array, using the
  + * precomputed mean value.  Returns codeDouble.NaN/code if the array
  + * is empty.
  + * p
  + * See [EMAIL PROTECTED] Variance} for details on the computing algorithm.
  + * p
  + * Returns 0 for a single-value (i.e. length = 1) sample.
  + * p
  + * Throws codeIllegalArgumentException/code if the array is null.
  + * p
  + * Does not change the internal state of the statistic.
  + * 
  + * @param values the input array
  + * @param mean the precomputed mean value
  + * @return the variance of the values or Double.NaN if the array is empty
  + * @throws IllegalArgumentException if the array is null
  + */
  +public double evaluate(final double[] values, final double mean) {
  +if (values == null) {
  +throw new IllegalArgumentException(input values array is null);
  +}
  +return evaluate(values, mean, 0, values.length);
  +}
   
   }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/rank Max.java Min.java Percentile.java

2004-07-11 Thread psteitz
psteitz 2004/07/11 11:39:08

  Modified:math/src/java/org/apache/commons/math/stat/univariate/rank
Max.java Min.java Percentile.java
  Log:
  javadoc only.
  
  Revision  ChangesPath
  1.21  +2 -2  
jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/rank/Max.java
  
  Index: Max.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/rank/Max.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- Max.java  10 Jul 2004 17:09:08 -  1.20
  +++ Max.java  11 Jul 2004 18:39:08 -  1.21
  @@ -97,7 +97,7 @@
* @param values the input array
* @param begin index of the first array element to include
* @param length the number of elements to include
  - * @return the mean of the values or Double.NaN if length = 0
  + * @return the maximum of the values or Double.NaN if length = 0
* @throws IllegalArgumentException if the array is null or the array index
*  parameters are not valid
*/
  
  
  
  1.22  +2 -2  
jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/rank/Min.java
  
  Index: Min.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/rank/Min.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- Min.java  10 Jul 2004 17:09:08 -  1.21
  +++ Min.java  11 Jul 2004 18:39:08 -  1.22
  @@ -97,7 +97,7 @@
* @param values the input array
* @param begin index of the first array element to include
* @param length the number of elements to include
  - * @return the mean of the values or Double.NaN if length = 0
  + * @return the minimum of the values or Double.NaN if length = 0
* @throws IllegalArgumentException if the array is null or the array index
*  parameters are not valid
*/
  
  
  
  1.23  +8 -5  
jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/rank/Percentile.java
  
  Index: Percentile.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/rank/Percentile.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- Percentile.java   4 Jul 2004 09:02:36 -   1.22
  +++ Percentile.java   11 Jul 2004 18:39:08 -  1.23
  @@ -102,7 +102,8 @@
* liReturns (for any value of codep/code) codevalues[0]/code
*  if codevalues/code has length code1/code/li
* liThrows codeIllegalArgumentException/code if codevalues/code
  - *  is null /li
  + * is null or p is not a valid quantile value (p must be greater than 0
  + * and less than or equal to 100) /li
* /ul
* p
* See [EMAIL PROTECTED] Percentile} for a description of the percentile 
estimation
  @@ -110,8 +111,9 @@
* 
* @param values input array of values
* @param p the percentile value to compute
  - * @return the result of the evaluation or Double.NaN if the array is empty
  - * @throws IllegalArgumentException if codevalues/code is null
  + * @return the percentile value or Double.NaN if the array is empty
  + * @throws IllegalArgumentException if codevalues/code is null 
  + * or p is invalid
*/
   public double evaluate(final double[] values, final double p) {
   test(values, 0, 0);
  @@ -161,7 +163,8 @@
*  if codelength = 1 /code/li
* liThrows codeIllegalArgumentException/code if codevalues/code
*  is null , codebegin/code or codelength/code is invalid, or 
  - * codep/code is not a valid quantile value/li
  + * codep/code is not a valid quantile value (p must be greater than 0
  + * and less than or equal to 100)/li
* /ul
* p
 * See [EMAIL PROTECTED] Percentile} for a description of the percentile 
estimation
  
  
  

-
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 DateUtils.java

2004-07-11 Thread stevencaswell
stevencaswell2004/07/11 11:40:04

  Modified:lang/src/java/org/apache/commons/lang/time DateUtils.java
  Log:
  moved parseCVS to sandbox DateFormatter.java
  
  Revision  ChangesPath
  1.22  +1 -121
jakarta-commons/lang/src/java/org/apache/commons/lang/time/DateUtils.java
  
  Index: DateUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/time/DateUtils.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- DateUtils.java5 Jul 2004 18:07:44 -   1.21
  +++ DateUtils.java11 Jul 2004 18:40:04 -  1.22
  @@ -394,126 +394,6 @@
   
   }
   
  -// TODO: Decide whether this code is removed or goes into 2.1
  -//---
  -/*
  - * pParses a date string formatted in CVS format./p
  - * 
  - * @param dateStr  the date to parse
  - * @return the parsed date
  - * @throws IllegalArgumentException if the date cannot be parsed
  -public static Calendar parseCVS(String dateStr) {
  -if (dateStr == null) {
  -throw new IllegalArgumentException(The date must not be null);
  -}
  -//Get the symbol names
  -DateFormatSymbols symbols = new DateFormatSymbols(Locale.ENGLISH);
  -
  -//Prep the string to parse
  -String value = dateStr.toLowerCase().trim();
  -
  -//Get the current date/time
  -Calendar now = Calendar.getInstance();
  -if (value.endsWith( ago)) {
  -//If this was a date that was ago the current time...
  -//Strip out the ' ago' part
  -value = value.substring(0, value.length() - 4);
  -
  -//Split the value and unit
  -int start = value.indexOf( );
  -if (start  0) {
  -throw new IllegalArgumentException(Could not find space in between 
value and unit);
  -}
  -String unit = value.substring(start + 1);
  -value = value.substring(0, start);
  -//We support a week, so we need to parse the value as a
  -int val = 0;
  -if (value.equals(a) || value.equals(an)) {
  -val = 1;
  -} else {
  -val = Integer.parseInt(value);
  -}
  -
  -//Determine the unit
  -if (unit.equals(milliseconds) || unit.equals(millisecond)) {
  -now.add(Calendar.MILLISECOND, -val);
  -} else if (unit.equals(seconds) || unit.equals(second)) {
  -now.add(Calendar.SECOND, -val);
  -} else if (unit.equals(minutes) || unit.equals(minute)) {
  -now.add(Calendar.MINUTE, -val);
  -} else if (unit.equals(hours) || unit.equals(hour)) {
  -now.add(Calendar.HOUR, -val);
  -} else if (unit.equals(days) || unit.equals(day)) {
  -now.add(Calendar.DATE, -val);
  -} else if (unit.equals(weeks) || unit.equals(week)) {
  -now.add(Calendar.DATE, -val * 7);
  -} else if (unit.equals(fortnights) || unit.equals(fortnight)) {
  -now.add(Calendar.DATE, -val * 14);
  -} else if (unit.equals(months) || unit.equals(month)) {
  -now.add(Calendar.MONTH, -val);
  -} else if (unit.equals(years) || unit.equals(year)) {
  -now.add(Calendar.YEAR, -val);
  -} else {
  -throw new IllegalArgumentException(We do not understand that many 
units ago);
  -}
  -return now;
  -} else if (value.startsWith(last )) {
  -//If this was the last time a certain field was met
  -//Strip out the 'last ' part
  -value = value.substring(5);
  -//Get the current date/time
  -String[] strings = symbols.getWeekdays();
  -for (int i = 0; i  strings.length; i++) {
  -if (value.equalsIgnoreCase(strings[i])) {
  -//How many days after Sunday
  -int daysAgo = now.get(Calendar.DAY_OF_WEEK) - i;
  -if (daysAgo = 0) {
  -daysAgo += 7;
  -}
  -now.add(Calendar.DATE, -daysAgo);
  -return now;
  -}
  -}
  -strings = symbols.getMonths();
  -for (int i = 0; i  strings.length; i++) {
  -if (value.equalsIgnoreCase(strings[i])) {
  -//How many days after January
  -int monthsAgo = now.get(Calendar.MONTH) - i;
  -if (monthsAgo = 0) {
  -monthsAgo += 12;
  -}
  -now.add(Calendar.MONTH, -monthsAgo);
  - 

cvs commit: jakarta-commons/lang/src/test/org/apache/commons/lang/time DateUtilsTest.java

2004-07-11 Thread stevencaswell
stevencaswell2004/07/11 11:40:35

  Modified:lang/src/test/org/apache/commons/lang/time
DateUtilsTest.java
  Log:
  moved testParseCVS to sandbox DateFormatterTest.java
  
  Revision  ChangesPath
  1.14  +0 -206
jakarta-commons/lang/src/test/org/apache/commons/lang/time/DateUtilsTest.java
  
  Index: DateUtilsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/time/DateUtilsTest.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- DateUtilsTest.java5 Jul 2004 17:55:53 -   1.13
  +++ DateUtilsTest.java11 Jul 2004 18:40:35 -  1.14
  @@ -443,212 +443,6 @@
   dateTimeParser.setTimeZone(defaultZone);
   }
   
  -// TODO: Decide whether this code is removed or goes into 2.1
  -/*
  - * Tests the parse method, which is supposed to handle various strings
  - * as flexibly as CVS supports.
  -public void testParseCVS() throws Exception {
  -try {
  -DateUtils.parseCVS(null);
  -fail();
  -} catch (IllegalArgumentException ex) {}
  -try {
  -DateUtils.parseCVS(gobbledegook);
  -fail();
  -} catch (IllegalArgumentException ex) {}
  -try {
  -DateUtils.parseCVS(ago);
  -fail();
  -} catch (IllegalArgumentException ex) {}
  -try {
  -DateUtils.parseCVS(1 junk ago);
  -fail();
  -} catch (IllegalArgumentException ex) {}
  -try {
  -DateUtils.parseCVS(1month ago);
  -fail();
  -} catch (IllegalArgumentException ex) {}
  -try {
  -DateUtils.parseCVS(last month);
  -fail();
  -} catch (IllegalArgumentException ex) {}
  -
  -
  -//This is difficult to test since the now used in the
  -//  parse function cannot be controlled.  We could possibly control
  -//  it by trying before and after and making sure the value we expect
  -//  is between the two values calculated.
  -//For now we're just using the custom assertEquals that takes a delta
  -
  -Calendar now = null;
  -
  -// M/dd/yy H:mm:ss z
  -now = Calendar.getInstance();
  -now.set(Calendar.MILLISECOND, 0);
  -assertEquals(parseCVS format M/dd/yy H:mm:ss z,
  -  now, DateUtils.parseCVS(new SimpleDateFormat(M/dd/yy H:mm:ss 
z).format(now.getTime())), 50);
  -// MMM d,  h:mm a
  -now = Calendar.getInstance();
  -now.set(Calendar.MILLISECOND, 0);
  -now.set(Calendar.SECOND, 0);
  -assertEquals(parseCVS format MMM d,  h:mm a,
  -  now, DateUtils.parseCVS(new SimpleDateFormat(MMM d,  h:mm 
a).format(now.getTime())), 50);
  -// h:mm z
  -//
  -// This format is difficult to test using the current time because the
  -// parseCVS method applies the default date of January 1, 1970 to the
  -// parsed time. The most straightforward way to test the parse is to
  -// pass in a known value, and test the output against this know value.
  -// 
  -now = Calendar.getInstance();
  -now.setTime(new SimpleDateFormat(h:mm z).parse(16:30 GMT));
  -assertEquals(parseCVS format h:mm z 16:30 GMT, 
  -  now, DateUtils.parseCVS(16:30 GMT), 50);
  -now = Calendar.getInstance();
  -now.setTime(new SimpleDateFormat(h:mm z).parse(16:30 EST));
  -assertEquals(parseCVS format h:mm z 16:30 EST, 
  -  now, DateUtils.parseCVS(16:30 EST), 50);
  -now = Calendar.getInstance();
  -now.setTime(new SimpleDateFormat(h:mm z).parse(16:30 GMT-05:00));
  -assertEquals(parseCVS format h:mm z 16:30 GMT-05:00, 
  -  now, DateUtils.parseCVS(16:30 GMT-05:00), 50);
  -now = Calendar.getInstance();
  -now.setTime(new SimpleDateFormat(h:mm z).parse(16:30 GMT+01:00));
  -assertEquals(parseCVS format h:mm z 16:30 GMT+01:00, 
  -  now, DateUtils.parseCVS(16:30 GMT+01:00), 50);
  -
  -now = Calendar.getInstance();
  -now.setTime(new SimpleDateFormat(h:mm z).parse(06:30 GMT));
  -assertEquals(parseCVS format h:mm z 06:30 GMT, 
  -  now, DateUtils.parseCVS(06:30 GMT), 50);
  -now = Calendar.getInstance();
  -now.setTime(new SimpleDateFormat(h:mm z).parse(06:30 EST));
  -assertEquals(parseCVS format h:mm z 06:30 EST, 
  -  now, DateUtils.parseCVS(06:30 EST), 50);
  -now = Calendar.getInstance();
  -now.setTime(new SimpleDateFormat(h:mm z).parse(06:30 GMT-05:00));
  -assertEquals(parseCVS format h:mm z 06:30 GMT-05:00, 
  -  now, 

cvs commit: jakarta-commons/math/src/java/org/apache/commons/math/stat StatUtils.java

2004-07-11 Thread psteitz
psteitz 2004/07/11 11:41:19

  Modified:math/src/java/org/apache/commons/math/stat StatUtils.java
  Log:
  Added methods for computing variance using precomputed mean, javadoc.
  
  Revision  ChangesPath
  1.30  +323 -145  
jakarta-commons/math/src/java/org/apache/commons/math/stat/StatUtils.java
  
  Index: StatUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/StatUtils.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- StatUtils.java23 Jun 2004 16:26:17 -  1.29
  +++ StatUtils.java11 Jul 2004 18:41:19 -  1.30
  @@ -27,9 +27,9 @@
   import org.apache.commons.math.stat.univariate.summary.SumOfSquares;
   
   /**
  - * StatUtils provides static implementations of common double[] based
  - * statistical methods. These return a single result value or in some cases, as
  - * identified in the javadoc for each method, codeDouble.NaN./code
  + * StatUtils provides static methods for computing statistics based on data
  + * stored in double[] arrays. 
  + * 
* @version $Revision$ $Date$
*/
   public final class StatUtils {
  @@ -56,7 +56,7 @@
   private static UnivariateStatistic mean = new Mean();
   
   /** variance */
  -private static UnivariateStatistic variance = new Variance();
  +private static Variance variance = new Variance();
   
   /** variance */
   private static Percentile percentile = new Percentile();
  @@ -68,251 +68,429 @@
   }
   
   /**
  - * The sum of the values that have been added to Univariate.
  - * @param values Is a double[] containing the values
  - * @return the sum of the values or codeDouble.NaN/code if the array is 
empty
  + * Returns the sum of the values in the input array, or
  + * codeDouble.NaN/code if the array is empty.
  + * p
  + * Throws codeIllegalArgumentException/code if the input array
  + * is null.
  + * 
  + * @param values  array of values to sum
  + * @return the sum of the values or codeDouble.NaN/code if the array
  + * is empty
  + * @throws IllegalArgumentException if the array is null
*/
   public static double sum(final double[] values) {
   return sum.evaluate(values);
   }
   
   /**
  - * The sum of the values that have been added to Univariate.
  - * @param values Is a double[] containing the values
  - * @param begin processing at this point in the array
  + * Returns the sum of the entries in the specified portion of
  + * the input array, or codeDouble.NaN/code if the designated subarray
  + * is empty.
  + * p
  + * Throws codeIllegalArgumentException/code if the array is null.
  + * 
  + * @param values the input array
  + * @param begin index of the first array element to include
* @param length the number of elements to include
  - * @return the sum of the values or codeDouble.NaN/code if the array is 
empty
  + * @return the sum of the values or Double.NaN if length = 0
  + * @throws IllegalArgumentException if the array is null or the array index
  + *  parameters are not valid
*/
  -public static double sum(
  -final double[] values,
  -final int begin,
  -final int length) {
  +public static double sum(final double[] values, final int begin, 
  +final int length) {
   return sum.evaluate(values, begin, length);
   }
   
   /**
  - * Returns the sum of the squares of the available values.
  - * @param values Is a double[] containing the values
  - * @return the sum of the squared values or codeDouble.NaN/code if the 
array is empty
  + * Returns the sum of the squares of the entries in the input array, or 
  + * codeDouble.NaN/code if the array is empty.
  + * p
  + * Throws codeIllegalArgumentException/code if the array is null.
  + * 
  + * @param values  input array
  + * @return the sum of the squared values or codeDouble.NaN/code if the
  + * array is empty
  + * @throws IllegalArgumentException if the array is null
*/
   public static double sumSq(final double[] values) {
   return sumSq.evaluate(values);
   }
   
   /**
  - * Returns the sum of the squares of the available values.
  - * @param values Is a double[] containing the values
  - * @param begin processing at this point in the array
  + * Returns the sum of the squares of the entries in the specified portion of
  + * the input array, or codeDouble.NaN/code if the designated subarray
  + * is empty.
  + * p
  + * Throws codeIllegalArgumentException/code if the array is null.
  + * 
  + * @param values the input array
  + * @param begin index of the first array element to include
* @param length the number of 

cvs commit: jakarta-commons/math/src/test/org/apache/commons/math/stat StatUtilsTest.java

2004-07-11 Thread psteitz
psteitz 2004/07/11 11:42:07

  Modified:math/src/test/org/apache/commons/math/stat
StatUtilsTest.java
  Log:
  Added tests for methods computing variance from mean, removed obsolete tests.
  
  Revision  ChangesPath
  1.18  +6 -42 
jakarta-commons/math/src/test/org/apache/commons/math/stat/StatUtilsTest.java
  
  Index: StatUtilsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/stat/StatUtilsTest.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- StatUtilsTest.java24 May 2004 05:33:42 -  1.17
  +++ StatUtilsTest.java11 Jul 2004 18:42:07 -  1.18
  @@ -62,6 +62,7 @@
   assertEquals(sum, sum, StatUtils.sum(values), tolerance);
   assertEquals(sumsq, sumSq, StatUtils.sumSq(values), tolerance);
   assertEquals(var, var, StatUtils.variance(values), tolerance);
  +assertEquals(var with mean, var, StatUtils.variance(values, mean), 
tolerance);
   assertEquals(mean, mean, StatUtils.mean(values), tolerance);
   assertEquals(min, min, StatUtils.min(values), tolerance);
   assertEquals(max, max, StatUtils.max(values), tolerance);
  @@ -87,47 +88,6 @@
   StatUtils.variance(values) == 0);
   }
   
  -public void testSkewAndKurtosis() {
  -
  -double[] values =
  -{
  -12.5,
  -12,
  -11.8,
  -14.2,
  -14.9,
  -14.5,
  -21,
  -8.2,
  -10.3,
  -11.3,
  -14.1,
  -9.9,
  -12.2,
  -12,
  -12.1,
  -11,
  -19.8,
  -11,
  -10,
  -8.8,
  -9,
  -12.3 };
  -
  -assertEquals(mean, 12.40455, StatUtils.mean(values), 0.0001);
  -assertEquals(variance, 10.00236, StatUtils.variance(values), 0.0001);
  -}
  -
  -public void testProductAndGeometricMean() throws Exception {
  -double[] values = { 1.0, 2.0, 3.0, 4.0 };
  -
  -assertEquals(
  -Product not expected,
  -24.0,
  -StatUtils.product(values),
  -Double.MIN_VALUE);
  -}
  -
   public void testArrayIndexConditions() throws Exception {
   double[] values = { 1.0, 2.0, 3.0, 4.0 };
   
  @@ -309,6 +269,10 @@
   // test many
   x = new double[] {one, two, two, three};
   TestUtils.assertEquals(0.5, StatUtils.variance(x, 2, 2), tolerance);
  +
  +// test precomputed mean
  +x = new double[] {one, two, two, three};
  +TestUtils.assertEquals(0.5, StatUtils.variance(x,2.5, 2, 2), tolerance);
   }
   
   public void testMax() {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



DO NOT REPLY [Bug 22172] - [lang] DateUtils.parseCVS behavior parsing h:mm z

2004-07-11 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://issues.apache.org/bugzilla/show_bug.cgi?id=22172.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=22172

[lang] DateUtils.parseCVS behavior parsing h:mm z

[EMAIL PROTECTED] changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||WONTFIX



--- Additional Comments From [EMAIL PROTECTED]  2004-07-11 18:44 ---
The method needs further development. It has been moved into the DateFormatter
class in the lang sandbox. Accompanying test (testParseCVS) has been moved to
DateformatterTest.java in the lang sandbox.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang project.xml

2004-07-11 Thread psteitz
psteitz 2004/07/11 16:21:01

  Modified:lang project.xml
  Log:
  Added C. Scott Ananian to contributors.
  
  Revision  ChangesPath
  1.35  +3 -0  jakarta-commons/lang/project.xml
  
  Index: project.xml
  ===
  RCS file: /home/cvs/jakarta-commons/lang/project.xml,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- project.xml   1 Jun 2004 21:10:37 -   1.34
  +++ project.xml   11 Jul 2004 23:21:01 -  1.35
  @@ -153,6 +153,9 @@
   
 contributors
   contributor
  +  nameC. Scott Ananian/name
  +/contributor
  +contributor
 nameChris Audley/name
   /contributor
   contributor
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



DO NOT REPLY [Bug 29294] - [lang][PATCH] lang.math.Fraction class deficiencies

2004-07-11 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://issues.apache.org/bugzilla/show_bug.cgi?id=29294.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=29294

[lang][PATCH] lang.math.Fraction class deficiencies

[EMAIL PROTECTED] changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED



--- Additional Comments From [EMAIL PROTECTED]  2004-07-11 23:23 ---
Numeric fixes committed.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/moment Variance.java

2004-07-11 Thread psteitz
psteitz 2004/07/11 16:39:08

  Modified:math/src/java/org/apache/commons/math/stat/univariate/moment
Variance.java
  Log:
  Removed redundant null check.
  
  Revision  ChangesPath
  1.27  +1 -4  
jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/moment/Variance.java
  
  Index: Variance.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/moment/Variance.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- Variance.java 11 Jul 2004 18:38:12 -  1.26
  +++ Variance.java 11 Jul 2004 23:39:08 -  1.27
  @@ -231,9 +231,6 @@
* @throws IllegalArgumentException if the array is null
*/
   public double evaluate(final double[] values, final double mean) {
  -if (values == null) {
  -throw new IllegalArgumentException(input values array is null);
  -}
   return evaluate(values, mean, 0, values.length);
   }
   
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [math] cvs commit: jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/moment Variance.java

2004-07-11 Thread Phil Steitz
Mark R. Diggory wrote:
Phil,
I wanted to point out there is a test(...) method in the
AbstractUnivariateStatistic class for validation of the input, this 
provides three test conditions for the incoming array and its 
starting/ending indicies. Most of the UnivariateStatistics reuse this 
for consistent validation. I'd recommend using it here:

+public double evaluate(final double[] values, final double mean) {
+if (values == null) { +throw new 
IllegalArgumentException(input values array  is null);
+} +return evaluate(values, mean, 0, values.length); 
+}
Actually, test() is being used under the covers by the last line.  The 
null check above is redundant and has been removed.  Good catch.

Phil


-
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 DateUtils.java

2004-07-11 Thread stevencaswell
stevencaswell2004/07/11 17:04:32

  Modified:lang/src/java/org/apache/commons/lang/time DateUtils.java
  Log:
  corrected calendar field used to calculate the offset when modifying the hour for a 
round or truncated based on AM_PM
  
  Revision  ChangesPath
  1.23  +3 -3  
jakarta-commons/lang/src/java/org/apache/commons/lang/time/DateUtils.java
  
  Index: DateUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/time/DateUtils.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- DateUtils.java11 Jul 2004 18:40:04 -  1.22
  +++ DateUtils.java12 Jul 2004 00:04:32 -  1.23
  @@ -367,10 +367,10 @@
   }
   break;
   case Calendar.AM_PM:
  -if (fields[i][0] == Calendar.HOUR) {
  +if (fields[i][0] == Calendar.HOUR_OF_DAY) {
   //If we're going to drop the HOUR field's value,
   //  we want to do this our own way.
  -offset = val.get(Calendar.HOUR);
  +offset = val.get(Calendar.HOUR_OF_DAY);
   if (offset = 12) {
   offset -= 12;
   }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/test/org/apache/commons/lang/time DateUtilsTest.java

2004-07-11 Thread stevencaswell
stevencaswell2004/07/11 17:08:51

  Modified:lang/src/test/org/apache/commons/lang/time
DateUtilsTest.java
  Log:
  added tests for rounding and truncating to AM_PM;
  added additional test of rounding to SEMI_MONTH
  
  Revision  ChangesPath
  1.15  +99 -0 
jakarta-commons/lang/src/test/org/apache/commons/lang/time/DateUtilsTest.java
  
  Index: DateUtilsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/time/DateUtilsTest.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- DateUtilsTest.java11 Jul 2004 18:40:35 -  1.14
  +++ DateUtilsTest.java12 Jul 2004 00:08:51 -  1.15
  @@ -42,6 +42,11 @@
   DateFormat dateParser = null;
   DateFormat dateTimeParser = null;
   DateFormat timeZoneDateParser = null;
  +Date dateAmPm1 = null;
  +Date dateAmPm2 = null;
  +Date dateAmPm3 = null;
  +Date dateAmPm4 = null;
  +Date date0 = null;
   Date date1 = null;
   Date date2 = null;
   Date date3 = null;
  @@ -50,6 +55,10 @@
   Date date6 = null;
   Date date7 = null;
   Date date8 = null;
  +Calendar calAmPm1 = null;
  +Calendar calAmPm2 = null;
  +Calendar calAmPm3 = null;
  +Calendar calAmPm4 = null;
   Calendar cal1 = null;
   Calendar cal2 = null;
   Calendar cal3 = null;
  @@ -81,6 +90,11 @@
   dateParser = new SimpleDateFormat(MMM dd, , Locale.ENGLISH);
   dateTimeParser = new SimpleDateFormat(MMM dd,  H:mm:ss.SSS, 
Locale.ENGLISH);
   
  +dateAmPm1 = dateTimeParser.parse(February 3, 2002 01:10:00.000);
  +dateAmPm2 = dateTimeParser.parse(February 3, 2002 11:10:00.000);
  +dateAmPm3 = dateTimeParser.parse(February 3, 2002 13:10:00.000);
  +dateAmPm4 = dateTimeParser.parse(February 3, 2002 19:10:00.000);
  +date0 = dateTimeParser.parse(February 3, 2002 12:34:56.789);
   date1 = dateTimeParser.parse(February 12, 2002 12:34:56.789);
   date2 = dateTimeParser.parse(November 18, 2001 1:23:11.321);
   defaultZone = TimeZone.getDefault();
  @@ -95,6 +109,14 @@
   date8 = dateTimeParser.parse(October 26, 2003 05:30:45.000);
   dateTimeParser.setTimeZone(defaultZone);
   TimeZone.setDefault(defaultZone);
  +calAmPm1 = Calendar.getInstance();
  +calAmPm1.setTime(dateAmPm1);
  +calAmPm2 = Calendar.getInstance();
  +calAmPm2.setTime(dateAmPm2);
  +calAmPm3 = Calendar.getInstance();
  +calAmPm3.setTime(dateAmPm3);
  +calAmPm4 = Calendar.getInstance();
  +calAmPm4.setTime(dateAmPm4);
   cal1 = Calendar.getInstance();
   cal1.setTime(date1);
   cal2 = Calendar.getInstance();
  @@ -147,6 +169,9 @@
   assertEquals(round month-2 failed,
   dateParser.parse(December 1, 2001),
   DateUtils.round(date2, Calendar.MONTH));
  +assertEquals(round semimonth-0 failed,
  +dateParser.parse(February 1, 2002),
  +DateUtils.round(date0, DateUtils.SEMI_MONTH));
   assertEquals(round semimonth-1 failed,
   dateParser.parse(February 16, 2002),
   DateUtils.round(date1, DateUtils.SEMI_MONTH));
  @@ -177,6 +202,18 @@
   assertEquals(round second-2 failed,
   dateTimeParser.parse(November 18, 2001 1:23:11.000),
   DateUtils.round(date2, Calendar.SECOND));
  +assertEquals(truncate ampm-1 failed,
  +dateTimeParser.parse(February 3, 2002 00:00:00.000),
  +DateUtils.round(dateAmPm1, Calendar.AM_PM));
  +assertEquals(truncate ampm-2 failed,
  +dateTimeParser.parse(February 4, 2002 00:00:00.000),
  +DateUtils.round(dateAmPm2, Calendar.AM_PM));
  +assertEquals(truncate ampm-3 failed,
  +dateTimeParser.parse(February 3, 2002 12:00:00.000),
  +DateUtils.round(dateAmPm3, Calendar.AM_PM));
  +assertEquals(truncate ampm-4 failed,
  +dateTimeParser.parse(February 4, 2002 12:00:00.000),
  +DateUtils.round(dateAmPm4, Calendar.AM_PM));
   
   // tests for public static Date round(Object date, int field)
   assertEquals(round year-1 failed,
  @@ -227,6 +264,18 @@
   assertEquals(round calendar second-2 failed,
   dateTimeParser.parse(November 18, 2001 1:23:11.000),
   DateUtils.round((Object) cal2, Calendar.SECOND));
  +assertEquals(truncate ampm-1 failed,
  +dateTimeParser.parse(February 3, 2002 00:00:00.000),
  +DateUtils.round((Object) dateAmPm1, Calendar.AM_PM));
  +assertEquals(truncate ampm-2 failed,
  +dateTimeParser.parse(February 

DO NOT REPLY [Bug 23815] - [beanutils]PropertyUtils.getNestedProperty() doesn't allow getXxxx on Map-Instances any longer

2004-07-11 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://issues.apache.org/bugzilla/show_bug.cgi?id=23815.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=23815

[beanutils]PropertyUtils.getNestedProperty() doesn't allow getXxxx on Map-Instances 
any longer





--- Additional Comments From [EMAIL PROTECTED]  2004-07-12 00:26 ---
I just thought I would document better the change in behaviour I am proposing 
to make.

1) Change the getSimpleProperty and setSimpleProperty methods so that if 
a regular property doesn't exist, it checks if the bean is a map and if it 
is, sets the mapped property (as requested in Bug 26904).

2) setNestedProperty already did the above for Maps (first checking if 
a regular property existed, otherwise setting the mapped property) but since 
I added this behaviour to setSimpleProperty I changed it to just call 
setSimpleProperty - should be no difference in behaviour from this change.

3) getNestedProperty was inconsistent with setNestedProperty - for Maps it just 
returned the mapped property. I changed it to call getSimpleProperty (which now 
checks first for regular property and then for mapped) so that it behaves in 
the same way as setNestedProperty.

Although I have attached a patch to show the changes I propose - I am also 
proposing another change to PropertyUtilsBean in Bug 28813 and that patch also 
incorporates this change - I propose to apply that patch.

Niall

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/math/src/test/org/apache/commons/math/complex ComplexUtilsTest.java ComplexMathTest.java

2004-07-11 Thread psteitz
psteitz 2004/07/11 17:27:09

  Added:   math/src/java/org/apache/commons/math/complex
ComplexUtils.java
   math/src/test/org/apache/commons/math/complex
ComplexUtilsTest.java
  Removed: math/src/java/org/apache/commons/math/complex
ComplexMath.java
   math/src/test/org/apache/commons/math/complex
ComplexMathTest.java
  Log:
  Renamed ComplexMath to ComplexUtils.
  
  Revision  ChangesPath
  1.1  
jakarta-commons/math/src/java/org/apache/commons/math/complex/ComplexUtils.java
  
  Index: ComplexUtils.java
  ===
  /*
   * Copyright 2003-2004 The Apache Software Foundation.
   *
   * Licensed under the Apache License, Version 2.0 (the License);
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *  http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an AS IS BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package org.apache.commons.math.complex;
  
  import org.apache.commons.math.util.MathUtils;
  
  /**
   * Implementations of various transcendental functions for
   * [EMAIL PROTECTED] org.apache.commons.math.complex.Complex} arguments.
   *
   * Reference:
   * ul
   * lia href=http://myweb.lmu.edu/dmsmith/ZMLIB.pdf;
   * Multiple Precision Complex Arithmetic and Functions/a/li
   * /ul
   *
   * @version $Revision: 1.1 $ $Date: 2004/07/12 00:27:09 $
   */
  public class ComplexUtils {
  
  /**
   * Default constructor.
   */
  private ComplexUtils() {
  super();
  }
  
  /**
   * Compute the a href=http://mathworld.wolfram.com/InverseCosine.html;
   * inverse cosine/a for the given complex argument.
   * @param z the value whose inverse cosine is to be returned.
   * @return the inverse cosine of codez/code.
   */
  public static Complex acos(Complex z) {
  if (z.isNaN()) {
  return Complex.NaN;
  }
  
  return Complex.I.negate().multiply(log(z.add(
  Complex.I.multiply(sqrt1z(z);   
  }
  
  /**
   * Compute the a href=http://mathworld.wolfram.com/InverseSine.html;
   * inverse sine/a for the given complex argument.
   * @param z the value whose inverse sine is to be returned.
   * @return the inverse sine of codez/code.
   */
  public static Complex asin(Complex z) {
  if (z.isNaN()) {
  return Complex.NaN;
  }
  
  return Complex.I.negate().multiply(log(sqrt1z(z).add(
  Complex.I.multiply(z;   
  }
  
  /**
   * Compute the a href=http://mathworld.wolfram.com/InverseTangent.html;
   * inverse tangent/a for the given complex argument.
   * @param z the value whose inverse tangent is to be returned.
   * @return the inverse tangent of codez/code.
   */
  public static Complex atan(Complex z) {
  if (z.isNaN()) {
  return Complex.NaN;
  }
  
  
  return Complex.I.multiply(
  log(Complex.I.add(z).divide(Complex.I.subtract(z
  .divide(new Complex(2.0, 0.0));
  }
  
  /**
   * Compute the a href=http://mathworld.wolfram.com/Cosine.html;cosine/a
   * for the given complex argument.
   * @param z the value whose cosine is to be returned.
   * @return the cosine of codez/code.
   */
  public static Complex cos(Complex z) {
  if (z.isNaN()) {
  return Complex.NaN;
  }
  
  double a = z.getReal();
  double b = z.getImaginary();
  
  return new Complex(Math.cos(a) * MathUtils.cosh(b),
  -Math.sin(a) * MathUtils.sinh(b));
  }
  
  /**
   * Compute the a href=http://mathworld.wolfram.com/HyperbolicCosine.html;
   * hyperbolic cosine/a for the given complex argument.
   * @param z the value whose hyperbolic cosine is to be returned.
   * @return the hyperbolic cosine of codez/code.
   */
  public static Complex cosh(Complex z) {
  if (z.isNaN()) {
  return Complex.NaN;
  }
  
  double a = z.getReal();
  double b = z.getImaginary();
  
  return new Complex(MathUtils.cosh(a) * Math.cos(b),
  MathUtils.sinh(a) * Math.sin(b));
  }
  
  /**
   * Compute the
   * a href=http://mathworld.wolfram.com/ExponentialFunction.html;
   * exponential function/a for the given complex argument.
   

[beanutils] Summary of propsed/committed changes for Bugs

2004-07-11 Thread Niall Pemberton
Robert,

I thought I would just summarise what I've done on beanutils to date, so
that its easier for you (or others to review) - theres basically four main
pieces of work which I highlight in the Summary below, but I've also
detailed all the bugs I changed under Detail below.

SUMMARY
=
1)   Committed fixes for Bug 28684 to the numeric locale converters and
added test cases.
2)   Added patch for review to Bug 29772 to fix issues in
DateLocaleConverter and addtional tests
3)   Added patch for review to Bug 23815 to fix issues in
PropertyUtilsBean - however these changes are also incorporated in the patch
attached to Bug 28813 below and its that patch that I hope to committ.
4)   Added patch for review to Bug 28813 to fix issues in
PropertyUtilsBean - working on addtional tests which I will attach to the
bug for review when I've completed them.


DETAIL
==

1) Bug 28254getIndexedProperty problems on JDK 1.4.1
http://issues.apache.org/bugzilla/show_bug.cgi?id=28254

I closed this because it was a duplicate of Bug 28358 (same reporter and
same wording!)


2) Bug 28684BigDecimalLocaleConverter seems not working as designed
http://issues.apache.org/bugzilla/show_bug.cgi?id=28684

BigDecimalLocaleConverter was basically returning the results of whatever
the DecimalFormat.parse() returned - i.e. either a Double or Long. The same
issue also existed in three of the other locale converter clases. This IMO
was a pretty straight forward bug and so I have actually committed fixes for
these and added unit tests for all the numeric locale converters and fixed
another small bug I found while testing.


3) Bug 29772DateLocaleConverter does NOT return a default value if a
conversion error occurs
http://issues.apache.org/bugzilla/show_bug.cgi?id=29772

This bug I think might already have been resolved by previous changes.
Anyway I decided to add some more tests to DateLocaleConverterTestCase to
see if I could reproduce the problem and I found that while it worked under
JDK 1.3, I had a number of problems under JDK 1.4.  I have attached  a patch
to the bug with a workaround for these issues along with the modified Test
Case. Feedback on whether you (or anyone else) are happy for me to apply
this patch would be much appreciated.


4) Bug 23815, 26904 and 29571

Bug 23815   PropertyUtils.getNestedProperty() doesn't allow getXxxx on
Map-Instances any longer
Bug 26904  (g|s)etSimpleProperty fails when passing a Map
Bug 29571  Inconsistent behaviour of BeanUtils.setProperty() and
BeanUtils.getProperty() methods
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23815
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26904
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=29571

These bugs all related to the same issue. Craig McClanahan posted concerns
in one of the bugs that what was being requested would break backward
compatibility. I believe that the change in behaviour I'm proposing
satisfies both camps and resolves the inconsistencies between some of the
methods. I've documented on Bug  23815 the changes in behaviour to
PropertyUtilsBean I'm proposing.


5) Bugs 23108 and 28813

Bug 28813Can't use . (dot) in mapped properties for setProperty or
getPropertyDescriptor
Bug 23108Setting complex mapped properties using PropertyUtils
http://issues.apache.org/bugzilla/show_bug.cgi?id=28813
http://issues.apache.org/bugzilla/show_bug.cgi?id=23108

Both these bugs deal with the same issue so I closed Bug 23108 as a
duplicate of 28813

PropertyUtils was changed in Bug 10478 so that mapped propery keys could
contain dot notation - but only the get method was changed, not the set
or getPropertyDescriptor methods. I have attached a patch to the bug with
the changes to PropertyUtilsBean - the changes in the diff file look more
complex than they seem - all I did was copy the while() loop logic from
the get method to the set and getPropertyDescriptor methods, so that they
are all working consistently the same way.

These bugs were for the same class (PropertyUtilsBean) as for the Bugs in 4)
so the patch attached to Bug 28813 also includes the changes for the bugs in
4). Feedback on whether you (or anyone else) are happy for me to apply this
patch would be much appreciated.

I'm currently working on adding additional tests for this patch and will
attach it to the Bug 28813 when I've finished it.


Niall

- Original Message - 
From: robert burrell donkin [EMAIL PROTECTED]
To: Jakarta Commons Developers List [EMAIL PROTECTED]
Sent: Sunday, July 11, 2004 9:53 PM
Subject: Re: [beanutils] LazyDynaClass and LazyDynaBean Bug [29879]


 cool.

 i see you've added reviewed a good number of bugs reports (thanks).
 i'll try to find time to go through as many as possible of them
 tomorrow.

 the general plan for beanutils (and some background) is on the wiki. we
 need to cut a 1.7.0 service release that will give compatibility with
 both collections 2.x and 3.x. this will enable a similar release to be
 cut for 

Re: [beanutils] beanification interfaces

2004-07-11 Thread Niall Pemberton
I'll try to reiew this sometime in the next week - unfortunately I spent far
longer on beanutils bugs than I planned this past week - the
DateLocaleConverter drove me mad at one point and I spent a load of time on
test cases that I didn't envisage.

Niall

- Original Message - 
From: robert burrell donkin [EMAIL PROTECTED]
To: Jakarta Commons Developers List [EMAIL PROTECTED]
Sent: Sunday, July 11, 2004 10:27 PM
Subject: [beanutils] beanification interfaces


 the code base which will be released as 1.7.0 contains the
 beanification changes. basically, the booch utilities which provided
 the main facade for beanutils (BeanUtils, PropertyUtils and
 ConvertUtils) have been converted into thin delegates for concrete
 classes (BeanUtilsBean, PropertyUtilsBean, ConvertUtilsBean) which now
 contain the implementation methods. a separate instance is used per
 context classloader (in other words, they are quasi-singletons). this
 should provide better isolation when run in a container environment
 (for example, in web applications).

 we should take this opportunity to review this design before we commit
 to supporting it in future releases.

 i think now that it would be better to separate the implementations
 from the (logical) interfaces for the beans (which would be empty
 abstract classes since it's easier to preserve compatibility with an
 abstract class than an interface). this would make it easier for
 alternative implementations to be created. in the long run, i'd like to
 be able to support stuff like alternative conversion engines and bean
 query languages. i think that separating interface from implementation
 would allow these features to be added more easily.

 comments encouraged :)

 - robert


 -
 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 28813] - [beanutils]Can't use . (dot) in mapped properties for setProperty or getPropertyDescriptor

2004-07-11 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://issues.apache.org/bugzilla/show_bug.cgi?id=28813.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=28813

[beanutils]Can't use . (dot) in mapped properties for setProperty or 
getPropertyDescriptor





--- Additional Comments From [EMAIL PROTECTED]  2004-07-12 01:55 ---
Created an attachment (id=12079)
Updated PropertyUtilsBean Test Case for Bug 28813 and Bug 23815

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



DO NOT REPLY [Bug 28358] - Problems on indexed property with JDK 1.4

2004-07-11 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://issues.apache.org/bugzilla/show_bug.cgi?id=28358.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=28358

Problems on indexed property with JDK 1.4





--- Additional Comments From [EMAIL PROTECTED]  2004-07-12 02:28 ---
The only observation I have on this is that you are naming your property and 
indexed property methods with the same name. If you modify one of the method 
names does it then work properly?

For example have:

  public List getChilds() {
return childs;
  }
  public ChildsBean getOneChild(int index) {

  }

for (int j = 0; j  newChilds.size(); j++)  {
   BeanUtils.copyProperties(PropertyUtils.getIndexedProperty
(valBean,oneChild,j), newChilds.get(j));
}

Niall

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



DO NOT REPLY [Bug 23815] - [beanutils]PropertyUtils.getNestedProperty() doesn't allow getXxxx on Map-Instances any longer

2004-07-11 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://issues.apache.org/bugzilla/show_bug.cgi?id=23815.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=23815

[beanutils]PropertyUtils.getNestedProperty() doesn't allow getXxxx on Map-Instances 
any longer





--- Additional Comments From [EMAIL PROTECTED]  2004-07-12 03:32 ---
In addition to the fact that this breaks backwards compatibility for all Struts
1.1 users, it is also inconsistent with the way that expression language (EL)
expressions have evolved in JSTL 1.0/1.1 and JSP 2.0, as well as JSF 1.0.  In
all of those cases, if an object is an instanceof Map, then it is *always*
treated as a Map -- any JavaBeans properties of the object are *not* accessible.

The same thing applies to the standard implementation of DynaBeans (including
the implementation that Struts creates for DynaActionForms) -- if it's a
DynaBean, then you are always getting/setting dynamic properties; never
accessing the JavaBeans properties of the implementation class.  Implementing
the proposed patch for nested properties still leaves things gratuitously
inconsistent -- and I consider the original Struts 1.0 behavior to be the one
that is incorrect.

Because of these reasons, I'm opposed to changing the *default* behavior of
BeanUtils as proposed.  I'm fine with making it possible once we have
beanification completed (and can tell the factory to give us a BeanUtils that
acts a certain way) -- but in the mean time I'm -1.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [beanutils] Summary of propsed/committed changes for Bugs

2004-07-11 Thread Craig McClanahan
Niall Pemberton wrote:
4) Bug 23815, 26904 and 29571
Bug 23815   PropertyUtils.getNestedProperty() doesn't allow getXxxx on
Map-Instances any longer
Bug 26904  (g|s)etSimpleProperty fails when passing a Map
Bug 29571  Inconsistent behaviour of BeanUtils.setProperty() and
BeanUtils.getProperty() methods
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23815
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26904
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=29571
These bugs all related to the same issue. Craig McClanahan posted concerns
in one of the bugs that what was being requested would break backward
compatibility. I believe that the change in behaviour I'm proposing
satisfies both camps and resolves the inconsistencies between some of the
methods. I've documented on Bug  23815 the changes in behaviour to
PropertyUtilsBean I'm proposing.
 

Niall,
Thanks for taking the time to propose a solution to this problem, as 
well as all the work you've done on the other BeanUtils issues.  As I 
just posted in the comments on bug 23815, I'm deeply concerned that 
changing this behavior will break Struts 1.1 apps (yes, I know that 
people only now converting from Struts 1.0 would find it easier; but 
it's the Struts 1.0 behavior that was badly broken).  What's worse is 
the fact that this isn't the only case where a map is treated specially 
-- exactly the same thing happens with the standard implementations of 
dynabeans (including DynaActionForm in Struts 1.1).

The standard implementations of expression evaluation (JSTL 1.0/1.1, JSP 
2.0, JSF 1.0/1.1) all conform to the way that BeanUtils currently works 
-- if the object you pass implements Map, it is *always* treated as a 
Map.  This is further evidence that the right path for default behavior 
lies in maintaining what we currently have, not going back to what was 
broken.

For making the Struts 1.0 transition easier, I'd be +1 on setting up a 
BeanUtilsFactory that allows you to set the characteristics of the 
BeanUtils instance to be created (somewhat like what JAXP does to set up 
a parser instance that is either validating or non-validating, for 
example).  But I'm -1 on changing the default behavior of these methods 
until we do the beanification step.

Craig
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Cannot use HttpClient to search google

2004-07-11 Thread Vincent Chain
I am encountering an interesting issue, and I guess the issue is probably not within 
the HttpClient itself, but I haven't figured out how to make it work yet. I am using 
the 2.0 version.
 
What I try to do is simple enough: I want to use HttpClient to simulate a typical 
browser request to search in google. For example a query like
 
http://www.google.com/search?hl=enie=UTF-8q=sql+server+trace
 
And I used some code like below
 
client = new HttpClient();
m = new GetMethod(http://www.google.com/search?hl=enie=UTF-8q=sql+server+trace;);
s = client.executeMethod(m);
 
Now s is always 403 for me (and this 403 should have nothing to do with Proxy), and 
the content of the response is basically google saying that the request is forbidden 
(because it reaches a host that the client is not supposed to)... the response is too 
large for this email, but it looks like this
 
htmlheadtitle403 Forbidden/title
blockquoteH1Forbidden/H1Your client does not have permission to get URL 
code/search?hl=enamp;ie=UTF-8amp;q=sql+server+trace/code from this server.  
(Client IP address: xx.xx.xx.xx)brbrPlease see Google's Terms of Service posted at 
http://www.google.com/terms_of_service.html

 
I guess the main reason is google uses akamai's network to distribute loads. On my 
server when I do an nslookup of google, I can see that the DNS records returned have 
very short valid duration: from several seconds to a couple of minutes. I guess this 
way the browser will be forced to issue another DNS query the next time I do a search. 
The issue when I use HttpClient however is it always uses a certain IP for 
www.google.com and seems to ignore the short life of the DNS entry. I think because 
HttpClient opened a socket to this 'old' IP address google somehow figured it's not a 
valid request and rejected it.
 
I did a quick check on the HttpClient code and it seems to me the Socket it uses to 
open the connection is implemented from java.net.Socket 
(DefaultProtocolSocketFactory::createSocket), so I guess HttpClient is not directly 
responsible for the problem here... Nevertheless, I wonder if any one having similar 
issue as I do? Especially considering some of the HttpClient sample codes uses 
http://www.google.com then it should have similar problems?
 
Thanks a lot for any tips.
 
 
 
 


-
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!

Re: Cannot use HttpClient to search google

2004-07-11 Thread Adrian Sutton
htmlheadtitle403 Forbidden/title
blockquoteH1Forbidden/H1Your client does not have permission to 
get URL code/search?hl=enamp;ie=UTF-8amp;q=sql+server+trace/code 
from this server.  (Client IP address: xx.xx.xx.xx)brbrPlease see 
Google's Terms of Service posted at 
http://www.google.com/terms_of_service.html


I guess the main reason is google uses akamai's network to distribute 
loads.
No it means you should read the terms of service, specifically the part 
about not using screen-scraping techniques to programatically perform 
searches (which is what you're trying to do).  You should use the 
Google SOAP search service instead as it will make your life a lot 
easier.

It would not be appropriate to discuss ways around the technical 
limitations Google uses to enforce their terms of service on an Apache 
Software Foundation mailing list.

The particular section of the Google ToS that I believe applies here is 
listed under the Personal Use Only and No Automated Querying 
headings.

Information on Google's SOAP APIs is available at 
http://www.google.com.au/apis/ (note they also have terms of service)

Finally, sorry if this seems abrupt, it is important for the ASF to 
clearly not support use of their products in any way that may cause 
legal trouble.  If you feel you are following the terms of services for 
Google and I've missed something then my apologies.

Regards,
Adrian Sutton.
--
Intencha tomorrow's technology today
Ph: 38478913 0422236329
Suite 8/29 Oatland Crescent
Holland Park West 4121
Australia QLD
www.intencha.com


PGP.sig
Description: This is a digitally signed message part


Re: Wire log to Log4J logger.

2004-07-11 Thread Eric Bloch
Hey Folks,
I'm having trouble making httpclient 2.0 use log4j logging inside 
Tomcat5 (when running against java 1.4).  Seems as though tomcat5 makes 
some call to the the commons logger early on (see below).  Tomcat5 
doesn't come with log4j... so the commons logging default log factory 
implementation picks up the jdk14 logger for tomcat as you'd expect.

I'm guessing that somehow when my webapp comes up... the commons logger 
fails to look for log4j in my WEB-INF/lib.  This feels like one of the 
class-loader disagreements that I've seen related to 
java/commons-logging and the servlet spec.  That is, my webapp is 
getting tomcat's copy of the default log factor impl, instead of its own.

Fwiw, this is a stack from early tomcat initialization:
LogFactoryImpl.getLogClassName() line: 331
LogFactoryImpl.getLogConstructor() line: 368
LogFactoryImpl.newInstance(String) line: 529
LogFactoryImpl.getInstance(String) line: 235
LogFactoryImpl.getInstance(Class) line: 209
LogFactory.getLog(Class) line: 351
JdkCompat.clinit() line: 53
StandardClassLoader.clinit() line: 207
ClassLoaderFactory.createClassLoader(File[], File[], URL[], ClassLoader) 
line: 189
Bootstrap.createClassLoader(String, ClassLoader) line: 160
Bootstrap.initClassLoaders() line: 104
Bootstrap.init() line: 193
Bootstrap.main(String[]) line: 399

And this is a stack where my initial use of the httpclient ends up 
picking up the JDK14 logger even though my webapp has log4j in it's 
WEB-INF/lib:

Jdk14Logger.init(String) line: 50
NativeConstructorAccessorImpl.newInstance0(Constructor, Object[]) line: 
not available [native method]
NativeConstructorAccessorImpl.newInstance(Object[]) line: 39
DelegatingConstructorAccessorImpl.newInstance(Object[]) line: 27
Constructor.newInstance(Object[]) line: 274
LogFactoryImpl.newInstance(String) line: 529
LogFactoryImpl.getInstance(String) line: 235
LogFactoryImpl.getInstance(Class) line: 209
LogFactory.getLog(Class) line: 351
MultiThreadedHttpConnectionManager.clinit() line: 98
.
.
.


It isn't an option for me to put touch any of the jars inside the 
container.  And I'd like to force httpclient to use log4j when it's used 
within my webapp.  This was working fine, fyi, in tomcat4.

Any clues/advice?
Thanks!
-Eric
Michael Becke wrote:
Hi John,
HttpClient uses commons-logging which defaults to Log4j when it is  
present on the classpath.  You can enable wire logging by setting the  
logger httpclient.wire to DEBUG.  This can be done using any of  
Log4j's standard configuration methods.

Mike
On May 24, 2004, at 10:07 AM, John Melody wrote:
Is there a way to configure the wire log to go to a Log4J log  configured
for the application.
I have configured Log4J as my application logger and I would like to  
send
the
Httpclient wire log to the same file. Currently it is set up as the
following -

System.setProperty(org.apache.commons.logging.simplelog.log.httpclient 
.wire
, debug);
which sends the wire log to the console.

Is it possible to configure this so that all the logging output  
including
the
wire log would go to my log4J application log?

thanks for any help,
regards, John.

John Melody
SyberNet Ltd.
Galway Business Park,
Dangan,
Galway.
Tel. No. +353 91 514400
Fax. NO. +353 91 514409
Mobile - 087-2345847
-
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]
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Cannot use HttpClient to search google

2004-07-11 Thread Vincent Chain
Well, I view this as a technical question. I have no
intention to use the
code for automated querying and this is for my
experiment of the HttpClient.
Google happens to be the URL i choose. There could be
another host that does
similar things as google, but does not enforce similar
terms. And the issue
would still be there right? I am asking a technical
question here, but your
points are taken.

Thanks

- Original Message - 
From: Adrian Sutton [EMAIL PROTECTED]
To: Commons HttpClient Project
[EMAIL PROTECTED]
Sent: Sunday, July 11, 2004 2:25 AM
Subject: Re: Cannot use HttpClient to search google

 htmlheadtitle403 Forbidden/title
 blockquoteH1Forbidden/H1Your client does not
have permission to
 get URL
code/search?hl=enamp;ie=UTF-8amp;q=sql+server+trace/code
 from this server.  (Client IP address:
xx.xx.xx.xx)brbrPlease see
 Google's Terms of Service posted at
 http://www.google.com/terms_of_service.html
 

 I guess the main reason is google uses akamai's
network to distribute
 loads.

No it means you should read the terms of service,
specifically the part
about not using screen-scraping techniques to
programatically perform
searches (which is what you're trying to do).  You
should use the
Google SOAP search service instead as it will make
your life a lot
easier.

It would not be appropriate to discuss ways around the
technical
limitations Google uses to enforce their terms of
service on an Apache
Software Foundation mailing list.

The particular section of the Google ToS that I
believe applies here is
listed under the Personal Use Only and No Automated
Querying
headings.

Information on Google's SOAP APIs is available at
http://www.google.com.au/apis/ (note they also have
terms of service)

Finally, sorry if this seems abrupt, it is important
for the ASF to
clearly not support use of their products in any way
that may cause
legal trouble.  If you feel you are following the
terms of services for
Google and I've missed something then my apologies.

Regards,

Adrian Sutton.

--
Intencha tomorrow's technology today
Ph: 38478913 0422236329
Suite 8/29 Oatland Crescent
Holland Park West 4121
Australia QLD
www.intencha.com




__
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Wire log to Log4J logger.

2004-07-11 Thread Michael Becke
Hi Eric,
I would suggest posting this question to the commons-logging and tomcat  
folks.  This one is pretty well out of our scope.

Mike
On Jul 11, 2004, at 9:16 PM, Eric Bloch wrote:
Hey Folks,
I'm having trouble making httpclient 2.0 use log4j logging inside  
Tomcat5 (when running against java 1.4).  Seems as though tomcat5  
makes some call to the the commons logger early on (see below).   
Tomcat5 doesn't come with log4j... so the commons logging default log  
factory implementation picks up the jdk14 logger for tomcat as you'd  
expect.

I'm guessing that somehow when my webapp comes up... the commons  
logger fails to look for log4j in my WEB-INF/lib.  This feels like one  
of the class-loader disagreements that I've seen related to  
java/commons-logging and the servlet spec.  That is, my webapp is  
getting tomcat's copy of the default log factor impl, instead of its  
own.

Fwiw, this is a stack from early tomcat initialization:
LogFactoryImpl.getLogClassName() line: 331
LogFactoryImpl.getLogConstructor() line: 368
LogFactoryImpl.newInstance(String) line: 529
LogFactoryImpl.getInstance(String) line: 235
LogFactoryImpl.getInstance(Class) line: 209
LogFactory.getLog(Class) line: 351
JdkCompat.clinit() line: 53
StandardClassLoader.clinit() line: 207
ClassLoaderFactory.createClassLoader(File[], File[], URL[],  
ClassLoader) line: 189
Bootstrap.createClassLoader(String, ClassLoader) line: 160
Bootstrap.initClassLoaders() line: 104
Bootstrap.init() line: 193
Bootstrap.main(String[]) line: 399

And this is a stack where my initial use of the httpclient ends up  
picking up the JDK14 logger even though my webapp has log4j in it's  
WEB-INF/lib:

Jdk14Logger.init(String) line: 50
NativeConstructorAccessorImpl.newInstance0(Constructor, Object[])  
line: not available [native method]
NativeConstructorAccessorImpl.newInstance(Object[]) line: 39
DelegatingConstructorAccessorImpl.newInstance(Object[]) line: 27
Constructor.newInstance(Object[]) line: 274
LogFactoryImpl.newInstance(String) line: 529
LogFactoryImpl.getInstance(String) line: 235
LogFactoryImpl.getInstance(Class) line: 209
LogFactory.getLog(Class) line: 351
MultiThreadedHttpConnectionManager.clinit() line: 98
.
.
.


It isn't an option for me to put touch any of the jars inside the  
container.  And I'd like to force httpclient to use log4j when it's  
used within my webapp.  This was working fine, fyi, in tomcat4.

Any clues/advice?
Thanks!
-Eric
Michael Becke wrote:
Hi John,
HttpClient uses commons-logging which defaults to Log4j when it is   
present on the classpath.  You can enable wire logging by setting the  
 logger httpclient.wire to DEBUG.  This can be done using any of   
Log4j's standard configuration methods.
Mike
On May 24, 2004, at 10:07 AM, John Melody wrote:
Is there a way to configure the wire log to go to a Log4J log   
configured
for the application.

I have configured Log4J as my application logger and I would like to  
 send
the
Httpclient wire log to the same file. Currently it is set up as the
following -

System.setProperty(org.apache.commons.logging.simplelog.log.httpclie 
nt .wire
, debug);
which sends the wire log to the console.

Is it possible to configure this so that all the logging output   
including
the
wire log would go to my log4J application log?

thanks for any help,
regards, John.

John Melody
SyberNet Ltd.
Galway Business Park,
Dangan,
Galway.
Tel. No. +353 91 514400
Fax. NO. +353 91 514409
Mobile - 087-2345847
-
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]
-
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 29636] - Setting different MAX_HOST_CONNECTION values per host using a single MultiThreadedHttpConnectionManager

2004-07-11 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://issues.apache.org/bugzilla/show_bug.cgi?id=29636.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=29636

Setting different MAX_HOST_CONNECTION values per host using a single 
MultiThreadedHttpConnectionManager





--- Additional Comments From [EMAIL PROTECTED]  2004-07-12 03:26 ---
Created an attachment (id=12080)
patch 2

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



DO NOT REPLY [Bug 29636] - Setting different MAX_HOST_CONNECTION values per host using a single MultiThreadedHttpConnectionManager

2004-07-11 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://issues.apache.org/bugzilla/show_bug.cgi?id=29636.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=29636

Setting different MAX_HOST_CONNECTION values per host using a single 
MultiThreadedHttpConnectionManager





--- Additional Comments From [EMAIL PROTECTED]  2004-07-12 03:27 ---
Hi Oleg, Roland,

Thanks for taking a look at this one.  Here is a new version that should address both 
of the points 
mentioned.  Please let me know what you think.

Thanks,

Mike

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Cannot use HttpClient to search google

2004-07-11 Thread Adrian Sutton
Hi Vincent,
While I appreciate that your intentions are not malicious and that you 
may well be within the terms of Google's service, I would very much 
prefer to avoid the potential issues altogether by not working around 
Google's technical limitations.

For experimenting with HttpClient I'd suggest you just pick a different 
URL - http://jakarta.apache.org would be a good one.  If you do come 
across this problem or ones like it at other sites where the terms of 
service are less risky then we can certainly help you work how to get 
HttpClient to access the site. You'll find in the list archives that 
we've helped quite a number of people get HttpClient to work with sites 
that for some reason pose technical problems (usually because of their 
lack of standards compliance).

Regards,
Adrian Sutton.
On 12/07/2004, at 11:36 AM, Vincent Chain wrote:
Well, I view this as a technical question. I have no
intention to use the
code for automated querying and this is for my
experiment of the HttpClient.
Google happens to be the URL i choose. There could be
another host that does
similar things as google, but does not enforce similar
terms. And the issue
would still be there right? I am asking a technical
question here, but your
points are taken.
Thanks
--
Intencha tomorrow's technology today
Ph: 38478913 0422236329
Suite 8/29 Oatland Crescent
Holland Park West 4121
Australia QLD
www.intencha.com


PGP.sig
Description: This is a digitally signed message part