com.webrenderer.se.event
Class NetworkEvent

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

public class NetworkEvent
extends java.util.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
protected  int current
          The current number of bytes downloaded for a resource.
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 cancelled the connection.
protected  int failure
          Failure status.
protected  int maximum
          The maximum number of bytes that will be downloaded for a resource.
protected  MutableRequestHeaders mutableHeaders
           
protected  boolean pendingLoads
           
protected  int status
          Request status.
static int STATUS_NEGOTIATING
          Flag indicating the browser is awaiting authorisation.
static int STATUS_REDIRECTING
          Flag indicating the browser is being redirected.
static int STATUS_TRANSFERRING
          Flag indicating that browser is transferring data from server.
protected  java.lang.String strFrame
           
protected  java.lang.String strURL
           
protected  int transactionId
           
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
NetworkEvent(java.lang.Object source)
          Constructor for NetworkEvent with a source.
NetworkEvent(java.lang.Object source, MutableRequestHeaders mrh)
           
 
Method Summary
 int getCurrentProgress()
          Returns the number of bytes currently downloaded.
 int getFailure()
          Gets the failure status of the network error.
 java.lang.String getFrame()
          Returns the strFrame.
 java.lang.String getHeaders()
          Deprecated. instead use getRequestHeaders() or getResponseHeaders()
 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.
 java.lang.String getRequestHeaders()
          Returns the requestHeaders.
 java.lang.String getResponseHeaders()
          Returns the responseHeaders.
 int getStatus()
          Gets the network status.
 java.lang.String getStatusText()
          Gets the status text
 int getTransactionId()
          Used to link a BrowserEvent.onBeforeNavigate to a NetowrkEvent.onHTTPResponse
 java.lang.String getURL()
          Returns the strURL.
 boolean hasPendingRequests()
          Returns true if the page has pending network requests (such as Ajax) that have yet to complete.
 void setFailure(int flags)
          Sets the failure status of the network error.
 void setFrame(java.lang.String strFrame)
          Sets the strFrame.
 void setHeaders(java.lang.String string)
           
 void setPendingLoads(boolean isPending)
           
 void setProgress(int current, int maximum)
          Sets the current and maximum number of bytes that will be downloaded for the resource.
 void setRequestHeaders(java.lang.String requestHeaders)
          Sets the requestHeaders.
 void setResponseHeaders(java.lang.String responseHeaders)
          Sets the responseHeaders.
 void setStatus(int flags)
          Sets the network status.
 void setStatusText(java.lang.String string)
           
 void setTransactionId(int i)
           
 void setURL(java.lang.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

strURL

protected java.lang.String strURL

strFrame

protected java.lang.String strFrame

transactionId

protected int transactionId

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 cancelled the connection.

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 authorisation.

See Also:
Constant Field Values

failure

protected int failure
Failure status.


status

protected int status
Request status.


current

protected int current
The current number of bytes downloaded for a resource.


maximum

protected int maximum
The maximum number of bytes that will be downloaded for a resource.


pendingLoads

protected boolean pendingLoads

mutableHeaders

protected MutableRequestHeaders mutableHeaders
Constructor Detail

NetworkEvent

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

See Also:
EventObject.EventObject(Object)

NetworkEvent

public NetworkEvent(java.lang.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()
Gets the network status.

Returns:
int Network status defined using STATUS_*

getHeaders

public java.lang.String getHeaders()
Deprecated. instead use getRequestHeaders() or getResponseHeaders()

Gets the response headers.

Returns:
String contiaing the response headers

getStatusText

public java.lang.String getStatusText()
Gets the status text

Returns:
String containing the status text of a response

setHeaders

public void setHeaders(java.lang.String string)
Parameters:
string -

setStatusText

public void setStatusText(java.lang.String string)
Parameters:
string -

getFrame

public java.lang.String getFrame()
Returns the strFrame.

Returns:
String

getURL

public java.lang.String getURL()
Returns the strURL.

Returns:
String

setFrame

public void setFrame(java.lang.String strFrame)
Sets the strFrame.

Parameters:
strFrame - The strFrame to set

setURL

public void setURL(java.lang.String strURL)
Sets the strURL.

Parameters:
strURL - The strURL to set

getTransactionId

public int getTransactionId()
Used to link a BrowserEvent.onBeforeNavigate to a NetowrkEvent.onHTTPResponse

Returns:
Transaction ID

setTransactionId

public void setTransactionId(int i)
Parameters:
i -

getRequestHeaders

public java.lang.String getRequestHeaders()
Returns the requestHeaders.

Returns:
String

getResponseHeaders

public java.lang.String getResponseHeaders()
Returns the responseHeaders.

Returns:
String

setRequestHeaders

public void setRequestHeaders(java.lang.String requestHeaders)
Sets the requestHeaders.

Parameters:
requestHeaders - The requestHeaders to set

setResponseHeaders

public void setResponseHeaders(java.lang.String responseHeaders)
Sets the responseHeaders.

Parameters:
responseHeaders - The responseHeaders to set

hasPendingRequests

public boolean hasPendingRequests()
Returns true if the page has pending network requests (such as Ajax) that have yet to complete. Only applicable to onDocumentComplete.


setPendingLoads

public void setPendingLoads(boolean isPending)