org.dspace.search
Class QueryArgs

java.lang.Object
  extended by org.dspace.search.QueryArgs

public class QueryArgs
extends Object

Contains the arguments for a query. Fill it out and pass to the query engine


Constructor Summary
QueryArgs()
           
 
Method Summary
 String buildHTTPQuery(javax.servlet.http.HttpServletRequest request)
          Builds an HTTP query string for some parameters with the value taken from the request context passed in.
 String buildQuery(javax.servlet.http.HttpServletRequest request)
          Builds an advanced-query description string.
 HashMap buildQueryHash(javax.servlet.http.HttpServletRequest request)
          Constructs a HashMap with the keys field{1,2,3}, query{1,2,3} and conjunction{1,2} taking the values from the passed-in argument defaulting to "".
 int getEtAl()
           
 int getPageSize()
          get the count of hits to return
 String getQuery()
          retrieve the query string
 SortOption getSortOption()
           
 String getSortOrder()
           
 int getStart()
          read the search's starting offset
 void setEtAl(int etAl)
          set the number of metadata fields at which to truncate with "et al"
 void setPageSize(int newSize)
          set the count of hits to return; used to implement paged searching see the initializer for the default value
 void setQuery(String newQuery)
          set the query string
 void setSortOption(SortOption sortOption)
           
 void setSortOrder(String sortOrder)
           
 void setStart(int newStart)
          set the offset of the desired search results, beginning with 0 ; used to page results (the default value is 0)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryArgs

public QueryArgs()
Method Detail

getEtAl

public int getEtAl()
Returns:
the number of metadata fields at which to truncate with "et al"

setEtAl

public void setEtAl(int etAl)
set the number of metadata fields at which to truncate with "et al"

Parameters:
etAl -

setQuery

public void setQuery(String newQuery)
set the query string

Parameters:
newQuery -

getQuery

public String getQuery()
retrieve the query string

Returns:
the current query string

setStart

public void setStart(int newStart)
set the offset of the desired search results, beginning with 0 ; used to page results (the default value is 0)

Parameters:
newStart - index of first desired result

getStart

public int getStart()
read the search's starting offset

Returns:
current index of first desired result

setPageSize

public void setPageSize(int newSize)
set the count of hits to return; used to implement paged searching see the initializer for the default value

Parameters:
newSize - number of hits per page

getPageSize

public int getPageSize()
get the count of hits to return

Returns:
number of results per page

getSortOption

public SortOption getSortOption()

setSortOption

public void setSortOption(SortOption sortOption)

getSortOrder

public String getSortOrder()

setSortOrder

public void setSortOrder(String sortOrder)

buildQuery

public String buildQuery(javax.servlet.http.HttpServletRequest request)
Builds an advanced-query description string. The string is built using the passed in values query{1,2,3}, field{1,2,3} and conjunction{1,2} taken from the parameter request.

Parameters:
request - the request object to take the values from
Returns:
the query description string built

buildQueryHash

public HashMap buildQueryHash(javax.servlet.http.HttpServletRequest request)
Constructs a HashMap with the keys field{1,2,3}, query{1,2,3} and conjunction{1,2} taking the values from the passed-in argument defaulting to "".

Parameters:
request - the request-describing object to take the values from
Returns:
the created HashMap

buildHTTPQuery

public String buildHTTPQuery(javax.servlet.http.HttpServletRequest request)
                      throws UnsupportedEncodingException
Builds an HTTP query string for some parameters with the value taken from the request context passed in. The returned string includes key/value pairs in the HTTP query string format (key1=value1&key2=value2...) for the keys query{1,2,3}, field{1,2,3} and conjunction{1,2} with values taken from request and defaulting to "".

Note, that the values are url-encoded using the UTF-8 encoding scheme as the corresponding W3C recommendation states.

Also note that neither leading ? (question mark) nor leading & (ampersand mark) is included. Take this into account when appending to a real URL.

Parameters:
request - the request object to take the values from
Returns:
the query string that can be used without further transformationin URLs
Throws:
UnsupportedEncodingException


Copyright © 2010 DuraSpace. All Rights Reserved.