net.sf.j2ep.rules
Class DirectoryRule

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

public class DirectoryRule
extends BaseRule

A rule that will check the start of the URI for a specifed starting directory/directories. If the directory is at the start this rule matches. The process method will then remove this directory from the URI, making it easy to map various servers to directory structures. If one needs some more advanced types of rewriting use the RewriteRule.

Author:
Anders Nyman

Constructor Summary
DirectoryRule()
           
 
Method Summary
 java.lang.String getDirectory()
          Returns the directory structure that this rule will match on.
 boolean matches(HttpServletRequest request)
          Will see if the directory for the incoming URI is the same as this rule is set to match on.
 java.lang.String process(java.lang.String uri)
          Removes the specified mapping directory from the URI.
 java.lang.String revert(java.lang.String uri)
          Does the opposite of process. revert(String URI) will add the directory specified to the start of the incoming URI.
 void setDirectory(java.lang.String directory)
          Sets the directory structure that will be mapped to a specified server.
 
Methods inherited from class net.sf.j2ep.rules.BaseRule
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DirectoryRule

public DirectoryRule()
Method Detail

setDirectory

public void setDirectory(java.lang.String directory)
Sets the directory structure that will be mapped to a specified server.

Parameters:
directory - The directory string

getDirectory

public java.lang.String getDirectory()
Returns the directory structure that this rule will match on.

Returns:
The directory string

matches

public boolean matches(HttpServletRequest request)
Will see if the directory for the incoming URI is the same as this rule is set to match on.

Parameters:
request - The request
Returns:
true if the request is matched, otherwise false
See Also:
net.sf.j2ep.model.Rule#matches(javax.servlet.http.HttpServletRequest)

process

public java.lang.String process(java.lang.String uri)
Removes the specified mapping directory from 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)
Does the opposite of process. revert(String URI) will add the directory specified to the start of the incoming URI.

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)