KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > thauvin > google > taglibs > QuerySupport


1 /*
2  * @(#)QuerySupport.java
3  *
4  * Copyright (c) 2002-2003, Erik C. Thauvin (erik@thauvin.net)
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are
9  * met:
10  *
11  * Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the following disclaimer.
13  *
14  * Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * Neither the name of the author nor the names of its contributors may be
19  * used to endorse or promote products derived from this software without
20  * specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
23  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
26  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  * $Id: QuerySupport.java,v 1.1.1.1 2003/09/24 14:59:02 ethauvin Exp $
35  *
36  */

37 package net.thauvin.google.taglibs;
38
39 import net.thauvin.google.TagUtility;
40
41
42 /**
43  * Implements supports for specifying the Google query string.
44  * <p>
45  * The query can be specified using one the following:
46  * <ul>
47  * <li>The {@link net.thauvin.google.TagUtility#QUERY_PARAM query} request parameter.</li>
48  * <li>Directly within the body of the tag.</li>
49  * </ul>
50  *
51  * @author Erik C. Thauvin
52  * @created April 29, 2002
53  * @version $Revision: 1.1.1.1 $
54  * @since 1.0
55  */

56 public abstract class QuerySupport extends KeySupport
57 {
58     /**
59      * Release method.
60      */

61     public void release()
62     {
63         super.release();
64     }
65
66     /**
67      * Returns the specified query.
68      *
69      * @return The query value.
70      */

71     protected final String JavaDoc getQuery()
72     {
73         String JavaDoc query =
74             TagUtility.getParameter(pageContext.getRequest(),
75                                     TagUtility.QUERY_PARAM);
76
77         if (TagUtility.isValidString(query, true))
78         {
79             return query;
80         }
81
82         query = TagUtility.getTagBody(bodyContent, true);
83
84         if (TagUtility.isValidString(query, true))
85         {
86             return query;
87         }
88
89         return "";
90     }
91
92     /**
93      * Reset the values.
94      */

95     protected void reset()
96     {
97         super.reset();
98     }
99 }
100
Popular Tags