com.veraxsystems.icmp.ping.handlers
Class PingRequest

java.lang.Object
  extended by com.veraxsystems.icmp.ping.handlers.PingRequest
All Implemented Interfaces:
java.lang.Comparable<PingRequest>

public class PingRequest
extends java.lang.Object
implements java.lang.Comparable<PingRequest>

Class contains data for passing ICMP request between application, ICMP Sender and ICMP Receiver.


Constructor Summary
PingRequest(java.net.InetAddress addressVal, byte[] dataVal, int dataLengthVal, long timeoutVal, int messageIdVal, PingResponseHandler handlerVal)
          Constructor initializes all class attributes.
PingRequest(PingRequest request)
          Copy constructor
 
Method Summary
 int compareTo(PingRequest o)
          Compares this object with the specified object for sorting.
 java.net.InetAddress getAddress()
          Get ICMP request destination address
 long getCreationTime()
          Get time when object was created.
 byte[] getData()
          Get ICMP EchoRequest data that shall be send
 int getDataLength()
          Get length of data to be sent.
 long getEndTime()
          Get request due time (when request timeout occurs)
 PingResponseHandler getHandler()
          Get result handler object that is executed when ICMP result is obtained
 int getMessageId()
          Get identifier of message related to this request (see IcmpJniBridge API for more information.
 long getSendTime()
          Get time the request was handled by sender
 long getTimeout()
          Get timeout attribute
 void updateSendTime()
          Set time when request was handled (sent) by Sender
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PingRequest

public PingRequest(java.net.InetAddress addressVal,
                   byte[] dataVal,
                   int dataLengthVal,
                   long timeoutVal,
                   int messageIdVal,
                   PingResponseHandler handlerVal)
Constructor initializes all class attributes. Te only attribute that may be changed after object is created is sendTime (it is changed when object is passed between Sender and >code>Receiver.

Parameters:
addressVal - address of host echo request is sent to
dataVal - data to be sent (when null default data is used)
dataLengthVal - the length of data to be sent (its value cannot be bigger than data buffer length)
timeoutVal - send timeout in milliseconds
messageIdVal - identifier of ICMP message
handlerVal - result handler object

PingRequest

public PingRequest(PingRequest request)
Copy constructor

Parameters:
request - source object to be copied
Method Detail

getCreationTime

public long getCreationTime()
Get time when object was created.

Returns:
creation time in milliseconds

getTimeout

public long getTimeout()
Get timeout attribute

Returns:
timeout value in milliseconds

getAddress

public java.net.InetAddress getAddress()
Get ICMP request destination address

Returns:
network address

getData

public byte[] getData()
Get ICMP EchoRequest data that shall be send

Returns:
data buffer

getHandler

public PingResponseHandler getHandler()
Get result handler object that is executed when ICMP result is obtained

Returns:
handler object

getEndTime

public long getEndTime()
Get request due time (when request timeout occurs)

Returns:
request end time in milliseconds

getMessageId

public int getMessageId()
Get identifier of message related to this request (see IcmpJniBridge API for more information.

Returns:
request identifier

getSendTime

public long getSendTime()
Get time the request was handled by sender

Returns:
sent time in milliseconds

updateSendTime

public void updateSendTime()
Set time when request was handled (sent) by Sender


compareTo

public int compareTo(PingRequest o)
Compares this object with the specified object for sorting. Compare two objects and returns a -1, 0, or +1 integer as this object is less than, equal to, or greater than the specified object.

Specified by:
compareTo in interface java.lang.Comparable<PingRequest>
Parameters:
o - object to be compared
Returns:
Returns -1, 0, +1 integer as this object is less than, equal to, or greater than the specified object.

getDataLength

public int getDataLength()
Get length of data to be sent.

Returns:
data length