net.thauvin.google
Class TagUtility

java.lang.Object
  extended bynet.thauvin.google.TagUtility

public class TagUtility
extends java.lang.Object

Implements various methods commonly used by custom tags.

Since:
1.0
Version:
$Revision: 1.5 $
Author:
Erik C. Thauvin

Field Summary
static java.lang.String CACHE_PARAM
          The name of the cache request parameter.
static java.lang.String FILTER_PARAM
          The name of the filter request parameter.
static java.lang.String GOOGLE_PROXY_HOST
          The HTTP proxy host.
static java.lang.String GOOGLE_PROXY_PASSWORD
          The HTTP proxy password.
static java.lang.String GOOGLE_PROXY_PORT
          The HTTP proxy port.
static java.lang.String GOOGLE_PROXY_USERNAME
          The HTTP proxy username.
static java.lang.String GOOGLE_SEARCH_BEAN
          The name of the Google Search bean attribute.
static java.lang.String IE_PARAM
          The name of the input encoding context parameter.
static java.lang.String KEY_CONTEXT_PARAM
          The name of the key context parameter.
static java.lang.String KEY_PARAM
          The name of the key request parameter.
static java.lang.String LR_PARAM
          The name of the language restrict context parameter.
static java.lang.String MAX_RESULTS_PARAM
          The name of the maxResults request parameter.
static java.lang.String OE_PARAM
          The name of the output encoding context parameter.
static java.lang.String QUERY_PARAM
          The name of the query request parameter.
static java.lang.String RESTRICT_PARAM
          The name of the restrict context parameter.
static java.lang.String SAFE_SEARCH_PARAM
          The name of the safeSearch context parameter.
static java.lang.String SITE_PARAM
          The name of the site context parameter.
static java.lang.String START_PARAM
          The name of the start request parameter.
static java.lang.String TYPE_PARAM
          The name of the (file) type request parameter.
 
Constructor Summary
protected TagUtility()
          Protected constructor to disable instantiation.
 
Method Summary
static java.lang.String buildRefLink(java.lang.String url, java.lang.String body, java.lang.String target, java.lang.String style, java.lang.String css)
          Builds a HTML reference link: For example: <a href="url" class="css" style="style" target="target">body</a>.
static GoogleSearchBean getGoogleSearchBean(javax.servlet.jsp.PageContext pageContext)
          Returns the GoogleSearchBean attribute using the default bean name.
static java.lang.String getParameter(javax.servlet.ServletRequest request, java.lang.String paramName)
          Returns the value a specified parameter.
static java.lang.String getTagBody(javax.servlet.jsp.tagext.BodyContent bodyContent)
          Returns the body of a tag.
static java.lang.String getTagBody(javax.servlet.jsp.tagext.BodyContent bodyContent, boolean trim)
          Returns the body of a tag.
static boolean isValidString(java.lang.String stringValue)
          Validates a string value by insuring it is not null or empty.
static boolean isValidString(java.lang.String stringValue, boolean trim)
          Validates a string value by insuring it is not null or empty.
static javax.servlet.jsp.JspTagException misplacedError(java.lang.String tag)
          Returns the default tag misplaced (not in valid container) error exception.
static javax.servlet.jsp.JspTagException misplacedError(java.lang.String tag, java.lang.String container)
          Returns the default tag misplaced (not in container) error exception.
static java.lang.String nameValuePair(java.lang.String name, java.lang.String value)
          Builds name=value pair with URL encoding.
static javax.servlet.jsp.JspTagException nestedException(java.lang.String msg, java.lang.Exception old)
          Returns a nested exception.
static javax.servlet.jsp.JspTagException outputError(java.lang.String tag, java.lang.Exception e)
          Returns the default tag output error exception.
static java.lang.String requestParamsToUrl(javax.servlet.http.HttpServletRequest request, java.lang.String remove)
          Converts the request's parameter names/values into ampersand-delimited and URL-encoded name/value pairs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CACHE_PARAM

public static final java.lang.String CACHE_PARAM
The name of the cache request parameter.

See Also:
Constant Field Values

FILTER_PARAM

public static final java.lang.String FILTER_PARAM
The name of the filter request parameter.

See Also:
Constant Field Values

GOOGLE_PROXY_HOST

public static final java.lang.String GOOGLE_PROXY_HOST
The HTTP proxy host.

See Also:
Constant Field Values

GOOGLE_PROXY_PASSWORD

public static final java.lang.String GOOGLE_PROXY_PASSWORD
The HTTP proxy password.

See Also:
Constant Field Values

GOOGLE_PROXY_PORT

public static final java.lang.String GOOGLE_PROXY_PORT
The HTTP proxy port.

See Also:
Constant Field Values

GOOGLE_PROXY_USERNAME

public static final java.lang.String GOOGLE_PROXY_USERNAME
The HTTP proxy username.

See Also:
Constant Field Values

GOOGLE_SEARCH_BEAN

public static final java.lang.String GOOGLE_SEARCH_BEAN
The name of the Google Search bean attribute.

See Also:
Constant Field Values

IE_PARAM

public static final java.lang.String IE_PARAM
The name of the input encoding context parameter.

See Also:
Constant Field Values

KEY_CONTEXT_PARAM

public static final java.lang.String KEY_CONTEXT_PARAM
The name of the key context parameter.

See Also:
Constant Field Values

KEY_PARAM

public static final java.lang.String KEY_PARAM
The name of the key request parameter.

See Also:
Constant Field Values

LR_PARAM

public static final java.lang.String LR_PARAM
The name of the language restrict context parameter.

See Also:
Constant Field Values

MAX_RESULTS_PARAM

public static final java.lang.String MAX_RESULTS_PARAM
The name of the maxResults request parameter.

See Also:
Constant Field Values

OE_PARAM

public static final java.lang.String OE_PARAM
The name of the output encoding context parameter.

See Also:
Constant Field Values

QUERY_PARAM

public static final java.lang.String QUERY_PARAM
The name of the query request parameter.

See Also:
Constant Field Values

RESTRICT_PARAM

public static final java.lang.String RESTRICT_PARAM
The name of the restrict context parameter.

See Also:
Constant Field Values

SAFE_SEARCH_PARAM

public static final java.lang.String SAFE_SEARCH_PARAM
The name of the safeSearch context parameter.

See Also:
Constant Field Values

SITE_PARAM

public static final java.lang.String SITE_PARAM
The name of the site context parameter.

See Also:
Constant Field Values

START_PARAM

public static final java.lang.String START_PARAM
The name of the start request parameter.

See Also:
Constant Field Values

TYPE_PARAM

public static final java.lang.String TYPE_PARAM
The name of the (file) type request parameter.

See Also:
Constant Field Values
Constructor Detail

TagUtility

protected TagUtility()
Protected constructor to disable instantiation.

Method Detail

getTagBody

public static final java.lang.String getTagBody(javax.servlet.jsp.tagext.BodyContent bodyContent)
Returns the body of a tag.

Parameters:
bodyContent - The body.
Returns:
The tag body string or null.

getTagBody

public static final java.lang.String getTagBody(javax.servlet.jsp.tagext.BodyContent bodyContent,
                                                boolean trim)
Returns the body of a tag.

Parameters:
bodyContent - The body.
trim - Trim the body if true
Returns:
The tag body string or null.

isValidString

public static final boolean isValidString(java.lang.String stringValue,
                                          boolean trim)
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.

Parameters:
stringValue - The String value.
trim - The trim flag.
Returns:
true if valid, false if not.

isValidString

public static final boolean isValidString(java.lang.String stringValue)
Validates a string value by insuring it is not null or empty.

Parameters:
stringValue - The String value.
Returns:
true if valid, false if not.

getGoogleSearchBean

public static GoogleSearchBean getGoogleSearchBean(javax.servlet.jsp.PageContext pageContext)
Returns the GoogleSearchBean attribute using the default bean name.

Parameters:
pageContext - The page context.
Returns:
The default Google search bean.

getParameter

public static java.lang.String getParameter(javax.servlet.ServletRequest request,
                                            java.lang.String paramName)
Returns the value a specified parameter.

Parameters:
request - The ServletRequest object
paramName - The parameter name String value.
Returns:
The parameter value or null.

buildRefLink

public static final java.lang.String buildRefLink(java.lang.String url,
                                                  java.lang.String body,
                                                  java.lang.String target,
                                                  java.lang.String style,
                                                  java.lang.String css)
Builds a HTML reference link:

For example: <a href="url" class="css" style="style" target="target">body</a>.

Parameters:
url - The reference URL.
body - The link body text.
target - The link target.
style - The link CSS style.
css - The link CSS class.
Returns:
A HTML reference link.

misplacedError

public static final javax.servlet.jsp.JspTagException misplacedError(java.lang.String tag,
                                                                     java.lang.String container)
Returns the default tag misplaced (not in container) error exception.

Parameters:
tag - The tag name.
container - The container name.
Returns:
The default misplaced error exception.

misplacedError

public static final javax.servlet.jsp.JspTagException misplacedError(java.lang.String tag)
Returns the default tag misplaced (not in valid container) error exception.

Parameters:
tag - The tag name.
Returns:
The default misplaced error exception.

nameValuePair

public static final java.lang.String nameValuePair(java.lang.String name,
                                                   java.lang.String value)
Builds name=value pair with URL encoding.

Parameters:
name - The name string.
value - The value string.
Returns:
The name=value pair.

nestedException

public static final javax.servlet.jsp.JspTagException nestedException(java.lang.String msg,
                                                                      java.lang.Exception old)
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

Parameters:
msg - The new exception message.
old - The old exception object.
Returns:
A nested exception.

outputError

public static final javax.servlet.jsp.JspTagException outputError(java.lang.String tag,
                                                                  java.lang.Exception e)
Returns the default tag output error exception.

Parameters:
tag - The tag name.
e - The caught exception.
Returns:
The default tag output error exception.

requestParamsToUrl

public static final java.lang.String requestParamsToUrl(javax.servlet.http.HttpServletRequest request,
                                                        java.lang.String remove)
Converts the request's parameter names/values into ampersand-delimited and URL-encoded name/value pairs.

Parameters:
request - The servlet request object.
remove - The parameter to be removed.
Returns:
The name/value pairs.