com.limegroup.gnutella
Class ResponseVerifier

java.lang.Object
  extended bycom.limegroup.gnutella.ResponseVerifier

public class ResponseVerifier
extends java.lang.Object

Records information about queries so that responses can be validated later. Typical use is to call record(..) on an outgoing query request, and score/matchesType/isMandragoreWorm on each incoming response.


Constructor Summary
ResponseVerifier()
           
 
Method Summary
 boolean isMandragoreWorm(byte[] guid, Response response)
          Returns true if the given response is an instance of the Mandragore Worm.
 boolean matchesType(byte[] guid, Response response)
          Returns true if response has the same media type as the corresponding query request the given GUID.
 void record(QueryRequest qr)
          Same as record(qr, null).
 void record(QueryRequest qr, MediaType type)
           
static int score(java.lang.String query, LimeXMLDocument richQuery, RemoteFileDesc response)
          Returns the score of the given response compared to the given query.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResponseVerifier

public ResponseVerifier()
Method Detail

record

public void record(QueryRequest qr)
Same as record(qr, null).


record

public void record(QueryRequest qr,
                   MediaType type)

score

public static int score(java.lang.String query,
                        LimeXMLDocument richQuery,
                        RemoteFileDesc response)
Returns the score of the given response compared to the given query.

Parameters:
query - the query keyword string sent
richQuery - the XML metadata string sent, or null if none
response - the response to score, converted to RemoteFileDesc
Returns:
the percentage of query keywords (0-100) matching

matchesType

public boolean matchesType(byte[] guid,
                           Response response)
Returns true if response has the same media type as the corresponding query request the given GUID. In the rare case that guid is not known (because this' buffers overflowed), conservatively returns true.


isMandragoreWorm

public boolean isMandragoreWorm(byte[] guid,
                                Response response)
Returns true if the given response is an instance of the Mandragore Worm. This worm responds to the query "x" with a 8KB file named "x.exe". In the rare case that the query for guid can't be found returns false.


toString

public java.lang.String toString()