|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.thauvin.google.GoogleSearchBean
Implements methods used to perform searches on Google.
Field Summary | |
static boolean |
DEFAULT_CACHE
The default cache flag. |
static boolean |
DEFAULT_FILTER
The default related-queries filter. |
static java.lang.String |
DEFAULT_LR
The default language restricts. |
static int |
DEFAULT_MAX_RESULTS
The default maximum number of results to be returned. |
static java.lang.String |
DEFAULT_RESTRICT
The default document store restrict. |
static boolean |
DEFAULT_SAFE_SEARCH
The default SafeSearch. |
static java.lang.String |
DEFAULT_SITE
The default site. |
static int |
DEFAULT_START
The default index of the result to be returned. |
static java.lang.String |
DEFAULT_TYPE
The default filetype. |
static java.lang.String |
NEXT_KEYWORD
The next keyword. |
static java.lang.String |
PREVIOUS_KEYWORD
The previous keyword. |
Constructor Summary | |
GoogleSearchBean()
Constructs a new instance of the bean. |
|
GoogleSearchBean(java.lang.String key)
Constructs a new instance of the bean with the specified authorization key. |
Method Summary | |
java.lang.String |
getCachedPage(java.lang.String url)
Returns a cached web page from Google. |
com.google.soap.search.GoogleSearchResult |
getGoogleSearch(java.lang.String q)
Returns the GoogleSearch attribute of the GoogleSearchBean object. |
com.google.soap.search.GoogleSearchResult |
getGoogleSearch(java.lang.String q,
int start,
int maxResults,
boolean filter,
java.lang.String restrict,
boolean safeSearch,
java.lang.String lr)
Invokes a Google search. |
com.google.soap.search.GoogleSearchResult |
getGoogleSearch(java.lang.String key,
java.lang.String q,
int start,
int maxResults,
boolean filter,
java.lang.String restrict,
boolean safeSearch,
java.lang.String lr)
Returns the GoogleSearch attribute of the GoogleSearchBean object. |
java.lang.String |
getKeywords()
Returns the keywords. |
com.google.soap.search.GoogleSearchResult |
getResult()
Returns the results of the search. |
java.lang.String |
getResultElementProperty(int index,
java.lang.String property)
Returns the specified property of the given element index in the current result set. |
com.google.soap.search.GoogleSearchResultElement[] |
getResultElements()
Returns an array of result elements that corresponds to the actual list of search results. |
int |
getResultElementsCount()
Returns the count of result elements. |
java.lang.String |
getResultProperty(java.lang.String property)
Returns the given property of the result set. |
java.lang.String |
getSpellingSuggestion(java.lang.String phrase)
Asks Google to return a spelling suggestion for a word or phrase. |
boolean |
isKeySet()
Returns true if the authorization key is set. |
boolean |
isValidResult()
Returns true whenever the result set is valid, indicating that a search was performed. |
static void |
main(java.lang.String[] args)
Demonstration program to perform various Google searches. |
void |
reset()
Reset the bean properties. |
void |
setKey(java.lang.String key)
Sets the authorization key. |
void |
setKeywords(java.lang.String keywords)
Sets the search keywords. |
void |
setProxyServer(java.lang.String proxyHost,
int proxyPort,
java.lang.String proxyUserName,
java.lang.String proxyPassword)
Sets the HTTP proxy host, port, user name and password. |
void |
setProxyServer(java.lang.String proxyHost,
java.lang.String proxyPort,
java.lang.String proxyUserName,
java.lang.String proxyPassword)
Sets the HTTP proxy host, port, user name and password. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final boolean DEFAULT_CACHE
public static final boolean DEFAULT_FILTER
public static final java.lang.String DEFAULT_LR
public static final int DEFAULT_MAX_RESULTS
public static final java.lang.String DEFAULT_RESTRICT
public static final boolean DEFAULT_SAFE_SEARCH
public static final java.lang.String DEFAULT_SITE
public static final int DEFAULT_START
public static final java.lang.String DEFAULT_TYPE
public static final java.lang.String NEXT_KEYWORD
public static final java.lang.String PREVIOUS_KEYWORD
Constructor Detail |
public GoogleSearchBean()
public GoogleSearchBean(java.lang.String key)
key
- The authorization key.Method Detail |
public final void setKey(java.lang.String key)
key
- The key string.public final boolean isKeySet()
public final void setKeywords(java.lang.String keywords)
keywords
- The keywordsgetKeywords()
public final java.lang.String getKeywords()
setKeywords(String)
public void setProxyServer(java.lang.String proxyHost, java.lang.String proxyPort, java.lang.String proxyUserName, java.lang.String proxyPassword)
proxyHost
- The host to use for the HTTP proxy.proxyPort
- The port to use for the HTTP proxy.proxyUserName
- The user name to use for the HTTP proxy.proxyPassword
- The password to use for the HTTP proxy.public void setProxyServer(java.lang.String proxyHost, int proxyPort, java.lang.String proxyUserName, java.lang.String proxyPassword)
proxyHost
- The host to use for the HTTP proxy.proxyPort
- The port to use for the HTTP proxy.proxyUserName
- The user name to use for the HTTP proxy.proxyPassword
- The password to use for the HTTP proxy.public final com.google.soap.search.GoogleSearchResult getResult()
public final com.google.soap.search.GoogleSearchResultElement[] getResultElements()
public final int getResultElementsCount()
getResultElements()
public final boolean isValidResult()
public java.lang.String getCachedPage(java.lang.String url) throws com.google.soap.search.GoogleSearchFault
url
- The page's URL.
com.google.soap.search.GoogleSearchFault
public com.google.soap.search.GoogleSearchResult getGoogleSearch(java.lang.String q, int start, int maxResults, boolean filter, java.lang.String restrict, boolean safeSearch, java.lang.String lr) throws com.google.soap.search.GoogleSearchFault
q
- The Google query.start
- The index of the result to be returned.maxResults
- The maximum number of results to be returned.filter
- The related-queries filter.restrict
- The document store restrict value (e.g.: "linux").safeSearch
- Enable or disable SafeSearch.lr
- The language restricts for the search.
com.google.soap.search.GoogleSearchFault
public com.google.soap.search.GoogleSearchResult getGoogleSearch(java.lang.String key, java.lang.String q, int start, int maxResults, boolean filter, java.lang.String restrict, boolean safeSearch, java.lang.String lr) throws com.google.soap.search.GoogleSearchFault
key
- The authorization key.q
- The Google query.start
- The index of the result to be returned.maxResults
- The maximum number of results to be returned.filter
- The related-queries filter.restrict
- The document store restrict value (e.g.: "linux").safeSearch
- Enable or disable SafeSearch.lr
- The language restricts for the search.
com.google.soap.search.GoogleSearchFault
getGoogleSearch(String, int, int, boolean, String, boolean, String)
public com.google.soap.search.GoogleSearchResult getGoogleSearch(java.lang.String q) throws com.google.soap.search.GoogleSearchFault
q
- The Google query.
com.google.soap.search.GoogleSearchFault
getGoogleSearch(String, int, int, boolean, String, boolean, String)
public java.lang.String getResultElementProperty(int index, java.lang.String property)
The properties are:
"summary" | Returns the ODP summary text string. |
"url" | Returns the absolute URL path of the search. |
"snippet" | Returns a text snippet of the query in context. |
"title" | Returns the title (HTML) of the search result. |
"cachedSize" | Returns the size of (size +
k ) the cached version of the URL, in kilobytes. |
"relatedInformationPresent" | Returns
true when the related: query term is supported for
this URL; false , otherwise. |
"hostName" | Returns the host name. |
"directoryTitle" | Returns the ODP directory title. |
"directoryCategoryName" | Returns the ODP directory name of the current ODP category. |
"directoryCategoryEncoding" | Returns the encoding scheme of the current ODP category. |
"relatedQuery" | Returns the related query
string, suitable for use as a search
query string.For example: related:www.example.com/search?q=vacation%20hawaii |
"cachedQuery" | Returns the cached query
string, suitable for use as a cached query
string.For example: www.example.com/search?q=vacation%20hawaii
|
"staticQuery" | The static query, suitable for
display. For example: www.example.com/search?q=vacation hawaii
|
index
- The element index.property
- The property name.
public java.lang.String getResultProperty(java.lang.String property)
The properties are:
"estimatedTotalResultsCount" | Returns the estimated total number of results returned for the query. |
"startIndex" | Returns the index (1-based) of the first search result in the result elements. |
"endIndex" | Returns the index (1-based) of the last search result in the result elements. |
"searchTime" | Returns the total server time to process the query, in seconds. |
"searchTips" | Returns a string providing instructive suggestions on how to use Google. |
"searchComments" | Returns a string intended for display to the end user. (e.g.: list of removed stop words, etc.) |
"documentFiltering" | Returns
true if filtering was performed on the search results;
false otherwise. |
"searchQuery" | Returns the query string that generated this result. |
| Returns the start index of the next set of results. |
| Returns the start index of the previous set of results. |
property
- The property name.
public java.lang.String getSpellingSuggestion(java.lang.String phrase) throws com.google.soap.search.GoogleSearchFault
phrase
- The word or phrase to correct the spelling for.
com.google.soap.search.GoogleSearchFault
public static final void main(java.lang.String[] args)
The arguments are:
<client-key> (search <query> | cached <URL> |
spell <phrase>)
args
- The command line arguments.public void reset()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |