ucr.core
Class SearchReplyMessage

java.lang.Object
  extended byucr.core.Message
      extended byucr.core.SearchReplyMessage

public class SearchReplyMessage
extends Message

Search Reply message(QUERY HIT), response to a search request


Field Summary
private  java.util.Vector fileRecords
           
private  java.lang.String ipAddress
           
private  short port
           
private  SearchMessage searchMessage
           
private  int speed
           
private  java.lang.String vendorCode
           
 
Fields inherited from class ucr.core.Message
guid, hops, originatingConnection, payload, payloadSize, QUERY, QUERYREPLY, SIZE, SIZE_QUERY_PAYLOAD, SIZE_QUERYREPLY_PAYLOAD, TRACE, TRACEREPLY, ttl, type
 
Constructor Summary
(package private) SearchReplyMessage()
           
(package private) SearchReplyMessage(Message m)
          Construct a SearchReply message
  SearchReplyMessage(SearchMessage searchMessage, short port, java.lang.String ipAddress, int speed)
          Used to respond to a query message
  SearchReplyMessage(SearchMessage searchMessage, short port, java.lang.String ipAddress, int speed, java.lang.String vendorCode)
          Used to respond to a query message
(package private) SearchReplyMessage(short[] rawMessage, Connection originatingConnection)
          Construct a search reply message from data read read from network
 
Method Summary
 void addFileRecord(FileRecord fileRecord)
          Adds a file record.
(package private)  void buildPayload()
          Contructs the payload for the search reply message
(package private)  byte[] getByteArray()
          Produces a byte[] suitable for GNUTELLA network
 GUID getClientIdentifier()
          Retrieve the client GUID for the replying servant
 int getDownloadSpeed()
          Returns the replying host's connection bandwidth
 int getFileCount()
          Query the umber of files found for the search
 FileRecord getFileRecord(int index)
          Get information about the files found
private  int getFileRecordBounds()
          Method to determine the ending ending for file data.
 java.lang.String getIPAddress()
          Query the IP address for this pong message result is an IP address in the form of "206.26.48.100".
 int getPort()
          Query the port for this search reply
 java.lang.String getVendorCode()
          Retrieve the vendor code for the responding servant
private  boolean isBearShareTrailerPresent()
          Check if the bearshare trailer is present between file records and GUID
 
Methods inherited from class ucr.core.Message
addPayload, addPayload, getGUID, getHops, getOriginatingConnection, getPayload, getPayloadLength, getTTL, getType, setGUID, setHops, setTTL, toRawString, toString, validatePayloadSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fileRecords

private java.util.Vector fileRecords

searchMessage

private SearchMessage searchMessage

port

private short port

ipAddress

private java.lang.String ipAddress

speed

private int speed

vendorCode

private java.lang.String vendorCode
Constructor Detail

SearchReplyMessage

SearchReplyMessage(Message m)
Construct a SearchReply message


SearchReplyMessage

SearchReplyMessage()

SearchReplyMessage

SearchReplyMessage(short[] rawMessage,
                   Connection originatingConnection)
Construct a search reply message from data read read from network

Parameters:
rawMessage - binary data from a connection
originatingConnection - Connection creating this message

SearchReplyMessage

public SearchReplyMessage(SearchMessage searchMessage,
                          short port,
                          java.lang.String ipAddress,
                          int speed)
Used to respond to a query message

Parameters:
searchMessage - the search thats being responded to
port - the point used for download
ipAddress - of the servant
speed - download speed in kilobytes/sec

SearchReplyMessage

public SearchReplyMessage(SearchMessage searchMessage,
                          short port,
                          java.lang.String ipAddress,
                          int speed,
                          java.lang.String vendorCode)
Used to respond to a query message

Parameters:
searchMessage - the search thats being responded to
port - the point used for download
ipAddress - of the servant
speed - download speed in kilobytes/sec
vendorCode - option 4 byte value identifying the servant vendor
Method Detail

buildPayload

void buildPayload()
Contructs the payload for the search reply message


getFileCount

public int getFileCount()
Query the umber of files found for the search


getPort

public int getPort()
Query the port for this search reply

Returns:
port

getIPAddress

public java.lang.String getIPAddress()
Query the IP address for this pong message result is an IP address in the form of "206.26.48.100".

Returns:
IP address

getDownloadSpeed

public int getDownloadSpeed()
Returns the replying host's connection bandwidth

Returns:
download speed, in kilobytes/sec

addFileRecord

public void addFileRecord(FileRecord fileRecord)
Adds a file record. This is for originating a message for a query hit

Parameters:
fileRecord - file information

getFileRecord

public FileRecord getFileRecord(int index)
Get information about the files found


getClientIdentifier

public GUID getClientIdentifier()
Retrieve the client GUID for the replying servant

Returns:
client GUID

getVendorCode

public java.lang.String getVendorCode()
Retrieve the vendor code for the responding servant

Returns:
vendor code or NONE if the code is not present

getByteArray

byte[] getByteArray()
Produces a byte[] suitable for GNUTELLA network

Overrides:
getByteArray in class Message

isBearShareTrailerPresent

private boolean isBearShareTrailerPresent()
Check if the bearshare trailer is present between file records and GUID


getFileRecordBounds

private int getFileRecordBounds()
Method to determine the ending ending for file data. This can be used to determine if the message contains the BearShare trailer

Returns:
ending index