|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object googlesearch.Query
public abstract class Query
Encapsulates a Google search query. It will let you search the Google indexes from a program just as you can from Google.com
This is version 2. It has the following differences from V1. (a) it uses Java 5 for its collections (templates). (b) it constructs the query string as late as possible, using a recursive look at the decorator chain that defines it. As such, it removes some responsibility from the user to construct a correct query. For exampmle it will guarantee that site: searches put the site: attribute last in any query. To use this you will need to get your own Google Key by registering at http://www.google.com/apis/ You will also need to download the googleapi.jar file from there and put it into your project.
Created on Apr 12, 2006
Field Summary | |
---|---|
static Query |
NULL_QUERY
An empty Query. |
Constructor Summary | |
---|---|
Query()
|
Method Summary | |
---|---|
abstract java.lang.String |
buildSearchString(java.util.List<Query> start,
java.util.List<Query> finish)
Used by getSearchString to build up the query string recursively from the parts. |
static java.lang.String |
getQueryKey()
Get the Google search key that you set with setQueryKey. |
abstract java.lang.String |
getSearchString()
Obtain the search string specified when the object was created. |
SearchResultPage |
lucky()
Return the top ranked page for this result |
java.lang.String |
modifier()
Used only by queries that must place their query text first or last in the full query string. |
SearchResult |
search()
Search for the highest ranked results. |
SearchResult |
search(int start)
Return up to ten search result pages starting with the index (ranking) you specify. |
static void |
setQueryKey(java.lang.String googleKey)
Set the Google search key. |
static java.lang.String |
suggestSpelling(java.lang.String trial)
Ask the Google servers to suggest spellings for a possible search "trial". |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Query NULL_QUERY
Constructor Detail |
---|
public Query()
Method Detail |
---|
public SearchResult search()
public SearchResult search(int start)
start
- the (zero based) index at which to start
public SearchResultPage lucky()
public java.lang.String toString()
toString
in class java.lang.Object
public abstract java.lang.String getSearchString()
public abstract java.lang.String buildSearchString(java.util.List<Query> start, java.util.List<Query> finish)
start
- the list of query objects that must come first in a Google
queryfinish
- the list of query objects that must come last in a Google
query. e.g. site:
public java.lang.String modifier()
public static java.lang.String suggestSpelling(java.lang.String trial)
trial
- the trial string that you think may be misspelled
public static java.lang.String getQueryKey()
public static void setQueryKey(java.lang.String googleKey)
googleKey
- the Google-supplied search key.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |