luetzkendorf    2004/08/08 06:28:07

  Modified:    webdavclient/ant/src/java/org/apache/webdav/ant/taskdefs
                        WebdavTask.java
  Log:
  replacment for usage of StringBuffer.indexOf to make the tasks JDK1.3 compatible
  
  Revision  Changes    Path
  1.4       +20 -8     
jakarta-slide/webdavclient/ant/src/java/org/apache/webdav/ant/taskdefs/WebdavTask.java
  
  Index: WebdavTask.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/webdavclient/ant/src/java/org/apache/webdav/ant/taskdefs/WebdavTask.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- WebdavTask.java   28 Jul 2004 09:31:47 -0000      1.3
  +++ WebdavTask.java   8 Aug 2004 13:28:07 -0000       1.4
  @@ -95,11 +95,7 @@
          try {
             this.url = new HttpURL(url);
             // remove double slashes in url like /DAV/files//document.txt
  -          StringBuffer path = new StringBuffer(this.url.getPath());
  -          for(int pos = path.indexOf("//"); pos != -1; pos = path.indexOf("//", 
pos+2)) {
  -             path.replace(pos, pos+2, "/");
  -          }
  -          this.url.setPath(path.toString());
  +          this.url.setPath(removeDoubleShashes(this.url.getPath()));
          } catch (URIException e) {
             throw new BuildException("Invalid uri!", e);
          }
  @@ -133,5 +129,21 @@
            coll.setPath(url.getPath() + "/");
            return coll;
         }
  +   }
  +   
  +   static String removeDoubleShashes(String path) {
  +      if (path.indexOf("//") == -1) return path;
  +      
  +      StringBuffer r = new StringBuffer(path.length());
  +      for(int i = 0, l = path.length(); i < l; i++) {
  +         if (path.charAt(i) == '/') {
  +            if (!(i > 0 && path.charAt(i-1) == '/')) {
  +               r.append('/');
  +            }
  +         } else {
  +            r.append(path.charAt(i));
  +         }
  +      }
  +      return r.toString();
      }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to