Path: blob/master/src/java.base/share/classes/sun/net/ProgressEvent.java
41152 views
/*1* Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24package sun.net;2526import java.util.EventObject;27import java.net.URL;2829/**30* ProgressEvent represents an progress event in monitering network input stream.31*32* @author Stanley Man-Kit Ho33*/34@SuppressWarnings("serial") // never serialized35public class ProgressEvent extends EventObject {36// URL of the stream37private URL url;38// content type of the stream39private String contentType;40// method associated with URL41private String method;42// bytes read43private long progress;44// bytes expected45private long expected;46// the last thing to happen47private ProgressSource.State state;4849/**50* Construct a ProgressEvent object.51*/52public ProgressEvent(ProgressSource source, URL url, String method, String contentType, ProgressSource.State state, long progress, long expected) {53super(source);54this.url = url;55this.method = method;56this.contentType = contentType;57this.progress = progress;58this.expected = expected;59this.state = state;60}6162/**63* Return URL related to the progress.64*/65public URL getURL()66{67return url;68}6970/**71* Return method associated with URL.72*/73public String getMethod()74{75return method;76}7778/**79* Return content type of the URL.80*/81public String getContentType()82{83return contentType;84}8586/**87* Return current progress value.88*/89public long getProgress()90{91return progress;92}9394/**95* Return expected maximum progress value; -1 if expected is unknown.96*/97public long getExpected() {98return expected;99}100101/**102* Return state.103*/104public ProgressSource.State getState() {105return state;106}107108public String toString() {109return getClass().getName() + "[url=" + url + ", method=" + method + ", state=" + state110+ ", content-type=" + contentType + ", progress=" + progress + ", expected=" + expected + "]";111}112}113114115