googlesearch
Class SearchResult

java.lang.Object
  extended by googlesearch.SearchResult

public class SearchResult
extends java.lang.Object

Represents the result of doing a Google search. It contains information about the search, such as the search string, and also the result web pages returned from the search. This is an adapter class to obtain a simpler (and safer) interface to the official GoogleSearchResult object. In particular it hides setter methods that would be dangerous to use here. It also returns the result objects as a java.util.List, rather than an array.

Author:
jbergin

Field Summary
static SearchResult NULL_RESULT
          Represents an empty search result.
 
Constructor Summary
SearchResult(com.google.soap.search.GoogleSearchResult adapted)
          Create a SearchResult object containg a set of result pages and information about the search.
 
Method Summary
 int getEndIndex()
          Get the Google-supplied index ranking of the end of this result set
 int getEstimatedTotalResultsCount()
          Obtain an estimate of the number of hits (pages) in this search.
 java.util.List<SearchResultPage> getResultPages()
          Return up to ten result pages in a list.
 java.lang.String getSearchQuery()
          Get the query string that was used to retrieve these results
 int getStartIndex()
          Get the google supplied index ranking of the beginning of this result set
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NULL_RESULT

public static final SearchResult NULL_RESULT
Represents an empty search result. i.e. one generated from a null query

Constructor Detail

SearchResult

public SearchResult(com.google.soap.search.GoogleSearchResult adapted)
Create a SearchResult object containg a set of result pages and information about the search. This is an adapter for a class supplied by the Google API.

Parameters:
adapted - The Google API equivalent object
Method Detail

getSearchQuery

public java.lang.String getSearchQuery()
Get the query string that was used to retrieve these results

Returns:
the query string

getStartIndex

public int getStartIndex()
Get the google supplied index ranking of the beginning of this result set

Returns:
the start index (ranking)

getEndIndex

public int getEndIndex()
Get the Google-supplied index ranking of the end of this result set

Returns:
the end index (ranking). i.e. the index of the last item returned.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getEstimatedTotalResultsCount

public int getEstimatedTotalResultsCount()
Obtain an estimate of the number of hits (pages) in this search. Note that the estimate is often exact, but need not be.

Returns:
the number of pages Google estimates result from this search

getResultPages

public java.util.List<SearchResultPage> getResultPages()
Return up to ten result pages in a list.

Returns:
a list of the result pages