com.sun.portal.search.demo
Class Search

java.lang.Object
  |
  +--com.sun.portal.search.demo.Search
Direct Known Subclasses:
SearchContext

public class Search
extends Object

Search encapsulation class.


Constructor Summary
Search()
          Constructor.
Search(String scope, String RDMServer)
          Constructor.
Search(String scope, String viewAttributes, String viewOrder, int firstHit, int viewHits, String ql, String database, String RDMServer, 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.
 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.
 String getQuery()
          Return the fully formatted query url sent to the server.
 String getQueryLanguage()
          Returns the current query language.
 SOIF getRDMHeaderSOIF()
          Return the SOIF RDM result header.
 String getRDMServer()
          Returns the current RDMServer variable.
 String getRDMType()
          Returns the current RDMType.
 int getResultCount()
          The number of results returned by the search.
 SOIFInputStream getResultStream()
          Return results as a DataInputStream.
 String getScope()
          Returns the current scope (query) for the search.
 String getSessionID()
           
 String getStringResult()
          Return result.
 int getToHit()
          Gets the last hit value being displayed
 String getViewAttributes()
          Returns the SOIF attributes which are retrieved by a search.
 int getViewHits()
          Get the maximum number of hits returned.
 String getViewOrder()
          Gets the sorting order for results.
 boolean noHits()
           
 void setDatabase(String database)
           
 void setFirstHit(int firstHit)
          Set the starting hit offset.
 void setQueryLanguage(String ql)
          Sets the query language.
 void setRDMServer(String RDMServer)
          Sets the RDMServer variable.
 void setRDMType(String RDMType)
          Sets the RDM Request type.
 void setScope(String scope)
          Sets the scope (query) for the search.
 void setSessionID(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(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(String viewOrder)
          Sets the sorting order for results.
 String toString()
          Return debug string version of Search instance.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Search

public Search()
Constructor.

Search

public Search(String scope,
              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(String scope,
              String viewAttributes,
              String viewOrder,
              int firstHit,
              int viewHits,
              String ql,
              String database,
              String RDMServer,
              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)
ql - query language
database - name (can be null for server's default database)
RDMServer - Search server URL, eg, http://portal.siroe.com:2222/portal/search
sessID - Identity Server single sign-on session ID
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 String getRDMServer()
Returns the current RDMServer variable.
Since:
3.01C

setRDMServer

public void setRDMServer(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 String getScope()
Returns the current scope (query) for the search.
Since:
3.01C
See Also:
setScope(java.lang.String)

setScope

public void setScope(String scope)
Sets the scope (query) for the search.
Since:
3.01C
See Also:
getScope()

getRDMType

public String getRDMType()
Returns the current RDMType.
Since:
3.01C
See Also:
setRDMType(java.lang.String)

setRDMType

public void setRDMType(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 String getQueryLanguage()
Returns the current query language.
Since:
3.01C
See Also:
setQueryLanguage(java.lang.String)

setQueryLanguage

public void setQueryLanguage(String ql)
Sets the query language.
Parameters:
ql - 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 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(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 String getViewOrder()
Gets the sorting order for results.
Parameters:
strVal - 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"
Since:
3.01C
See Also:
setViewOrder(java.lang.String)

setViewOrder

public void setViewOrder(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 String getQuery()
Return the fully formatted query url sent to the server.

setDatabase

public void setDatabase(String database)
Parameters:
The - database name

setSessionID

public void setSessionID(String sessID)
Parameters:
The - access token from the portal server

getSessionID

public 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.

getStringResult

public String getStringResult()
Return result.

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 String toString()
Return debug string version of Search instance.
Overrides:
toString in class Object