Package edu.indiana.lib.twinpeaks.search
Class SearchResultBase
- java.lang.Object
-
- edu.indiana.lib.twinpeaks.search.SearchResultBase
-
- All Implemented Interfaces:
SearchResultInterface
- Direct Known Subclasses:
Response,Response,Web2Response
public abstract class SearchResultBase extends Object implements SearchResultInterface
Result rendering - base class and helpers
-
-
Field Summary
Fields Modifier and Type Field Description protected String_baseUrlprotected String_databaseprotected String_searchQueryprotected byte[]_searchResponseBytesprotected Document_searchResponseDocumentprotected String_searchResponseStringprotected String_sessionId
-
Constructor Summary
Constructors Constructor Description SearchResultBase()Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddItem(MatchItem item)Add a MatchItem objectbooleancanPaginate()Can this display be paginated (next/previous pages for display)?booleanexpectedNodeCount(NodeList nodeList, int expected)Verify we have the expected number of Elements in a Node listStringgetFullUrl(String urlFragment)Form a full URL (protocol, server, arguments) from a provided URL and a previously provided base URLStringgetFullUrl(String baseUrl, String urlFragment)Form a full URL (protocol, server, arguments) from a base URL and provided parametersStringgetImageAttribute(Element parent, String name)Locate select attribute of the first matching imageintgetMatchCount()Return the count of matching items returnedStringgetNextPreviewPage()Fetch the "next preview page" reference (used to paginate results null if none)StringgetPreviousPreviewPage()Fetch the "previous preview page" reference (used to paginate results, null if none)StringgetQuery()Fetch the original query textDocumentgetSearchResponseDocument()Return search results as a DocumentStringgetSearchResponseString()Return search results as a StringintgetSearchStart()Return the starting item number for this search (one based)voidinitialize(QueryBase query)Save various attributes of the general search requestIteratoriterator()Get an iterator to the result listprotected DocumentparseResponse()Parse the search engine response as HTML.StringprependProxy(String url, String proxy)Prepend proxy string (if not already present)voidsaveBaseUrl(String url)Save the request URL base (the server portion only)voidsetNextPreviewPage(String reference)Set the "next preview page" referencevoidsetPreviousPreviewPage(String reference)Set the "previous preview page" referencevoidsetSearchStart(int start)Set the starting item number for this search (one based)voidsetSearchStart(String start)Set the starting item number for this search (one based)MatchItem[]toArray()Return the MatchItem list as a simple array-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface edu.indiana.lib.twinpeaks.search.SearchResultInterface
doParse
-
-
-
-
Field Detail
-
_searchQuery
protected String _searchQuery
-
_searchResponseBytes
protected byte[] _searchResponseBytes
-
_searchResponseString
protected String _searchResponseString
-
_searchResponseDocument
protected Document _searchResponseDocument
-
_database
protected String _database
-
_sessionId
protected String _sessionId
-
_baseUrl
protected String _baseUrl
-
-
Method Detail
-
initialize
public void initialize(QueryBase query)
Save various attributes of the general search request- Specified by:
initializein interfaceSearchResultInterface- Parameters:
query- The QueryBase extension that sent the search request
-
addItem
public void addItem(MatchItem item)
Add a MatchItem object- Parameters:
item- MatchItem to add
-
getQuery
public String getQuery()
Fetch the original query text- Specified by:
getQueryin interfaceSearchResultInterface- Returns:
- Search string
-
getSearchStart
public int getSearchStart()
Return the starting item number for this search (one based)- Specified by:
getSearchStartin interfaceSearchResultInterface- Returns:
- Starting item number
-
setSearchStart
public void setSearchStart(int start)
Set the starting item number for this search (one based)- Parameters:
start- Starting item number
-
setSearchStart
public void setSearchStart(String start)
Set the starting item number for this search (one based)- Parameters:
start- Starting item number
-
getMatchCount
public int getMatchCount()
Return the count of matching items returned- Specified by:
getMatchCountin interfaceSearchResultInterface- Returns:
- Item count
-
getNextPreviewPage
public String getNextPreviewPage()
Fetch the "next preview page" reference (used to paginate results null if none)- Specified by:
getNextPreviewPagein interfaceSearchResultInterface- Returns:
- Next page reference
-
setNextPreviewPage
public void setNextPreviewPage(String reference)
Set the "next preview page" reference- Parameters:
reference- Next page reference
-
getPreviousPreviewPage
public String getPreviousPreviewPage()
Fetch the "previous preview page" reference (used to paginate results, null if none)- Specified by:
getPreviousPreviewPagein interfaceSearchResultInterface- Returns:
- Previous page reference
-
setPreviousPreviewPage
public void setPreviousPreviewPage(String reference)
Set the "previous preview page" reference- Parameters:
reference- Previous page reference
-
canPaginate
public boolean canPaginate()
Can this display be paginated (next/previous pages for display)?- Specified by:
canPaginatein interfaceSearchResultInterface- Returns:
- true if so
-
iterator
public Iterator iterator()
Get an iterator to the result list- Specified by:
iteratorin interfaceSearchResultInterface- Returns:
- SearchResult Iterator
-
toArray
public MatchItem[] toArray()
Return the MatchItem list as a simple array- Returns:
- MatchItem array
-
getSearchResponseString
public String getSearchResponseString()
Return search results as a String- Specified by:
getSearchResponseStringin interfaceSearchResultInterface- Returns:
- Result Document
-
getSearchResponseDocument
public Document getSearchResponseDocument()
Return search results as a Document- Returns:
- Result Document
-
parseResponse
protected Document parseResponse() throws SearchException
Parse the search engine response as HTML. Seeinitialize()(override as reqired)- Returns:
- Response as a DOM Document
- Throws:
SearchException
-
saveBaseUrl
public void saveBaseUrl(String url)
Save the request URL base (the server portion only)- Parameters:
url- Request URL (with or without parameters)
-
getFullUrl
public String getFullUrl(String baseUrl, String urlFragment)
Form a full URL (protocol, server, arguments) from a base URL and provided parameters- Parameters:
baseUrl- The base (or template) URLurlFragment- The (possibly) relative URL to be combined with the base- Returns:
- A full URL (as a String)
-
getFullUrl
public String getFullUrl(String urlFragment)
Form a full URL (protocol, server, arguments) from a provided URL and a previously provided base URL- Parameters:
urlFragment- The (possibly) relative URL to be combined with the base- Returns:
- A full URL (as a String)
-
prependProxy
public String prependProxy(String url, String proxy)
Prepend proxy string (if not already present)- Parameters:
url- Target URLproxy- Proxy specification- Returns:
- (Possibly) updated URL string
-
expectedNodeCount
public boolean expectedNodeCount(NodeList nodeList, int expected)
Verify we have the expected number of Elements in a Node list- Parameters:
nodeList- List of collected Elementsexpected- Number of Elements we expect to see- Returns:
- true If we have the expected number Elements
-
-