com.sun.portal.search.demo
Class Search

java.lang.Object
  extended bycom.sun.portal.search.demo.Search
Direct Known Subclasses:
SearchContext

public class Search
extends java.lang.Object

Search encapsulation class.


Field Summary
protected  java.lang.String database
          The comma delimited list of databases to be searched.
protected  int firstHit
          The first hit to be returned (counting from 1).
 java.lang.String proxyDN
           
protected  java.lang.String query
          The fully formatted URL query string that will be sent to the server.
protected  java.lang.String queryLanguage
          The query language.
protected  java.lang.String RDMServer
          The RDM server URL
protected  java.lang.String RDMType
          The RDM request type.
protected  java.lang.String scope
          The query string.
protected  java.lang.String SSOToken
          Identity Server Single Sign On token.
protected  java.lang.String viewAttributes
          The comma delimited requested result attribute list.
protected  int viewHits
          The maximum number of results requested.
protected  java.lang.String viewOrder
          The comma delimited sort order w/ +ascending and -descending.
 
Constructor Summary
Search()
          Constructor.
Search(java.lang.String scope, java.lang.String RDMServer)
          Constructor.
Search(java.lang.String scope, java.lang.String viewAttributes, java.lang.String viewOrder, int firstHit, int viewHits, java.lang.String queryLanguage, java.lang.String database, java.lang.String RDMServer, java.lang.String ssoToken)
          Constructor.
 
Method Summary
 void doQuery()
          Execute the query.
 void doQuery(int firstHit, int viewHits)
          Execute the query, returning viewHits hits starting at firstHit.
 java.lang.String getDatabase()
           
 int getDocumentCount()
          The total number of documents available to be searched.
 int getFirstHit()
          Get the starting hit offset.
 int getHitCount()
          The total number of results that matched the search.
 java.lang.String getProxyDN()
          Returns the current target DN for the search.
 java.lang.String getQuery()
          Return the fully formatted query url sent to the server.
 java.lang.String getQueryLanguage()
          Returns the current query language.
 SOIF getRDMHeaderSOIF()
          Return the SOIF RDM result header.
 java.lang.String getRDMServer()
          Returns the current RDMServer variable.
 java.lang.String getRDMType()
          Returns the current RDMType.
 int getResultCount()
          The number of results returned by the search.
 SOIFInputStream getResultStream()
          Return results as a DataInputStream.
 java.lang.String getScope()
          Returns the current scope (query) for the search.
 java.lang.String getSessionID()
           
 int getToHit()
          Gets the last hit value being displayed
 java.lang.String getViewAttributes()
          Returns the SOIF attributes which are retrieved by a search.
 int getViewHits()
          Get the maximum number of hits returned.
 java.lang.String getViewOrder()
          Gets the sorting order for results.
 boolean noHits()
           
 void setDatabase(java.lang.String database)
           
 void setFirstHit(int firstHit)
          Set the starting hit offset.
 void setProxyDN(java.lang.String proxyDN)
          Sets the target DN for the search.
 void setQueryLanguage(java.lang.String queryLanguage)
          Sets the query language.
 void setRDMServer(java.lang.String RDMServer)
          Sets the RDMServer variable.
 void setRDMType(java.lang.String RDMType)
          Sets the RDM Request type.
 void setScope(java.lang.String scope)
          Sets the scope (query) for the search.
 void setSessionID(java.lang.String sessID)
           
 void setSOIFParse(boolean b)
          Set whether SOIF parsing is to be done or not.
 void setStreamMode(boolean m)
          Sets whether streaming is enabled or disabled.
 void setViewAttributes(java.lang.String viewAttributes)
          Sets the SOIF attributes which are returned for the search.
 void setViewHits(int viewHits)
          Set the maximum number of hits returned.
 void setViewOrder(java.lang.String viewOrder)
          Sets the sorting order for results.
 java.lang.String toString()
          Return debug string version of Search instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

query

protected java.lang.String query
The fully formatted URL query string that will be sent to the server.


scope

protected java.lang.String scope
The query string.


database

protected java.lang.String database
The comma delimited list of databases to be searched.


RDMServer

protected java.lang.String RDMServer
The RDM server URL


viewAttributes

protected java.lang.String viewAttributes
The comma delimited requested result attribute list.


viewOrder

protected java.lang.String viewOrder
The comma delimited sort order w/ +ascending and -descending.

Eg, "-score,+title". Default value is "-score".


SSOToken

protected java.lang.String SSOToken
Identity Server Single Sign On token.


viewHits

protected int viewHits
The maximum number of results requested.


firstHit

protected int firstHit
The first hit to be returned (counting from 1).


RDMType

protected java.lang.String RDMType
The RDM request type.


queryLanguage

protected java.lang.String queryLanguage
The query language.


proxyDN

public java.lang.String proxyDN
Constructor Detail

Search

public Search()
Constructor.


Search

public Search(java.lang.String scope,
              java.lang.String RDMServer)
Constructor.

Default values implicit in this constructor are:
- viewAttributes: null. Return all attributes
- viewOrder: null. Return server default (ie, sorted by relevance)
- firsthit: 1. Start hits at hit number 1
- viewhits: 10. Return 10 hits only
- query language: search. Search documents
- database: null. Use the default database for the server

Parameters:
scope - the query qualification
RDMServer - Search server URL, eg, http://portal.siroe.com:2222/portal/search
Since:
3.01C

Search

public Search(java.lang.String scope,
              java.lang.String viewAttributes,
              java.lang.String viewOrder,
              int firstHit,
              int viewHits,
              java.lang.String queryLanguage,
              java.lang.String database,
              java.lang.String RDMServer,
              java.lang.String ssoToken)
Constructor.

Parameters:
scope - the search query
viewAttributes - comma delimited desired result attributes
viewOrder - comma delimited sort order w/ +ascend and -descend
firstHit - first requested hit (numbered from 1)
viewHits - number of results requested (starting with the firstHit result)
queryLanguage - query language
database - name (can be null for server's default database)
RDMServer - Search server URL, eg, http://portal.siroe.com:2222/portal/search
Method Detail

setSOIFParse

public void setSOIFParse(boolean b)
Set whether SOIF parsing is to be done or not. By default, SOIF parsing is true.


setStreamMode

public void setStreamMode(boolean m)
Sets whether streaming is enabled or disabled. By default, this is set to false.
When stream mode is enabled, the search results RDM header SOIF will still be parsed, so that result, hit and document counts are available, but the document hit data will not be parsed. Instead, use getResultStream() to access the document SOIF DataInputStream directly.

Since:
3.01C

getFirstHit

public int getFirstHit()
Get the starting hit offset.

See Also:
setFirstHit(int)

setFirstHit

public void setFirstHit(int firstHit)
Set the starting hit offset.

See Also:
setFirstHit(int)

getViewHits

public int getViewHits()
Get the maximum number of hits returned.

See Also:
setViewHits(int)

setViewHits

public void setViewHits(int viewHits)
Set the maximum number of hits returned.

See Also:
getViewHits()

getRDMServer

public java.lang.String getRDMServer()
Returns the current RDMServer variable.

Since:
3.01C

setRDMServer

public void setRDMServer(java.lang.String RDMServer)
Sets the RDMServer variable.

Parameters:
RDMServer - Search server URL, eg, http://portal.siroe.com:2222/portal/search (Portal server) http://compass.siroe.com:2222/rdm/incoming (Compass server)
Since:
3.01C

getScope

public java.lang.String getScope()
Returns the current scope (query) for the search.

Since:
3.01C
See Also:
setScope(java.lang.String)

setScope

public void setScope(java.lang.String scope)
Sets the scope (query) for the search.

Since:
3.01C
See Also:
getScope()

getRDMType

public java.lang.String getRDMType()
Returns the current RDMType.

Since:
3.01C
See Also:
setRDMType(java.lang.String)

getProxyDN

public java.lang.String getProxyDN()
Returns the current target DN for the search.

Since:
6.3
See Also:
setProxyDN(java.lang.String)

setProxyDN

public void setProxyDN(java.lang.String proxyDN)
Sets the target DN for the search.

Since:
6.3
See Also:
getProxyDN()

setRDMType

public void setRDMType(java.lang.String RDMType)
Sets the RDM Request type.

Parameters:
RDMType - Can be one of:
  • rd-request: The default request. Resource descriptions (documents).
  • taxonomy-request: Taxonomy.
  • schema-request: The schema.
  • server-request: Server information.
  • status-request: Server status information.
Since:
3.01C
See Also:
getRDMType(), setQueryLanguage(java.lang.String)

getQueryLanguage

public java.lang.String getQueryLanguage()
Returns the current query language.

Since:
3.01C
See Also:
setQueryLanguage(java.lang.String)

setQueryLanguage

public void setQueryLanguage(java.lang.String queryLanguage)
Sets the query language.

Parameters:
queryLanguage - Can be one of:
  • search: The default query language. Searches documents or the taxonomy.
  • taxonomy-basic: Used for requesting branches or parts of the taxonomy.
  • schema-basic: Queries the search schema.
  • url: Retrieves RDs by url (scope=url).
Since:
3.01C
See Also:
getQueryLanguage(), setRDMType(java.lang.String)

getViewAttributes

public java.lang.String getViewAttributes()
Returns the SOIF attributes which are retrieved by a search.

Returns:
viewAttributes as set by setViewAttributes. A comma delimited list of attributes, returned by a search, eg
"score,title,description,url"
NB: a null string denotes that ALL SOIF attributes are returned.
Since:
3.01C
See Also:
setViewAttributes(java.lang.String)

setViewAttributes

public void setViewAttributes(java.lang.String viewAttributes)
Sets the SOIF attributes which are returned for the search.

Parameters:
viewAttributes - A null string will return all attributes. A comma delimited list of attributes is accepted, eg
"score,title,description,url"
Since:
3.01C
See Also:
getViewAttributes()

getViewOrder

public java.lang.String getViewOrder()
Gets the sorting order for results.

Since:
3.01C
See Also:
setViewOrder(java.lang.String)

setViewOrder

public void setViewOrder(java.lang.String viewOrder)
Sets the sorting order for results.

Parameters:
viewOrder - A null string will return sorting according to the server default of -score (descending relevance). A comma delimited list of attributes is accepted, with + to denote ascending order and - to denote descending order, eg
"-score,-title,+description"
Since:
3.01C
See Also:
getViewOrder()

getQuery

public java.lang.String getQuery()
Return the fully formatted query url sent to the server.


setDatabase

public void setDatabase(java.lang.String database)

getDatabase

public java.lang.String getDatabase()

setSessionID

public void setSessionID(java.lang.String sessID)

getSessionID

public java.lang.String getSessionID()

doQuery

public void doQuery()
Execute the query.

Note: Query results are concatenated into a single StringBuffer. Use doQuery(int,int) to process search results iteratively.


doQuery

public void doQuery(int firstHit,
                    int viewHits)
Execute the query, returning viewHits hits starting at firstHit.


getRDMHeaderSOIF

public SOIF getRDMHeaderSOIF()
Return the SOIF RDM result header.


getResultStream

public SOIFInputStream getResultStream()
Return results as a DataInputStream. Can only be used if stream mode is enabled.

See Also:
setStreamMode(boolean)

getResultCount

public int getResultCount()
The number of results returned by the search. Returns -1 on error. The result count is based on the RDM header SOIF, so if doSOIFParse is false, -1 will be returned.

Since:
3.01C

getHitCount

public int getHitCount()
The total number of results that matched the search.

Since:
3.01C

getDocumentCount

public int getDocumentCount()
The total number of documents available to be searched.

Since:
3.01C

getToHit

public int getToHit()
Gets the last hit value being displayed

Returns:
firstHit+resultCount-1

noHits

public boolean noHits()
Returns:
true if no matches were found and false otherwise

toString

public java.lang.String toString()
Return debug string version of Search instance.