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/04/11 18:02:01 UTC

cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/lib ProgressUtil.java ProgressListener.java ProgressEvent.java WebdavClient.java ResponseInputStream.java RequestOutputStream.java

jericho     01/04/11 09:02:01

  Modified:    src/webdav/client/src/org/apache/webdav/lib
                        WebdavClient.java ResponseInputStream.java
                        RequestOutputStream.java
  Added:       src/webdav/client/src/org/apache/webdav/lib
                        ProgressUtil.java ProgressListener.java
                        ProgressEvent.java
  Log:
  - Add the function of not only getting events for downloading and uploading files but also communicating with the WebDAV server of reading and sending headers. (XML document could be large)
  
  Revision  Changes    Path
  1.32      +44 -5     jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavClient.java
  
  Index: WebdavClient.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavClient.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- WebdavClient.java	2001/03/23 05:06:33	1.31
  +++ WebdavClient.java	2001/04/11 16:02:00	1.32
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavClient.java,v 1.31 2001/03/23 05:06:33 remm Exp $
  - * $Revision: 1.31 $
  - * $Date: 2001/03/23 05:06:33 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavClient.java,v 1.32 2001/04/11 16:02:00 jericho Exp $
  + * $Revision: 1.32 $
  + * $Date: 2001/04/11 16:02:00 $
    *
    * ====================================================================
    *
  @@ -84,7 +84,7 @@
    *
    * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
    */
  -public class WebdavClient {
  +public class WebdavClient implements ProgressListener {
   
   
       // -------------------------------------------------------------- Constants
  @@ -184,6 +184,18 @@
   
   
       /**
  +     * The utility of the process event and listener.
  +     */
  +    private ProgressUtil streamProgress;
  +
  +
  +    /**
  +     * The utility of the process event and listener.
  +     */
  +    private ProgressUtil clientProgress = new ProgressUtil();
  +
  +
  +    /**
        * Debug level.
        */
       protected int debug = 0;
  @@ -406,10 +418,15 @@
           // Parse response
           ResponseInputStream responseInputStream =
               new ResponseInputStream(input, responseHeaders);
  -        method.parseResponse(responseInputStream);
   
  +        // Add the progress listener.
  +        streamProgress = responseInputStream.getProgressUtil();
  +        streamProgress.addProgressListener((ProgressListener) this);
  +
  +        method.parseResponse(responseInputStream);
           method.setUsed();
   
  +        streamProgress.removeProgressListener((ProgressListener) this);
           responseInputStream.close();
   
           if (needToCloseConnection(method, responseHeaders)) {
  @@ -605,6 +622,10 @@
           RequestOutputStream requestOutputStream =
               new RequestOutputStream(output);
   
  +        // Add the progress listener.
  +        streamProgress = requestOutputStream.getProgressUtil();
  +        streamProgress.addProgressListener((ProgressListener) this);
  +        
           if (method.isStreamedQuery()) {
               if ((http11) && (method.getHeader("Content-Length") == null)) {
                   requestOutputStream.setUseChunking(true);
  @@ -614,6 +635,9 @@
               requestOutputStream.write(query.getBytes());
           }
   
  +        // Remove the progress listener.
  +        streamProgress.removeProgressListener(this);
  +
           // Closing wrapped output stream
           requestOutputStream.close();
   
  @@ -815,5 +839,20 @@
               return false;
       }
   
  +
  +    /**
  +     * Progressing something by the progress event.
  +     */
  +    public void progressing(ProgressEvent pe) {
  +        getProgressUtil().fireProgress(pe);
  +    }
  +
  +
  +    /**
  +     * Get the utility of this progress event and listener.
  +     */
  +    public ProgressUtil getProgressUtil() {
  +        return clientProgress;
  +    }
   
   }
  
  
  
  1.6       +25 -5     jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/ResponseInputStream.java
  
  Index: ResponseInputStream.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/ResponseInputStream.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ResponseInputStream.java	2001/03/06 01:04:44	1.5
  +++ ResponseInputStream.java	2001/04/11 16:02:01	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/ResponseInputStream.java,v 1.5 2001/03/06 01:04:44 remm Exp $
  - * $Revision: 1.5 $
  - * $Date: 2001/03/06 01:04:44 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/ResponseInputStream.java,v 1.6 2001/04/11 16:02:01 jericho Exp $
  + * $Revision: 1.6 $
  + * $Date: 2001/04/11 16:02:01 $
    *
    * ====================================================================
    *
  @@ -74,7 +74,7 @@
    * Socket input stream wrapper.
    *
    * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
  - * @version $Revision: 1.5 $ $Date: 2001/03/06 01:04:44 $
  + * @version $Revision: 1.6 $ $Date: 2001/04/11 16:02:01 $
    */
   
   public class ResponseInputStream
  @@ -175,6 +175,12 @@
       protected InputStream stream = null;
   
   
  +    /**
  +     * The utility of the process event and listener.
  +     */
  +    private ProgressUtil streamProgress = new ProgressUtil();
  +
  +
       // --------------------------------------------------------- Public Methods
   
   
  @@ -279,6 +285,10 @@
                           if (currentRead == -1)
                               throw new IOException("Unexpected end of stream");
                           nbRead += currentRead;
  +                        // Make the progress event.
  +                        streamProgress.fireProgress(ProgressEvent.RESPONSE,
  +                                                    (long) chunkLength-nbRead,
  +                                                    (long) chunkLength);
                       }
   
                       // Skipping the CRLF
  @@ -299,6 +309,9 @@
   
               // Read and count the next byte, then return it
               int b = stream.read();
  +
  +            // Make the progress event.
  +            streamProgress.fireProgress(ProgressEvent.GET_ACTION, (long) b);
               if (b >= 0)
                   count++;
               return (b);
  @@ -342,6 +355,13 @@
           }
           return (sb.toString());
   
  -        }
  +    }
  +
   
  +    /**
  +     * Get the utility of this progress event and listener.
  +     */
  +    public ProgressUtil getProgressUtil() {
  +        return streamProgress;
  +    }
   }
  
  
  
  1.4       +20 -4     jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/RequestOutputStream.java
  
  Index: RequestOutputStream.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/RequestOutputStream.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RequestOutputStream.java	2001/03/01 22:01:00	1.3
  +++ RequestOutputStream.java	2001/04/11 16:02:01	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/RequestOutputStream.java,v 1.3 2001/03/01 22:01:00 jericho Exp $
  - * $Revision: 1.3 $
  - * $Date: 2001/03/01 22:01:00 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/RequestOutputStream.java,v 1.4 2001/04/11 16:02:01 jericho Exp $
  + * $Revision: 1.4 $
  + * $Date: 2001/04/11 16:02:01 $
    *
    * ====================================================================
    *
  @@ -74,7 +74,7 @@
    * Socket output stream wrapper.
    *
    * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
  - * @version $Revision: 1.3 $ $Date: 2001/03/01 22:01:00 $
  + * @version $Revision: 1.4 $ $Date: 2001/04/11 16:02:01 $
    */
   
   public class RequestOutputStream
  @@ -149,6 +149,12 @@
       private byte one[] = "1".getBytes();
   
   
  +    /**
  +     * The utility of the process event and listener.
  +     */
  +    private ProgressUtil streamProgress = new ProgressUtil();
  +
  +
       // ------------------------------------------------------------- Properties
   
   
  @@ -248,8 +254,12 @@
               stream.write(chunkHeader, 0, chunkHeader.length);
               stream.write(b, off, len);
               stream.write(endChunk, 0, endChunk.length);
  +            // Make the progress event.
  +            streamProgress.fireProgress(ProgressEvent.PUT_ACTION, (long) len);
           } else {
               stream.write(b, off, len);
  +            // Make the progress event.
  +            streamProgress.fireProgress(ProgressEvent.REQUEST, (long) len);
           }
       }
   
  @@ -271,4 +281,10 @@
       }
   
   
  +    /**
  +     * Get the utility of this progress event and listener.
  +     */
  +    public ProgressUtil getProgressUtil() {
  +        return streamProgress;
  +    }
   }
  
  
  
  1.1                  jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/ProgressUtil.java
  
  Index: ProgressUtil.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/ProgressUtil.java,v 1.1 2001/04/11 16:02:01 jericho Exp $
   * $Revision: 1.1 $
   * $Date: 2001/04/11 16:02:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  package org.apache.webdav.lib;
  
  import java.util.Vector;
  import java.util.Enumeration;
  
  /**
   * The utility class for progress listener and event.
   * 
   * @author <a href="mailto:jericho@thinkfree.com">Park, Sung-Gu</a>
   */
  
  public class ProgressUtil {
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The listener list.
       */
      private Vector listeners = new Vector();
      
      
      /**
       * The source object.
       */
      private Object sourceObject = new Object();
      
      
      // --------------------------------------------------------- Public Methods
      
      
      /**
       * Add the specified progress event listener.
       *
       * @param pl The progress listener.
       */
      public void addProgressListener(ProgressListener pl) {
          listeners.addElement(pl);
      }
      
      
      /**
       * Remove the specified progress event listener.
       *
       * @param pl The progress listener.
       */
      public void removeProgressListener(ProgressListener pl) {
          listeners.removeElement(pl);
      }
  
      
      /**
       * Fire the progress event to the specified progress event listener.
       *
       * @param action @see #ProgressEvent
       * @param soMany
       */
      public void fireProgress(int action, long soMany) {
          ProgressEvent pe = new ProgressEvent(sourceObject, action, soMany);
          Enumeration enum = listeners.elements();
          while (enum.hasMoreElements()) {
              ProgressListener listener =
                  (ProgressListener) enum.nextElement();
              listener.progressing(pe);
          }
      }
  
     
      /**
       * Fire the progress event to the specified progress event listener.
       *
       * @param action @see #ProgressEvent
       * @param remainedSize The remained size.
       * @param totalSize The total size.
       */
      public void fireProgress(int action, long remainedSize, long totalSize) {
          ProgressEvent pe = new ProgressEvent(sourceObject, action,
                                               remainedSize, totalSize);
          Enumeration enum = listeners.elements();
          while (enum.hasMoreElements()) {
              ProgressListener listener =
                  (ProgressListener) enum.nextElement();
              listener.progressing(pe);
          }
      }
  
     
      /**
       * Fire the progress event to the specified progress event listener.
       *
       * @param action @see #ProgressEvent
       * @param resourceName The resource name.
       * @param remainedSize The remained size.
       * @param totalSize The total size.
       * @param remainedCount The remained count.
       * @param totalCount The total count.
       */
      public void fireProgress(int action, String resourceName,
                               long remainedSize, long totalSize,
                               long remainedCount, long totalCount) {
          ProgressEvent pe = new ProgressEvent(sourceObject, action, 
                                               resourceName, remainedSize,
                                               totalSize, remainedCount,
                                               totalCount);
          Enumeration enum = listeners.elements();
          while (enum.hasMoreElements()) {
              ProgressListener listener =
                  (ProgressListener) enum.nextElement();
              listener.progressing(pe);
          }
      }
  
  
      /**
       * Fire the progress event to the specified progress event listener.
       *
       * @param pe The progress event.
       */
      public void fireProgress(ProgressEvent pe) {
          Enumeration enum = listeners.elements();
          while (enum.hasMoreElements()) {
              ProgressListener listener =
                  (ProgressListener) enum.nextElement();
              listener.progressing(pe);
          }
      }
  }
  
  
  
  
  1.1                  jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/ProgressListener.java
  
  Index: ProgressListener.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/ProgressListener.java,v 1.1 2001/04/11 16:02:01 jericho Exp $
   * $Revision: 1.1 $
   * $Date: 2001/04/11 16:02:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  package org.apache.webdav.lib;
  
  /**
   * The progress listener.
   * 
   * @author <a href="mailto:jericho@thinkfree.com">Park, Sung-Gu</a>
   */
  
  public interface ProgressListener extends java.util.EventListener {
  
      // --------------------------------------------------------- Public Methods
  
      /**
       * Progressing.
       *
       * @param pe The progress event.
       */
      public void progressing(ProgressEvent pe);
  
  }
  
  
  
  1.1                  jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/ProgressEvent.java
  
  Index: ProgressEvent.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/ProgressEvent.java,v 1.1 2001/04/11 16:02:01 jericho Exp $
   * $Revision: 1.1 $
   * $Date: 2001/04/11 16:02:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  package org.apache.webdav.lib;
  
  import java.util.Vector;
  
  /**
   * The progress event class.
   * 
   * @author <a href="mailto:jericho@thinkfree.com">Park, Sung-Gu</a>
   */
  
  public class ProgressEvent extends java.util.EventObject {
  
      // ---------------------------------------------------------- Constructors
  
  
      /**
       * Default constructor.
       */
      public ProgressEvent(Object eventSource) {
          super(eventSource);
      }
  
  
      /**
       * Constructor.
       */
      public ProgressEvent(Object eventSource, int action, long soMany) {
          super(eventSource);
          this.action = action;
          this.soMany = soMany;
      }
  
  
      /**
       * Constructor.
       */
      public ProgressEvent(Object eventSource, int action, long remainedSize,
                           long totalSize) {
          super(eventSource);
          this.action = action;
          this.remainedSize = remainedSize;
          this.totalSize = totalSize;
      }
  
  
      /**
       * Constructor.
       */
      public ProgressEvent(Object eventSource, int action, String resourceName,
                           long remainedSize, long totalSize, long remainedCount,
                           long totalCount) {
          super(eventSource);
          this.resourceName = resourceName;
          this.remainedSize = remainedSize;
          this.totalSize = totalSize;
          this.totalCount = totalCount;
      }
  
  
      // ---------------------------------------------------- Instance Variables
  
  
      /**
       * The resource name.
       */
      private String resourceName;
  
  
      /**
       * The action status.
       */
      private int action;
  
  
      /**
       * The so many size to be processed.
       */
      private long soMany;
  
  
      /**
       * The remained value.
       */
      private long remainedSize;
  
  
      /**
       * The total value.
       */
      private long totalSize;
  
  
      /**
       * The remained count.
       */
      private long remainedCount;
  
  
      /**
       * The total count.
       */
      private long totalCount;
  
  
      // ---------------------------------------------------- Constants Instances
  
  
      /**
       * The action of requesting headers.
       */
      public static final int REQUEST = 0;
  
  
      /**
       * The action of responsing headers.
       */
      public static final int RESPONSE = 1;
  
  
      /**
       * The action of uploading stream.
       */
      public static final int PUT_ACTION = 2;
  
  
      /**
       * The action of downloading stream.
       */
      public static final int GET_ACTION = 3;
  
  
      // -------------------------------------------------------- Public Methods
  
  
      /**
       * Get the action.
       *
       * @return The action.
       */
      public int getAction() {
          return action;
      }
  
  
      /**
       * Get the so many size.
       *
       * @return The size.
       */
      public long getSoMany() {
          return soMany;
      }
  
  
      /**
       * Get the name string.
       *
       * @return The resource name.
       */
      public String getResourceName() {
          return resourceName;
      }
  
  
      /**
       * Get the remained value.
       *
       * @return The remained size.
       */
      public long getRemainedSize() {
          return remainedSize;
      }
  
  
      /**
       * Get the total value.
       *
       * @return The total size.
       */
      public long getTotalSize() {
          return totalSize;
      }
  
  
      /**
       * Get the remained count.
       *
       * @return The remained count.
       */
      public long getRemainedCount() {
          return remainedCount;
      }
  
  
      /**
       * Get the total value.
       *
       * @return The total count.
       */
      public long getTotalCount() {
          return totalCount;
      }
  
  
      /**
       * Set the action.
       *
       * @param action The action.
       */
      public void setAction(int action) {
          this.action = action;
      }
  
  
      /**
       * Set the so many size.
       *
       * @param soMany The so many size.
       */
      public void setSoMany(long soMany) {
          this.soMany = soMany;
      }
  
  
      /**
       * Set the name string.
       *
       * @param resourceName The resource name.
       */
      public void setResourceName(String resourceName) {
          this.resourceName = resourceName;
      }
  
  
      /**
       * Set the remained value.
       *
       * @param remainedSize The remained size.
       */
      public void setRemainedSize(long remainedSize) {
          this.remainedSize = remainedSize;
      }
  
  
      /**
       * Set the total value.
       *
       * @param totalSize The total size.
       */
      public void setTotalSize(long totalSize) {
          this.totalSize = totalSize;
      }
  
  
      /**
       * Set the remained count.
       *
       * @param remainedCount The remained count.
       */
      public void setRemainedCount(long remainedCount) {
          this.remainedCount = remainedCount;
      }
  
  
      /**
       * Set the total count.
       *
       * @param totalCount The total count.
       */
      public void setTotalCount(long totalCount) {
          this.totalCount = totalCount;
      }
  
  
      /**
       * Set the values of this progress event.
       *
       * @param action The action.
       * @param soMany The so many size.
       */
      public void setProgress(int action, long soMany) {
          setAction(action);
          setSoMany(soMany);
      }
  
  
      /**
       * Set the values of this progress event.
       *
       * @param action The action.
       * @param remaindSize The remained size.
       * @param totalSize The total size.
       */
      public void setProgress(int action, long remainedSize, long totalSize) {
          setAction(action);
          setTotalSize(totalSize);
      }
  
  
      /**
       * Set the values of this progress event.
       *
       * @param action The action.
       * @param resourceName The resource name.
       * @param remaindSize The remained size.
       * @param totalSize The total size.
       * @param remainedCount The remained count.
       * @param totalCount The total count.
       */
      public void setProgress(int action, String resourceName, long remainedSize,
                              long totalSize, long remainedCount,
                              long totalCount) {
          setAction(action);
          setResourceName(resourceName);
          setRemainedSize(remainedSize);
          setTotalSize(totalSize);
          setRemainedCount(remainedCount);
          setTotalCount(totalCount);
      }
  }