net.sf.j2ep.rules
Class CompositeRule

java.lang.Object
  extended by net.sf.j2ep.rules.BaseRule
      extended by net.sf.j2ep.rules.CompositeRule
All Implemented Interfaces:
Rule

public class CompositeRule
extends BaseRule

This rule consists of many other rules using the composite design pattern. The rule is matches if all the included rules are matched.

Author:
Anders Nyman

Constructor Summary
CompositeRule()
          Empty constructor, will only create the list of rules.
 
Method Summary
 void addRule(Rule rule)
          Used to add a rule to the list.
 boolean matches(HttpServletRequest request)
          Iterates over all the rules in the list checking that they all match.
 java.lang.String process(java.lang.String uri)
          Process all the rules in the list, allowing them all to change the URI.
 java.lang.String revert(java.lang.String uri)
          Will do the opposite of process, that is revert all URIs to there default value.
 java.lang.String toString()
          Returns a String representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CompositeRule

public CompositeRule()
Empty constructor, will only create the list of rules.

Method Detail

addRule

public void addRule(Rule rule)
Used to add a rule to the list.

Parameters:
rule - The rule to be added

matches

public boolean matches(HttpServletRequest request)
Iterates over all the rules in the list checking that they all match.

Parameters:
request - The request
Returns:
true if all the rules match or there are no rules, false otherwise
See Also:
net.sf.j2ep.model.Rule#matches(javax.servlet.http.HttpServletRequest)

process

public java.lang.String process(java.lang.String uri)
Process all the rules in the list, allowing them all to change the URI.

Specified by:
process in interface Rule
Overrides:
process in class BaseRule
Parameters:
uri - URI to be processed
Returns:
The final URI
See Also:
Rule.process(java.lang.String)

revert

public java.lang.String revert(java.lang.String uri)
Will do the opposite of process, that is revert all URIs to there default value. This method will call all rules in the rule list and call revert on them. Rules are called in a reversed order in comparison with process.

Specified by:
revert in interface Rule
Overrides:
revert in class BaseRule
Parameters:
uri - URI to be reverted
Returns:
The reverted URI
See Also:
Rule.revert(java.lang.String)

toString

public java.lang.String toString()
Returns a String representation of this object.

Overrides:
toString in class BaseRule
Returns:
A string representation