net.sf.gsaapi
Class GSAClient

java.lang.Object
  extended bynet.sf.gsaapi.GSAClient

public class GSAClient
extends java.lang.Object

Use a GSAClient instance to fire queries to a specific GSA site. Typical usage:

 GSAClient client = new GSAClient("http", "www.mygsa.net", 7777, "/search");
 GSAQuery query = new GSAQuery();
 // insert calls to (see GSAQuery): query.setXyz(xyzValue);
 InputStream istream = client.search(query);
 // 'istream' is an InputStream to the gsa xml results.
 // parse data from 'istream' using desired XML parser api.
 
A single GSAClient instance may be shared by multiple threads accessing the same target search appliance. Note however that the same GSAClientDelegate instance (if used) will be used for all the threads. Thus you must appropriately design the GSAClientDelegate for multi-threaded access.

Author:
Amol S Deshmukh adeshmuk .at inxight .dot com
See Also:
GSAQuery

Field Summary
static java.lang.String DEFAULT_PATH
          default path used by contructor that allows you to skip speciyfing the path
static int DEFAULT_PORT
          default port number used by constructor that allows you to skip specifying the port
static java.lang.String DEFAULT_PROTOCOL
          default protocol used by constructor that allows you to skip specifying the protocol
 
Constructor Summary
GSAClient(java.lang.String host)
          overloaded constructor that sets the defaults: DEFAULT_PROTOCOL, DEFAULT_PORT, DEFAULT_PATH
GSAClient(java.lang.String host, int port, java.lang.String path)
          overloaded constructor that sets the defaults: DEFAULT_PROTOCOL
GSAClient(java.lang.String host, java.lang.String path)
          overloaded constructor that sets the defaults: DEFAULT_PROTOCOL, DEFAULT_PORT
GSAClient(java.lang.String protocol, java.lang.String host, int port, java.lang.String path)
           
 
Method Summary
 GSAResponse getGSAResponse(GSAQuery query)
          Returns the search results parsed and wrapped by GSAReponse instance.
 GSAResponse getGSAResponse(java.lang.String rawQuery)
          Normally you should be using one of the overloaded "search(GSAQuery)" functions.
 java.lang.String getHost()
          returns the value for the host parameter passed to the constructor
 java.lang.String getPath()
          returns the value for the path parameter passed to the constructor
 int getPort()
          returns the value for the port parameter passed to the constructor
 java.lang.String getProtocol()
          returns the value for the protocol parameter passed to the constructor
 java.io.InputStream search(GSAQuery query)
          If a valid query does not result in any results, an empty List will be returned.
 java.io.InputStream search(java.lang.String rawQuery)
          Normally, you should be using one of the overloaded "search(GSAQuery)" methods which internally call this method.
 void setClientDelegate(GSAClientDelegate delegate)
          specify the GSAClientDelegate instance that will actually query the url and return an input stream to the response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PORT

public static final int DEFAULT_PORT
default port number used by constructor that allows you to skip specifying the port

See Also:
Constant Field Values

DEFAULT_PATH

public static final java.lang.String DEFAULT_PATH
default path used by contructor that allows you to skip speciyfing the path

See Also:
Constant Field Values

DEFAULT_PROTOCOL

public static final java.lang.String DEFAULT_PROTOCOL
default protocol used by constructor that allows you to skip specifying the protocol

See Also:
Constant Field Values
Constructor Detail

GSAClient

public GSAClient(java.lang.String protocol,
                 java.lang.String host,
                 int port,
                 java.lang.String path)
Parameters:
protocol - protocol to use to connect to GSA eg. "http"
host - hostname for the GSA eg. "www.mysite.net"
port - port at which GSA is serving eg. 3300
path - path for the search program on GSA eg. "/search"

GSAClient

public GSAClient(java.lang.String host,
                 int port,
                 java.lang.String path)
overloaded constructor that sets the defaults: DEFAULT_PROTOCOL

Parameters:
host -
port -
path -

GSAClient

public GSAClient(java.lang.String host,
                 java.lang.String path)
overloaded constructor that sets the defaults: DEFAULT_PROTOCOL, DEFAULT_PORT

Parameters:
host -
path -

GSAClient

public GSAClient(java.lang.String host)
overloaded constructor that sets the defaults: DEFAULT_PROTOCOL, DEFAULT_PORT, DEFAULT_PATH

Parameters:
host -
Method Detail

setClientDelegate

public void setClientDelegate(GSAClientDelegate delegate)
specify the GSAClientDelegate instance that will actually query the url and return an input stream to the response. If the GSAClientDelegate is not specified, the GSAClient will itself connect to the request url and attempt to fetch the results.

Parameters:
delegate -

search

public java.io.InputStream search(GSAQuery query)
                           throws java.io.IOException
If a valid query does not result in any results, an empty List will be returned.

Returns:
List of GSAResponse objects
Throws:
java.io.IOException

search

public java.io.InputStream search(java.lang.String rawQuery)
                           throws java.io.IOException
Normally, you should be using one of the overloaded "search(GSAQuery)" methods which internally call this method.
The rawQuery parameter to this function should be of the general form: "key1=value1&key2=value2&key3=value3" In this case, hostname, port and path should not be specified. The leading '?' character may or may not be present.
For further details, refer to the GSA protocol reference page at http://code.google.com/gsa_apis/xml_reference.html

Parameters:
rawQuery - rawQuery string
Returns:
InputStream to the search results page
Throws:
java.io.IOException

getGSAResponse

public GSAResponse getGSAResponse(GSAQuery query)
                           throws java.io.IOException
Returns the search results parsed and wrapped by GSAReponse instance.

Parameters:
query - The properly configured GSAQuery instance
Returns:
GSAResponse instance wrapping the search results
Throws:
java.io.IOException

getGSAResponse

public GSAResponse getGSAResponse(java.lang.String rawQuery)
                           throws java.io.IOException
Normally you should be using one of the overloaded "search(GSAQuery)" functions. Returns the search results parsed and wrapped by GSAReponse instance.
The rawQuery parameter to this function should be of the general form: "key1=value1&key2=value2&key3=value3" ie. hostname, port and path should not be specified. The leading '?' character may or may not be present.
For further details, refer to the GSA protocol reference page at http://code.google.com/gsa_apis/xml_reference.html

Parameters:
rawQuery - raw query string
Returns:
GSAResponse instance wrapping the search results
Throws:
java.io.IOException

getHost

public java.lang.String getHost()
returns the value for the host parameter passed to the constructor

Returns:
returns the hostname as a String

getPath

public java.lang.String getPath()
returns the value for the path parameter passed to the constructor

Returns:
returns the path to the search appliance following the host port specification.

getPort

public int getPort()
returns the value for the port parameter passed to the constructor

Returns:
returns the port number at which the search appliance serves search results.

getProtocol

public java.lang.String getProtocol()
returns the value for the protocol parameter passed to the constructor

Returns:
returns the protocol used by the search appliance


© Copyright 2006 Inxight Software, Inc.