JXTA

net.jxta.impl.protocol
Class ResolverQuery

java.lang.Object
  extended by net.jxta.protocol.ResolverQueryMsg
      extended by net.jxta.impl.protocol.ResolverQuery
All Implemented Interfaces:
Cloneable

public class ResolverQuery
extends ResolverQueryMsg
implements Cloneable

Implements the Resolver Query Message according to the schema defined by the core JXTA Peer Resolver Protocol (PRP).

 <xs:element name="ResolverQuery" type="jxta:ResolverQuery"/>
 

<xs:complexType name="ResolverQuery"> <xs:all> <xs:element ref="jxta:Cred" minOccurs="0"/> <xs:element name="SrcPeerID" type="jxta:JXTAID"/> <xs:element name="SrcPeerRoute" type="jxta:JXTA RouteAdv"/> <!-- This could be extended with a pattern restriction --> <xs:element name="HandlerName" type="xs:string"/> <xs:element name="QueryID" type="xs:string"/> <xs:element name="HC" type="xs:unsignedInt"/> <xs:element name="Query" type="xs:anyType"/> </xs:all> </xs:complexType>

IMPORTANT: a ResolverQuery contains an internal state, the hopCount, which is incremented by various services that needs to. As a result, a ResolverQuery may have to be cloned when the hopCount state needs to be reset.

See Also:
ResolverService, ResolverQueryMsg, JXTA Protocols Specification : Peer Resolver Protocol

Field Summary
 
Fields inherited from class net.jxta.protocol.ResolverQueryMsg
hopcount, queryid
 
Constructor Summary
ResolverQuery()
          Default constructor
ResolverQuery(Element root)
          Construct from a StructuredDocument
ResolverQuery(String HandlerName, StructuredDocument Credential, String pId, String Query, int qid)
          Deprecated. use the individual accessor methods instead.
 
Method Summary
 ResolverQuery clone()
          
 Document getDocument(MimeMediaType encodeAs)
          Write advertisement into a document. asMimeType is a mime media-type specification and provides the form of the document which is being requested.
 ResolverResponseMsg makeResponse()
          Create a ResolverResponse from a ResolverQuery message.
 void readIt(XMLElement doc)
          parses an XML document into this object
 String toString()
          

Result is the query as an XML string.

 
Methods inherited from class net.jxta.protocol.ResolverQueryMsg
getAdvertisementType, getCredential, getHandlerName, getHopCount, getQuery, getQueryId, getSrc, getSrcPeer, getSrcPeerRoute, incrementHopCount, setCredential, setHandlerName, setHopCount, setQuery, setQueryId, setSrc, setSrcPeer, setSrcPeerRoute
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResolverQuery

public ResolverQuery()
Default constructor


ResolverQuery

@Deprecated
public ResolverQuery(String HandlerName,
                                StructuredDocument Credential,
                                String pId,
                                String Query,
                                int qid)
Deprecated. use the individual accessor methods instead.

Construct a doc from strings

Parameters:
HandlerName - the handler name
Credential - credential document
pId - source PeerID
Query - opaque query string
qid - query ID

ResolverQuery

public ResolverQuery(Element root)
Construct from a StructuredDocument

Parameters:
root - the element
Method Detail

readIt

public void readIt(XMLElement doc)
parses an XML document into this object

Parameters:
doc - the element

getDocument

public Document getDocument(MimeMediaType encodeAs)
Write advertisement into a document. asMimeType is a mime media-type specification and provides the form of the document which is being requested. Two standard document forms are defined. 'text/text' encodes the document in a form nice for printing out and 'text/xml' which provides an XML format.

Specified by:
getDocument in class ResolverQueryMsg
Parameters:
encodeAs - mime-type requested representation for the returned document
Returns:
Document document representing the advertisement

toString

public String toString()

Result is the query as an XML string.

Overrides:
toString in class Object

clone

public ResolverQuery clone()

Overrides:
clone in class Object

makeResponse

public ResolverResponseMsg makeResponse()
Create a ResolverResponse from a ResolverQuery message. This method takes advantage of any internal information available in an incoming Resolver query to build a resolver response for that query. For instance, optional route information which may be available in the query will be used to bypass the route resolution to send the response.

WARNING: A side effect of this call is that the following fields are transfered from the query to the response: - HandlerName - QueryId

Specified by:
makeResponse in class ResolverQueryMsg
Returns:
ResolverResponse Msg

JXSE