com.sun.portal.search.providers
Class SearchContext

java.lang.Object
  |
  +--com.sun.portal.search.demo.Search
        |
        +--com.sun.portal.search.providers.SearchContext

public class SearchContext
extends Search

This class provides convenient methods to handle advanced search and also evolved from the frontend application requirements.

See Also:
Search

Field Summary
static String ALL
          corresponds to <ALL> string operation
static String ANY
          corresponds to <OR> operation
static String CONTAIN
          corresponds to <CONTAINS> operation
static String EQUAL
          corresponds to '=' operation used to compare number type
static String EXACT
          corresponds to <EXACT> string operation
static String GREATER
          corresponds to '>' operation used to compare number type
static String LESS
          corresponds to '<' operation used to compare number type
static String NOT
          corresponds to <NOT> operation
static String NOTCONTAIN
          corresponds to <NOT> <CONTAINS> operation
static String NOTEQUAL
          corresponds to 'not equal to' operation used to compare number type
static String OPERAND
           
static String OPERATION
          The operation in a list element
static String PASSAGE
          corresponds to <PASSAGE> string operation
static String VALUE
          The right operand in a list element
 
Constructor Summary
SearchContext()
          Public Constructor calls super()
 
Method Summary
 void execute()
          Executes the query
 String getCategory()
          Gets the value of category
 int getPage()
          Gets the current page value
 int getTotalPages()
          Gets the total pages
static String htmlEncode(String s)
          Encodes > <, ", & characters
 void setCategory(String bc)
          Sets the category value.
 void setPage(int p)
          Sets the current page value.
 void setScope(ArrayList c)
          Sets the list of criteria for the scope.
 void setSearchAllCategories(boolean all)
          Sets the searchAllCategories property.
 
Methods inherited from class com.sun.portal.search.demo.Search
doQuery, doQuery, getDocumentCount, getFirstHit, getHitCount, getQuery, getQueryLanguage, getRDMHeaderSOIF, getRDMServer, getRDMType, getResultCount, getResultStream, getScope, getSessionID, getStringResult, getToHit, getViewAttributes, getViewHits, getViewOrder, noHits, setDatabase, setFirstHit, setQueryLanguage, setRDMServer, setRDMType, setScope, setSessionID, setSOIFParse, setStreamMode, setViewAttributes, setViewHits, setViewOrder, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OPERAND

public static final String OPERAND

OPERATION

public static final String OPERATION
The operation in a list element

VALUE

public static final String VALUE
The right operand in a list element

CONTAIN

public static final String CONTAIN
corresponds to <CONTAINS> operation

NOTCONTAIN

public static final String NOTCONTAIN
corresponds to <NOT> <CONTAINS> operation

NOT

public static final String NOT
corresponds to <NOT> operation

ANY

public static final String ANY
corresponds to <OR> operation

EXACT

public static final String EXACT
corresponds to <EXACT> string operation

ALL

public static final String ALL
corresponds to <ALL> string operation

PASSAGE

public static final String PASSAGE
corresponds to <PASSAGE> string operation

GREATER

public static final String GREATER
corresponds to '>' operation used to compare number type

LESS

public static final String LESS
corresponds to '<' operation used to compare number type

EQUAL

public static final String EQUAL
corresponds to '=' operation used to compare number type

NOTEQUAL

public static final String NOTEQUAL
corresponds to 'not equal to' operation used to compare number type
Constructor Detail

SearchContext

public SearchContext()
Public Constructor calls super()
Method Detail

setPage

public void setPage(int p)
Sets the current page value.

firstHit for searches is calculated based on the current page and viewHits.

Parameters:
page - is the current page value

getPage

public int getPage()
Gets the current page value
Returns:
the current page value

getCategory

public String getCategory()
Gets the value of category

The category value is used to create the scope value in the execute() method. The scope and the category are combined together based on the type of request. taxonomy-request v/s rd-request

Returns:
The current category value
See Also:
setSearchAllCategories(boolean)

setCategory

public void setCategory(String bc)
Sets the category value.

category setting is mainly required if category search is needed.

Parameters:
bc - is the current category level, If the category is not set then the category is set to the root of the taxonomy tree and the search is executed for all categories.
See Also:
getCategory(), setSearchAllCategories(boolean)

setSearchAllCategories

public void setSearchAllCategories(boolean all)
Sets the searchAllCategories property.

This property value is used in the execute() to create the scope

Parameters:
all - true implies that search should be in all the cateogories and false means that search should be within a specific category

setScope

public void setScope(ArrayList c)
Sets the list of criteria for the scope.

Advanced search related methods.The list should have specific operands, operations and values. The list is then internally converted to a String query as per the search engine query language.

Parameters:
c - criteria list for the search query

execute

public void execute()
             throws Exception
Executes the query

Calls the parent doQuery() method after doing some preprocessing to the query string. Merges category, searchAllCategories, scope string into a final scope string.

Throws:
Exception - is thrown if any of the input parameters are not specified or if the resultset is null or if connection to the search server failed

getTotalPages

public int getTotalPages()
Gets the total pages

Calculated based on the hitCount and viewHits. totalPages has no value if called before calling execute() first

Returns:
total pages

htmlEncode

public static String htmlEncode(String s)
Encodes > <, ", & characters
Parameters:
s - string that needs to be html encoded