ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rainer Noack" <rai...@noacks.net>
Subject RE: cvs commit: ant/src/main/org/apache/tools/ant/launch Locator.java
Date Sun, 04 Apr 2004 10:34:38 GMT
Hi Matt,
another point:
URL.getPath() has been introduced in jdk 1.3
but maybe you can use URL.getFile() instead.
Regards,
Rainer


> -----Original Message-----
> From: Matt Benson [mailto:gudnabrsam@yahoo.com] 
> Sent: Saturday, April 03, 2004 9:32 PM
> To: Ant Developers List
> Subject: Re: cvs commit: 
> ant/src/main/org/apache/tools/ant/launch Locator.java
> 
> 
> Good point.  I'll alter that.  :)
> 
> -Matt
> 
> --- Martijn Kruithof <martijn@kruithof.xs4all.nl>
> wrote:
> > mbenson@apache.org wrote:
> > 
> > >  
> > >  1.12      +12 -7    
> >
> ant/src/main/org/apache/tools/ant/launch/Locator.java
> > >  
> > >  Index: Locator.java
> > > 
> >
> ===================================================================
> > >  RCS file:
> >
> /home/cvs/ant/src/main/org/apache/tools/ant/launch/Locator.java,v
> > >  retrieving revision 1.11
> > >  retrieving revision 1.12
> > >  diff -u -r1.11 -r1.12
> > >  --- Locator.java	9 Mar 2004 16:48:03 -0000	1.11
> > >  +++ Locator.java	2 Apr 2004 20:20:43 -0000	1.12
> > >  @@ -101,13 +101,18 @@
> > >        * @since Ant 1.6
> > >        */
> > >       public static String fromURI(String uri) {
> > >  -        if (!uri.startsWith("file:")) {
> > >  -            throw new
> > IllegalArgumentException("Can only handle file:
> > URIs");
> > >  -        }
> > >  -        if (uri.startsWith("file://")) {
> > >  -            uri = uri.substring(7);
> > >  -        } else {
> > >  -            uri = uri.substring(5);
> > >  +        try {
> > >  +            URL url = new URL(uri);
> > >  +            if
> > (!("file".equals(url.getProtocol()))) {
> > >  +                throw new
> > IllegalArgumentException("Can only handle file:
> > URIs");
> > >  +            }
> > >  +            StringBuffer buf = new
> > StringBuffer(url.getHost());
> > >  +            if (buf.length() > 0) {
> > >  +                buf.insert(0, "//");
> > >  +            }
> > >  +            buf.append(url.getPath());
> > >  +            uri = buf.toString();
> > >  +        } catch (MalformedURLException
> > emYouEarlEx) {
> > >           }
> > >   
> > >           uri = uri.replace('/',
> > File.separatorChar);
> > >  
> > >  
> > >
> > This is funny, If the URL isn't a file URL we throw
> > an
> > IllegalArgumentException, but if the URL isn't a
> > valid URL at all we 
> > just continue? (Without removing the file:(//) which
> > could have been in 
> > front, which would have been removed before?)
> > 
> > 
> > 
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > dev-unsubscribe@ant.apache.org
> > For additional commands, e-mail:
> > dev-help@ant.apache.org
> > 
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Small Business $15K Web Design Giveaway 
> http://promotions.yahoo.com/design_giveaway/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message