You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by je...@apache.org on 2001/02/28 06:48:21 UTC
cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/util GenericURI.java
jericho 01/02/27 21:48:21
Modified: src/webdav/client/src/org/apache/webdav/util GenericURI.java
Log:
- Fix the getName method for collection.
- when you get a collection, the collection name ends with the slash.
Revision Changes Path
1.5 +18 -15 jakarta-slide/src/webdav/client/src/org/apache/webdav/util/GenericURI.java
Index: GenericURI.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/GenericURI.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- GenericURI.java 2001/02/26 12:58:38 1.4
+++ GenericURI.java 2001/02/28 05:48:21 1.5
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/GenericURI.java,v 1.4 2001/02/26 12:58:38 jericho Exp $
- * $Revision: 1.4 $
- * $Date: 2001/02/26 12:58:38 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/GenericURI.java,v 1.5 2001/02/28 05:48:21 jericho Exp $
+ * $Revision: 1.5 $
+ * $Date: 2001/02/28 05:48:21 $
*
* ====================================================================
*
@@ -615,11 +615,10 @@
/*
- * Get the resource or file name for this generic URI.
+ * Get the resource or collection name for this generic URI.
+ * When you get a collection, the collection name ends with the slash.
*
- * @return The resource or file name string for this generic URI.
- * If it's a collection or directory,
- * the empty string is returned.
+ * @return The resource or collection name string for this generic URI.
*/
public String getName() {
@@ -628,20 +627,24 @@
/*
- * Get the resource or file name of the given path.
+ * Get the resource or collection name of the already-normalized path.
+ * When you get a collection, the collection name ends with the slash.
*
- * @param path A path string.
- * @return The resource or file name string of the given path.
- * If it's a collection or directory,
- * the empty string is returned.
+ * @param path the already-normalized path.
+ * @return the collection name, if the path is a collection,
+ * the resource name, if the path is a resource.
*/
public static String getName(String path) {
- String pathname = getPath(path);
+ String name = getPath(path);
+
+ int at = name.lastIndexOf("/");
+ int len = name.length();
- int at = pathname.lastIndexOf("/");
+ if ((at != 0) && (at == len-1))
+ at = name.substring(0, at-1).lastIndexOf("/");
- return (at >= 0) ? pathname.substring(at+1) : pathname;
+ return (at == 0) ? "/" : name.substring(at+1);
}