|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.shale.application.AbstractRegExpFilter
public abstract class AbstractRegExpFilter
Convenience base class for Command
implementations that
perform regular expression matching against a set of zero or more
patterns. The default Command
implementation will perform
the following algorithm.
value()
.null
, call reject()
and return true
to indicate that request procesing is
complete.accept()
and return
false
to indicate request processing should continue.reject()
and return
true
to indicate that request processing is complete.reject()
and return
true
to indicate that request processing is complete.accept()
and return false
to indicate
that request processing should continue.USAGE NOTE: - See the class JavaDocs for
java.util.regex.Pattern
for the valid syntax for regular
expression patterns supported by this command.
USAGE NOTE: - Commands based on this class will only
be effective if used before the regular filter chain is processed. In
other words, you should invoke it as part of a preprocess
chain in the shale
catalog.
Field Summary |
---|
Fields inherited from interface org.apache.commons.chain.Command |
---|
CONTINUE_PROCESSING, PROCESSING_COMPLETE |
Constructor Summary | |
---|---|
AbstractRegExpFilter()
|
Method Summary | |
---|---|
protected void |
accept(ShaleWebContext context)
Perform whatever processing is necessary to mark this request as being accepted. |
boolean |
execute(Context context)
Perform the matching algorithm described in our class Javadocs against the value returned by the value() method. |
String |
getExcludes()
Return the comma-delimited regular expresson patterns to exclude remote host names that match, if any; otherwise, return null . |
String |
getIncludes()
Return the comma-delimited regular expresson patterns to include remote host names that match, if any; otherwise, return null . |
protected Pattern[] |
getIncludesPatterns()
Returns an array of regular expression patterns for the includes list. |
protected boolean |
matches(String expr,
Pattern[] patterns,
boolean unrestricted)
Match the specified expression against the specified precompiled patterns. |
protected void |
reject(ShaleWebContext context)
Perform whatever processing is necessary to mark this request as being rejected. |
void |
setExcludes(String excludes)
Set the comma-delimited regular expression patterns to exclude remote host names that match, if any; or null for no
restrictions. |
void |
setIncludes(String includes)
Set the comma-delimited regular expression patterns to include remote host names that match, if any; or null for no
restrictions. |
protected abstract String |
value(ShaleWebContext context)
Return the value, from the specified context, that should be used to match against the configured exclude and include patterns. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AbstractRegExpFilter()
Method Detail |
---|
protected Pattern[] getIncludesPatterns()
Returns an array of regular expression patterns for the includes list.
public String getExcludes()
Return the comma-delimited regular expresson patterns to exclude
remote host names that match, if any; otherwise, return
null
.
public void setExcludes(String excludes)
Set the comma-delimited regular expression patterns to exclude
remote host names that match, if any; or null
for no
restrictions.
excludes
- New exclude pattern(s)public String getIncludes()
Return the comma-delimited regular expresson patterns to include
remote host names that match, if any; otherwise, return
null
.
public void setIncludes(String includes)
Set the comma-delimited regular expression patterns to include
remote host names that match, if any; or null
for no
restrictions.
includes
- New include pattern(s)public boolean execute(Context context) throws Exception
Perform the matching algorithm described in our class Javadocs
against the value returned by the value()
method.
execute
in interface Command
context
- ShaleWebContext
for this request
Exception
- if an error occursprotected void accept(ShaleWebContext context) throws Exception
Perform whatever processing is necessary to mark this request as being accepted. The default implementation does nothing.
context
- Context
for the current request
Exception
- if an error occursprotected void reject(ShaleWebContext context) throws Exception
Perform whatever processing is necessary to mark this request as
being rejected. The default implementation returns a status code
of HttpServletResponse.SC_FORBIDDEN
.
context
- Context
for the current request
Exception
- if an error occursprotected abstract String value(ShaleWebContext context)
Return the value, from the specified context, that should be used to match against the configured exclude and include patterns. This method must be implemented by a concrete subclass.
context
- Context
for the current requestprotected boolean matches(String expr, Pattern[] patterns, boolean unrestricted)
Match the specified expression against the specified precompiled
patterns. If there are no patterns, return the specified unrestricted
return value; otherwise, return true
if the expression
matches one of the patterns, or false
otherwise.
expr
- Expression to be testedpatterns
- Array of Pattern
to be tested againstunrestricted
- Result to be returned if there are no matches
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |