Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@apache.org Received: (qmail 59253 invoked from network); 17 Jan 2003 15:20:04 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 17 Jan 2003 15:20:04 -0000 Received: (qmail 20715 invoked by uid 97); 17 Jan 2003 14:36:28 -0000 Delivered-To: qmlist-jakarta-archive-ant-dev@jakarta.apache.org Received: (qmail 20585 invoked by uid 97); 17 Jan 2003 14:36:27 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 20505 invoked by uid 97); 17 Jan 2003 14:36:26 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Date: 17 Jan 2003 14:34:56 -0000 Message-ID: <20030117143456.99737.qmail@icarus.apache.org> From: bodewig@apache.org To: jakarta-ant-cvs@apache.org Subject: cvs commit: jakarta-ant/src/main/org/apache/tools/ant/util FileUtils.java LazyHashtable.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N bodewig 2003/01/17 06:34:56 Modified: src/main/org/apache/tools/ant/types XMLCatalog.java src/main/org/apache/tools/ant/util FileUtils.java LazyHashtable.java Log: Fix some JDK 1.1 issues - only culprit remaining is Diagnostics with its class locating code. Learned by failing tests that FileUtils.getFileURL wouldn't append slashes where it should (because normalize strips them). Revision Changes Path 1.22 +9 -5 jakarta-ant/src/main/org/apache/tools/ant/types/XMLCatalog.java Index: XMLCatalog.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/XMLCatalog.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- XMLCatalog.java 13 Jan 2003 15:52:12 -0000 1.21 +++ XMLCatalog.java 17 Jan 2003 14:34:55 -0000 1.22 @@ -76,6 +76,7 @@ import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; +import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.util.JAXPUtils; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; @@ -162,6 +163,9 @@ public class XMLCatalog extends DataType implements Cloneable, EntityResolver, URIResolver { + /** helper for some File.toURL connversions */ + private static FileUtils fileUtils = FileUtils.newFileUtils(); + //-- Fields ---------------------------------------------------------------- /** Holds dtd/entity objects until needed. */ @@ -477,7 +481,7 @@ URL baseURL = null; try { if (base == null) { - baseURL = getProject().getBaseDir().toURL(); + baseURL = fileUtils.getFileURL(getProject().getBaseDir()); } else { baseURL = new URL(base); @@ -646,7 +650,7 @@ baseURL = matchingEntry.getBase(); } else { try { - baseURL = getProject().getBaseDir().toURL(); + baseURL = fileUtils.getFileURL(getProject().getBaseDir()); } catch (MalformedURLException ex) { throw new BuildException("Project basedir cannot be converted to a URL"); @@ -666,7 +670,7 @@ if (url != null) { String fileName = url.getFile(); if (fileName != null) { - log("fileName"+fileName, Project.MSG_DEBUG); + log("fileName " + fileName, Project.MSG_DEBUG); File resFile = new File(fileName); if (resFile.exists() && resFile.canRead()) { try { @@ -743,7 +747,7 @@ baseURL = matchingEntry.getBase(); } else { try { - baseURL = getProject().getBaseDir().toURL(); + baseURL = fileUtils.getFileURL(getProject().getBaseDir()); } catch (MalformedURLException ex) { throw new BuildException("Project basedir cannot be converted to a URL"); 1.35 +10 -9 jakarta-ant/src/main/org/apache/tools/ant/util/FileUtils.java Index: FileUtils.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/util/FileUtils.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- FileUtils.java 19 Dec 2002 11:20:29 -0000 1.34 +++ FileUtils.java 17 Jan 2003 14:34:55 -0000 1.35 @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2001-2002 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -154,11 +154,7 @@ * formed. */ public URL getFileURL(File file) throws MalformedURLException { - String path = file.getAbsolutePath(); - if (file.isDirectory()) { - path += "/"; - } - return new URL(toURI(path)); + return new URL(toURI(file.getAbsolutePath())); } /** @@ -706,8 +702,7 @@ synchronized (rand) { do { result = new File(parent, - prefix - + fmt.format(rand.nextInt(Integer.MAX_VALUE)) + prefix + fmt.format(Math.abs(rand.nextInt())) + suffix); } while (result.exists()); } @@ -915,6 +910,8 @@ * @since Ant 1.6 */ public String toURI(String path) { + boolean isDir = (new File(path)).isDirectory(); + StringBuffer sb = new StringBuffer("file:"); // catch exception if normalize thinks this is not an absolute path @@ -931,6 +928,7 @@ } path = path.replace('\\', '/'); + CharacterIterator iter = new StringCharacterIterator(path); for (char c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) { @@ -941,6 +939,9 @@ } else { sb.append(c); } + } + if (isDir && !path.endsWith("/")) { + sb.append('/'); } return sb.toString(); } 1.2 +2 -2 jakarta-ant/src/main/org/apache/tools/ant/util/LazyHashtable.java Index: LazyHashtable.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/util/LazyHashtable.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- LazyHashtable.java 6 Dec 2002 23:02:30 -0000 1.1 +++ LazyHashtable.java 17 Jan 2003 14:34:55 -0000 1.2 @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2000-2002 The Apache Software Foundation. All rights + * Copyright (c) 2000-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -101,7 +101,7 @@ public boolean containsValue( Object value ) { initAll(); - return super.containsValue( value ); + return super.contains( value ); } public Enumeration keys() { -- To unsubscribe, e-mail: For additional commands, e-mail: