mbenson 2005/08/05 10:34:36 Modified: src/main/org/apache/tools/ant/types/resources FileResource.java Log: Change behavior of getName(); refine compareTo(). Revision Changes Path 1.3 +20 -3 ant/src/main/org/apache/tools/ant/types/resources/FileResource.java Index: FileResource.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/resources/FileResource.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- FileResource.java 31 May 2005 19:18:55 -0000 1.2 +++ FileResource.java 5 Aug 2005 17:34:36 -0000 1.3 @@ -124,7 +124,9 @@ } /** - * Get the name of this FileResource relative to its baseDir, if any. + * Get the name of this FileResource. If the basedir is set, + * the name will be relative to that. Otherwise the basename + * only will be returned. * @return the name of this resource. */ public String getName() { @@ -132,7 +134,7 @@ return ((Resource) getCheckedRef()).getName(); } File b = getBaseDir(); - return b == null ? getNotNullFile().getAbsolutePath() + return b == null ? getNotNullFile().getName() : FILE_UTILS.removeLeadingPath(b, getNotNullFile()); } @@ -220,7 +222,22 @@ if (isReference()) { return ((Comparable) getCheckedRef()).compareTo(another); } - return this.equals(another) ? 0 : super.compareTo(another); + if (this.equals(another)) { + return 0; + } + if (another.getClass().equals(getClass())) { + FileResource otherfr = (FileResource) another; + File f = getFile(); + if (f == null) { + return -1; + } + File of = otherfr.getFile(); + if (of == null) { + return 1; + } + return f.compareTo(of); + } + return super.compareTo(another); } /**
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]