googlesearch
Class SearchResultPage

java.lang.Object
  extended by googlesearch.SearchResultPage

public class SearchResultPage
extends java.lang.Object

Represents one of many pages returned by a Google search. It is essentially just an adapter for a GoogleSearchResultElement object, providing a more convenient interface.

Author:
jbergin

Field Summary
static SearchResultPage NULL_PAGE
          Represents an empty page.
 
Constructor Summary
SearchResultPage(com.google.soap.search.GoogleSearchResultElement adapted)
          Create an object representing a single result page from a search.
 
Method Summary
 void displayPage()
           
 java.lang.String getCachedPage()
           
 java.lang.Object getContent()
          Get the contents of the url of this page.
 java.lang.String getContentType()
          Retrieve the Mime type of the page.
 java.lang.String getHTML()
          Get the html or text of a page with Mime type "text/html" or "text/plain".
 java.lang.String getSnippet()
          Return a small part of the page as a string
 java.net.URL getURL()
          Obtain a URL object for this page
 java.lang.String getURLString()
          Retrieve the full URL string including protocol.This string can be pasted into a browser to retrieve the page.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NULL_PAGE

public static final SearchResultPage NULL_PAGE
Represents an empty page.

Constructor Detail

SearchResultPage

public SearchResultPage(com.google.soap.search.GoogleSearchResultElement adapted)
Create an object representing a single result page from a search. It contains the URL and other information. It also knows how to image a page in a window.

Parameters:
adapted - the Google API equivalent object
Method Detail

getURL

public java.net.URL getURL()
                    throws java.lang.RuntimeException
Obtain a URL object for this page

Returns:
a URL
Throws:
java.lang.RuntimeException

getURLString

public java.lang.String getURLString()
Retrieve the full URL string including protocol.This string can be pasted into a browser to retrieve the page.

Returns:
the URL string

displayPage

public void displayPage()

getHTML

public java.lang.String getHTML()
Get the html or text of a page with Mime type "text/html" or "text/plain". Returns an error string in other cases or if there is an error.

Returns:
The html or an error message

getCachedPage

public java.lang.String getCachedPage()

getSnippet

public java.lang.String getSnippet()
Return a small part of the page as a string

Returns:
the page snippet

getContent

public java.lang.Object getContent()
                            throws java.io.IOException
Get the contents of the url of this page. See the JavaDocs for java.net.URL for more information on interpreting the returned result. The objects returned are often InputStreams from which you can read the content. This is the case for an html page.

Returns:
An object containing the page. It may be html, pdf, or other
Throws:
java.io.IOException

getContentType

public java.lang.String getContentType()
Retrieve the Mime type of the page. Common types are "text/html", "text/plain" and "application/pdf". The Mime type tells you how to interpret the content of the page.

Returns:
the Mime type

toString

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