Methods Summary |
---|
public boolean | getFilter()
return filter;
|
public java.lang.String | getLangRestrict()
return langRestrict;
|
public java.lang.String | getLineSep()
return lineSep;
|
public int | getMaxResults()
return maxResults;
|
public java.lang.String | getQuery()
return query;
|
public java.lang.String | getRestrict()
return restrict;
|
public boolean | getSafeSearch()
return safeSearch;
|
public java.lang.String | getSearchResults()
search = new GoogleSearch();
search.setKey(GOOGLE_KEY);
search.setFilter(filter);
if(restrict.length() > 0)
search.setRestrict(restrict);
search.setQueryString(query);
googleRes = search.doSearch();
return structureResult(googleRes);
|
public int | getStartRes()
return startRes;
|
public void | release()
search = null;
googleRes = null;
|
public void | setFilter(boolean filter)
this.filter = filter;
|
public void | setLangRestrict(java.lang.String query)
this.langRestrict = langRestrict;
|
public void | setLineSep(java.lang.String lineSep)
this.lineSep=lineSep;
|
public void | setMaxResults(int maxResults)
this.maxResults = maxResults;
|
public void | setQuery(java.lang.String query)
this.query = query;
|
public void | setRestrict(java.lang.String query)
this.restrict = restrict;
|
public void | setSafeSearch(boolean filter)
this.safeSearch = safeSearch;
|
public void | setStartRes(int startRes)
this.startRes = startRes;
|
public java.lang.String | structureResult(GoogleSearchResult res)
GoogleSearchResultElement[] elements = res.getResultElements();
String url ="";
String results = "Estimated total results count: " +
res.getEstimatedTotalResultsCount() + lineSep + lineSep;
for (int i = 0; i < elements.length; i++){
url = elements[i].getURL();
results += ("Title: " + elements[i].getTitle() + lineSep +
"URL: <a href=\"" + url + "\">" + url + "</a>"+ lineSep +
"Summary: " + elements[i].getSummary() + lineSep +
"Snippet: " + elements[i].getSnippet() + lineSep + lineSep);
}
return results;
|