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 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 String DEFAULT_MATCH_TYPE
           
protected  List errors
           
protected  String from
           
protected  int id
           
protected  boolean initialised
           
static String MATCH_TYPE_WILDCARD
           
protected  String name
           
protected  List setAttributes
           
protected  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(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.
 List getConditions()
          Will get the List of conditions.
 String getDisplayName()
           
 List getErrors()
          Will get the list of errors.
 String getFrom()
          Will get the contents of the from element.
 String getFullDisplayName()
           
 int getId()
          Will get the rule's id.
 String getMatchType()
           
 String getName()
           
 String getNote()
           
 List getRuns()
           
 javax.servlet.ServletContext getServletContext()
           
 List getSetAttributes()
           
 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(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(String from)
          Will set from, usually called by Digester.
 void setFromCaseSensitive(boolean fromCaseSensitive)
           
 void setId(int id)
           
 void setMatchType(String matchType)
           
 void setName(String name)
           
 void setNote(String note)
           
 void setTo(String to)
          Will set the to, usually called by Digester.
 void setToLast(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 String name

from

protected String from

to

protected String to

errors

protected final List errors

setAttributes

protected final List setAttributes

MATCH_TYPE_WILDCARD

public static final String MATCH_TYPE_WILDCARD
See Also:
Constant Field Values

DEFAULT_MATCH_TYPE

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

RuleBase

public RuleBase()
Constructor.

Method Detail

matchesBase

protected RuleExecutionOutput matchesBase(String url,
                                          javax.servlet.http.HttpServletRequest hsRequest,
                                          javax.servlet.http.HttpServletResponse hsResponse,
                                          RuleChain chain)
                                   throws IOException,
                                          javax.servlet.ServletException,
                                          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:
IOException
javax.servlet.ServletException
InvocationTargetException

getDisplayName

public 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 String getFullDisplayName()

addError

protected void addError(String s)

destroy

public void destroy()
Destroy the rule gracefully.


getFrom

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

Returns:
the contents of the from element

setFrom

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

Parameters:
from - the url to match from

setTo

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

Parameters:
to - url for redirecting/passing through to

setToLast

public void setToLast(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 String getTo()
Get to.

Returns:
String

getId

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

Returns:
int

getErrors

public 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 List getSetAttributes()

getConditions

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

Returns:
the List of Condition objects

getName

public String getName()

setName

public void setName(String name)

getNote

public String getNote()

setNote

public void setNote(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 List getRuns()

isValid

public boolean isValid()

getMatchType

public String getMatchType()

setMatchType

public void setMatchType(String matchType)

isFilter

public boolean isFilter()

isNoSubstitution

public boolean isNoSubstitution()

getServletContext

public javax.servlet.ServletContext getServletContext()


Copyright © 2001-2012 Paul Tuckey. All Rights Reserved.