|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.limegroup.gnutella.messages.Message
com.limegroup.gnutella.messages.QueryRequest
This class creates Gnutella query messages, either from scratch, or from data read from the network. Queries can contain query strings, XML query strings, URNs, etc. The minimum speed field is now used for bit flags to indicate such things as the firewalled status of the querier.
This class also has factory constructors for requeries originated from this LimeWire. These requeries have specially marked GUIDs that allow us to identify them as requeries.
Field Summary | |
static int |
SPECIAL_FIREWALL_MASK
|
static int |
SPECIAL_MINSPEED_MASK
|
static int |
SPECIAL_OUTOFBAND_MASK
|
static int |
SPECIAL_XML_MASK
|
Fields inherited from class com.limegroup.gnutella.messages.Message |
F_PING, F_PING_REPLY, F_PUSH, F_QUERY, F_QUERY_REPLY, F_ROUTE_TABLE_UPDATE, F_VENDOR_MESSAGE, F_VENDOR_MESSAGE_STABLE, N_MULTICAST, N_TCP, N_UDP, N_UNKNOWN, RECORD_STATS, SOFT_MAX |
Constructor Summary | |
QueryRequest(byte[] guid,
byte ttl,
java.lang.String query,
java.lang.String richQuery,
java.util.Set requestedUrnTypes,
java.util.Set queryUrns,
QueryKey queryKey,
boolean isFirewalled,
int network,
boolean canReceiveOutOfBandReplies)
Builds a new query from scratch but you can flag it as a Requery, if needed. |
Method Summary | |
static QueryRequest |
createBrowseHostQuery()
Creates a new specialized QueryRequest instance for browse host queries so that FileManager can understand them. |
static QueryRequest |
createMulticastQuery(QueryRequest qr)
Creates a new QueryRequest instance for multicast queries. |
static QueryRequest |
createNetworkQuery(byte[] guid,
byte ttl,
byte hops,
byte[] payload,
int network)
Creates a new query from the network. |
static QueryRequest |
createNonFirewalledQuery(java.lang.String query,
byte ttl)
Specialized constructor used to create a query without the firewalled bit set. |
static QueryRequest |
createOutOfBandQuery(java.lang.String query,
byte[] ip,
int port)
|
static QueryRequest |
createQuery(byte[] guid,
java.lang.String query,
java.lang.String xmlQuery)
Creates a new query with the specified guid, query string, and xml query string. |
static QueryRequest |
createQuery(QueryRequest qr,
byte ttl)
Creates a new query from the existing query with the specified ttl. |
static QueryRequest |
createQuery(java.util.Set urnTypeSet,
java.util.Set urnSet)
Creates a new query for the specified UrnType set and URN set. |
static QueryRequest |
createQuery(java.lang.String query)
Creates a new query for the specified file name, with no XML. |
static QueryRequest |
createQuery(java.lang.String query,
byte ttl)
Creates a new query for the specified file name, with no XML. |
static QueryRequest |
createQuery(java.lang.String query,
java.lang.String xmlQuery)
Creates a new query for the specified file name, with no XML. |
static QueryRequest |
createQuery(URN sha1)
Creates a new query for the specified SHA1 value. |
static QueryRequest |
createQuery(URN sha1,
java.lang.String filename)
Creates a new query for the specified SHA1 value with file name thrown in for good measure (or at least until \ works as a query). |
static QueryRequest |
createQueryKeyQuery(QueryRequest qr,
QueryKey key)
Creates a new QueryRequest that is a copy of the input query, except that it includes the specified query key. |
static QueryRequest |
createQueryKeyQuery(java.lang.String query,
QueryKey key)
Creates a new query with the specified query key for use in GUESS-style UDP queries. |
static QueryRequest |
createRequery(java.lang.String query)
Creates a requery for when we don't know the hash of the file -- we don't know the hash. |
static QueryRequest |
createRequery(URN sha1)
Creates a new requery for the specified SHA1 value. |
static QueryRequest |
createRequery(URN sha1,
byte ttl)
Creates a new requery for the specified SHA1 value and the specified firewall boolean. |
static QueryRequest |
createRequery(URN sha1,
java.lang.String filename)
Creates a new requery for the specified SHA1 value with file name thrown in for good measure (or at least until \ works as a query). |
boolean |
desiresOutOfBandReplies()
Returns true if the query source can accept out-of-band replies. |
boolean |
desiresXMLResponses()
Returns true if the query source desires Lime meta-data in responses. |
boolean |
equals(java.lang.Object o)
|
int |
getMinSpeed()
Note: the minimum speed can be represented as a 2-byte unsigned number, but Java shorts are signed. |
byte[] |
getPayload()
Accessor fot the payload of the query hit. |
java.lang.String |
getQuery()
Returns the query string of this message. |
QueryKey |
getQueryKey()
Returns the QueryKey associated with this Request. |
java.util.Set |
getQueryUrns()
Returns the Set of URN instances for this query. |
java.lang.String |
getReplyAddress()
Returns the address to send a out-of-band reply to. |
int |
getReplyPort()
Returns the port to send a out-of-band reply to. |
java.util.Set |
getRequestedUrnTypes()
Returns the Set of URN types requested for this query. |
LimeXMLDocument |
getRichQuery()
Returns the rich query LimeXMLDocument. |
int |
hashCode()
|
boolean |
hasQueryUrns()
Returns whether or not this query contains URNs. |
boolean |
isFirewalledSource()
Returns true if the query source is a firewalled servent. |
boolean |
isLimeRequery()
Accessor for whether or not this is a requery from a LimeWire. |
static byte[] |
newQueryGUID(boolean isRequery)
Returns a new GUID appropriate for query requests. |
void |
recordDrop()
Records the dropping of this message in statistics. |
Message |
stripExtendedPayload()
Returns this, because it's always safe to send big queries. |
java.lang.String |
toString()
|
protected void |
writePayload(java.io.OutputStream out)
|
Methods inherited from class com.limegroup.gnutella.messages.Message |
compareTo, getCreationTime, getFunc, getGUID, getHops, getLength, getNetwork, getPriority, getTotalLength, getTTL, hop, isMulticast, isTCP, isUDP, isUnknownNetwork, makeGuid, read, read, read, read, read, readNullTerminatedBytes, repOk, setGUID, setHops, setPriority, setTTL, updateLength, write, writeGemExtension, writeGemExtension, writeGemExtensions |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int SPECIAL_MINSPEED_MASK
public static final int SPECIAL_FIREWALL_MASK
public static final int SPECIAL_XML_MASK
public static final int SPECIAL_OUTOFBAND_MASK
Constructor Detail |
public QueryRequest(byte[] guid, byte ttl, java.lang.String query, java.lang.String richQuery, java.util.Set requestedUrnTypes, java.util.Set queryUrns, QueryKey queryKey, boolean isFirewalled, int network, boolean canReceiveOutOfBandReplies)
requestedUrnTypes
- Set of UrnType instances
requested for this query, which may be empty or null if no types were
requestedqueryUrns
- Set of URN instances requested for
this query, which may be empty or null if no URNs were requested
IllegalArgumentException
- if the query string, the xml
query string, and the urns are all emptyMethod Detail |
public static QueryRequest createRequery(URN sha1)
sha1
- the URN of the file to search for
NullPointerException
- if the sha1 argument
is nullpublic static QueryRequest createQuery(URN sha1)
sha1
- the URN of the file to search for
NullPointerException
- if the sha1 argument
is nullpublic static QueryRequest createRequery(URN sha1, java.lang.String filename)
sha1
- the URN of the file to search for
NullPointerException
- if the sha1 argument
is nullpublic static QueryRequest createQuery(URN sha1, java.lang.String filename)
sha1
- the URN of the file to search for
NullPointerException
- if the sha1 argument
is nullpublic static QueryRequest createRequery(URN sha1, byte ttl)
sha1
- the URN of the file to search forttl
- the time to live (ttl) of the query
NullPointerException
- if the sha1 argument
is null
IllegalArgumentException
- if the ttl value is
negative or greater than the maximum allowed valuepublic static QueryRequest createQuery(java.util.Set urnTypeSet, java.util.Set urnSet)
urnTypeSet
- the Set of UrnTypes to request.urnSet
- the Set of URNss to request.
NullPointerException
- if either sets are null.public static QueryRequest createRequery(java.lang.String query)
query
- the query string
NullPointerException
- if the query argument
is null
IllegalArgumentException
- if the query
argument is zero-length (empty)public static QueryRequest createQuery(java.lang.String query)
query
- the file name to search for
NullPointerException
- if the query argument
is null
IllegalArgumentException
- if the query
argument is zero-length (empty)public static QueryRequest createOutOfBandQuery(java.lang.String query, byte[] ip, int port)
public static QueryRequest createQuery(java.lang.String query, java.lang.String xmlQuery)
query
- the file name to search for
NullPointerException
- if the query argument
is null or if the xmlQuery argument is
null
IllegalArgumentException
- if the query
argument and the xml query are both zero-length (empty)public static QueryRequest createQuery(java.lang.String query, byte ttl)
query
- the file name to search forttl
- the time to live (ttl) of the query
NullPointerException
- if the query argument
is null
IllegalArgumentException
- if the query
argument is zero-length (empty)
IllegalArgumentException
- if the ttl value is
negative or greater than the maximum allowed valuepublic static QueryRequest createQuery(byte[] guid, java.lang.String query, java.lang.String xmlQuery)
guid
- the message GUID for the queryquery
- the query stringxmlQuery
- the xml query string
NullPointerException
- if the query argument
is null, if the xmlQuery argument is null,
or if the guid argument is null
IllegalArgumentException
- if the guid length is
not 16, if both the query strings are empty, or if the XML does
not appear to be validpublic static QueryRequest createQuery(QueryRequest qr, byte ttl)
qr
- the QueryRequest to copyttl
- the new ttl
public static QueryRequest createQueryKeyQuery(java.lang.String query, QueryKey key)
query
- the query stringkey
- the query key
NullPointerException
- if the query argument
is null or if the key argument is null
IllegalArgumentException
- if the query
argument is zero-length (empty)public static QueryRequest createMulticastQuery(QueryRequest qr)
qr
- the QueryRequest instance containing all the
data necessary to create a multicast query
NullPointerException
- if the qr argument
is nullpublic static QueryRequest createQueryKeyQuery(QueryRequest qr, QueryKey key)
qr
- the QueryRequest to usekey
- the QueryKey to add
public static QueryRequest createBrowseHostQuery()
public static QueryRequest createNonFirewalledQuery(java.lang.String query, byte ttl)
query
- the query string
public static QueryRequest createNetworkQuery(byte[] guid, byte ttl, byte hops, byte[] payload, int network) throws BadPacketException
guid
- the GUID of the queryttl
- the time to live of the queryhops
- the hops of the querypayload
- the query payload
BadPacketException
public static byte[] newQueryGUID(boolean isRequery)
protected void writePayload(java.io.OutputStream out) throws java.io.IOException
writePayload
in class Message
java.io.IOException
public byte[] getPayload()
public java.lang.String getQuery()
The caller should not call the getBytes() method on the returned value, as this seems to cause problems on the Japanese Macintosh. If you need the raw bytes of the query string, call getQueryByteAt(int).
public LimeXMLDocument getRichQuery()
public java.util.Set getRequestedUrnTypes()
public java.util.Set getQueryUrns()
public boolean hasQueryUrns()
public int getMinSpeed()
public boolean isFirewalledSource()
public boolean desiresXMLResponses()
public boolean desiresOutOfBandReplies()
public java.lang.String getReplyAddress()
public int getReplyPort()
public boolean isLimeRequery()
public QueryKey getQueryKey()
public void recordDrop()
Message
recordDrop
in class Message
public Message stripExtendedPayload()
stripExtendedPayload
in class Message
public int hashCode()
public boolean equals(java.lang.Object o)
public java.lang.String toString()
toString
in class Message
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |