com.webrenderer.swing.event
Class NetworkEvent

java.lang.Object
  extended by java.util.EventObject
      extended by com.webrenderer.swing.event.NetworkEvent
All Implemented Interfaces:
Serializable

public class NetworkEvent
extends EventObject

An event which indicates that there has been network activity. Currently, a NetworkEvent will be invoked if:

To reduce the cost of multiple method invocations, the event object will record the new data pertaining to the event. The object will only contain the data required for the given event. This implies that if the event was generated due to a progress change, then the other information will be invalid.

See Also:
Serialized Form

Field Summary
static int FAILED_CONNECT
          Flag indicating that connection has failed.
static int FAILED_DNS
          Flag indicating that DNS resolution has failed.
static int FAILED_TIMEOUT
          Flag indicating that the connection timed out.
static int FAILED_USER_CANCEL
          Flag indicating that the user canceled the connection.
static int STATUS_LOAD_ERROR
          Flag indicating an error has occurred when loading the page.
static int STATUS_NEGOTIATING
          Flag indicating the browser is awaiting authorization.
static int STATUS_REDIRECTING
          Flag indicating the browser is being redirected.
static int STATUS_TRANSFERRING
          Flag indicating that browser is transferring data from server.
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
NetworkEvent(Object source)
          Constructor for NetworkEvent with a source.
NetworkEvent(Object source, MutableRequestHeaders mrh)
           
 
Method Summary
 X509Certificate getCertificate()
          Gets the X.509 Certificate.
 int getCurrentProgress()
          Returns the number of bytes currently downloaded.
 String getExpectedFaviconURL()
          Returns a favicon URL for this HTTP/HTTPS page load.
 int getFailure()
          Gets the failure status of the network error.
 String getFrame()
          Returns the strFrame.
 int getMaximumProgress()
          Returns the maximum number of bytes to download.
 MutableRequestHeaders getMutableRequestHeaders()
          Returns a MutableRequestHeaders object that allows modification of the request headers for the current transaction.
 String getRequestHeaders()
          Returns the requestHeaders.
 String getResponseHeaders()
          Returns the responseHeaders.
 int getStatus()
          This will return a different status code based on which method of the NetworkEvent it is called from.
 String getStatusText()
          Gets the status text
 String getURL()
          Returns the strURL.
 void setCertificate(X509Certificate cert)
          Sets the X.509 Certificate.
 void setFailure(int flags)
          Sets the failure status of the network error.
 void setFaviconURL(String faviconUrl)
          Set the URL.
 void setFrame(String strFrame)
          Sets the strFrame.
 void setProgress(int current, int maximum)
          Sets the current and maximum number of bytes that will be downloaded for the resource.
 void setRequestHeaders(String requestHeaders)
          Sets the requestHeaders.
 void setResponseHeaders(String responseHeaders)
          Sets the responseHeaders.
 void setStatus(int flags)
          Sets the network status.
 void setStatusText(String string)
           
 void setURL(String strURL)
          Sets the strURL.
 
Methods inherited from class java.util.EventObject
getSource, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FAILED_DNS

public static final int FAILED_DNS
Flag indicating that DNS resolution has failed.

See Also:
Constant Field Values

FAILED_CONNECT

public static final int FAILED_CONNECT
Flag indicating that connection has failed.

See Also:
Constant Field Values

FAILED_TIMEOUT

public static final int FAILED_TIMEOUT
Flag indicating that the connection timed out.

See Also:
Constant Field Values

FAILED_USER_CANCEL

public static final int FAILED_USER_CANCEL
Flag indicating that the user canceled the connection.

See Also:
Constant Field Values

STATUS_LOAD_ERROR

public static final int STATUS_LOAD_ERROR
Flag indicating an error has occurred when loading the page.

See Also:
Constant Field Values

STATUS_REDIRECTING

public static final int STATUS_REDIRECTING
Flag indicating the browser is being redirected.

See Also:
Constant Field Values

STATUS_TRANSFERRING

public static final int STATUS_TRANSFERRING
Flag indicating that browser is transferring data from server.

See Also:
Constant Field Values

STATUS_NEGOTIATING

public static final int STATUS_NEGOTIATING
Flag indicating the browser is awaiting authorization.

See Also:
Constant Field Values
Constructor Detail

NetworkEvent

public NetworkEvent(Object source)
Constructor for NetworkEvent with a source. The current and maximum progress will be initialized to 0.

See Also:
EventObject.EventObject(Object)

NetworkEvent

public NetworkEvent(Object source,
                    MutableRequestHeaders mrh)
Method Detail

getMutableRequestHeaders

public MutableRequestHeaders getMutableRequestHeaders()
Returns a MutableRequestHeaders object that allows modification of the request headers for the current transaction.

Returns:
Returns the mutableReqestHeaders.

getCurrentProgress

public int getCurrentProgress()
Returns the number of bytes currently downloaded.

Returns:
int Number of bytes.

getMaximumProgress

public int getMaximumProgress()
Returns the maximum number of bytes to download.

Returns:
int Number of bytes.

setProgress

public void setProgress(int current,
                        int maximum)
Sets the current and maximum number of bytes that will be downloaded for the resource.

Parameters:
current - The current number of bytes downloaded.
maximum - The maximum number of bytes to download.

setFailure

public void setFailure(int flags)
Sets the failure status of the network error.

Parameters:
flags - Failure status defined using FAILED_*

getFailure

public int getFailure()
Gets the failure status of the network error.

Returns:
int Failure status defined using FAILED_*

setStatus

public void setStatus(int flags)
Sets the network status.

Parameters:
flags - Network status defined using STATUS_*

getStatus

public int getStatus()
This will return a different status code based on which method of the NetworkEvent it is called from.

From onHTTPResponse: The HTTP status code will be returned. E.g. 404
From onNetworkStatus: The network status defined using STATUS_* will be returned.

Returns:
int Status code depending on the event this is called from.

getStatusText

public String getStatusText()
Gets the status text

Returns:
String containing the status text of a response

setStatusText

public void setStatusText(String string)
Parameters:
string -

getFrame

public String getFrame()
Returns the strFrame.

Returns:
String

getURL

public String getURL()
Returns the strURL.

Returns:
String

setFrame

public void setFrame(String strFrame)
Sets the strFrame.

Parameters:
strFrame - The strFrame to set

setURL

public void setURL(String strURL)
Sets the strURL.

Parameters:
strURL - The strURL to set

getRequestHeaders

public String getRequestHeaders()
Returns the requestHeaders.

Returns:
String

getResponseHeaders

public String getResponseHeaders()
Returns the responseHeaders.

Returns:
String

setRequestHeaders

public void setRequestHeaders(String requestHeaders)
Sets the requestHeaders.

Parameters:
requestHeaders - The requestHeaders to set

setResponseHeaders

public void setResponseHeaders(String responseHeaders)
Sets the responseHeaders.

Parameters:
responseHeaders - The responseHeaders to set

getCertificate

public X509Certificate getCertificate()
Gets the X.509 Certificate.

Returns:
X509Certificate

setCertificate

public void setCertificate(X509Certificate cert)
Sets the X.509 Certificate.

Parameters:
cert - the X509Certificate to set

getExpectedFaviconURL

public String getExpectedFaviconURL()
Returns a favicon URL for this HTTP/HTTPS page load. This URL is not guaranteed to exist.

Returns:
the favicon URL

setFaviconURL

public void setFaviconURL(String faviconUrl)
Set the URL. This should only be used for constructing new events.

Parameters:
url - The URL.