org.tuckey.web.filters.urlrewrite
Class NormalRule

java.lang.Object
  extended by org.tuckey.web.filters.urlrewrite.RuleBase
      extended by org.tuckey.web.filters.urlrewrite.NormalRule
All Implemented Interfaces:
Rule, Runnable

public class NormalRule
extends RuleBase
implements Rule

Defines a rule that can be run against an incoming request. 20040304 - Thanks to Scott Askew for help with concurrency issue with Perl5Compiler and Perl5Matcher.

Version:
$Revision: 36 $ $Date: 2006-09-19 18:32:39 +1200 (Tue, 19 Sep 2006) $
Author:
Paul Tuckey

Field Summary
static short TO_TYPE_FORWARD
           
static short TO_TYPE_PERMANENT_REDIRECT
           
static short TO_TYPE_POST_INCLUDE
           
static short TO_TYPE_PRE_INCLUDE
           
static short TO_TYPE_PROXY
           
static short TO_TYPE_REDIRECT
           
static short TO_TYPE_TEMPORARY_REDIRECT
           
 short toType
           
 
Fields inherited from class org.tuckey.web.filters.urlrewrite.RuleBase
DEFAULT_MATCH_TYPE, errors, from, id, initialised, MATCH_TYPE_WILDCARD, name, setAttributes, to, valid
 
Constructor Summary
NormalRule()
          Constructor.
 
Method Summary
protected  void addError(java.lang.String s)
           
 java.lang.String getDisplayName()
           
 java.lang.String getFullDisplayName()
           
 java.lang.String getName()
           
 java.lang.String getToContextStr()
           
 javax.servlet.ServletContext getToServletContext()
           
 java.lang.String getToType()
          Will get to type ie redirect or passthrough.
 boolean initialise(javax.servlet.ServletContext context)
          Will initialise the rule.
 boolean isEncodeToUrl()
           
 RewrittenUrl matches(java.lang.String url, javax.servlet.http.HttpServletRequest hsRequest, javax.servlet.http.HttpServletResponse hsResponse)
           
 RewrittenUrl matches(java.lang.String url, javax.servlet.http.HttpServletRequest hsRequest, javax.servlet.http.HttpServletResponse hsResponse, RuleChain chain)
          Will run the rule against the uri and perform action required will return false is not matched otherwise true.
 void setEncodeToUrl(boolean encodeToUrl)
           
 void setToContextStr(java.lang.String toContextStr)
           
 void setToType(java.lang.String toTypeStr)
          Redirect or passthrough, passthrough is the default.
 
Methods inherited from class org.tuckey.web.filters.urlrewrite.RuleBase
addCondition, addRun, addSetAttribute, destroy, getConditions, getErrors, getFrom, getId, getMatchType, getNote, getRuns, getSetAttributes, getTo, isEnabled, isFilter, isFromCaseSensitive, isLast, isMatchTypeWildcard, isNoSubstitution, isToContainsBackReference, isToContainsFunction, isToContainsVariable, isValid, matchesBase, setEnabled, setFrom, setFromCaseSensitive, setId, setMatchType, setName, setNote, setTo, setToLast
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.tuckey.web.filters.urlrewrite.Rule
destroy, getErrors, getId, isFilter, isLast, isValid, setId
 

Field Detail

toType

public short toType

TO_TYPE_REDIRECT

public static final short TO_TYPE_REDIRECT
See Also:
Constant Field Values

TO_TYPE_FORWARD

public static final short TO_TYPE_FORWARD
See Also:
Constant Field Values

TO_TYPE_PERMANENT_REDIRECT

public static final short TO_TYPE_PERMANENT_REDIRECT
See Also:
Constant Field Values

TO_TYPE_TEMPORARY_REDIRECT

public static final short TO_TYPE_TEMPORARY_REDIRECT
See Also:
Constant Field Values

TO_TYPE_PRE_INCLUDE

public static final short TO_TYPE_PRE_INCLUDE
See Also:
Constant Field Values

TO_TYPE_POST_INCLUDE

public static final short TO_TYPE_POST_INCLUDE
See Also:
Constant Field Values

TO_TYPE_PROXY

public static final short TO_TYPE_PROXY
See Also:
Constant Field Values
Constructor Detail

NormalRule

public NormalRule()
Constructor.

Method Detail

matches

public RewrittenUrl matches(java.lang.String url,
                            javax.servlet.http.HttpServletRequest hsRequest,
                            javax.servlet.http.HttpServletResponse hsResponse,
                            RuleChain chain)
                     throws java.io.IOException,
                            javax.servlet.ServletException,
                            java.lang.reflect.InvocationTargetException
Will run the rule against the uri and perform action required will return false is not matched otherwise true.

Specified by:
matches in interface Rule
Parameters:
url -
hsRequest -
Returns:
String of the rewritten url or the same as the url passed in if no match was made
Throws:
java.io.IOException
javax.servlet.ServletException
java.lang.reflect.InvocationTargetException

matches

public RewrittenUrl matches(java.lang.String url,
                            javax.servlet.http.HttpServletRequest hsRequest,
                            javax.servlet.http.HttpServletResponse hsResponse)
                     throws java.io.IOException,
                            javax.servlet.ServletException,
                            java.lang.reflect.InvocationTargetException
Specified by:
matches in interface Rule
Throws:
java.io.IOException
javax.servlet.ServletException
java.lang.reflect.InvocationTargetException

initialise

public boolean initialise(javax.servlet.ServletContext context)
Will initialise the rule.

Specified by:
initialise in interface Rule
Overrides:
initialise in class RuleBase
Returns:
true on success

setToType

public void setToType(java.lang.String toTypeStr)
Redirect or passthrough, passthrough is the default.

Parameters:
toTypeStr - to type string

getToType

public java.lang.String getToType()
Will get to type ie redirect or passthrough.

Returns:
String

addError

protected void addError(java.lang.String s)
Overrides:
addError in class RuleBase

getDisplayName

public java.lang.String getDisplayName()
Specified by:
getDisplayName in interface Rule
Overrides:
getDisplayName in class RuleBase

getName

public java.lang.String getName()
Specified by:
getName in interface Rule
Overrides:
getName in class RuleBase

getFullDisplayName

public java.lang.String getFullDisplayName()
Overrides:
getFullDisplayName in class RuleBase

isEncodeToUrl

public boolean isEncodeToUrl()

setEncodeToUrl

public void setEncodeToUrl(boolean encodeToUrl)

getToContextStr

public java.lang.String getToContextStr()

setToContextStr

public void setToContextStr(java.lang.String toContextStr)

getToServletContext

public javax.servlet.ServletContext getToServletContext()