googlesearch
Class SiteQuery

java.lang.Object
  extended by googlesearch.Query
      extended by googlesearch.CompositeQuery
          extended by googlesearch.SiteQuery

public class SiteQuery
extends CompositeQuery

A decorator for querys to search a specific site like www.google.com. Note that if you attempt to apply several site queries, to a base query, only the first will be effective. ("First" means the first found in a postorder search of the query object tree.)

Author:
jbergin

Field Summary
 
Fields inherited from class googlesearch.Query
NULL_QUERY
 
Constructor Summary
SiteQuery(Query baseQuery, java.lang.String site)
          Create a query that applies a site search to a given query
 
Method Summary
 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.
 java.lang.String modifier()
          Used only by queries that must place their query text first or last in the full query string.
static boolean validateSite(java.lang.String site)
          Determine if a site string creates a well formed URL.You can use this before creating a SiteQuery to check your site string.
 
Methods inherited from class googlesearch.CompositeQuery
getSearchString
 
Methods inherited from class googlesearch.Query
getQueryKey, lucky, search, search, setQueryKey, suggestSpelling, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SiteQuery

public SiteQuery(Query baseQuery,
                 java.lang.String site)
Create a query that applies a site search to a given query

Parameters:
baseQuery - the terms to search for
site - the single site to search. This should be a complete site name. e.g. www.google.com.
Method Detail

modifier

public java.lang.String modifier()
Description copied from class: Query
Used only by queries that must place their query text first or last in the full query string. See SiteQuery, for example.

Overrides:
modifier in class Query
Returns:
the modifier text that should be pre/post pended to the rest of the query.

buildSearchString

public java.lang.String buildSearchString(java.util.List<Query> start,
                                          java.util.List<Query> finish)
Description copied from class: Query
Used by getSearchString to build up the query string recursively from the parts. Note that the work is done on the unwinding phase of the recursion. Those query fragments that must appear first or last in a query string defer being added to the string until the end, by putting a reference to themselves intoone of the two lists. These lists are then processed at the end after some verification.

Specified by:
buildSearchString in class Query
Parameters:
start - the list of query objects that must come first in a Google query
finish - the list of query objects that must come last in a Google query. e.g. site:
Returns:
the query string

validateSite

public static boolean validateSite(java.lang.String site)
Determine if a site string creates a well formed URL.You can use this before creating a SiteQuery to check your site string. Note that it does not check that the site exists, only that the URL is well formed.

Parameters:
site - the site string to check
Returns:
true if the site url is well formed