Class SearchResultBase

    • 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
    • Constructor Detail

      • SearchResultBase

        public SearchResultBase()
        Constructor
    • Method Detail

      • initialize

        public void initialize​(QueryBase query)
        Save various attributes of the general search request
        Specified by:
        initialize in interface SearchResultInterface
        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
      • getSearchStart

        public int getSearchStart()
        Return the starting item number for this search (one based)
        Specified by:
        getSearchStart in interface SearchResultInterface
        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:
        getMatchCount in interface SearchResultInterface
        Returns:
        Item count
      • getNextPreviewPage

        public String getNextPreviewPage()
        Fetch the "next preview page" reference (used to paginate results null if none)
        Specified by:
        getNextPreviewPage in interface SearchResultInterface
        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:
        getPreviousPreviewPage in interface SearchResultInterface
        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:
        canPaginate in interface SearchResultInterface
        Returns:
        true if so
      • toArray

        public MatchItem[] toArray()
        Return the MatchItem list as a simple array
        Returns:
        MatchItem array
      • 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. See initialize() (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) URL
        urlFragment - 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 URL
        proxy - 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 Elements
        expected - Number of Elements we expect to see
        Returns:
        true If we have the expected number Elements
      • getImageAttribute

        public String getImageAttribute​(Element parent,
                                        String name)
        Locate select attribute of the first matching image
        Parameters:
        parent - Parent element (look here for IMG tag)
        name - Attribute name (src, alt, etc)
        Returns:
        Image name value (null if none)