jdk/src/share/classes/sun/net/ProgressEvent.java
changeset 2 90ce3da70b43
child 1334 21b652819b97
equal deleted inserted replaced
0:fd16c54261b3 2:90ce3da70b43
       
     1 /*
       
     2  * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.  Sun designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Sun in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    22  * CA 95054 USA or visit www.sun.com if you need additional information or
       
    23  * have any questions.
       
    24  */
       
    25 package sun.net;
       
    26 
       
    27 import java.util.EventObject;
       
    28 import java.net.URL;
       
    29 
       
    30 /**
       
    31  * ProgressEvent represents an progress event in monitering network input stream.
       
    32  *
       
    33  * @author Stanley Man-Kit Ho
       
    34  */
       
    35 public class ProgressEvent extends EventObject  {
       
    36     // URL of the stream
       
    37     private URL url;
       
    38     // content type of the stream
       
    39     private String contentType;
       
    40     // method associated with URL
       
    41     private String method;
       
    42     // bytes read
       
    43     private long progress;
       
    44     // bytes expected
       
    45     private long expected;
       
    46     // the last thing to happen
       
    47     private ProgressSource.State state;
       
    48 
       
    49     /**
       
    50      * Construct a ProgressEvent object.
       
    51      */
       
    52     public ProgressEvent(ProgressSource source, URL url, String method, String contentType, ProgressSource.State state, long progress, long expected) {
       
    53         super(source);
       
    54         this.url = url;
       
    55         this.method = method;
       
    56         this.contentType = contentType;
       
    57         this.progress = progress;
       
    58         this.expected = expected;
       
    59         this.state = state;
       
    60     }
       
    61 
       
    62     /**
       
    63      * Return URL related to the progress.
       
    64      */
       
    65     public URL getURL()
       
    66     {
       
    67         return url;
       
    68     }
       
    69 
       
    70     /**
       
    71      * Return method associated with URL.
       
    72      */
       
    73     public String getMethod()
       
    74     {
       
    75         return method;
       
    76     }
       
    77 
       
    78     /**
       
    79      * Return content type of the URL.
       
    80      */
       
    81     public String getContentType()
       
    82     {
       
    83         return contentType;
       
    84     }
       
    85 
       
    86     /**
       
    87      * Return current progress value.
       
    88      */
       
    89     public long getProgress()
       
    90     {
       
    91         return progress;
       
    92     }
       
    93 
       
    94     /**
       
    95      * Return expected maximum progress value; -1 if expected is unknown.
       
    96      */
       
    97     public long getExpected() {
       
    98         return expected;
       
    99     }
       
   100 
       
   101     /**
       
   102      * Return state.
       
   103      */
       
   104     public ProgressSource.State getState() {
       
   105         return state;
       
   106     }
       
   107 
       
   108     public String toString()    {
       
   109         return getClass().getName() + "[url=" + url + ", method=" + method + ", state=" + state
       
   110              + ", content-type=" + contentType + ", progress=" + progress + ", expected=" + expected + "]";
       
   111     }
       
   112 }