org.tuckey.web.filters.urlrewrite
Class RuleBase

java.lang.Object
  extended by org.tuckey.web.filters.urlrewrite.RuleBase
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
NormalRule, OutboundRule

public class RuleBase
extends java.lang.Object
implements Runnable

Defines a rule that can be run against an incoming request.

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

Field Summary
static java.lang.String DEFAULT_MATCH_TYPE
           
protected  java.util.List errors
           
protected  java.lang.String from
           
protected  int id
           
protected  boolean initialised
           
static java.lang.String MATCH_TYPE_WILDCARD
           
protected  java.lang.String name
           
protected  java.util.List setAttributes
           
protected  java.lang.String to
           
protected  boolean valid
           
 
Constructor Summary
RuleBase()
          Constructor.
 
Method Summary
 void addCondition(Condition condition)
          Will add the condition to the List.
protected  void addError(java.lang.String s)
           
 void addRun(Run run)
          Will add the run to the List.
 void addSetAttribute(SetAttribute setAttribute)
          Will add the SetAttribute to the List.
 void destroy()
          Destroy the rule gracefully.
 java.util.List getConditions()
          Will get the List of conditions.
 java.lang.String getDisplayName()
           
 java.util.List getErrors()
          Will get the list of errors.
 java.lang.String getFrom()
          Will get the contents of the from element.
 java.lang.String getFullDisplayName()
           
 int getId()
          Will get the rule's id.
 java.lang.String getMatchType()
           
 java.lang.String getName()
           
 java.lang.String getNote()
           
 java.util.List getRuns()
           
 java.util.List getSetAttributes()
           
 java.lang.String getTo()
          Get to.
 boolean initialise(javax.servlet.ServletContext context)
          Will initialise the rule.
 boolean isEnabled()
           
 boolean isFilter()
           
 boolean isFromCaseSensitive()
           
 boolean isLast()
          Is this rule last?.
 boolean isMatchTypeWildcard()
           
 boolean isNoSubstitution()
           
 boolean isToContainsBackReference()
           
 boolean isToContainsFunction()
           
 boolean isToContainsVariable()
           
 boolean isValid()
           
protected  RuleExecutionOutput matchesBase(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 setEnabled(boolean enabled)
           
 void setFrom(java.lang.String from)
          Will set from, usually called by Digester.
 void setFromCaseSensitive(boolean fromCaseSensitive)
           
 void setId(int id)
           
 void setMatchType(java.lang.String matchType)
           
 void setName(java.lang.String name)
           
 void setNote(java.lang.String note)
           
 void setTo(java.lang.String to)
          Will set the to, usually called by Digester.
 void setToLast(java.lang.String lastStr)
          Set to type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

protected int id

initialised

protected boolean initialised

valid

protected boolean valid

name

protected java.lang.String name

from

protected java.lang.String from

to

protected java.lang.String to

errors

protected final java.util.List errors

setAttributes

protected final java.util.List setAttributes

MATCH_TYPE_WILDCARD

public static final java.lang.String MATCH_TYPE_WILDCARD
See Also:
Constant Field Values

DEFAULT_MATCH_TYPE

public static final java.lang.String DEFAULT_MATCH_TYPE
See Also:
Constant Field Values
Constructor Detail

RuleBase

public RuleBase()
Constructor.

Method Detail

matchesBase

protected RuleExecutionOutput matchesBase(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.

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

getDisplayName

public java.lang.String getDisplayName()

initialise

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

Returns:
true on success

isMatchTypeWildcard

public boolean isMatchTypeWildcard()

isToContainsBackReference

public boolean isToContainsBackReference()

isToContainsVariable

public boolean isToContainsVariable()

isToContainsFunction

public boolean isToContainsFunction()

getFullDisplayName

public java.lang.String getFullDisplayName()

addError

protected void addError(java.lang.String s)

destroy

public void destroy()
Destroy the rule gracefully.


getFrom

public java.lang.String getFrom()
Will get the contents of the from element.

Returns:
the contents of the from element

setFrom

public void setFrom(java.lang.String from)
Will set from, usually called by Digester.

Parameters:
from - the url to match from

setTo

public void setTo(java.lang.String to)
Will set the to, usually called by Digester.

Parameters:
to - url for redirecting/passing through to

setToLast

public void setToLast(java.lang.String lastStr)
Set to type. note, it will default to false.

Parameters:
lastStr - true or false

isLast

public boolean isLast()
Is this rule last?.

Returns:
boolean

getTo

public java.lang.String getTo()
Get to.

Returns:
String

getId

public int getId()
Will get the rule's id.

Returns:
int

getErrors

public java.util.List getErrors()
Will get the list of errors.

Returns:
the list of errors

addCondition

public void addCondition(Condition condition)
Will add the condition to the List.

Parameters:
condition - The Condition object to add

addRun

public void addRun(Run run)
Will add the run to the List.

Specified by:
addRun in interface Runnable
Parameters:
run - The Run object to add

addSetAttribute

public void addSetAttribute(SetAttribute setAttribute)
Will add the SetAttribute to the List.

Parameters:
setAttribute - The SetAttribute object to add

getSetAttributes

public java.util.List getSetAttributes()

getConditions

public java.util.List getConditions()
Will get the List of conditions.

Returns:
the List of Condition objects

getName

public java.lang.String getName()

setName

public void setName(java.lang.String name)

getNote

public java.lang.String getNote()

setNote

public void setNote(java.lang.String note)

isEnabled

public boolean isEnabled()

setEnabled

public void setEnabled(boolean enabled)

setId

public void setId(int id)

isFromCaseSensitive

public boolean isFromCaseSensitive()

setFromCaseSensitive

public void setFromCaseSensitive(boolean fromCaseSensitive)

getRuns

public java.util.List getRuns()

isValid

public boolean isValid()

getMatchType

public java.lang.String getMatchType()

setMatchType

public void setMatchType(java.lang.String matchType)

isFilter

public boolean isFilter()

isNoSubstitution

public boolean isNoSubstitution()