Package org.faceless.publisher.type
Class RegexEgressFilter
java.lang.Object
org.faceless.publisher.type.RegexEgressFilter
- All Implemented Interfaces:
EgressFilter
An implementation of
EgressFilter
which works on regluar expressions.
A list of patterns can be supplied, along with replacement patterns. This can
be used to replace HTTP with HTTPS, for example, or to disallow access to files.
Here's an example showing that.
RegexEgressFilter f = new RegexEgressFilter("nofiles-and-https");
f.add(null, "^file:", null);
f.add(null, Pattern.compile("^http:(.*)"), "https:$1);
This can be set on the ReportFactory via ReportFactory.setEgressFilter(org.faceless.publisher.type.EgressFilter)
-
Field Summary
-
Constructor Summary
ConstructorDescriptionRegexEgressFilter
(Pattern base, Pattern search, String replace) Create a new RegexEgressFilter to match against the URL, and the replacement value to use -
Method Summary
Modifier and TypeMethodDescriptionReturn the "base" pattern, which may be null to match everythingReturn the "replace" pattern, or null if the URL is disallowed on match.Return the "uri" patternThis method will be supplied with the URL about to be loaded, and the base URL of the Document loading it.toString()
-
Constructor Details
-
RegexEgressFilter
Create a new RegexEgressFilter to match against the URL, and the replacement value to use- Parameters:
base
- the pattern to match against the base uri, or null to match all of themsearch
- the pattern to match against the urireplace
- the replacement pattern, or null to delete the URL (and disallow access)
-
-
Method Details
-
getBasePattern
Return the "base" pattern, which may be null to match everything -
getSearchPattern
Return the "uri" pattern -
getReplacement
Return the "replace" pattern, or null if the URL is disallowed on match. -
rewrite
Description copied from interface:EgressFilter
This method will be supplied with the URL about to be loaded, and the base URL of the Document loading it. It can return the URL as it is to load it, a rewritten URL to load a new resource instead, ornull
to disallow the load.- Specified by:
rewrite
in interfaceEgressFilter
- Parameters:
uri
- the destination URLbase
- the URL of the document, or null if we're testing the base URL of the document- Returns:
- the URL to load, or
null
to disallow access
-
toString
-