/*
 * @(#)HttpConnectedEvent.java
 *
 * Copyright (c) 2001-2002 JScape
 * 1147 S. 53rd Pl., Mesa, Arizona, 85206, U.S.A.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * JScape. ("Confidential Information").  You shall not disclose such
 * Confidential Information and shall use it only in accordance with
 * the terms of the license agreement you entered into with JScape.
 */
package com.jscape.inet.http;

import java.util.EventObject;


/**
 * Fired on significant progress in upload and download operations in Http
 * class.
 */
public class HttpProgressEvent
        extends EventObject {

    /**
     * Download mode
     */
    public static final int MODE_DOWNLOAD = 0;

    /**
     * Upload mode
     */
    public static final int MODE_UPLOAD = 1;

    private String url;
    private long bytes;
    private int mode = MODE_DOWNLOAD;

    /**
     * Constructs a new <code>HttpProgressEvent </code>.
     *
     * @param source the source of this event
     * @param url    String representation of the <code>URL</code> associated with this event
     * @param bytes  The number of bytes transferred so far.
     * @param mode   the transfer mode
     *
     * @see #MODE_UPLOAD
     * @see #MODE_DOWNLOAD
     */
    public HttpProgressEvent(Object source, String url, long bytes, int mode) {
        super(source);
        this.url = url;
        this.bytes = bytes;
        this.mode = mode;
    }


    /**
     * Gets the String representation of the URL this event is associated with.
     *
     * @return a String representation of the <code>URL</code>
     */
    public String getURL() {
        return url;
    }

    /**
     * Get the number of bytes transferred so far.
     *
     * @return the number of bytes transferred
     */
    public long getBytes() {
        return bytes;
    }

    /**
     * Gets transfer mode of event.
     *
     * @return upload or download mode
     *
     * @see #MODE_UPLOAD
     * @see #MODE_DOWNLOAD
     */
    public int getMode() {
        return mode;
    }

}
