Showing the changes to java/pkg/sun/net/ProgressEvent.java (1 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,113 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2004, 2008, Oracle and/or its affiliates. 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. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
| 22 | * or visit www.oracle.com if you need additional information or have any | ||
| 23 | * 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 | @SuppressWarnings("serial") // never serialized | ||
| 36 | public class ProgressEvent extends EventObject { | ||
| 37 | // URL of the stream | ||
| 38 | private URL url; | ||
| 39 | // content type of the stream | ||
| 40 | private String contentType; | ||
| 41 | // method associated with URL | ||
| 42 | private String method; | ||
| 43 | // bytes read | ||
| 44 | private long progress; | ||
| 45 | // bytes expected | ||
| 46 | private long expected; | ||
| 47 | // the last thing to happen | ||
| 48 | private ProgressSource.State state; | ||
| 49 | |||
| 50 | /** | ||
| 51 | * Construct a ProgressEvent object. | ||
| 52 | */ | ||
| 53 | public ProgressEvent(ProgressSource source, URL url, String method, String contentType, ProgressSource.State state, long progress, long expected) { | ||
| 54 | super(source); | ||
| 55 | this.url = url; | ||
| 56 | this.method = method; | ||
| 57 | this.contentType = contentType; | ||
| 58 | this.progress = progress; | ||
| 59 | this.expected = expected; | ||
| 60 | this.state = state; | ||
| 61 | } | ||
| 62 | |||
| 63 | /** | ||
| 64 | * Return URL related to the progress. | ||
| 65 | */ | ||
| 66 | public URL getURL() | ||
| 67 | { | ||
| 68 | return url; | ||
| 69 | } | ||
| 70 | |||
| 71 | /** | ||
| 72 | * Return method associated with URL. | ||
| 73 | */ | ||
| 74 | public String getMethod() | ||
| 75 | { | ||
| 76 | return method; | ||
| 77 | } | ||
| 78 | |||
| 79 | /** | ||
| 80 | * Return content type of the URL. | ||
| 81 | */ | ||
| 82 | public String getContentType() | ||
| 83 | { | ||
| 84 | return contentType; | ||
| 85 | } | ||
| 86 | |||
| 87 | /** | ||
| 88 | * Return current progress value. | ||
| 89 | */ | ||
| 90 | public long getProgress() | ||
| 91 | { | ||
| 92 | return progress; | ||
| 93 | } | ||
| 94 | |||
| 95 | /** | ||
| 96 | * Return expected maximum progress value; -1 if expected is unknown. | ||
| 97 | */ | ||
| 98 | public long getExpected() { | ||
| 99 | return expected; | ||
| 100 | } | ||
| 101 | |||
| 102 | /** | ||
| 103 | * Return state. | ||
| 104 | */ | ||
| 105 | public ProgressSource.State getState() { | ||
| 106 | return state; | ||
| 107 | } | ||
| 108 | |||
| 109 | public String toString() { | ||
| 110 | return getClass().getName() + "[url=" + url + ", method=" + method + ", state=" + state | ||
| 111 | + ", content-type=" + contentType + ", progress=" + progress + ", expected=" + expected + "]"; | ||
| 112 | } | ||
| 113 | } | ||