Return-Path: Delivered-To: apmail-jakarta-httpclient-dev-archive@www.apache.org Received: (qmail 84626 invoked from network); 11 Mar 2006 09:19:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 11 Mar 2006 09:19:36 -0000 Received: (qmail 69819 invoked by uid 500); 11 Mar 2006 09:19:36 -0000 Delivered-To: apmail-jakarta-httpclient-dev-archive@jakarta.apache.org Received: (qmail 69794 invoked by uid 500); 11 Mar 2006 09:19:35 -0000 Mailing-List: contact httpclient-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "HttpClient Project" Reply-To: "HttpClient Project" Delivered-To: mailing list httpclient-dev@jakarta.apache.org Received: (qmail 69783 invoked by uid 99); 11 Mar 2006 09:19:35 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 Mar 2006 01:19:35 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [212.227.126.177] (HELO moutng.kundenserver.de) (212.227.126.177) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 Mar 2006 01:19:34 -0800 Received: from [85.180.37.135] (helo=[85.180.37.135]) by mrelayeu.kundenserver.de (node=mrelayeu9) with ESMTP (Nemesis), id 0ML2xA-1FI0Fk3Nho-0003ER; Sat, 11 Mar 2006 10:19:12 +0100 Message-ID: <44129642.7020607@dubioso.net> Date: Sat, 11 Mar 2006 10:20:02 +0100 From: Roland Weber User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20051110 X-Accept-Language: en-us, en MIME-Version: 1.0 To: HttpClient Project Subject: Re: java.net.URL or URI References: <1142028751.4494.12.camel@localhost.localdomain> In-Reply-To: <1142028751.4494.12.camel@localhost.localdomain> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Provags-ID: kundenserver.de abuse@kundenserver.de login:4601b1d39ab4ddfc21c613822e406392 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi John, > Pattern pat = new Pattern(someReallyCoolRegexHere); > Matcher match = pat.matcher(webPageTextHere); > while( match.find() ) > GetMethod get = new GetMethod( new URL( topURL, > match.group(1)).toString() ); > > but if the url was supported, and extended with some of the simple > features, it would be cleaner: > > GetMethod get = new GetMethod( topUrl, match.group(1) ); > > As I type this I realize it is probably trivial, but surely a reason > must exist that string was supported rather than url? The URL class has 6 constructors in JDK 1.4.2 (I didn't bother to check which ones were in the eralier JDK version which is the prerequisite for HttpClient). Surely you don't expect us to duplicate all of them just to save you a single line of code and two braces? while( match.find() ) { URL from = new URL( topURL, match.group(1) ); GetMethod get = new GetMethod( from.toString() ); ... // I assume that something was omitted here, otherwise // you are pointlessly creating objects in a loop :-) } If you choose to make your code unreadable by nesting statements, it is only fair that *you* should suffer the consequences. The URI class was introduced with JDK 1.4. HttpClient requires only an older JDK, I don't have in mind whether that was 1.2 or 1.3. But the URI class also has a toString() method that can easily be used in the way shown above. See how flexible the string constructor is? cheers, Roland --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org