diff --git a/google-taglib/.cvsignore b/google-taglib/.cvsignore new file mode 100644 index 0000000..7b3e786 --- /dev/null +++ b/google-taglib/.cvsignore @@ -0,0 +1,5 @@ +build +dist +javadoc +*.bat +key.txt \ No newline at end of file diff --git a/google-taglib/GoogleTagLib.iml b/google-taglib/GoogleTagLib.iml new file mode 100644 index 0000000..c800be7 --- /dev/null +++ b/google-taglib/GoogleTagLib.iml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/google-taglib/GoogleTagLib.ipr b/google-taglib/GoogleTagLib.ipr new file mode 100644 index 0000000..33924de --- /dev/null +++ b/google-taglib/GoogleTagLib.ipr @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/google-taglib/GoogleTagLib.iws b/google-taglib/GoogleTagLib.iws new file mode 100644 index 0000000..a985d52 --- /dev/null +++ b/google-taglib/GoogleTagLib.iws @@ -0,0 +1,476 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/google-taglib/README.txt b/google-taglib/README.txt new file mode 100644 index 0000000..80db474 --- /dev/null +++ b/google-taglib/README.txt @@ -0,0 +1,85 @@ +Google Tag Library README +========================= + + +Overview +======== + +This README file describes the Google Tag Library distribution. + +With the Google JSP Tag Library, developers and designers can easily +incorporate Google queries, search results, cached pages and spelling +suggestions into any web site or application. + +For more information about using the custom tag library in your own web +applications, point your browser to: + + http://google-taglib.sourceforge.net/ + +See the "LICENSE.txt" file for licensing details. + +The Google Tag Library uses the Google Web APIs, but is not associated with +or sponsored by Google, Inc. + +Installation +============ + +The Google Tag Library requires a JSP (1.1 or higher) container, such as +Tomcat. + +To use the Google Tag Library, simply copy the library's JAR file +(google.jar) to your application's WEB-INF/lib directory. The Tag Library +Descriptor (google.tld) should be placed in your application's WEB-INF +directory. + +You should also modify your web application deployment descriptor (web.xml) +file to map the Google Tag Library TLD URI to its location: + + + /google-taglib + /WEB-INF/google.tld + + + +Google Web APIs +=============== + +The Google Web APIs Java library is required in order to use the Google Tag +Library. The library's JAR file (googleapi.jar) should be placed into the +application's WEB-INF/lib directory. + + http://www.google.com/apis/download.html + +You must also register with Google (free) in order to obtain a license key. +The license key is required to access Google's Web Services. + + https://www.google.com/accounts/NewAccount + + +Google License Key +================== + +The license key can be specified as a context parameter in the web +application deployment descriptor (web.xml) as follows: + + + google_key + 000000000000000000000000 + + +The license key can also be specified using the key search form parameter, +key tag attribute or the google_key application scope attribute. + + +TagLib Directive +================ + +Using the Google Tag Library is easy; you simply need to import it into your +JSP pages using the taglib directive. For instance, you would include the +following line at the top of your JSP page: + + <%@taglib uri="/google-taglib" prefix="google"%> + + +=========================================================================== +$Id$ \ No newline at end of file diff --git a/google-taglib/build.properties b/google-taglib/build.properties new file mode 100644 index 0000000..ae81e9c --- /dev/null +++ b/google-taglib/build.properties @@ -0,0 +1,24 @@ +# Version +version=1.0 + +# Project +project.name=google +release.name=${project.name}-taglib-${version} + +# Locations +src.dir=src +build.dir=build +dist.dir=dist +lib.dir=lib +tlds.dir=tlds +licenses.dir=licenses +war.dir=${project.name}-examples + +# Javadoc +javadoc.dir=javadoc +javadoc.title=Google Tag Library +javadoc.packages=net.thauvin.google.* + +# Docs +doc.license=LICENSE.txt +doc.readme=README.txt \ No newline at end of file diff --git a/google-taglib/build.xml b/google-taglib/build.xml new file mode 100644 index 0000000..a8dc42d --- /dev/null +++ b/google-taglib/build.xml @@ -0,0 +1,108 @@ + + + Google Tag Library + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/google-taglib/google-examples/README.txt b/google-taglib/google-examples/README.txt new file mode 100644 index 0000000..c3cbf29 --- /dev/null +++ b/google-taglib/google-examples/README.txt @@ -0,0 +1,64 @@ +Google Tag Library Examples README +================================== + + +Overview +======== + +This README file describes the Google Tag Library Examples web application. + +This web application contains a collection of examples demonstrating the +usage of the Google JSP Tag Library. For more information about using the +custom tag library in your own web applications, point your browser to: + + http://google-taglib.sourceforge.net/ + +See the "LICENSE.txt" file for licensing details. + +The Google Tag Library uses the Google Web APIs, but is not associated with +or sponsored by Google, Inc. + + +Google Web APIs +=============== + +The Google Web APIs Java library is required in order to use the Google Tag +Library. The library's JAR file (googleapi.jar) should be placed into the +application's WEB-INF/lib directory. + + http://www.google.com/apis/download.html + +You must also register with Google (free) in order to obtain a license key. +The license key is required to access Google's Web Services. + + https://www.google.com/accounts/NewAccount + + +Google License Key +================== + +The license key can be specified as a context parameter in the web +application deployment descriptor (web.xml) as follows: + + + google_key + 000000000000000000000000 + + +The license key can also be temporarily specified from the index page of +the web application. + + +Examples +======== + +The following examples are included: + + - Perform a simple Google search + - Perform an advanced Google search + - View a page cached by Google + - Perform a Google spelling suggestion + + +=========================================================================== +$Id$ diff --git a/google-taglib/google-examples/WEB-INF/web.xml b/google-taglib/google-examples/WEB-INF/web.xml new file mode 100644 index 0000000..7458f6f --- /dev/null +++ b/google-taglib/google-examples/WEB-INF/web.xml @@ -0,0 +1,18 @@ + + + + google-examples + Google Examples Web Application + + google_key + + The Google Web APIs client authorization key. + + + index.html + + + /google-taglib + /WEB-INF/google.tld + + diff --git a/google-taglib/google-examples/advanced.html b/google-taglib/google-examples/advanced.html new file mode 100644 index 0000000..e6b0f12 --- /dev/null +++ b/google-taglib/google-examples/advanced.html @@ -0,0 +1,113 @@ + + + +Search Google + + + + +
+ + + + +
+ + + + + + + + + + + + +
+ + + + + +
Find results + + + + + + +
with all of the words + + +
+
+
+ + + + + + +
LanguageReturn pages written in + + +
+
+ + + + + +
SafeSearchNo filtering  Filter using SafeSearch
+
+
+
+ + \ No newline at end of file diff --git a/google-taglib/google-examples/advanced.jsp b/google-taglib/google-examples/advanced.jsp new file mode 100644 index 0000000..4b457fb --- /dev/null +++ b/google-taglib/google-examples/advanced.jsp @@ -0,0 +1,52 @@ + +<%@ taglib uri="/google-taglib" prefix="google" %> + + + + Google Search: <google:searchQuery/> + + + + + + + + +
Searched the web for .   Results - of about . Search took seconds. +
+ +


+ +
+ Description:
+ Category: " target="_blank">
+ - " target="_blank">Cached - - ">Similar Pages + +

+ + + + + +
+ Previous +   + +   + Next +
+ + diff --git a/google-taglib/google-examples/cache.html b/google-taglib/google-examples/cache.html new file mode 100644 index 0000000..8ec0e15 --- /dev/null +++ b/google-taglib/google-examples/cache.html @@ -0,0 +1,17 @@ + + + +Google Cached Page + + + + +

+   + +
+ + diff --git a/google-taglib/google-examples/cache.jsp b/google-taglib/google-examples/cache.jsp new file mode 100644 index 0000000..a451597 --- /dev/null +++ b/google-taglib/google-examples/cache.jsp @@ -0,0 +1,2 @@ +<%@ taglib uri="/google-taglib" prefix="google" %> + \ No newline at end of file diff --git a/google-taglib/google-examples/index.html b/google-taglib/google-examples/index.html new file mode 100644 index 0000000..7b6bc06 --- /dev/null +++ b/google-taglib/google-examples/index.html @@ -0,0 +1,83 @@ + + + +Google Tag Library Examples + + + + + +Google Tag Library Examples +

+This is a collection of examples demonstrating the usage of the Google +JSP Tag Library. +

+

+The Google Web APIs Java library is required in order to use the Google Tag +Library. The library's JAR file (googleapi.jar) should be placed +into the application's WEB-INF/lib directory. +

+ +

+You must also register with Google (free) in order to obtain a license key. The +license key is required to access Google's Web Services. +

+ +

+The license key can be specified as a context parameter in the web application +deployment descriptor (web.xml) as follows: +

+
+
<context-param>
<param-name>google_key</param-name>
<param-value>000000000000000000000000</param-value>
</context-param>
+
+

+The license key can also be temporarily specified using the following: +

+ +

+The included examples will allow you to: +

+ +

 

+

+The Google Tag Library uses the Google Web APIs, but is not associated with +or sponsored by Google, Inc. +
+Click here for licensing information. +
+

+ + \ No newline at end of file diff --git a/google-taglib/google-examples/key.html b/google-taglib/google-examples/key.html new file mode 100644 index 0000000..564276f --- /dev/null +++ b/google-taglib/google-examples/key.html @@ -0,0 +1,16 @@ + + + +Set Google Key + + + + +
+   +
+ + diff --git a/google-taglib/google-examples/key.jsp b/google-taglib/google-examples/key.jsp new file mode 100644 index 0000000..2896dd8 --- /dev/null +++ b/google-taglib/google-examples/key.jsp @@ -0,0 +1,21 @@ +<% + // Copyright (c) 2002-2003, Erik C. Thauvin + // All rights reserved. + + String key = request.getParameter("key"); + + if ((key != null)&& (key.trim().length() > 0)) + { + pageContext.setAttribute("google_key", key, PageContext.APPLICATION_SCOPE); +%> + <%@include file="advanced.html"%> +<% + } + else + { +%> + <%@include file="key.html"%> +<% + } +%> + diff --git a/google-taglib/google-examples/search.html b/google-taglib/google-examples/search.html new file mode 100644 index 0000000..ab6906f --- /dev/null +++ b/google-taglib/google-examples/search.html @@ -0,0 +1,16 @@ + + + +Search Google + + + + +
+   +
+ + diff --git a/google-taglib/google-examples/search.jsp b/google-taglib/google-examples/search.jsp new file mode 100644 index 0000000..f0c9004 --- /dev/null +++ b/google-taglib/google-examples/search.jsp @@ -0,0 +1,20 @@ + +<%@ taglib uri="/google-taglib" prefix="google" %> + + + + Google Search: <google:searchQuery/> + + + + +
    + +
  1. +
    +
+ + \ No newline at end of file diff --git a/google-taglib/google-examples/spelling.html b/google-taglib/google-examples/spelling.html new file mode 100644 index 0000000..60cd1f1 --- /dev/null +++ b/google-taglib/google-examples/spelling.html @@ -0,0 +1,16 @@ + + + +Google Spelling Suggestion + + + + +
+   +
+ + diff --git a/google-taglib/google-examples/spelling.jsp b/google-taglib/google-examples/spelling.jsp new file mode 100644 index 0000000..96309e8 --- /dev/null +++ b/google-taglib/google-examples/spelling.jsp @@ -0,0 +1,15 @@ + +<%@ taglib uri="/google-taglib" prefix="google" %> + + + Google Spelling Suggestion + + + + + + + \ No newline at end of file diff --git a/google-taglib/htdocs/about.html b/google-taglib/htdocs/about.html new file mode 100644 index 0000000..eb60136 --- /dev/null +++ b/google-taglib/htdocs/about.html @@ -0,0 +1,89 @@ + + + +Google Tag Library - About + + + + + + + + +
Return to Google homepage. +

+ + + + +
 Google Tag Library
+

+ + + + + + + +
+

+
+   Overview
+   Download
+   Documentation
+   HowTo
+   Javadoc
+ arrow About +
+

+ + + + + +
+ + +
+
+

+ About +

+

+ The following people are currently working on the Google Tag + Library development: +

+ + + +

+ The Google Tag Library is an open source + project, and is not associated with or sponsored by + Google, Inc. +

+ If you comments, find errors, or just have questions, please + visit the project's support area.

+ + diff --git a/google-taglib/htdocs/docs.html b/google-taglib/htdocs/docs.html new file mode 100644 index 0000000..8d7ca0d --- /dev/null +++ b/google-taglib/htdocs/docs.html @@ -0,0 +1,831 @@ + + + +Google Tag Library - Documentation + + + + + + + + +
Return to Google homepage.

+ + + + +
+

+  Google Tag Library +

+
+

+ + + + + + + + +
+

+
+   Overview
+   Download
+ arrow Documentation +
+   HowTo
+   Javadoc
+   About
+

+ + + + + +
+ + +
+
+

+ Google Tag Library Documentation +

+ + + + +
Contents
+

+     1. Overview +

+ 1.1 Installation
+ 1.2 Google API Library
+ 1.3 TagLib Directive
+
+

+     2. Search Tags +   +

+ 2.1 Search Tag
+ 2.2 SearchResult Tag
+ 2.3 Element Tag
+ 2.4 Next & Previous Tags
+ 2.5 StartIndex & EndIndex Tags
+ 2.6 EstimatedTotal Tag
+ 2.7 SearchComments Tag
+ 2.8 SearchQuery Tag
+ 2.9 SearchTime Tag
+ 2.10 SearchTips Tag
+
+
+

+     3. CachedPage & Spelling + Tags   +

+ 3.1 CachedPage Tag
+ 3.2 Spelling Tag
+
+ + + + + +
1. Overview    +      
+

+ This document explains in detail the semantics of the JSP tags + provided by the Google Tag Library. In this document, you will learn: +

    +
  • + How to install the Google Tag Library. +
  • +
  • + How to use the various Search, CachedPage and Spelling tags. +
  • +
  • + How to customize searches and interpret the search results data. +
  • + +
+

+ You may also find the following helpful: +

    +
  • + The Google Tag Library HowTo. +
  • +
  • + The Google Tag Library Javadoc documention. +
  • +
+

+ If you have comments, find errors, or just have questions, + please visit the project's support area. +

+ +

+ + + + + + + +
1.1 Installation Back + to top    
+

+ The Google Tag Library requires a JSP (1.1 or higher) container, + such as Tomcat. +

+ To use the Google Tag Library, simply copy the library's JAR + file (google.jar) to your application's WEB-INF/lib + directory. The Tag Library Descriptor (google.tld) should be placed + in your application's WEB-INF directory. +

+ You should also modify your web application deployment + descriptor (web.xml) file to map the Google Tag Library TLD URI to + its location: +

+
<taglib>
<taglib-uri>/google-taglib</taglib-uri>
<taglib-location>/WEB-INF/google.tld</taglib-location>
</taglib>
+
+

+ + + + + + +
1.2 Google API Library Back + to top    
+

+ The Google Web APIs Java library is required in order to use + the Google Tag Library. The library is included in the Google Web APIs developer's kit. + The library's JAR file (googleapi.jar) should be placed into your + application's WEB-INF/lib directory. +

+ You must also register with Google (free) in order to obtain a + license key. The license key is required to access Google's Web Services. +

+ The license key can be specified as a context parameter in your + web application deployment descriptor (web.xml) as follows: +

+
<context-param>
<param-name>google_key</param-name>
<param-value>000000000000000000000000</param-value>
</context-param>
+
+

+ The license key can also be specified using the key + search form parameter, key tag attribute or the google_key + application scope attribute. +

+ + + + + + +
1.3 + TagLib Directive Back + to top    
+

+ Using the Google Tag Library is easy; you simply need to import + it into your JSP pages using the taglib directive. For instance, you would + include the following line at the top of your JSP page: +

+
<%@taglib uri="/google-taglib" prefix="google"%>
+
+
+

+ + + + + +
2. Search + Tags
+

+ +

+ + + + + +
2.1 Search Tag Back + to top    
+

+ The <google:search/> tag is used to perform + searches on Google's index of over 2 billion web pages. +

+ Tag Syntax +

+ The search query can be specified directly in the tag body , + e.g.: +

+
<google:search>my search query</google:search>
+
+

+ or via the q request parameter: +

+
+
(search page) 
<form action="search.jsp" >
<input type= text" name="q">
...
</form>

(result page)
<google:search/>
+
+

+ Similarly the <google:search/> tag options + can be specified as attributes, e.g.: +

+
<google:search start ="10" maxResults ="5" / >
+
+

+ or via request parameters: +

+
+
(search page)
<form action="search.jsp" >
<input type="hidden" name="start" value="10">
<input type="hidden" name="maxResults" value="5">
...
</form>

(result page)
<google:search/>
+
+

+ Tag Attributes / Request Parameters +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ Name +
+
+
+ Description +
+
+
+ Default
+ Value
+
+
+
+ key +
+
Provided by Google, this is required for you to access the + Google service. Google uses the key for authentication and logging. 
+
+ q +
+
The search query string.
+ Note: There is no q attribute. The query is specified directly within the + body of the tag.
 
+
+ start +
+
Zero-based index of the first desired result. +
+ 0 +
+
+
+ maxResults +
+
Number of results desired per query. The maximum value per + query is 10.
+ Note: If you do a query that doesn't have many matches, the actual number + of results you get may be smaller than what you request.
+
+ 10 +
+
+
+ filter +
+
Activates or deactivates automatic results filtering, which + hides very similar results and results that all come from the same web host. + Filtering tends to improve the end user experience on Google, but for your + application you may prefer to turn it off. +
+ true +
+
+
+ restricts +
+
Restricts the search to a subset of the Google web index, + such as a country like "Ukraine" or a topic like "Linux." 
+
+ safeSearch +
+
A Boolean value which enables filtering of adult content in + the search results. +
+ false +
+
+
+ lr +
+
Language Restrict - Restricts the search to documents + within one or more languages. +
+ latin1 +
+
The parameters listed below are not + part of the Google Web APIs.
+
+ cache +
+
By default the search results are cached between search requests. To ensure that a new query has been specified set this parameter to false. +
+ true +
+
+
+ site +
+
Restricts the search to documents within the specfied + site. 
+

+ For detailed information on the above Google search options, + please refer to the Google + Web APIs documentation. +

+ + + + + + +
2.2 + SearchResult Tag Back + to top    
+

+ The <google:searchResult/> tag is used to + loop through the results returned by of a Google search. +

+ Tag Syntax +

+ The search results can be displayed using an HTML ordered list: +

+
<ol>
<google:searchResult>
<li><google:element name="title-url"/></li>
</google:searchResult>
</ol>
+
+

+ The <google:element/> tag + is used to display the details of the current result set item. +

+ + + + + + + +
2.3 Element Tag Back + to top    
+

+ The <google:element/> tag is used to display + the properties of the current result set item. It can only be used inside the + <google:searchResult/> tag. +

+ Tag Syntax +

+ The URL property of the search results can be displayed as follows: +

+
<google:searchResult>
<google:element name="url"/><br>
</google:searchResult>
+
+

+ The name attribute is used to specify the desired + property of the current result set item. +

+

+ Name Attributes Values +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ Name +
+
+
+ Description +
+
+
+ summary +
+
The search result has a listing in the ODP directory, the + ODP summary appears here as a text string.
+
+ URL +
+
The URL of the search result, returned as text, with an + absolute URL path.
+
+ snippet +
+
A snippet which shows the query in context on the URL where + it appears.
+
+ title +
+
The title of the search result, returned as HTML.
+
+ cachedSize +
+
Indicates that a cached version of the URL is available; + size is indicated in kilobytes.
+
+ relatedInformationPresent +
+
Boolean indicating that the "related:" query term is + supported for this URL.
+
+ hostName +
+
When filtering occurs, a maximum of two results from any + given host is returned. When this occurs, the second result element that comes + from that host contains the host name in this parameter.
+
+ directoryTitle +
+
The title that appears in the ODP directory, if any.
+
+ directoryCategoryName +
+
The ODP directory name for the current ODP category.
+
+ directoryCategoryEncoding +
+
Specifies the encoding scheme of the directory information.
The properties listed below are not + part of the Google Web APIs.
+
+ relatedQuery +
+
The related query, suitable for use with q + request parameter of the <google:search/> + tag.
For example: related:www.example.com/search?q=vacation%20hawaii
+
+ cachedQuery +
+
The cached query, suitable for use with the q + request parameter of the <google:cachedPage/> + tag.
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
+

+ For detailed information on the above Google search elements + options, please refer to the Google + Web APIs documentation. +

+ Automatic Link Creation +

+ The name of two properties can be combined to automatically + generate properly formatted HTML links. For example, to automatically create a + link whose location is the URL of the current element and whose text is the + current element's title use the following syntax: +

+
<google:element name="title-url"/>
+
+

+ which will automatically generate a property formatted HTML link: +

+
<a href="[url]">[title]</a>
+
+

+ Additionally, the link's target and style options can be specify + using the target, style and css attributes of the <google:element/> + tag: +

+
<google:element name="title-url" target="_blank" style="text-decoration:none" css="c"/>
+
+

+ which will generate: +

+
<a href="[url]" target="_blank" class="c" style="text-decoration:none">[title]</a>
+
+

+ + + + + + +
2.4 Next & Previous + Tags Back + to top    
+

+ The <google:next/> tag is used to + + + used to display a link to more search results.
+ The <google:previous/> tag is used to used to display a link + to previous search results.
+ +

+ Tag Syntax +

+ The next set of results can be displayed using: +

+
Click <google:next>here</google:next> to view more results.
+					
+
+

+ Additionally, the link's target and style options can be specify + using the target, style and css attributes. +

+ + + + + + + +
2.5 StartIndex & + EndIndex Tags Back + to top    
+

+ The <google:startIndex/> tag is + + + used to display the index (1-based) of the first search result in the current + result set.
+ The <google:endIndex/> tag is used to used to + + + display the index (1-based) of the last search result in the current result set.
+

+ + + + + + + +
2.6 EstimatedTotal Tag Back + to top    
+

+ The <google:estimatedTotal/> tag is used to + + + display the estimated total number of results that exist for the current query. +

+ + + + + + + +
2.7 SearchComments Tag Back + to top    
+

+ The <google:searchComments/> + tag is used to + + + display the comments (if any) included with the current result set. +

+ + + + + + + +
2.8 SearchQuery Tag Back + to top    
+

+ The <google:searchQuery/> + tag is used to + + + display the text of the current query. + + +

+ + + + + + + +
2.9 SearchTime Tag Back + to top    
+

+ The <google:searchTime/> + tag is used to + + + display the total server time used to return the search results, measured in + seconds. +

+ + + + + + + +
2.10 SearchTips Tag Back + to top    
+

+ The <google:searchTips/> + tag is used to + + + display the tips (if any) included with the current result set. +

+

+ + + + + +
3. CachedPage & Spelling Tags
+

+ +

+ + + + + +
3.1 CachedPage Tag Back + to top    
+

+ The <google:cachedPage/> tag is used to + display Google's cached web pages. +

+ Tag Syntax +

+ The URL can be specified directly in the tag body, e.g.: +

+
<google:cachedPage>http://www.google.com</google:cachedPage>
+
+

+ or via the q request parameter: +

+
(search page)
<form action="cache.jsp">
<input type="text" name="q">
...
</form>

(result page)
<google:cachedPage/>
+
+

+ Upon submission the cached page will be displayed. +

+ +

+ + + + + +
3.2 Spelling Back + to top    
+

+ The <google:spelling/> tag is used to display Google's + spelling suggestions. +

+ Tag Syntax +

+ The text can be specified directly in the tag body, e.g.: +

+
<google:spelling>long knifes</google:spelling>
+
+

+ or via the q request parameter: +

+
(search page)
<form action="spelling.jsp">
<input type="text" name="q">
...
</form>

(result page)
<google:spelling/>
+
+

+ Upon submission the spelling suggestion ("long knives") + will be displayed. +

+
+ + \ No newline at end of file diff --git a/google-taglib/htdocs/howto.html b/google-taglib/htdocs/howto.html new file mode 100644 index 0000000..589e238 --- /dev/null +++ b/google-taglib/htdocs/howto.html @@ -0,0 +1,441 @@ + + + +Google Tag Library - HowTo + + + + + + + + +
Return to Google homepage.

+ + + + +
+

+  Google Tag Library +

+
+

+ + + + + + + + +
+

+
+   Overview
+   Download
+   Documentation
+ arrow HowTo +
+   Javadoc
+   About
+

+ + + + + +
+ + +
+
+

+  Google Tag Library HowTo +

+ + + + +
Contents
+

+     1. Search & Display the + Results of a Goggle Search +

+ 1.1 Create a Search Form
+ 1.2 Create a Result Page
+ 1.3 Display the Results
+
+ +

+     2. Display a Page Cached by Goggle +

+ 2.1 Create a Search From
+ 2.2 Create a Result Page
+ 2.3 Display the Cached Page
+
+ +

+

+     3. Display a Goggle Spelling Suggestion
+
+ 3.1 Create a Search Form
+ 3.2 Create a Result Page
+ 3.3 Display the Spelling Suggestion
+
+
+ + + + + +
1. Search & Display the + Results of a Google Search
+

+

+ + + + + + +
1.1 Create a Search From Back + to top    
+

+ Create the following HTML form on your search page: +

+ + + + + + + +
 <form action="results.jsp" + >
+   <input type="text" + name="q">
+   <input type="submit" + >

+ </form>
arrowsearch
+

+ The q parameter is required and used to store the + search query string.
+ The form action points to the results.jsp page, which is + created in step 1.2.
+

+ The Google Web APIs authentication key can be + specified as an hidden form input parameter:
+
+ + + + + +
 <input type="hidden" name="key" + value="000000000000000000000000">
+

+

+ + + + + + +
1.2 Create a Results Page Back + to top    
+

+ Create a page called results.jsp containing: +

+ + + + + +
 <%@taglib uri="/google-taglib" + prefix="google"%> +
+ <google:search/>
+

+ The taglib directive is used to specify the Google Tag + library reference and prefix.
+ The <google:search/> tag is used to perform the query.
+

+ The Google Web APIs authentication key can be + specified as a tag attribute:
+
+ + + + + +
 <google:search key="000000000000000000000000"/>
+

+ + + + + + +
+ 1.3 Display the Search Results Back + to top    
+

+ + + + + + + +
 <ol>
+ <google:searchResult>
+   <li><google:element + name="title-url"/></li> +
+ </google:searchResult>
+ </ol>
arrowsearchresults
+

+ The <google:searchResult/> tag is used to loop + through the results.
+ The <google:element/> tag is used to display the attributes of + the current result set element.
+

+ + + + + +
2. + Display a Page Cached by Google
+
+ +

+ + + + + +
2.1 Create a Search FromBack + to top    
+

+ Create the following HTML form on your search page: +

+ + + + + + + +
 <form action="results.jsp" + >
+   <input type="text" + name="q">
+   <input type="submit" + >

+ </form>
arrowsearch
+

+ The q parameter is required and used to store the + search query string.
+ The form action points to the results.jsp page, which is + created in step 2.2.
+

+ The Google Web APIs authentication key can be + specified as an hidden form input parameter:
+
+ + + + + +
 <input type="hidden" name="key" + value="000000000000000000000000">
+

+ +

+ + + + + + +
2.2 Create a + Result Page Back + to top    
+

+

+ Create a page called results.jsp containing: +

+ + + + + +
 <%@taglib uri="/google-taglib" + prefix="google"%>
+

+ The taglib directive is used to specify the Google Tag + library reference and prefix. +

+ + + + + + +
2.3 Display the Cached Page Back + to top    
+

+ + + + + + + +
 <google:cachedPage/>arrowsearchresults
+

+ The <google:cachedPage> tag is used to display + the content of the cached page. +

+ The Google Web APIs authentication key can be + specified as a tag attribute:
+
+ + + + + +
 <google:cachedPage key="000000000000000000000000"/>
+

+

+

+ + + + + +
3. Display a Google Spelling Suggestion
+

+ +

+ + + + + +
3.1 Create a Search FormBack + to top    
+

+ +

+ Create the following HTML form on your search page: +

+ + + + + + + +
 <form action="results.jsp" + >
+   <input type="text" + name="q">
+   <input type="submit" + >

+ </form>
arrowsearch
+

+ The q parameter is required and used to store the + search query string.
+ The form action points to the results.jsp page, which is + created in step 3.2.
+

+ The Google Web APIs authentication key can be + specified as an hidden form input parameter:
+
+ + + + + +
 <input type="hidden" name="key" + value="000000000000000000000000">
+

+ +

+ + + + + +
3.2 Create a Result Page Back + to top    
+

+ +

+ Create a page called results.jsp containing: +

+ + + + + +
 <%@taglib uri="/google-taglib" + prefix="google"%>
+

+ The taglib directive is used to specify the Google Tag + library reference and prefix. +

+ +

+ + + + + +
3.3 Display the Spelling + Suggestion Back + to top    
+

+ + + + + + + + +
 <google:spelling/>arrowlong knives
+

+ The <google:spelling> tag is used to display the + suggested spelling for the given query. +

+ The Google Web APIs authentication key can be + specified as a tag attribute:
+
+ + + + + +
 <google:spelling key="000000000000000000000000"/>
+

+

+
+ + diff --git a/google-taglib/htdocs/images/arrow.gif b/google-taglib/htdocs/images/arrow.gif new file mode 100644 index 0000000..9377088 Binary files /dev/null and b/google-taglib/htdocs/images/arrow.gif differ diff --git a/google-taglib/htdocs/images/arrow.jpg b/google-taglib/htdocs/images/arrow.jpg new file mode 100644 index 0000000..18711f0 Binary files /dev/null and b/google-taglib/htdocs/images/arrow.jpg differ diff --git a/google-taglib/htdocs/images/cached.jpg b/google-taglib/htdocs/images/cached.jpg new file mode 100644 index 0000000..f8ab947 Binary files /dev/null and b/google-taglib/htdocs/images/cached.jpg differ diff --git a/google-taglib/htdocs/images/cachedresults.jpg b/google-taglib/htdocs/images/cachedresults.jpg new file mode 100644 index 0000000..779dc8e Binary files /dev/null and b/google-taglib/htdocs/images/cachedresults.jpg differ diff --git a/google-taglib/htdocs/images/duktumbl.gif b/google-taglib/htdocs/images/duktumbl.gif new file mode 100644 index 0000000..95dd2bb Binary files /dev/null and b/google-taglib/htdocs/images/duktumbl.gif differ diff --git a/google-taglib/htdocs/images/google_sm.gif b/google-taglib/htdocs/images/google_sm.gif new file mode 100644 index 0000000..d9d266d Binary files /dev/null and b/google-taglib/htdocs/images/google_sm.gif differ diff --git a/google-taglib/htdocs/images/google_sm.png b/google-taglib/htdocs/images/google_sm.png new file mode 100644 index 0000000..ae3bab5 Binary files /dev/null and b/google-taglib/htdocs/images/google_sm.png differ diff --git a/google-taglib/htdocs/images/search.jpg b/google-taglib/htdocs/images/search.jpg new file mode 100644 index 0000000..d6299d1 Binary files /dev/null and b/google-taglib/htdocs/images/search.jpg differ diff --git a/google-taglib/htdocs/images/searchresults.jpg b/google-taglib/htdocs/images/searchresults.jpg new file mode 100644 index 0000000..407e71c Binary files /dev/null and b/google-taglib/htdocs/images/searchresults.jpg differ diff --git a/google-taglib/htdocs/images/spelling.jpg b/google-taglib/htdocs/images/spelling.jpg new file mode 100644 index 0000000..1a601b8 Binary files /dev/null and b/google-taglib/htdocs/images/spelling.jpg differ diff --git a/google-taglib/htdocs/images/yellowarrow.gif b/google-taglib/htdocs/images/yellowarrow.gif new file mode 100644 index 0000000..6178a6e Binary files /dev/null and b/google-taglib/htdocs/images/yellowarrow.gif differ diff --git a/google-taglib/htdocs/includes/google.css b/google-taglib/htdocs/includes/google.css new file mode 100644 index 0000000..caf675f --- /dev/null +++ b/google-taglib/htdocs/includes/google.css @@ -0,0 +1,42 @@ +body, td { background-color: white; } + +h1 td, h1, h2, h3, h4, h5, h6, div.topnav, +div.sidenav, div.sidesearch, div.sidequote, div.bottomnav, div.footer, small, +td#sidebartitle { font-family: arial,sans-serif; } + +/* rules for the bottom navigation on the results page */ +div.bottomnav { margin-top: 1ex; } + +div.bottomnav a, span.bottomnav { font-size: 10pt; } + +div.bottomnav a, span.big { font-size: 12pt; color: #0000cc; } + +/* standard link colors */ +a:link { color: #0000cc; } +a:visited { color: #551a8b; } +a:active { color: #ff0000; } + + +/* top part of the page */ +div.topnav { margin-bottom: 0.1ex; } +h1 td { font-size: .95em; font-weight: bolder; } +h1 td { background-color: #669900; color: white; border: none; padding: 2pt; } +div.side { margin-right: 3ex; padding: 2pt; } +div.sidenav { } +div.sidesearch { margin-top: 1em; font-size: 0.75em; } +div.sidequote { text-align: center; margin-top: 1.5in; border-color: red; border-style: solid; border-top-width: 1px; border-bottom-width: 1px; border-left-width: 0px; border-right-width: 0px; } +div.footer { text-align: center; color: #6f6f6f; padding: 3pt; } +/* sidebar on the right */ +table.sidebarborder { margin: 3pt; margin-top: 1pt; } +td#sidebarcontent { background-color: #ffffff; } +/* color schemes for different sections of the site */ +body.corporate h1 td, body.corporate table.sidebarborder td { background-color: #339966; } +body.corporate td#sidebartitle { background-color: #d8f1e4; } +body.siteowners h1 td, body.siteowners table.sidebarborder td { background-color: #ddad08; } +body.siteowners td#sidebartitle { background-color: #f1e4d8; } +body.search h1 td, body.search table.sidebarborder td { background-color: #336699; } +body.search td#sidebartitle { background-color: #d8e4f1; } +body.zealots h1 td, body.zealots table.sidebarborder td { background-color: #aa1002; } +body.zealots td#sidebartitle { background-color: #f1e4d8; } + + diff --git a/google-taglib/htdocs/index.html b/google-taglib/htdocs/index.html new file mode 100644 index 0000000..b653c3b --- /dev/null +++ b/google-taglib/htdocs/index.html @@ -0,0 +1,230 @@ + + + +Google Tag Library + + + + + + + + +
Return to Google homepage.

+ + + + +
 Google Tag Library
+

+ + + + + + + +
+

+
+ arrow Overview +
+   Download
+   Documentation
+   HowTo
+   Javadoc
+   About
+

+ + + + + +
+ + +
+

+  SourceForge.net Logo +

+
+ + + + + +
+

+ Easily Include Google Searches in Your Web Applications +

+

+ With the Google JSP Tag Library, developers and designers can + easily incorporate Google queries, search results, cached pages and spelling + suggestions into any web site or application. +

+

+ To start using the Google Tag Library: +

+ + + + + + + + + + + + + + + + + + + + + +
1Download the Google Tag Library
+ The download includes the tag library and associated TLD.
  + +   + +
2Download the Google Web API
+ To use the Google Web APIs service, you also must obtain + a license key.
  + +   + +
3Incorporate the tags in your web pages
+ Check out the HowTo or read the Documentation + for more information.
+
+
+ + + + + + + +
+
+ Google Web APIs +
+
+
+

+ Duke does the Google dance. +

+
+
+

+ + + + +
+ + + + + + + + + + + + + + + + +
+

+ + + + +
+ + + + + + + + + + + + + + + + + +
+

+ + + + +
+ + + + + + + + +
+

+
+
+ + diff --git a/google-taglib/htdocs/license.html b/google-taglib/htdocs/license.html new file mode 100644 index 0000000..963ed33 --- /dev/null +++ b/google-taglib/htdocs/license.html @@ -0,0 +1,100 @@ + + + +Google Tag Library - License + + + + + + + + +
Return to Google homepage.

+ + + + +
 Google Tag Library
+

+ + + + + + + +
+

+
+   Overview
+   Download
+   Documentation
+   HowTo
+   Javadoc
+ arrow About +
+

+ + + + + +
+ + +
+
+

+ Google Tag Libary License +

+

+ Copyright (c) 2002-2003, Erik C. Thauvin.
+ All rights reserved.
+

+ +

+ Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: +

+

+ Redistributions of source code must retain the above copyright notice, this list + of conditions and the following disclaimer. +

+

+ Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. +

+

+ Neither the name of the author nor the names of its contributors may be used to + endorse or promote products derived from this software without specific prior + written permission. +

+

+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +

+
+ + \ No newline at end of file diff --git a/google-taglib/lib/doccheck.jar b/google-taglib/lib/doccheck.jar new file mode 100644 index 0000000..0b83105 Binary files /dev/null and b/google-taglib/lib/doccheck.jar differ diff --git a/google-taglib/lib/googleapi.jar b/google-taglib/lib/googleapi.jar new file mode 100644 index 0000000..2aade51 Binary files /dev/null and b/google-taglib/lib/googleapi.jar differ diff --git a/google-taglib/lib/servlet.jar b/google-taglib/lib/servlet.jar new file mode 100644 index 0000000..dbf42a4 Binary files /dev/null and b/google-taglib/lib/servlet.jar differ diff --git a/google-taglib/licenses/LICENSE-activation.txt b/google-taglib/licenses/LICENSE-activation.txt new file mode 100644 index 0000000..83efd2d --- /dev/null +++ b/google-taglib/licenses/LICENSE-activation.txt @@ -0,0 +1,90 @@ +License Agreement + +SUN MICROSYSTEMS, INC. (``SUN'') IS WILLING TO LICENSE ITS JAVABEANS(tm) +ACTIVATION FRAMEWORK SOFTWARE (``SOFTWARE'') TO +YOU ("CUSTOMER") ONLY UPON THE CONDITION THAT YOU ACCEPT ALL OF THE +TERMS CONTAINED IN THIS LICENSE AGREEMENT ("AGREEMENT"). READ THE +TERMS AND CONDITIONS OF THE AGREEMENT CAREFULLY BEFORE SELECTING THE +"ACCEPT" BUTTON AT THE BOTTOM OF THIS PAGE. BY SELECTING THE +"ACCEPT" BUTTON YOU AGREE TO THE TERMS AND CONDITIONS OF THE +AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY ITS TERMS, SELECT +THE "DO NOT ACCEPT" BUTTON AT THE BOTTOM OF THIS PAGE AND THE +INSTALLATION PROCESS WILL NOT CONTINUE. + +1. License to Distribute. Customer is granted a royalty-free, +non-transferable right to reproduce and use the Software +for the purpose of developing applications which run in +conjunction with the Software. Customer may not modify the Software +(including any APIs exposed by the Software) in any way. + +2. Restrictions. Software is confidential copyrighted information +of Sun and title to all copies is retained by Sun and/or its +licensors. Except to the extent enforcement of this provision is +prohibited by applicable law, if at all, Customer shall not decompile, +disassemble, decrypt, extract, or otherwise reverse engineer Software. +Software is not designed or intended for use in on-line control of +aircraft, air traffic, aircraft navigation or aircraft communications; +or in the design, construction, operation or maintenance of any nuclear +facility. Customer warrants that it will not use or redistribute the +Software for such purposes. + +3. Trademarks and Logos. This Agreement does not authorize +Customer to use any Sun name, trademark or logo. Customer acknowledges +that Sun owns the Java trademark and all Java-related trademarks, logos +and icons including the Coffee Cup and Duke (``Java Marks'') and agrees +to: (i) comply with the Java Trademark Guidelines at +http://java.sun.com/trademarks.html; (ii) not do anything harmful to or +inconsistent with Sun's rights in the Java Marks; and (iii) assist Sun +in protecting those rights, including assigning to Sun any rights +acquired by Customer in any Java Mark. + +4. Disclaimer of Warranty. Software is provided ``AS IS,'' without a +warranty of any kind. ALL EXPRESS OR IMPLIED REPRESENTATIONS AND +WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. + +5.Limitation of Liability. IN NO EVENT WILL SUN OR ITS LICENSORS +BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR SPECIAL, +INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES HOWEVER CAUSED +AND REGARDLESS OF THE THEORY OF LIABILITY ARISING OUT OF THE +DOWNLOADING OF, USE OF, OR INABILITY TO USE, SOFTWARE, EVEN IF SUN HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +6. Termination. Customer may terminate this Agreement at any time +by destroying all copies of Software. This Agreement will terminate +immediately without notice from Sun if Customer fails to comply with any +provision of this Agreement. Upon such termination, Customer must destroy +all copies of Software. Sections 4 and 5 above shall survive termination +of this Agreement. + +7. Export Regulations. Software, including technical data, is +subject to U.S. export control laws, including the U.S. Export +Administration Act and its associated regulations, and may be subject +to export or import regulations in other countries. Customer agrees to +comply strictly with all such regulations and acknowledges that it has +the responsibility to obtain licenses to export, re-export, or import +Software. Software may not be downloaded, or otherwise exported or +re-exported (i) into, or to a national or resident of, Cuba, Iraq, +Iran, North Korea, Libya, Sudan, Syria or any country to which the U.S. +has embargoed goods; or (ii) to anyone on the U.S. Treasury +Department's list of Specially Designated Nations or the U.S. Commerce +Department's Table of Denial Orders. + +8. Restricted Rights. Use, duplication or disclosure by the United +States government is subject to the restrictions as set forth in the +Rights in Technical Data and Computer Software Clauses in DFARS +252.227-7013(c) (1) (ii) and FAR 52.227-19(c) (2) as applicable. + +9. Governing Law. Any action related to this Agreement will be +governed by California law and controlling U.S. federal law. No choice +of law rules of any jurisdiction will apply. + +10. Severability. If any of the above provisions are held to be in +violation of applicable law, void, or unenforceable in any +jurisdiction, then such provisions are herewith waived or amended to +the extent necessary for the Agreement to be otherwise enforceable in +such jurisdiction. However, if in Sun's opinion deletion or amendment +of any provisions of the Agreement by operation of this paragraph +unreasonably compromises the rights or increase the liabilities of Sun +or its licensors, Sun reserves the right to terminate the Agreement. + diff --git a/google-taglib/licenses/LICENSE-apache-soap.txt b/google-taglib/licenses/LICENSE-apache-soap.txt new file mode 100644 index 0000000..8c1e633 --- /dev/null +++ b/google-taglib/licenses/LICENSE-apache-soap.txt @@ -0,0 +1,54 @@ +/* + * The Apache Software License, Version 1.1 + * + * + * Copyright (c) 1999 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "SOAP" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ diff --git a/google-taglib/licenses/LICENSE-crimson.txt b/google-taglib/licenses/LICENSE-crimson.txt new file mode 100644 index 0000000..bf1dafa --- /dev/null +++ b/google-taglib/licenses/LICENSE-crimson.txt @@ -0,0 +1,54 @@ +/* + * The Apache Software License, Version 1.1 + * + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The name "Apache Software Foundation" must not be used to endorse or + * promote products derived from this software without prior written + * permission. For written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation and was + * originally based on software copyright (c) 1999-2001, Sun Microsystems, + * Inc., http://www.sun.com. For more information on the Apache Software + * Foundation, please see . + */ diff --git a/google-taglib/licenses/LICENSE-doccheck.html b/google-taglib/licenses/LICENSE-doccheck.html new file mode 100644 index 0000000..8c6b970 --- /dev/null +++ b/google-taglib/licenses/LICENSE-doccheck.html @@ -0,0 +1,273 @@ + + + + + + + + + + +

Sun +Doc Check Doclet, Version 1.2 Beta 2 +

+

Pre-Release +Software Evaluation Agreement

+


+

+

SUN +MICROSYSTEMS, INC. ("SUN") IS WILLING TO LICENSE SUN DOC +CHECK DOCLET, VERSION 1.2 BETA 2 SOFTWARE TO YOU ("LICENSEE") +ONLY UPON THE CONDITION THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN +THIS LICENSE AGREEMENT ("AGREEMENT"). PLEASE READ THE TERMS +AND CONDITIONS OF THIS LICENSE CAREFULLY. BY INSTALLING THIS +SOFTWARE, YOU ACCEPT THE TERMS AND CONDITIONS OF THIS LICENSE +AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY ITS TERMS, SELECT +THE "DO NOT ACCEPT" BUTTON AT THE BOTTOM OF THIS PAGE AND +THE INSTALLATION PROCESS WILL NOT CONTINUE. +

+

1.0 DEFINITIONS +

+

"Licensed +Software" means the Sun Doc Check Doclet, Version 1.2 Beta 2 in +source form, any portions of the software code provided in binary +form, and any user manuals, programming guides and other +documentation provided to Licensee by Sun under the agreement.

+

1.2 "Derivative +Product" means: (a) any work or invention, new material, +information or data which is based in whole or in part upon the +Licensed Software, including any derivative work, improvement, +extension, revision, modification, translation, abridgement, +condensation, expansion, collection, compilation, or any other form +in which the Licensed Software may be recast, transformed or adapted; +or (b) any modification, addition, procedure, routine or work-around +intended to correct any failure of the Licensed Software to perform +its intended functions or any failure to perform in accordance with +any accompanying documentation or specifications.

+

2.0 LIMITED +LICENSE +

+

Sun grants to +Licensee, a non-exclusive, non-transferable, royalty-free and limited +license to use and modify the Licensed Software internally for the +purpose of generating documentation for commercial and non-commercial +use; provided, that Licensee will hold Sun harmless from any +liability arising from distribution and use of such documentation. No +license is granted to Licensee for any other purpose. Licensee may +not sell, rent, loan or otherwise encumber or transfer Licensed +Software in whole or in part, to any third party.

+

3.0 LICENSE +RESTRICTIONS +

+

3.1 Licensee may +not duplicate Licensed Software other than for a single copy of +Licensed Software for archival purposes only. Licensee agrees to +reproduce any copyright and other proprietary right notices on any +such copy.

+

3.2 Except as +otherwise provided by law and Section 2.0, Licensee may not modify or +create derivative works of the Licensed Software, or reverse +engineer, disassemble or decompile binary portions of the Licensed +Software, or otherwise attempt to derive the source code from such +portions.

+

3.3 No right, +title, or interest in or to Licensed Software, any trademarks, +service marks, or trade names of Sun or Sun's licensors is granted +under this Agreement.

+

3.4 Except as +provided for in Section 2.0, Licensee shall have no right to use the +Licensed Software for productive or commercial use.

+

3.5 +Sun will retain ownership of Licensed Software, and all copies +thereof. Sun will own all Derivative Product. Licensee irrevocably +transfers and assigns to Sun any interest it may have in Derivative +Products, including without limitation all world­wide +intellectual property rights and moral rights.  Licensee forever +waives and agrees never to assert any moral rights (including without +limitation rights of paternity and attribution) or other intellectual +property rights it may have in Derivative Products, even after +termination of this Agreement. Licensee will assist Sun in taking any +actions required for Sun to obtain or perfect intellectual property +rights in Derivative Products worldwide, as Sun deems reasonably +appropriate. Licensee will enter into agreements with its employees, +employees of subsidiaries and contractors who may create Derivative +Products to ensure the free assignment of the rights granted to Sun +under this Agreement.

+

4.0 NO SUPPORT +

+

Sun is under no +obligation to support Licensed Software or to provide Licensee with +updates or error corrections (collectively "Software Updates"). +If Sun, at its sole option, supplies Software Updates to Licensee, +the Software Updates will be considered part of Licensed Software, +and subject to the terms of this Agreement.

+

5.0 LICENSEE +DUTIES +

+

Licensee agrees +to evaluate and test the Licensed Software for use with Licensee's +products and to provide feedback to Sun's email address: +doccheck-feedback@sun.com. Sun shall treat any oral or written +feedback or results of Licensee's testing of the Licensed Software +which Licensee provides to Sun as Sun's Confidential Information +(defined in Section 7 below).

+

6.0 TERM AND +TERMINATION OF AGREEMENT +

+

6.1 This +Agreement will commence on the date on which Licensee receives +Licensed Software (the "Effective Date") and will expire +two (2) years from the Effective Date, unless terminated earlier as +provided below.

+

6.2 Either party +may terminate this Agreement upon ten (10) days written notice to the +other party. However, Sun may terminate this Agreement immediately +should any Licensed Software become, or in Sun's opinion be likely to +become, the subject of a claim of infringement of a patent, trade +secret or copyright.

+

6.3 Sun may +terminate this Agreement immediately should Licensee materially +breach any of its provisions or take any action in derogation of +Sun's rights to the Confidential Information licensed to Licensee.

+

6.4 Upon +termination or expiration of this Agreement, Licensee will +immediately cease use of and destroy Licensed Software and Derivative +Product and any copies thereof and provide Sun a written statement +certifying that Licensee has complied with the foregoing obligations.

+

6.5 Rights and +obligations under this Agreement which by their nature should +survive, will remain in effect after termination or expiration +hereof.

+

7.0 CONFIDENTIAL +INFORMATION +

+

7.1 For purposes +of this Agreement, "Confidential Information" means: (i) +business and technical information and any source code or binary code +which Sun discloses to Licensee related to Licensed Software; (ii) +any Derivative Product, and (iii) the terms, conditions, and +existence of this Agreement. Licensee may not disclose Confidential +Information or use it except for the purposes specified in this +Agreement. Licensee will protect the confidentiality of Confidential +Information to the same degree of care, but no less than reasonable +care, as Licensee uses to protect its own Confidential Information. +Licensee's obligations regarding Confidential Information will expire +no less than five (5) years from the date of receipt of the +Confidential Information, except for Sun source code which will be +protected in perpetuity. Licensee agrees that Licensed Software +contains trade secrets of Sun.

+

7.2 +Notwithstanding any provisions contained in this Agreement concerning +nondisclosure and non-use of the Confidential Information, the +nondisclosure obligations of Section 7.1 will not apply to any +portion of Confidential Information that a Licensee can demonstrate +in writing is: (i) now, or hereafter through no act or failure to act +on the part of Licensee becomes, generally known to the general +public; (ii) known to Licensee at the time of receiving the +Confidential Information without an obligation of confidentiality; +(iii) hereafter rightfully furnished to Licensee by a third party +without restriction on disclosure; or (iv) independently developed by +Licensee without any use of the Confidential Information.

+

7.3 Licensee +must restrict access to Confidential Information to its employees or +contractors with a need for this access to perform their employment +or contractual obligations and who have agreed in writing to be bound +by a confidentiality obligation which incorporates the protections +and restrictions substantially as set forth in this Agreement.

+

8.0 DISCLAIMER +OF WARRANTY +

+

8.1 Licensee +acknowledges that Licensed Software may contain errors and is not +designed or intended for use in the design, construction, operation +or maintenance of any nuclear facility ("High Risk Activities"). +Sun disclaims an express or implied warranty of fitness for such +uses. Licensee represents and warrants to Sun that it will not use, +distribute or license the Licensed Software for High Risk Activities.

+

8.2 LICENSED +SOFTWARE IS PROVIDED "AS IS". ALL EXPRESS OR IMPLIED +CONDITIONS, REPRESENTATIONS, AND WARRANTIES, INCLUDING ANY IMPLIED +WARRANTY OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO +THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.

+

9.0 +LIMITATION OF LIABILITY +

+

9.1 Licensee +acknowledges that the Licensed Software is experimental. Licensee +acknowledges that the Licensed Software may have defects or +deficiencies which cannot or will not be corrected by Sun. Licensee +will hold Sun harmless from any claims based on Licensee's use of the +Licensed Software for any purposes other than those in Section 2.0, +and from any claims that later versions or releases of any Licensed +Software furnished to Licensee are incompatible with the Licensed +Software provided to Licensee under this Agreement.

+

9.2 Licensee +shall have the sole responsibility to protect adequately and backup +Licensee's data and/or equipment used in connection with the Licensed +Software. Licensee shall not claim against Sun for lost data, re-run +time, inaccurate output, work delays or lost profits resulting from +Licensee' use of the Licensed Software.

+

9.3 Licensee +acknowledges that Sun is under no obligation to release the Licensed +Software as a product of Sun.

+

9.4 To +the extent not prohibited by law, in no event will Sun be liable for +any indirect, punitive, special, incidental or consequential damage +in connection with or arising out of this Agreement (including loss +of business, revenue, profits, use, data or other economic +advantage), however it arises, whether for breach or in tort, even if +the other party has been previously advised of the possibility of +such damage.

+

10.0 U.S. +GOVERNMENT RIGHTS +

+

If Licensed +Software is being acquired by or on behalf of the U.S. Government or +by a U.S. Government prime contractor or subcontractor (at any tier), +then the Government's rights in Software will be only as set forth in +this Agreement; this is in accordance with 48 CFR 227.7201 through +227.7202-4 (for Department of Defense (DOD) acquisitions) and with 48 +CFR 2.101 and 12.212 (for non-DOD acquisitions).

+

11.0 GENERAL +TERMS +

+

11.1 Any action +related to this Agreement will be governed by California law and +controlling U.S. federal law. The U.N. Convention for the +International Sale of Goods and the choice of law rules of any +jurisdiction will not apply.

+

11.2 Licensed +Software and technical data delivered under this Agreement are +subject to U.S. export control laws and may be subject to export or +import regulations in other countries. Licensee agrees to comply +strictly with all such laws and regulations and acknowledges that it +has the responsibility to obtain such licenses to export, re-export +or import as may be required after delivery to Licensee.

+

11.3 It is +understood and agreed that, notwithstanding any other provision of +this Agreement, Licensee's breach of the provisions of Section 7 of +this Agreement will cause Sun irreparable damage for which recovery +of money damages would be inadequate, and that Sun will therefore be +entitled to seek timely injunctive relief to protect Sun's rights +under this Agreement in addition to any and all remedies available at +law.

+

11.4 Neither +party may assign or otherwise transfer any of its rights or +obligations under this Agreement, without the prior written consent +of the other party, except that Sun may assign this Agreement to an +affiliated company.

+

11.5 This +Agreement is the parties' entire agreement relating to its subject +matter. It supersedes all prior or contemporaneous oral or written +communications, proposals, conditions, representations and warranties +and prevails over any conflicting or additional terms of any quote, +order, acknowledgment, or other communication between the parties +relating to its subject matter during the term of this Agreement. No +modification to this Agreement will be binding, unless in writing and +signed by an authorized representative of each party.

+

(LFI#133032/Form +ID#011801) +

+ + diff --git a/google-taglib/licenses/LICENSE-google.txt b/google-taglib/licenses/LICENSE-google.txt new file mode 100644 index 0000000..50f948b --- /dev/null +++ b/google-taglib/licenses/LICENSE-google.txt @@ -0,0 +1,150 @@ +Thank you for using the Google Web APIs (TM) service! By using this +service ("Google Web APIs") you agree to be bound by the following +terms and conditions (the "Terms and Conditions"). + +PERSONAL AND LEGITIMATE USES ONLY + +The Google Web APIs service is made available to you for your +personal, non-commercial use only (at home or at work). You may only +create a single account and must provide accurate identification, +contact, and other information required as part of the registration +process. You may not create any script or other automated tool that +attempts to create multiple Google Web APIs accounts. And you may not +use the search results provided by the Google Web APIs service with an +existing product or service that competes with products or services +offered by Google. + +If you are interested in doing anything different than the foregoing, +you must first obtain Google's written consent. If you fail to do so, +Google reserves the right to take legal action against you. + +Furthermore, you may not use Google Web APIs in any manner that either +directly or indirectly violates any laws or proprietary rights. This +includes laws and proprietary rights in the United States as well as +in other countries. + +If you have questions on your contemplated use or if you have comments +on Google Web APIs or ideas on how to improve it, please email +api-support@google.com. Please note that by doing so, you also grant +Google permission to use and incorporate your ideas or comments into +Google Web APIs without further compensation. + +INTELLECTUAL PROPERTY + +You agree not to remove, obscure, or alter Google's copyright notice, +trademarks, or other proprietary rights notices affixed to or +contained within Google Web APIs. You also acknowledge that Google +owns all right, title and interest in and to Google Web APIs, +including without limitation all intellectual property rights (the +"Google Rights"). The Google Rights include rights to the following: +(1) the APIs developed and provided by Google, (2) all software +associated with the Google Web APIs server, and (3) the search results +and spell checking you obtain when you use Google Web APIs. The Google +Rights do not include the following: (1) third party components used +as part of Google Web APIs; or (2) software developed by you in +conjunction with using Google Web APIs. + +PUBLICITY + +So long as you comply with your obligations under this Agreement, you +may indicate that a product or service that you created either used or +is based on Google Web APIs provided that those products or services +do not in Google's reasonable opinion (1) tarnish, infringe, or dilute +Google's trademarks, (2) violate any applicable law, and (3) infringe +any third party rights. If you wish to use the GOOGLE trademark and/or +logo in any other manner, you must first obtain Google's written +consent. + +DISCLAIMER OF WARRANTIES + +The Google Web APIs service is presently in Beta form and has not been +fully tested or debugged. Accordingly, Google disclaims any +responsibility for any harm resulting from your use of Google Web APIs. + +The Google Web APIs service is provided "as is," with no warranties +whatsoever. Google expressly disclaims to the fullest extent permitted +by law all express, implied, and statutory warranties, including, +without limitation, the warranties of merchantability, fitness for a +particular purpose, and non-infringement of proprietary rights. Google +disclaims any warranties regarding the security, reliability, +timeliness, availability, and performance of Google Web APIs. + +You understand and agree that you use Google Web APIs at your own +discretion and risk and that you will be solely responsible for any +damages to your computer system or loss of data that results from the +download or use of Google Web APIs. + +Some states or other jurisdictions do not allow the exclusion of +implied warranties, so the above exclusions may not apply to you. You +may also have other rights that vary from state to state and +jurisdiction to jurisdiction. + +LIMITATION OF LIABILITY + +The Google Web APIs service is being provided free of charge. +Accordingly, you agree that Google shall have no liability arising +from or based on your use of Google Web APIs. + +Under no circumstances shall Google be liable to any user on account +of that user's use or misuse of Google Web APIs. Such limitation of +liability shall apply to prevent recovery of direct, indirect, +incidental, consequential, special, exemplary, and punitive damages +whether such claim is based on warranty, contract, tort (including +negligence), or otherwise, even if Google has been advised of the +possibility of such damages). Such limitation of liability shall apply +whether the damages arise from use or misuse of and reliance on the +Google Web APIs, from inability to use Google Web APIs, or from the +interruption, suspension, or termination of Google Web APIs (including +such damages incurred by third parties). Such limitation shall apply +notwithstanding a failure of essential purpose of any limited remedy +and to the fullest extent permitted by law. + +Some states or other jurisdictions do not allow the exclusion or +limitation of liability for incidental or consequential damages, so +the above limitations and exclusions may not apply to you. + +INDEMNIFICATION + +You hereby agree to indemnify, defend and hold Google, and its +officers, directors, agents, licensors and licensees (collectively, +the "Indemnified Parties") harmless from and against any and all +liability and costs incurred by the Indemnified Parties in connection +with any claim arising out of your use of Google Web APIs, including, +without limitation, reasonable attorneys' fees. You shall cooperate as +fully as reasonably required in the defense of any claim. Google +reserves the right, at its own expense, to assume the exclusive +defense and control of any matter subject to indemnification by you. + +GOOGLE'S SEARCH SERVICE + +The Google Web APIs service is designed to be used in conjunction with +Google's search services. Accordingly, your use of Google Web APIs is +also defined by Google's Terms of Service and Privacy Policy. In the +event of a conflict between these Terms and Conditions and Google's +Terms of Service, these Terms and Conditions shall prevail. + +TERM AND TERMINATION + +If you wish to terminate this Agreement, you may simply cease using +the Google Web APIs service. In such a case, you must delete any +search result information that you may have obtained from the Google +Web APIs service. Google may terminate this Agreement (and your +account) at any time, with or without cause. + +GENERAL PROVISIONS + +These Terms and Conditions will be governed by and construed in +accordance with the laws of the State of California, without giving +effect to the conflict of laws provisions of California or your actual +state or country of residence. Any dispute arising from these Terms +and Conditions shall be adjudicated in the federal or state courts +located in Santa Clara County, California. If for any reason a court +of competent jurisdiction finds any provision or portion of these +Terms and Conditions to be unenforceable, the remainder of these Terms +and Conditions will continue in full force and effect. These Terms and +Conditions constitute the entire agreement between the parties with +respect to the subject matter hereof and supersede and replace all +prior or contemporaneous understandings or agreements, written or +oral, regarding such subject matter. Any waiver of any provision of +these Terms and Conditions will be effective only if in writing and +signed by Google. diff --git a/google-taglib/licenses/LICENSE-javamail.txt b/google-taglib/licenses/LICENSE-javamail.txt new file mode 100644 index 0000000..6984ddb --- /dev/null +++ b/google-taglib/licenses/LICENSE-javamail.txt @@ -0,0 +1,170 @@ + Sun Microsystems, Inc. + Binary Code License Agreement + +READ THE TERMS OF THIS AGREEMENT AND ANY PROVIDED SUPPLEMENTAL LICENSE TERMS +(COLLECTIVELY "AGREEMENT") CAREFULLY BEFORE OPENING THE SOFTWARE MEDIA +PACKAGE. BY OPENING THE SOFTWARE MEDIA PACKAGE, YOU AGREE TO THE TERMS OF +THIS AGREEMENT. IF YOU ARE ACCESSING THE SOFTWARE ELECTRONICALLY, INDICATE +YOUR ACCEPTANCE OF THESE TERMS BY SELECTING THE "ACCEPT" BUTTON AT THE END +OF THIS AGREEMENT. IF YOU DO NOT AGREE TO ALL THESE TERMS, PROMPTLY RETURN +THE UNUSED SOFTWARE TO YOUR PLACE OF PURCHASE FOR A REFUND OR, IF THE +SOFTWARE IS ACCESSED ELECTRONICALLY, SELECT THE "DECLINE" BUTTON AT THE END +OF THIS AGREEMENT. + +1. LICENSE TO USE. Sun grants you a non-exclusive and non-transferable +license for the internal use only of the accompanying software and +documentation and any error corrections provided by Sun (collectively +"Software"), by the number of users and the class of computer hardware for +which the corresponding fee has been paid. + +2. RESTRICTIONS. Software is confidential and copyrighted. Title to +Software and all associated intellectual property rights is retained by Sun +and/or its licensors. Except as specifically authorized in any Supplemental +License Terms, you may not make copies of Software, other than a single copy +of Software for archival purposes. Unless enforcement is prohibited by +applicable law, you may not modify, decompile, or reverse engineer +Software. You acknowledge that Software is not designed, licensed or +intended for use in the design, construction, operation or maintenance of +any nuclear facility. Sun disclaims any express or implied warranty of +fitness for such uses. No right, title or interest in or to any trademark, +service mark, logo or trade name of Sun or its licensors is granted under +this Agreement. + +3. LIMITED WARRANTY. Sun warrants to you that for a period of ninety (90) +days from the date of purchase, as evidenced by a copy of the receipt, the +media on which Software is furnished (if any) will be free of defects in +materials and workmanship under normal use. Except for the foregoing, +Software is provided "AS IS". Your exclusive remedy and Sun's entire +liability under this limited warranty will be at Sun's option to replace +Software media or refund the fee paid for Software. + +4. DISCLAIMER OF WARRANTY. UNLESS SPECIFIED IN THIS AGREEMENT, ALL EXPRESS +OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED +WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR +NON-INFRINGEMENT ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT THESE DISCLAIMERS +ARE HELD TO BE LEGALLY INVALID. + +5. LIMITATION OF LIABILITY. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO +EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR +DATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE +DAMAGES, HOWEVER CAUSED REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT +OF OR RELATED TO THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. In no event will Sun's +liability to you, whether in contract, tort (including negligence), or +otherwise, exceed the amount paid by you for Software under this Agreement. +The foregoing limitations will apply even if the above stated warranty fails +of its essential purpose. + +6. Termination. This Agreement is effective until terminated. You may +terminate this Agreement at any time by destroying all copies of Software. +This Agreement will terminate immediately without notice from Sun if you +fail to comply with any provision of this Agreement. Upon Termination, you +must destroy all copies of Software. + +7. Export Regulations. All Software and technical data delivered under this +Agreement are subject to US export control laws and may be subject to export +or import regulations in other countries. You agree to comply strictly with +all such laws and regulations and acknowledge that you have the +responsibility to obtain such licenses to export, re-export, or import as +may be required after delivery to you. + +8. U.S. Government Restricted Rights. If Software is being acquired by or +on behalf of the U.S. Government or by a U.S. Government prime contractor or +subcontractor (at any tier), then the Government's rights in Software and +accompanying documentation will be only as set forth in this Agreement; this +is in accordance with 48 CFR 227.7201 through 227.7202-4 (for Department of +Defense (DOD) acquisitions) and with 48 CFR 2.101 and 12.212 (for non-DOD +acquisitions). + +9. Governing Law. Any action related to this Agreement will be governed by +California law and controlling U.S. federal law. No choice of law rules of +any jurisdiction will apply. + +10. Severability. If any provision of this Agreement is held to be +unenforceable, this Agreement will remain in effect with the provision +omitted, unless omission would frustrate the intent of the parties, in which +case this Agreement will immediately terminate. + +11. Integration. This Agreement is the entire agreement between you and +Sun relating to its subject matter. It supersedes all prior or +contemporaneous oral or written communications, proposals, representations +and warranties and prevails over any conflicting or additional terms of any +quote, order, acknowledgment, or other communication between the parties +relating to its subject matter during the term of this Agreement. No +modification of this Agreement will be binding, unless in writing and signed +by an authorized representative of each party. + + + + JAVAMAIL, VERSION 1.2 + SUPPLEMENTAL LICENSE TERMS + +These supplemental license terms ("Supplemental Terms") add to or modify the +terms of the Binary Code License Agreement (collectively, the "Agreement"). +Capitalized terms not defined in these Supplemental Terms shall have the +same meanings ascribed to them in the Agreement. These Supplemental Terms +shall supersede any inconsistent or conflicting terms in the Agreement, or +in any license contained within the Software. + +1. Software Internal Use and Development License Grant. Subject to the +terms and conditions of this Agreement, including, but not limited to +Section 3 (Java(TM) Technology Restrictions) of these Supplemental Terms, +Sun grants you a non-exclusive, non-transferable, limited license to +reproduce internally and use internally the binary form of the Software, +complete and unmodified, for the sole purpose of designing, developing and +testing your Java applets and applications ("Programs"). + +2. License to Distribute Software. Subject to the terms and conditions of +this Agreement, including, but not limited to Section 3 (Java (TM) +Technology Restrictions) of these Supplemental Terms, Sun grants you a +non-exclusive, non-transferable, limited license to reproduce and distribute +the Software in binary code form only, provided that (i) you distribute the +Software complete and unmodified and only bundled as part of, and for the +sole purpose of running, your Java applets or applications ("Programs"), +(ii) the Programs add significant and primary functionality to the Software, +(iii) you do not distribute additional software intended to replace any +component(s) of the Software, (iv) you do not remove or alter any +proprietary legends or notices contained in the Software, (v) you only +distribute the Software subject to a license agreement that protects Sun's +interests consistent with the terms contained in this Agreement, and (vi) +you agree to defend and indemnify Sun and its licensors from and against any +damages, costs, liabilities, settlement amounts and/or expenses (including +attorneys' fees) incurred in connection with any claim, lawsuit or action by +any third party that arises or results from the use or distribution of any +and all Programs and/or Software. + +3. Java Technology Restrictions. You may not modify the Java Platform +Interface ("JPI", identified as classes contained within the "java" package +or any subpackages of the "java" package), by creating additional classes +within the JPI or otherwise causing the addition to or modification of the +classes in the JPI. In the event that you create an additional class and +associated API(s) which (i) extends the functionality of the Java platform, +and (ii) is exposed to third party software developers for the purpose of +developing additional software which invokes such additional API, you must +promptly publish broadly an accurate specification for such API for free use +by all developers. You may not create, or authorize your licensees to +create additional classes, interfaces, or subpackages that are in any way +identified as "java", "javax", "sun" or similar convention as specified by +Sun in any naming convention designation. + +4. Trademarks and Logos. You acknowledge and agree as between you and Sun +that Sun owns the SUN, SOLARIS, JAVA, JINI, FORTE, STAROFFICE, STARPORTAL +and iPLANET trademarks and all SUN, SOLARIS, JAVA, JINI, FORTE, STAROFFICE, +STARPORTAL and iPLANET-related trademarks, service marks, logos and other +brand designations ("Sun Marks"), and you agree to comply with the Sun +Trademark and Logo Usage Requirements currently located at +http://www.sun.com/policies/trademarks. Any use you make of the Sun Marks +inures to Sun's benefit. + +5. Source Code. Software may contain source code that is provided solely for +reference purposes pursuant to the terms of this Agreement. Source code may +not be redistributed unless expressly provided for in this Agreement. + +6. Termination for Infringement. Either party may terminate this Agreement +immediately should any Software become, or in either party's opinion be +likely to become, the subject of a claim of infringement of any intellectual +property right. + +For inquiries please contact: Sun Microsystems, Inc. 901 San Antonio Road, +Palo Alto, California 94303 + diff --git a/google-taglib/licenses/LICENSE.txt b/google-taglib/licenses/LICENSE.txt new file mode 100644 index 0000000..c300b97 --- /dev/null +++ b/google-taglib/licenses/LICENSE.txt @@ -0,0 +1,29 @@ +Google Tag Library License + +Copyright (c) 2002-2003, Erik C. Thauvin (erik@thauvin.net) +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +Neither the name of the author nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/google-taglib/src/net/thauvin/google/GoogleSearchBean.java b/google-taglib/src/net/thauvin/google/GoogleSearchBean.java new file mode 100644 index 0000000..a08785d --- /dev/null +++ b/google-taglib/src/net/thauvin/google/GoogleSearchBean.java @@ -0,0 +1,648 @@ +/* + * @(#)GoogleSearchBean.java + * + * Copyright (c) 2002-2003, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the author nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.google; + +import com.google.soap.search.GoogleSearch; +import com.google.soap.search.GoogleSearchFault; +import com.google.soap.search.GoogleSearchResult; +import com.google.soap.search.GoogleSearchResultElement; + +import java.net.URL; +import java.net.URLEncoder; + + +/** + * Implements methods used to perform searches on Google. + * + * @author Erik C. Thauvin + * @created April 25, 2002 + * @version $Revision$ + * @since 1.0 + */ +public class GoogleSearchBean +{ + /** + * The default related-queries filter. + */ + public static final boolean DEFAULT_FILTER = true; + + /** + * The default language restricts. + */ + public static final String DEFAULT_LR = ""; + + /** + * The default maximum number of results to be returned. + */ + public static final int DEFAULT_MAX_RESULTS = 10; + + /** + * The default document store restrict. + */ + public static final String DEFAULT_RESTRICT = ""; + + /** + * The default SafeSearch. + */ + public static final boolean DEFAULT_SAFE_SEARCH = false; + + /** + * The default site. + */ + public static final String DEFAULT_SITE = ""; + + /** + * The default index of the result to be returned. + */ + public static final int DEFAULT_START = 0; + + /** + * The next keyword. + */ + public static final String NEXT_KEYWORD = "next"; + + /** + * The previous keyword. + */ + public static final String PREVIOUS_KEYWORD = "previous"; + + // Invalid key error message. + private static final String INVALID_KEY_ERROR = + "The authorization key has not been specified."; + private GoogleSearch service = null; + private GoogleSearchResult result = null; + private GoogleSearchResultElement elements[] = null; + private boolean keySet = false; + private int maxResults = 10; + + /** + * Constructs a new instance of the bean. + */ + public GoogleSearchBean() + { + service = new GoogleSearch(); + } + + /** + * Constructs a new instance of the bean with the specified authorization + * key. + * + * @param key The authorization key. + */ + public GoogleSearchBean(String key) + { + this(); + setKey(key); + } + + /** + * Sets the authorization key. + * + * @param key The key string. + */ + public final void setKey(String key) + { + service.setKey(key); + + if ((key != null) && (key.trim().length() > 0)) + { + keySet = true; + } + else + { + keySet = false; + } + } + + /** + * Returns true if the authorization key is set. + * + * @return true or false. + */ + public final boolean isKeySet() + { + return keySet; + } + + /** + * Sets the HTTP proxy host, port, user name and password. + * + * @param proxyHost The host to use for the HTTP proxy. + * @param proxyPort The port to use for the HTTP proxy. + * @param proxyUserName The user name to use for the HTTP proxy. + * @param proxyPassword The password to use for the HTTP proxy. + */ + public void setProxyServer(String proxyHost, int proxyPort, + String proxyUserName, String proxyPassword) + { + service.setProxyHost(proxyHost); + service.setProxyPort(proxyPort); + service.setProxyUserName(proxyUserName); + service.setProxyPassword(proxyPassword); + } + + /** + * Returns the results of the search. + * + * @return The GoogleSearchResult object. + */ + public final GoogleSearchResult getResult() + { + return result; + } + + /** + * Returns an array of result elements that corresponds to the actual list + * of search results. + * + * @return The array of result elements. + */ + public final GoogleSearchResultElement[] getResultElements() + { + return elements; + } + + /** + * Returns the count of result elements. + * + * @return The result elements count. + * @see #getResultElements() + */ + public final int getResultElementsCount() + { + if (elements != null) + { + return elements.length; + } + + return 0; + } + + /** + * Returns true whenever the result set is valid, indicating that a search + * was performed. + * + * @return true or false. + */ + public final boolean isValidResult() + { + if (result != null) + { + return true; + } + + return false; + } + + /** + * Returns a cached web page from Google. + * + * @param url The page's URL. + * @return The HTML code of the cached page. + * @exception GoogleSearchFault + */ + public String getCachedPage(String url) + throws GoogleSearchFault + { + if (isKeySet()) + { + reset(); + + return new String(service.doGetCachedPage(url)); + } + + throw new GoogleSearchFault(INVALID_KEY_ERROR); + } + + /** + * Invokes a Google search. + * + * @param q The Google query. + * @param start The index of the result to be returned. + * @param maxResults The maximum number of results to be returned. + * @param filter The related-queries filter. + * @param restrict The document store restrict value (e.g.: "linux"). + * @param safeSearch Enable or disable SafeSearch. + * @param lr The language restricts for the search. + * @return The results of the search. + * @exception GoogleSearchFault + */ + public GoogleSearchResult getGoogleSearch(String q, int start, + int maxResults, boolean filter, + String restrict, + boolean safeSearch, String lr) + throws GoogleSearchFault + { + if (isKeySet()) + { + reset(); + + service.setQueryString(q); + service.setStartResult(start); + + this.maxResults = maxResults; + service.setMaxResults(maxResults); + + service.setFilter(filter); + service.setRestrict(restrict); + service.setSafeSearch(safeSearch); + service.setLanguageRestricts(lr); + + result = service.doSearch(); + + if (result != null) + { + elements = result.getResultElements(); + } + + return result; + } + + throw new GoogleSearchFault(INVALID_KEY_ERROR); + } + + /** + * Returns the GoogleSearch attribute of the GoogleSearchBean object. + * + * @param key The authorization key. + * @param q The Google query. + * @param start The index of the result to be returned. + * @param maxResults The maximum number of results to be returned. + * @param filter The related-queries filter. + * @param restrict The document store restrict value (e.g.: "linux"). + * @param safeSearch Enable or disable SafeSearch. + * @param lr The language restricts for the search. + * @return The results of the search. + * @exception GoogleSearchFault + * @see #getGoogleSearch(String, int, int, boolean, String, boolean, String) + */ + public GoogleSearchResult getGoogleSearch(String key, String q, int start, + int maxResults, boolean filter, + String restrict, + boolean safeSearch, String lr) + throws GoogleSearchFault + { + setKey(key); + + return getGoogleSearch(q, start, maxResults, filter, restrict, + safeSearch, lr); + } + + /** + * Returns the GoogleSearch attribute of the GoogleSearchBean object. + * + * @param q The Google query. + * @return The results of the search. + * @exception GoogleSearchFault + * @see #getGoogleSearch(String, int, int, boolean, String, boolean, String) + */ + public GoogleSearchResult getGoogleSearch(String q) + throws GoogleSearchFault + { + return getGoogleSearch(q, DEFAULT_START, DEFAULT_MAX_RESULTS, + DEFAULT_FILTER, DEFAULT_RESTRICT, + DEFAULT_SAFE_SEARCH, DEFAULT_LR); + } + + /** + * Returns the specified property of the given element index in the current + * result set. + *

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 {@link #getGoogleSearch(String) search} + * query string.
"cachedQuery"Returns the cached query + * string, suitable for use as a {@link #getCachedPage(String) cached} query + * string.
+ * + * @param index The element index. + * @param property The property name. + * @return The property value. + */ + public String getResultElementProperty(int index, String property) + { + if (elements != null) + { + if ((index >= 0) && (index < elements.length)) + { + if (property.equalsIgnoreCase("url")) + { + return elements[index].getURL(); + } + else if (property.equalsIgnoreCase("summary")) + { + return elements[index].getSummary(); + } + else if (property.equalsIgnoreCase("snippet")) + { + return elements[index].getSnippet(); + } + else if (property.equalsIgnoreCase("title")) + { + return elements[index].getTitle(); + } + else if (property.equalsIgnoreCase("cachedSize")) + { + return elements[index].getCachedSize(); + } + else if (property.equalsIgnoreCase("hostName")) + { + return elements[index].getHostName(); + } + else if (property.equalsIgnoreCase("relatedInformationPresent")) + { + return String.valueOf(elements[index] + .getRelatedInformationPresent()); + } + else if (property.equalsIgnoreCase("directoryTitle")) + { + return elements[index].getDirectoryTitle(); + } + else if (property.equalsIgnoreCase("directoryCategoryName")) + { + return elements[index].getDirectoryCategory() + .getFullViewableName(); + } + else if (property.equalsIgnoreCase("directoryCategoryEncoding")) + { + return elements[index].getDirectoryCategory() + .getSpecialEncoding(); + } + else if (property.toLowerCase().endsWith("query")) + { + try + { + URL url = new URL(elements[index].getURL()); + String urlString = url.toString(); + String staticQuery = + urlString.substring(urlString.indexOf(url.getHost())); + + if (property.equalsIgnoreCase("relatedQuery")) + { + return ("related:" + URLEncoder.encode(staticQuery)); + } + else if (property.equalsIgnoreCase("cachedQuery")) + { + return (URLEncoder.encode(staticQuery)); + } + else if (property.equalsIgnoreCase("staticQuery")) + { + return staticQuery; + } + } + catch (Exception e) + { + ; // Do nothing + } + } + } + } + + return ""; + } + + /** + * Returns the given property of the result set. + *

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.
{@link #NEXT_KEYWORD next}Returns the start + * index of the next set of results.
{@link #PREVIOUS_KEYWORD previous}Returns + * the start index of the previous set of results.
+ * + * @param property The property name. + * @return The property value. + */ + public String getResultProperty(String property) + { + if (result != null) + { + if (property.equalsIgnoreCase("estimatedTotalResultsCount")) + { + return String.valueOf(result.getEstimatedTotalResultsCount()); + } + else if (property.equalsIgnoreCase("startIndex")) + { + return String.valueOf(result.getStartIndex()); + } + else if (property.equalsIgnoreCase("endIndex")) + { + return String.valueOf(result.getEndIndex()); + } + else if (property.equalsIgnoreCase("searchTime")) + { + return String.valueOf(result.getSearchTime()); + } + else if (property.equalsIgnoreCase("searchTips")) + { + return result.getSearchTips(); + } + else if (property.equalsIgnoreCase("searchComments")) + { + return result.getSearchComments(); + } + else if (property.equalsIgnoreCase("documentFiltering")) + { + return String.valueOf(result.getDocumentFiltering()); + } + else if (property.equalsIgnoreCase("searchQuery")) + { + return result.getSearchQuery(); + } + else if (property.equalsIgnoreCase(NEXT_KEYWORD)) + { + if (result.getEndIndex() < result.getEstimatedTotalResultsCount()) + { + if (maxResults == (result.getEndIndex() + - result.getStartIndex() + 1)) + { + return String.valueOf(result.getEndIndex()); + } + } + } + else if (property.equalsIgnoreCase(PREVIOUS_KEYWORD)) + { + if (result.getStartIndex() > 1) + { + return String.valueOf(result.getStartIndex() - maxResults + - 1); + } + } + } + + return ""; + } + + /** + * Asks Google to return a spelling suggestion for a word or phrase. + * + * @param phrase The word or phrase to correct the spelling for. + * @return The suggested correct spelling, or null if none. + * @exception GoogleSearchFault + */ + public String getSpellingSuggestion(String phrase) + throws GoogleSearchFault + { + if (isKeySet()) + { + reset(); + + return service.doSpellingSuggestion(phrase); + } + + throw new GoogleSearchFault(INVALID_KEY_ERROR); + } + + /** + * Demonstration program to perform various Google searches. + *

The arguments are:

+ * <client-key> (search <query> | cached <URL> | + * spell <phrase>) + * + * @param args The command line arguments. + */ + public static final void main(String args[]) + { + GoogleSearchBean bean = new GoogleSearchBean(); + + if (args.length == 3) + { + String action = args[1]; + + try + { + bean.setKey(args[0]); + + if (action.equalsIgnoreCase("search")) + { + bean.getGoogleSearch(args[2]); + + for (int i = 0; i < bean.getResultElementsCount(); i++) + { + System.out.println(bean.getResultElementProperty(i, + "title") + + " (" + + bean.getResultElementProperty(i, + "url") + + ')'); + } + } + else if (action.equalsIgnoreCase("spell")) + { + System.out.println(bean.getSpellingSuggestion(args[2])); + } + else if (action.equalsIgnoreCase("cached")) + { + System.out.println(bean.getCachedPage(args[2])); + } + else + { + usage(); + } + } + catch (GoogleSearchFault googleSearchFault) + { + googleSearchFault.printStackTrace(); + } + } + else + { + usage(); + } + } + + /** + * Reset the bean properties. + */ + public void reset() + { + // Reset the result and elements + result = null; + elements = null; + } + + /** + * Prints the usage and exits. + */ + private static void usage() + { + System.err.println("Usage: java " + GoogleSearchBean.class.getName() + + " (search | cached | spell )"); + System.exit(1); + } +} diff --git a/google-taglib/src/net/thauvin/google/TagUtility.java b/google-taglib/src/net/thauvin/google/TagUtility.java new file mode 100644 index 0000000..2203e35 --- /dev/null +++ b/google-taglib/src/net/thauvin/google/TagUtility.java @@ -0,0 +1,452 @@ +/* + * @(#)TagUtility.java + * + * Copyright (c) 2002-2003, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the author nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.google; + +import java.net.URLEncoder; + +import java.util.Enumeration; + +import javax.servlet.ServletRequest; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.jsp.JspTagException; +import javax.servlet.jsp.PageContext; +import javax.servlet.jsp.tagext.BodyContent; + + +/** + * Implements various methods commonly used by custom tags. + * + * @author Erik C. Thauvin + * @created April 25, 2002 + * @version $Revision$ + * @since 1.0 + */ +public class TagUtility +{ + /** + * The name of the cache request parameter. + */ + public static final String CACHE_PARAM = "cache"; + + /** + * The name of the filter request parameter. + */ + public static final String FILTER_PARAM = "filter"; + + /** + * The name of the Google Search bean attribute. + */ + public static final String GOOGLE_SEARCH_BEAN = "GoogleSearchBean"; + + /** + * The name of the input encoding context parameter. + */ + public static final String IE_PARAM = "ie"; + + /** + * The name of the key context parameter. + */ + public static final String KEY_CONTEXT_PARAM = "google_key"; + + /** + * The name of the key request parameter. + */ + public static final String KEY_PARAM = "key"; + + /** + * The name of the language restrict context parameter. + */ + public static final String LR_PARAM = "lr"; + + /** + * The name of the maxResults request parameter. + */ + public static final String MAX_RESULTS_PARAM = "maxResults"; + + /** + * The name of the output encoding context parameter. + */ + public static final String OE_PARAM = "oe"; + + /** + * The name of the query request parameter. + */ + public static final String QUERY_PARAM = "q"; + + /** + * The name of the restrict context parameter. + */ + public static final String RESTRICT_PARAM = "restrict"; + + /** + * The name of the safeSearch context parameter. + */ + public static final String SAFE_SEARCH_PARAM = "safeSearch"; + + /** + * The name of the site context parameter. + */ + public static final String SITE_PARAM = "site"; + + /** + * The name of the start request parameter. + */ + public static final String START_PARAM = "start"; + + /** + * Protected constructor to disable instantiation. + */ + protected TagUtility() + { + // Disabled + } + + /** + * Returns the body of a tag. + * + * @param bodyContent The body. + * @return The tag body string or null. + */ + public static final String getTagBody(BodyContent bodyContent) + { + return getTagBody(bodyContent, false); + } + + /** + * Returns the body of a tag. + * + * @param bodyContent The body. + * @param trim Trim the body if true + * @return The tag body string or null. + */ + public static final String getTagBody(BodyContent bodyContent, boolean trim) + { + try + { + if (trim) + { + return bodyContent.getString().trim(); + } + else + { + return bodyContent.getString(); + } + } + catch (NullPointerException e) + { + return null; + } + } + + /** + * Validates a string value by insuring it is not null or empty. + *

+ * Beginning and trailing spaces are removed whenever the trim + * flag is set to true. + * + * @param stringValue The String value. + * @param trim The trim flag. + * @return true if valid, false if not. + */ + public static final boolean isValidString(String stringValue, boolean trim) + { + if ((stringValue != null)) + { + if (trim) + { + return isValidString(stringValue.trim()); + } + else + { + return isValidString(stringValue); + } + } + + return false; + } + + /** + * Validates a string value by insuring it is not null or empty. + * + * @param stringValue The String value. + * @return true if valid, false if not. + */ + public static final boolean isValidString(String stringValue) + { + if ((stringValue != null) && (stringValue.length() > 0)) + { + return true; + } + + return false; + } + + /** + * Returns the GoogleSearchBean attribute using the default + * {@link #GOOGLE_SEARCH_BEAN bean name}. + * + * @param pageContext The page context. + * @return The default Google search bean. + */ + public static GoogleSearchBean getGoogleSearchBean(PageContext pageContext) + { + // Fetch the bean using the default name + return ((GoogleSearchBean)pageContext.findAttribute(GOOGLE_SEARCH_BEAN)); + } + + /** + * Returns the value a specified parameter. + * + * @param request The ServletRequest object + * @param paramName The parameter name String value. + * @return The parameter value or null. + */ + public static String getParameter(ServletRequest request, String paramName) + { + // The parameter value + String paramValue = null; + + if (isValidString(paramName)) + { + // Get all parameters names + final Enumeration names = request.getParameterNames(); + + // Loop thru the names + while (names.hasMoreElements()) + { + // Get the next parameter name + final String name = (String)names.nextElement(); + + // Is it our parameter? + if (name.equalsIgnoreCase(paramName)) + { + // Get the parameter value + paramValue = request.getParameter(name); + } + } + } + + // Return the parameter value + return paramValue; + } + + /** + * Builds a HTML reference link: + *

+ * For example: body. + * + * @param url The reference URL. + * @param body The link body text. + * @param target The link target. + * @param style The link CSS style. + * @param css The link CSS class + * @return A HTML reference link. + */ + public static final String buildRefLink(String url, String body, + String target, String style, + String css) + { + final StringBuffer refLink = new StringBuffer(); + + // Output the hyperlink reference + refLink.append("').append(body).append(""); + + return (refLink.toString()); + } + + /** + * Returns the default tag misplaced (not in container) error exception. + * + * @param tag The tag name. + * @param container The container name. + * @return The default misplaced error exception. + */ + public static final JspTagException misplacedError(String tag, + String container) + { + return new JspTagException("The '" + tag + + "' tag must be located within the '" + + container + "' container tag."); + } + + /** + * Returns the default tag misplaced (not in valid container) error + * exception. + * + * @param tag The tag name. + * @return The default misplaced error exception. + */ + public static final JspTagException misplacedError(String tag) + { + return new JspTagException("The '" + tag + + "' tag must be located within a valid container tag."); + } + + /** + * Builds name=value pair with URL encoding. + * + * @param name The name string. + * @param value The value string. + * @return The name=value pair. + */ + public static final String nameValuePair(String name, String value) + { + return (URLEncoder.encode(name) + "=" + URLEncoder.encode(value)); + } + + /** + * Returns a nested exception. + *

+ * The nested exception format is as follows: + *

+ * + * New Message
+ * <space>>space>nested exception is:<space>
+ * <tab> java.lang.Exception: Old Message + *
+ *
+ * + * @param msg The new exception message. + * @param old The old exception object. + * @return A nested exception. + */ + public static final JspTagException nestedException(String msg, + Exception old) + { + return new JspTagException(msg + "\n nested exception is: \n\t" + + old.toString()); + } + + /** + * Returns the default tag output error exception. + * + * @param tag The tag name. + * @param e The caught exception. + * @return The default tag output error exception. + */ + public static final JspTagException outputError(String tag, Exception e) + { + StringBuffer buff = + new StringBuffer("An error occurred while processing the '" + tag + + "' tag."); + + if (e != null) + { + buff.append("\n\nException:\n"); + } + + if (e != null) + { + buff.append("\n nested exception is: \n\t" + + e.getClass().getName() + ": " + + e.getLocalizedMessage()); + } + + return new JspTagException(buff.toString()); + } + + /** + * Converts the request's parameter names/values into ampersand-delimited + * and URL-encoded name/value pairs. + * + * @param request The servlet request object. + * @param remove The parameter to be removed. + * @return The name/value pairs. + */ + public static final String requestParamsToUrl(HttpServletRequest request, + String remove) + { + final StringBuffer buff = new StringBuffer(); + final Enumeration names = request.getParameterNames(); + + // Are there any parameters? + if (names.hasMoreElements()) + { + // Loop through the parameter names + while (names.hasMoreElements()) + { + // Get the next parameter name + final String name = (String)names.nextElement(); + + // Is it the name to be removed? + if ((remove == null) || (!remove.equals(name))) + { + // Get the parameter values + final String values[] = request.getParameterValues(name); + + // Loop through the values + for (int i = 0; i < values.length; i++) + { + // Is it the very first parameter? + if (buff.length() > 0) + { + // Append an ampersand to the buffer + buff.append("&"); + } + + // Append the parameter name and value to the buffer + buff.append(nameValuePair(name, values[i])); + } + } + } + } + + return (buff.toString()); + } +} diff --git a/google-taglib/src/net/thauvin/google/package.html b/google-taglib/src/net/thauvin/google/package.html new file mode 100644 index 0000000..fffe496 --- /dev/null +++ b/google-taglib/src/net/thauvin/google/package.html @@ -0,0 +1,11 @@ + + + + Google Tag Library + + +This package contains the core bean and utility classes. + +@since 1.0 + + diff --git a/google-taglib/src/net/thauvin/google/taglibs/CachedPage.java b/google-taglib/src/net/thauvin/google/taglibs/CachedPage.java new file mode 100644 index 0000000..831c71b --- /dev/null +++ b/google-taglib/src/net/thauvin/google/taglibs/CachedPage.java @@ -0,0 +1,105 @@ +/* + * @(#)CachedPage.java + * + * Copyright (c) 2002-2003, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the author nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.google.taglibs; + +import net.thauvin.google.GoogleSearchBean; +import net.thauvin.google.TagUtility; + +import javax.servlet.jsp.*; + + +/** + * A custom tag used to access and retrieve pages cached on Google. + * + * @author Erik C. Thauvin + * @created April 25, 2002 + * @version $Revision$ + * @since 1.0 + */ +public class CachedPage extends QuerySupport +{ + /** + * doEndTag method. + * + * @return EVAL_PAGE + * @exception JspException + */ + public int doEndTag() + throws JspException + { + final String query = getQuery(); + + if (TagUtility.isValidString(query, true)) + { + try + { + final GoogleSearchBean bean = new GoogleSearchBean(getKey()); + + // Output the body + pageContext.getOut().write(bean.getCachedPage(query)); + } + catch (Exception e) + { + throw TagUtility.outputError("cachedPage", e); + } + } + + // Reset the values + reset(); + + return EVAL_PAGE; + } + + /** + * Release method. + */ + public void release() + { + super.release(); + + // Reset the values + reset(); + } + + /** + * Reset the values. + */ + protected void reset() + { + super.reset(); + } +} diff --git a/google-taglib/src/net/thauvin/google/taglibs/Element.java b/google-taglib/src/net/thauvin/google/taglibs/Element.java new file mode 100644 index 0000000..2ae0c0f --- /dev/null +++ b/google-taglib/src/net/thauvin/google/taglibs/Element.java @@ -0,0 +1,158 @@ +/* + * @(#)Element.java + * + * Copyright (c) 2002-2003, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the author nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.google.taglibs; + +import net.thauvin.google.TagUtility; + +import javax.servlet.jsp.*; + + +/** + * A custom tag used to retrieve a Google search result element. + * + * @author Erik C. Thauvin + * @created April 25, 2002 + * @version $Revision$ + * @since 1.0 + */ +public class Element extends StyleSupport +{ + private SearchResult parentTag = null; + private String name = null; + + /** + * Sets the search result element name. + * + * @param name The name of the element. + */ + public final void setName(String name) + { + this.name = name; + } + + /** + * doAfterBody method. + * + * @return EVAL_PAGE + * @exception JspException + */ + public int doEndTag() + throws JspException + { + if (TagUtility.isValidString(name, true)) + { + try + { + String property = ""; + + int sep = name.indexOf('-'); + + if (sep != -1) + { + String url = + parentTag.getElementProperty(name.substring(sep + 1)); + String body = + parentTag.getElementProperty(name.substring(0, sep)); + + if (body.length() == 0) + { + body = url; + } + + property = + TagUtility.buildRefLink(url, body, target, style, css); + } + else + { + property = parentTag.getElementProperty(name); + } + + pageContext.getOut().write(property); + } + catch (Exception e) + { + throw TagUtility.outputError("result", e); + } + } + + // Reset the values + reset(); + + return EVAL_PAGE; + } + + /** + * doStartTag method. + * + * @return SKIP_BODY. + * @exception JspTagException + */ + public int doStartTag() + throws JspTagException + { + // Find the parent tag + parentTag = + (SearchResult)findAncestorWithClass(this, SearchResult.class); + + // Is it valid? + if (parentTag == null) + { + throw TagUtility.misplacedError("element", "searchResult"); + } + + return (SKIP_BODY); + } + + /** + * Release method. + */ + public void release() + { + super.release(); + + // Reset the parent tag + parentTag = null; + } + + /** + * Reset the values. + */ + protected void reset() + { + super.reset(); + } +} diff --git a/google-taglib/src/net/thauvin/google/taglibs/EndIndex.java b/google-taglib/src/net/thauvin/google/taglibs/EndIndex.java new file mode 100644 index 0000000..22eb27f --- /dev/null +++ b/google-taglib/src/net/thauvin/google/taglibs/EndIndex.java @@ -0,0 +1,69 @@ +/* + * @(#)EndIndex.java + * + * Copyright (c) 2002-2003, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the author nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.google.taglibs; + + +/** + * A custom tag used to retrieve the Google search result end index. + * + * @author Erik C. Thauvin + * @created April 26, 2002 + * @version $Revision$ + * @since 1.0 + */ +public class EndIndex extends SearchResultSupport +{ + /** + * Returns the property provided by this tag. + * + * @return The property name. + */ + protected String getPropertyName() + { + return "endIndex"; + } + + /** + * Returns the name of this tag. + * + * @return The tag name. + */ + protected String getTagName() + { + return "endIndex"; + } +} diff --git a/google-taglib/src/net/thauvin/google/taglibs/EstimatedTotal.java b/google-taglib/src/net/thauvin/google/taglibs/EstimatedTotal.java new file mode 100644 index 0000000..fe75e9f --- /dev/null +++ b/google-taglib/src/net/thauvin/google/taglibs/EstimatedTotal.java @@ -0,0 +1,70 @@ +/* + * @(#)EstimatedTotal.java + * + * Copyright (c) 2002-2003, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the author nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.google.taglibs; + + +/** + * A custom tag used to retrieve the estimated total results count of a Google + * search. + * + * @author Erik C. Thauvin + * @created April 26, 2002 + * @version $Revision$ + * @since 1.0 + */ +public class EstimatedTotal extends SearchResultSupport +{ + /** + * Returns the property provided by this tag. + * + * @return The property name. + */ + protected String getPropertyName() + { + return "estimatedTotalResultsCount"; + } + + /** + * Returns the name of this tag. + * + * @return The tag name. + */ + protected String getTagName() + { + return "estimatedTotal"; + } +} diff --git a/google-taglib/src/net/thauvin/google/taglibs/KeySupport.java b/google-taglib/src/net/thauvin/google/taglibs/KeySupport.java new file mode 100644 index 0000000..9fee9fe --- /dev/null +++ b/google-taglib/src/net/thauvin/google/taglibs/KeySupport.java @@ -0,0 +1,154 @@ +/* + * @(#)KeySupport.java + * + * Copyright (c) 2002-2003, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the author nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.google.taglibs; + +import net.thauvin.google.TagUtility; + +import javax.servlet.jsp.*; +import javax.servlet.jsp.tagext.*; + + +/** + * Implements support for specifying the key used for authorization in the + * Google API. + *

+ * The key can be specified using one the following: + *

    + *
  • The {@link #key key} attribute.
  • + *
  • The {@link net.thauvin.google.TagUtility#KEY_PARAM key} request parameter.
  • + *
  • The {@link net.thauvin.google.TagUtility#KEY_CONTEXT_PARAM key} context + * parameter.
  • + *
  • The {@link net.thauvin.google.TagUtility#KEY_CONTEXT_PARAM key} application scope + * attribute.
  • + *
+ * + * @author Erik C. Thauvin + * @created April 25, 2002 + * @version $Revision$ + * @since 1.0 + */ +public abstract class KeySupport extends BodyTagSupport +{ + /** + * The key attribute. + */ + protected String key = null; + + /** + * Sets the key attribute. + * + * @param key The new attribute value. + * @see #getKey + */ + public final void setKey(String key) + { + this.key = key; + } + + /** + * Returns the key attribute. + * + * @return The attribute value. + * @see #setKey(String) + */ + public String getKey() + { + if (TagUtility.isValidString(key, true)) + { + return key; + } + else + { + String keyParam = + TagUtility.getParameter(pageContext.getRequest(), + TagUtility.KEY_PARAM); + + if (TagUtility.isValidString(keyParam, true)) + { + return keyParam; + } + + keyParam = + pageContext.getServletContext().getInitParameter(TagUtility.KEY_CONTEXT_PARAM); + + if (TagUtility.isValidString(keyParam, true)) + { + return keyParam; + } + + try + { + keyParam = + (String)(pageContext.getAttribute(TagUtility.KEY_CONTEXT_PARAM, + PageContext.APPLICATION_SCOPE)); + + if (TagUtility.isValidString(keyParam, true)) + { + return keyParam; + } + } + catch (NullPointerException e) + { + ; // Do nothing + } + } + + return ""; + } + + /** + * Release method. + */ + public void release() + { + super.release(); + + // Reset the key value + key = null; + + // Reset the values + reset(); + } + + /** + * Reset the values. + */ + protected void reset() + { + //super.reset(); + } +} diff --git a/google-taglib/src/net/thauvin/google/taglibs/Next.java b/google-taglib/src/net/thauvin/google/taglibs/Next.java new file mode 100644 index 0000000..787f475 --- /dev/null +++ b/google-taglib/src/net/thauvin/google/taglibs/Next.java @@ -0,0 +1,71 @@ +/* + * @(#)Next.java + * + * Copyright (c) 2002-2003, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the author nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.google.taglibs; + +import net.thauvin.google.GoogleSearchBean; + + +/** + * A custom tag used to create a link to the next Google search result set. + * + * @author Erik C. Thauvin + * @created April 26, 2002 + * @version $Revision$ + * @since 1.0 + */ +public class Next extends SearchResultSupport +{ + /** + * Returns the property provided by this tag. + * + * @return The property name. + */ + protected String getPropertyName() + { + return GoogleSearchBean.NEXT_KEYWORD; + } + + /** + * Returns the name of this tag. + * + * @return The tag name. + */ + protected String getTagName() + { + return "next"; + } +} diff --git a/google-taglib/src/net/thauvin/google/taglibs/Previous.java b/google-taglib/src/net/thauvin/google/taglibs/Previous.java new file mode 100644 index 0000000..2b8329f --- /dev/null +++ b/google-taglib/src/net/thauvin/google/taglibs/Previous.java @@ -0,0 +1,71 @@ +/* + * @(#)Previous.java + * + * Copyright (c) 2002-2003, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the author nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.google.taglibs; + +import net.thauvin.google.GoogleSearchBean; + + +/** + * A custom tag used to create a link to the previous Google search result set. + * + * @author Erik C. Thauvin + * @created April 26, 2002 + * @version $Revision$ + * @since 1.0 + */ +public class Previous extends SearchResultSupport +{ + /** + * Returns the property provided by this tag. + * + * @return The property name. + */ + protected String getPropertyName() + { + return GoogleSearchBean.PREVIOUS_KEYWORD; + } + + /** + * Returns the name of this tag. + * + * @return The tag name. + */ + protected String getTagName() + { + return "previous"; + } +} diff --git a/google-taglib/src/net/thauvin/google/taglibs/QuerySupport.java b/google-taglib/src/net/thauvin/google/taglibs/QuerySupport.java new file mode 100644 index 0000000..064a66a --- /dev/null +++ b/google-taglib/src/net/thauvin/google/taglibs/QuerySupport.java @@ -0,0 +1,99 @@ +/* + * @(#)QuerySupport.java + * + * Copyright (c) 2002-2003, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the author nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.google.taglibs; + +import net.thauvin.google.TagUtility; + + +/** + * Implements supports for specifying the Google query string. + *

+ * The query can be specified using one the following: + *

    + *
  • The {@link net.thauvin.google.TagUtility#QUERY_PARAM query} request parameter.
  • + *
  • Directly within the body of the tag.
  • + *
+ * + * @author Erik C. Thauvin + * @created April 29, 2002 + * @version $Revision$ + * @since 1.0 + */ +public abstract class QuerySupport extends KeySupport +{ + /** + * Release method. + */ + public void release() + { + super.release(); + } + + /** + * Returns the specified query. + * + * @return The query value. + */ + protected final String getQuery() + { + String query = + TagUtility.getParameter(pageContext.getRequest(), + TagUtility.QUERY_PARAM); + + if (TagUtility.isValidString(query, true)) + { + return query; + } + + query = TagUtility.getTagBody(bodyContent, true); + + if (TagUtility.isValidString(query, true)) + { + return query; + } + + return ""; + } + + /** + * Reset the values. + */ + protected void reset() + { + super.reset(); + } +} diff --git a/google-taglib/src/net/thauvin/google/taglibs/Search.java b/google-taglib/src/net/thauvin/google/taglibs/Search.java new file mode 100644 index 0000000..ddf1e7f --- /dev/null +++ b/google-taglib/src/net/thauvin/google/taglibs/Search.java @@ -0,0 +1,428 @@ +/* + * @(#)Search.java + * + * Copyright (c) 2002-2003, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the author nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.google.taglibs; + +import net.thauvin.google.GoogleSearchBean; +import net.thauvin.google.TagUtility; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.PageContext; + + +/** + * A custom tag used to perform Google searches. + * + * @author Erik C. Thauvin + * @created April 25, 2002 + * @version $Revision$ + * @since 1.0 + */ +public class Search extends QuerySupport +{ + private GoogleSearchBean bean = null; + private String lr = GoogleSearchBean.DEFAULT_LR; + private String restrict = GoogleSearchBean.DEFAULT_RESTRICT; + private String site = GoogleSearchBean.DEFAULT_SITE; + private boolean cache = true; + private boolean filter = GoogleSearchBean.DEFAULT_FILTER; + private boolean safeSearch = GoogleSearchBean.DEFAULT_SAFE_SEARCH; + private int maxResults = GoogleSearchBean.DEFAULT_MAX_RESULTS; + private int start = GoogleSearchBean.DEFAULT_START; + + /** + * Sets the cache attribute. + * + * @param cache The new attribute value. + * @see #getCache() + */ + public final void setCache(String cache) + { + this.cache = Boolean.valueOf(cache).booleanValue(); + } + + /** + * Returns the cache attribute. + * + * @return The attribute value. + * @see #setCache(String) + */ + public final boolean getCache() + { + return getBoolParam(TagUtility.CACHE_PARAM, cache); + } + + /** + * Sets the (related-query) filter attribute. + * + * @param filter The new attribute value. + * @see #getFilter() + */ + public final void setFilter(String filter) + { + this.filter = Boolean.valueOf(filter).booleanValue(); + } + + /** + * Returns the (related-query) filter attribute. + * + * @return The attribute value. + * @see #setFilter(String) + */ + public final boolean getFilter() + { + return getBoolParam(TagUtility.FILTER_PARAM, filter); + } + + /** + * Sets the lr (language restrict) attribute. + * + * @param lr The new attribute value. + * @see #getLr() + */ + public final void setLr(String lr) + { + this.lr = lr; + } + + /** + * Returns the lr (language restrict) attribute. + * + * @return The attribute value. + * @see #setLr(String) + */ + public final String getLr() + { + return getStringParam(TagUtility.LR_PARAM, lr); + } + + /** + * Sets the maximum number of results to be returned. + * + * @param maxResults The new attribute value. + * @see #getMaxResults() + */ + public final void setMaxResults(String maxResults) + { + try + { + this.maxResults = Integer.valueOf(maxResults).intValue(); + } + catch (NumberFormatException e) + { + ; // Do nothing + } + } + + /** + * Returns the maximum number of results to be returned. + * + * @return The attribute value. + * @see #setMaxResults(String) + */ + public final int getMaxResults() + { + return getIntParam(TagUtility.MAX_RESULTS_PARAM, maxResults); + } + + /** + * Sets the restrict attribute. + * + * @param restrict The new restrict attribute. + * @see #getRestrict() + */ + public final void setRestrict(String restrict) + { + this.restrict = restrict; + } + + /** + * Returns the restrict attribute. + * + * @return The attribute value. + * @see #setRestrict(String) + */ + public final String getRestrict() + { + return getStringParam(TagUtility.RESTRICT_PARAM, restrict); + } + + /** + * Sets the safeSearch attribute. + * + * @param safeSearch The new attribute value. + * @see #getSafeSearch() + */ + public final void setSafeSearch(String safeSearch) + { + this.safeSearch = Boolean.valueOf(safeSearch).booleanValue(); + } + + /** + * Returns the safeSearch attribute. + * + * @return The attribute value. + * @see #setSafeSearch(String) + */ + public final boolean getSafeSearch() + { + return getBoolParam(TagUtility.SAFE_SEARCH_PARAM, safeSearch); + } + + /** + * Sets the site attribute. + * + * @param site The new attribute value. + * @see #getSite() + */ + public final void setSite(String site) + { + this.site = site; + } + + /** + * Returns the stie attribute. + * + * @return The attribute value. + * @see #setSite(String) + */ + public final String getSite() + { + String site = getStringParam(TagUtility.SITE_PARAM, this.site); + + if (site.length() > 0) + { + return ("site:" + site + ' '); + } + + return ""; + } + + /** + * Sets the start attribute. + * + * @param start The new attribute value. + * @see #getStart() + */ + public final void setStart(String start) + { + try + { + this.start = Integer.valueOf(start).intValue(); + } + catch (NumberFormatException e) + { + ; // Do nothing + } + } + + /** + * Returns the start attribute. + * + * @return The attribute value. + * @see #setStart(String) + */ + public final int getStart() + { + return getIntParam(TagUtility.START_PARAM, start); + } + + /** + * doEndTag method. + * + * @return EVAL_PAGE + * @exception JspException + */ + public int doEndTag() + throws JspException + { + final String query = getQuery(); + + if (TagUtility.isValidString(query, true)) + { + try + { + bean.getGoogleSearch(getKey(), getSite() + getQuery(), + getStart(), getMaxResults(), getFilter(), + getRestrict(), getSafeSearch(), getLr()); + } + catch (Exception e) + { + throw TagUtility.outputError("search", e); + } + } + else if (!getCache()) + { + bean.reset(); + } + + // Reset the values + reset(); + + return EVAL_PAGE; + } + + /** + * doStartTag method. + * + * @return EVAL_BODY_TAG. + * @exception JspException + */ + public int doStartTag() + throws JspException + { + // Get the Google bean + bean = TagUtility.getGoogleSearchBean(pageContext); + + // Create a new bean if it doesn't exists + if (bean == null) + { + try + { + bean = new GoogleSearchBean(); + + // Set the bean as named session attribute + pageContext.setAttribute(TagUtility.GOOGLE_SEARCH_BEAN, bean, + PageContext.SESSION_SCOPE); + } + catch (Exception e) + { + throw new JspException("An unknown error ocurred while creating the Google search bean."); + } + } + + return EVAL_BODY_TAG; + } + + /** + * Release method. + */ + public void release() + { + super.release(); + + // Reset all attributes + start = GoogleSearchBean.DEFAULT_START; + maxResults = GoogleSearchBean.DEFAULT_MAX_RESULTS; + filter = GoogleSearchBean.DEFAULT_FILTER; + safeSearch = GoogleSearchBean.DEFAULT_SAFE_SEARCH; + restrict = GoogleSearchBean.DEFAULT_RESTRICT; + lr = GoogleSearchBean.DEFAULT_LR; + site = GoogleSearchBean.DEFAULT_SITE; + cache = true; + + // Reset the bean + bean = null; + + // Reset the values + reset(); + } + + /** + * Reset the values. + */ + protected void reset() + { + super.reset(); + } + + /** + * Converts a request parameter to a boolean. + * + * @param paramName The parameter name. + * @param defaultValue The default value to use if the parameter is empty. + * @return The boolean value. + */ + private boolean getBoolParam(String paramName, boolean defaultValue) + { + String param = + TagUtility.getParameter(pageContext.getRequest(), paramName); + + if (TagUtility.isValidString(param, true)) + { + return Boolean.valueOf(param).booleanValue(); + } + + return defaultValue; + } + + /** + * Converts a request parameter to an int. + * + * @param paramName The parameter name. + * @param defaultValue The default value to use if the parameter is empty. + * @return The int value. + */ + private int getIntParam(String paramName, int defaultValue) + { + String param = + TagUtility.getParameter(pageContext.getRequest(), paramName); + + if (TagUtility.isValidString(param, true)) + { + try + { + return Integer.valueOf(param).intValue(); + } + catch (NumberFormatException e) + { + ; // Do nothing + } + } + + return defaultValue; + } + + /** + * Converts a request parameter to a string. + * + * @param paramName The parameter name. + * @param defaultValue The default value to use if the parameter is empty. + * @return The string value. + */ + private String getStringParam(String paramName, String defaultValue) + { + String param = + TagUtility.getParameter(pageContext.getRequest(), paramName); + + if (TagUtility.isValidString(param, true)) + { + return param; + } + + return defaultValue; + } +} diff --git a/google-taglib/src/net/thauvin/google/taglibs/SearchComments.java b/google-taglib/src/net/thauvin/google/taglibs/SearchComments.java new file mode 100644 index 0000000..e5a4636 --- /dev/null +++ b/google-taglib/src/net/thauvin/google/taglibs/SearchComments.java @@ -0,0 +1,69 @@ +/* + * @(#)SearchComments.java + * + * Copyright (c) 2002-2003, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the author nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.google.taglibs; + + +/** + * A custom tag used to retrieve the Google search comments message. + * + * @author Erik C. Thauvin + * @created April 26, 2002 + * @version $Revision$ + * @since 1.0 + */ +public class SearchComments extends SearchResultSupport +{ + /** + * Returns the property provided by this tag. + * + * @return The property name. + */ + protected String getPropertyName() + { + return "searchComments"; + } + + /** + * Returns the name of this tag. + * + * @return The tag name. + */ + protected String getTagName() + { + return "searchComments"; + } +} diff --git a/google-taglib/src/net/thauvin/google/taglibs/SearchQuery.java b/google-taglib/src/net/thauvin/google/taglibs/SearchQuery.java new file mode 100644 index 0000000..de530a7 --- /dev/null +++ b/google-taglib/src/net/thauvin/google/taglibs/SearchQuery.java @@ -0,0 +1,69 @@ +/* + * @(#)SearchQuery.java + * + * Copyright (c) 2002-2003, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the author nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.google.taglibs; + + +/** + * A custom tag used to retrieve the query string of a Google search. + * + * @author Erik C. Thauvin + * @created April 29, 2002 + * @version $Revision$ + * @since 1.0 + */ +public class SearchQuery extends SearchResultSupport +{ + /** + * Returns the property provided by this tag. + * + * @return The property name. + */ + protected String getPropertyName() + { + return "searchQuery"; + } + + /** + * Returns the name of this tag. + * + * @return The tag name. + */ + protected String getTagName() + { + return "searchQuery"; + } +} diff --git a/google-taglib/src/net/thauvin/google/taglibs/SearchResult.java b/google-taglib/src/net/thauvin/google/taglibs/SearchResult.java new file mode 100644 index 0000000..2f77275 --- /dev/null +++ b/google-taglib/src/net/thauvin/google/taglibs/SearchResult.java @@ -0,0 +1,191 @@ +/* + * @(#)SearchResult.java + * + * Copyright (c) 2002-2003, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the author nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.google.taglibs; + +import net.thauvin.google.GoogleSearchBean; +import net.thauvin.google.TagUtility; + +import javax.servlet.jsp.*; +import javax.servlet.jsp.tagext.*; + + +/** + * A custom tag used to parse and loop through Google search results. + * + * @author Erik C. Thauvin + * @created April 25, 2002 + * @version $Revision$ + * @since 1.0 + */ +public class SearchResult extends BodyTagSupport +{ + private GoogleSearchBean bean = null; + private StringBuffer output = null; + private int loopCount = 0; + + /** + * doAfterBody method. + * + * @return EVAL_BODY_TAG or SKIP_BODY. + * @exception JspTagException + */ + public int doAfterBody() + throws JspTagException + { + // Get the body content + final String body = bodyContent.getString(); + + // Append the body to the ouput + output.append(body); + + try + { + // Clear the body content + bodyContent.clear(); + } + catch (java.io.IOException e) + { + throw TagUtility.nestedException("An error occurred while clearing the content of the 'searchResult' tag.", + e); + } + + // Increment the loop count, if there are more elements + if (++loopCount < bean.getResultElementsCount()) + { + return EVAL_BODY_TAG; + } + + return SKIP_BODY; + } + + /** + * doEndTag method. + * + * @return EVAL_PAGE. + * @exception JspTagException + */ + public int doEndTag() + throws JspTagException + { + // Is there anything to ouput? + if (output.length() > 0) + { + try + { + // Write the output into the tag body + bodyContent.getEnclosingWriter().write(output.toString()); + } + catch (java.io.IOException e) + { + throw TagUtility.outputError("searchResult", e); + } + } + + // Reset the values + reset(); + + return EVAL_PAGE; + } + + /** + * doStartTag method. + * + * @return EVAL_BODY_TAG. + * @exception JspException + */ + public int doStartTag() + throws JspException + { + output = new StringBuffer(); + + // Reset the loopCount + loopCount = 0; + + // Get the Google bean + bean = TagUtility.getGoogleSearchBean(pageContext); + + // Are there any elements? + if ((bean != null) && (bean.getResultElementsCount() > 0)) + { + return EVAL_BODY_TAG; + } + + return SKIP_BODY; + } + + /** + * Release method. + */ + public void release() + { + super.release(); + + // Reset the bean + bean = null; + + // Reset the output + output = null; + + // Reset the values + reset(); + } + + /** + * Returns the current search result element specified property. + * + * @param name The property name. + * @return The property value. + */ + protected String getElementProperty(String name) + { + if (bean != null) + { + return bean.getResultElementProperty(loopCount, name); + } + + return ""; + } + + /** + * Reset the values. + */ + protected void reset() + { + // Reset the loop count value + loopCount = 0; + } +} diff --git a/google-taglib/src/net/thauvin/google/taglibs/SearchResultSupport.java b/google-taglib/src/net/thauvin/google/taglibs/SearchResultSupport.java new file mode 100644 index 0000000..f049b1d --- /dev/null +++ b/google-taglib/src/net/thauvin/google/taglibs/SearchResultSupport.java @@ -0,0 +1,188 @@ +/* + * @(#)SearchResultSupport.java + * + * Copyright (c) 2002-2003, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the author nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.google.taglibs; + +import net.thauvin.google.GoogleSearchBean; +import net.thauvin.google.TagUtility; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpUtils; +import javax.servlet.jsp.JspException; + + +/** + * Implements methods used to retrieve Google Search Result properties. + * + * @author Erik C. Thauvin + * @created April 26, 2002 + * @version $Revision$ + * @since 1.0 + */ +public abstract class SearchResultSupport extends StyleSupport +{ + /** + * The Google search bean. + */ + protected GoogleSearchBean bean = null; + + /** + * doEndTag method. + * + * @return EVAL_PAGE + * @exception JspException + */ + public int doEndTag() + throws JspException + { + try + { + // Is the result valid? + if ((bean != null) && (bean.isValidResult())) + { + // Output the property + pageContext.getOut().write(getResultProperty()); + } + } + catch (Exception e) + { + throw TagUtility.outputError(getTagName(), e); + } + + // Reset the values + reset(); + + return EVAL_PAGE; + } + + /** + * doStartTag method. + * + * @return EVAL_BODY_TAG or SKIP_BODY. + * @exception JspException + */ + public int doStartTag() + throws JspException + { + // Get the Google bean + bean = TagUtility.getGoogleSearchBean(pageContext); + + // Is the result valid? + if ((bean != null) && (bean.isValidResult())) + { + return EVAL_BODY_TAG; + } + + return SKIP_BODY; + } + + /** + * Release method. + */ + public void release() + { + super.release(); + + // Reset the bean + bean = null; + + // Reset the values + reset(); + } + + /** + * Returns the result of the build action and must be implemented by classes + * which extend SearchResultSupport. + *

+ * For example: + *

+ *

return "Some Value";
+ * + * @return The property name. + */ + protected abstract String getPropertyName(); + + /** + * Returns the value of specified search result property. + * + * @return The property value. + */ + protected String getResultProperty() + { + String name = getPropertyName(); + String value = bean.getResultProperty(name); + + if ((TagUtility.isValidString(value)) + && (name.equals(GoogleSearchBean.NEXT_KEYWORD) + || name.equals(GoogleSearchBean.PREVIOUS_KEYWORD))) + { + HttpServletRequest request = + (HttpServletRequest)pageContext.getRequest(); + + String url = + HttpUtils.getRequestURL(request).toString() + '?' + + TagUtility.START_PARAM + '=' + value + '&' + + TagUtility.requestParamsToUrl(request, TagUtility.START_PARAM); + + return (TagUtility.buildRefLink(url, + TagUtility.getTagBody(bodyContent), + target, style, css)); + } + else + { + return value; + } + } + + /** + * Returns the name of the tag extending SearchResultSupport. + *

+ * For example: + *

+ *

void getErrorString() { return "MyTag"; }
+ * + * @return The tag name. + */ + protected abstract String getTagName(); + + /** + * Reset the values. + */ + protected void reset() + { + super.reset(); + } +} diff --git a/google-taglib/src/net/thauvin/google/taglibs/SearchTime.java b/google-taglib/src/net/thauvin/google/taglibs/SearchTime.java new file mode 100644 index 0000000..94e27a6 --- /dev/null +++ b/google-taglib/src/net/thauvin/google/taglibs/SearchTime.java @@ -0,0 +1,69 @@ +/* + * @(#)SearchTime.java + * + * Copyright (c) 2002-2003, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the author nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.google.taglibs; + + +/** + * A custom tag used to retrieve the elapsed time of a Google search. + * + * @author Erik C. Thauvin + * @created April 26, 2002 + * @version $Revision$ + * @since 1.0 + */ +public class SearchTime extends SearchResultSupport +{ + /** + * Returns the property provided by this tag. + * + * @return The property name. + */ + protected String getPropertyName() + { + return "searchTime"; + } + + /** + * Returns the name of this tag. + * + * @return The tag name. + */ + protected String getTagName() + { + return "searchTime"; + } +} diff --git a/google-taglib/src/net/thauvin/google/taglibs/SearchTips.java b/google-taglib/src/net/thauvin/google/taglibs/SearchTips.java new file mode 100644 index 0000000..404c5f8 --- /dev/null +++ b/google-taglib/src/net/thauvin/google/taglibs/SearchTips.java @@ -0,0 +1,69 @@ +/* + * @(#)SearchTips.java + * + * Copyright (c) 2002-2003, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the author nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.google.taglibs; + + +/** + * A custom tag used to retrieve the Google search tips message. + * + * @author Erik C. Thauvin + * @created April 26, 2002 + * @version $Revision$ + * @since 1.0 + */ +public class SearchTips extends SearchResultSupport +{ + /** + * Returns the property provided by this tag. + * + * @return The property name. + */ + protected String getPropertyName() + { + return "searchTips"; + } + + /** + * Returns the name of this tag. + * + * @return The tag name. + */ + protected String getTagName() + { + return "searchTips"; + } +} diff --git a/google-taglib/src/net/thauvin/google/taglibs/Spelling.java b/google-taglib/src/net/thauvin/google/taglibs/Spelling.java new file mode 100644 index 0000000..63f06d8 --- /dev/null +++ b/google-taglib/src/net/thauvin/google/taglibs/Spelling.java @@ -0,0 +1,112 @@ +/* + * @(#)Spelling.java + * + * Copyright (c) 2002-2003, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the author nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.google.taglibs; + +import net.thauvin.google.GoogleSearchBean; +import net.thauvin.google.TagUtility; + +import javax.servlet.jsp.JspException; + + +/** + * A custom tag used to access and retrieve Google spelling suggestions. + * + * @author Erik C. Thauvin + * @created April 25, 2002 + * @version $Revision$ + * @since 1.0 + */ +public class Spelling extends QuerySupport +{ + /** + * doEndTag method. + * + * @return EVAL_PAGE + * @exception JspException + */ + public int doEndTag() + throws JspException + { + final String query = getQuery(); + + if (TagUtility.isValidString(query, true)) + { + try + { + final GoogleSearchBean bean = new GoogleSearchBean(getKey()); + + String result = bean.getSpellingSuggestion(query); + + if (!TagUtility.isValidString(result, true)) + { + result = query; + } + + // Output the spelling suggestion + pageContext.getOut().write(result); + } + catch (Exception e) + { + throw TagUtility.outputError("Spelling", e); + } + } + + // Reset the values + reset(); + + return EVAL_PAGE; + } + + /** + * Release method. + */ + public void release() + { + super.release(); + + // Reset the values + reset(); + } + + /** + * Reset the values. + */ + protected void reset() + { + super.reset(); + } +} diff --git a/google-taglib/src/net/thauvin/google/taglibs/StartIndex.java b/google-taglib/src/net/thauvin/google/taglibs/StartIndex.java new file mode 100644 index 0000000..9f5cc2e --- /dev/null +++ b/google-taglib/src/net/thauvin/google/taglibs/StartIndex.java @@ -0,0 +1,69 @@ +/* + * @(#)StartIndex.java + * + * Copyright (c) 2002-2003, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the author nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.google.taglibs; + + +/** + * A custom tag used to retrieve the Google search result start index. + * + * @author Erik C. Thauvin + * @created April 26, 2002 + * @version $Revision$ + * @since 1.0 + */ +public class StartIndex extends SearchResultSupport +{ + /** + * Returns the property provided by this tag. + * + * @return The property name. + */ + protected String getPropertyName() + { + return "startIndex"; + } + + /** + * Returns the name of this tag. + * + * @return The tag name. + */ + protected String getTagName() + { + return "startIndex"; + } +} diff --git a/google-taglib/src/net/thauvin/google/taglibs/StyleSupport.java b/google-taglib/src/net/thauvin/google/taglibs/StyleSupport.java new file mode 100644 index 0000000..cbf3e08 --- /dev/null +++ b/google-taglib/src/net/thauvin/google/taglibs/StyleSupport.java @@ -0,0 +1,116 @@ +/* + * @(#)StyleSupport.java + * + * Copyright (c) 2002-2003, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the author nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ +package net.thauvin.google.taglibs; + +import javax.servlet.jsp.tagext.BodyTagSupport; + + +/** + * Implements support for the style, target and css tag attributes. + * + * @author Erik C. Thauvin + * @created Sep 4, 2003 + * @version $Revision$ + * @since 1.0 + */ +public abstract class StyleSupport extends BodyTagSupport +{ + /** + * The css attribute. + */ + protected String css = null; + + /** + * The style attribute. + */ + protected String style = null; + + /** + * The target attribute. + */ + protected String target = null; + + /** + * Sets the css attribute. + * + * @param css The new attribute value. + */ + public final void setCss(String css) + { + this.css = css; + } + + /** + * Sets the style attribute. + * + * @param style The new attribute value. + */ + public final void setStyle(String style) + { + this.style = style; + } + + /** + * Sets the target attribute. + * + * @param target The new attribute value. + */ + public final void setTarget(String target) + { + this.target = target; + } + + /** + * Release method. + */ + public void release() + { + super.release(); + + // Reset the values + reset(); + } + + /** + * Reset the values. + */ + protected void reset() + { + // Reset the target, style and css + target = style = css = null; + } +} diff --git a/google-taglib/src/net/thauvin/google/taglibs/package.html b/google-taglib/src/net/thauvin/google/taglibs/package.html new file mode 100644 index 0000000..b91d530 --- /dev/null +++ b/google-taglib/src/net/thauvin/google/taglibs/package.html @@ -0,0 +1,11 @@ + + + + Google Tag Library + + +This package contains the custom tag libraries. + +@since 1.0 + + diff --git a/google-taglib/tlds/google.tld b/google-taglib/tlds/google.tld new file mode 100644 index 0000000..af98b4f --- /dev/null +++ b/google-taglib/tlds/google.tld @@ -0,0 +1,215 @@ + + + + + + @version@ + + 1.1 + + google + + http://www.thauvin.net/taglibs/google-taglib-@version@ + + + The Google Tag Library. + + + + cachedPage + net.thauvin.google.taglibs.CachedPage + JSP + Displays a page cached by Google. + + key + false + true + + + + + element + net.thauvin.google.taglibs.Element + empty + Displays the given property of the current search result element. + + css + false + true + + + name + true + true + + + style + false + true + + + target + false + true + + + + + endIndex + net.thauvin.google.taglibs.EndIndex + empty + Displays the current search result end index. + + + + estimatedTotal + net.thauvin.google.taglibs.EstimatedTotal + empty + Displays the estimated total results count of the current search. + + + + next + net.thauvin.google.taglibs.Next + JSP + Displays a link to the next search result set. + + css + false + true + + + style + false + true + + + target + false + true + + + + + previous + net.thauvin.google.taglibs.Previous + JSP + Displays a link to the previous search result set. + + css + false + true + + + style + false + true + + + target + false + true + + + + + search + net.thauvin.google.taglibs.Search + JSP + Performs a Google search. + + cache + false + true + + + filter + false + true + + + key + false + true + + + lr + false + true + + + maxResults + false + true + + + safeSearch + false + true + + + site + false + true + + + start + false + true + + + + + searchComments + net.thauvin.google.taglibs.SearchComments + empty + Displays the current search comments. + + + + searchQuery + net.thauvin.google.taglibs.SearchQuery + empty + Displays the current search query. + + + + searchResult + net.thauvin.google.taglibs.SearchResult + JSP + Loops through the current search results + + + + searchTime + net.thauvin.google.taglibs.SearchTime + empty + Displays the elapsed time of the current search. + + + + searchTips + net.thauvin.google.taglibs.SearchTips + empty + Displays the search tips of the current search. + + + + spelling + net.thauvin.google.taglibs.Spelling + JSP + Performs a Google spelling suggestion. + + key + false + true + + + + + startIndex + net.thauvin.google.taglibs.StartIndex + empty + Displays the current search result start index. + +