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 re...@apache.org on 2001/03/01 09:36:01 UTC

cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods GetMethod.java

remm        01/03/01 00:36:01

  Modified:    src/webdav/client/src/org/apache/webdav/lib/methods
                        GetMethod.java
  Log:
  - Add a new GetMethod(String path, File file) constructor which allows
    specifying the file to use as the buffer.
  - Add an accessor / mutator for the fileData field.
  
  Revision  Changes    Path
  1.7       +53 -20    jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/GetMethod.java
  
  Index: GetMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/GetMethod.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- GetMethod.java	2001/02/20 07:02:17	1.6
  +++ GetMethod.java	2001/03/01 08:36:00	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/GetMethod.java,v 1.6 2001/02/20 07:02:17 remm Exp $
  - * $Revision: 1.6 $
  - * $Date: 2001/02/20 07:02:17 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/GetMethod.java,v 1.7 2001/03/01 08:36:00 remm Exp $
  + * $Revision: 1.7 $
  + * $Date: 2001/03/01 08:36:00 $
    *
    * ====================================================================
    *
  @@ -131,7 +131,7 @@
       }
       
       
  -   /**
  +    /**
        * Method constructor.
        */
       public GetMethod(String path, String tempDir, String tempFile) {
  @@ -141,7 +141,7 @@
           setTempFile(tempFile);
       }
   
  -   /**
  +    /**
        * Method constructor.
        */
       public GetMethod(String path, boolean useDisk, String tempDir,
  @@ -155,6 +155,16 @@
       }
       
       
  +    /**
  +     * Method constructor.
  +     */
  +    public GetMethod(String path, File fileData) {
  +        this(path);
  +        useDisk = true;
  +        this.fileData = fileData;
  +    }
  +    
  +    
       // ----------------------------------------------------- Instance Variables
       
       
  @@ -260,6 +270,23 @@
       }
       
       
  +    /**
  +     * File data getter.
  +     */
  +    public File getFileData() {
  +        return fileData;
  +    }
  +    
  +    
  +    /**
  +     * File data setter.
  +     */
  +    public void setFileData(File fileData) {
  +        checkNotUsed();
  +        this.fileData = fileData;
  +    }
  +    
  +    
       // --------------------------------------------------------- Public Methods
       
       
  @@ -337,25 +364,31 @@
           OutputStream out = null;
           
           if (useDisk) {
  -            
  -            // Create a temporary file on the HD
  -            File dir = new File(tempDir);
  -            dir.mkdirs();
               
  -            String tempFileName = null;
  -            if (tempFile == null) {
  -                String encodedPath = URLEncoder.encode(getPath());
  -                int length = encodedPath.length();
  -                if (length > 240) {
  -                    encodedPath = encodedPath.substring(length - 200, length);
  +            if (fileData == null) {
  +                
  +                // Create a temporary file on the HD
  +                File dir = new File(tempDir);
  +                dir.mkdirs();
  +                
  +                String tempFileName = null;
  +                if (tempFile == null) {
  +                    String encodedPath = URLEncoder.encode(getPath());
  +                    int length = encodedPath.length();
  +                    if (length > 240) {
  +                        encodedPath = 
  +                            encodedPath.substring(length - 200, length);
  +                    }
  +                    tempFileName = System.currentTimeMillis() + "-" 
  +                        + encodedPath + ".tmp";
  +                } else {
  +                    tempFileName = tempFile;
                   }
  -                tempFileName = System.currentTimeMillis() + "-" 
  -                    + encodedPath + ".tmp";
  -            } else {
  -                tempFileName = tempFile;
  +                
  +                fileData = new File(tempDir, tempFileName);
  +                
               }
               
  -            fileData = new File(tempDir, tempFileName);
               out = new FileOutputStream(fileData);
               
           } else {