new InterestFilter(prefix, regexFilter)
An InterestFilter holds a Name prefix and optional regex match expression for
use in Face.setInterestFilter.
Create an InterestFilter to match any Interest whose name starts with the
given prefix. If the optional regexFilter is provided then the remaining
components match the regexFilter regular expression as described in doesMatch.
Parameters:
Name | Type | Description |
---|---|---|
prefix |
InterestFilter | Name | string | If prefix is another InterestFilter copy its values. If prefix is a Name then this makes a copy of the Name. Otherwise this creates a Name from the URI string. |
regexFilter |
string | (optional) The regular expression for matching the remaining name components. |
- Source:
Methods
(static) makePattern(regexFilter) → {string}
If regexFilter doesn't already have them, add ^ to the beginning and $ to
the end since these are required by NdnRegexTopMatcher.
Parameters:
Name | Type | Description |
---|---|---|
regexFilter |
string | The regex filter. |
- Source:
Returns:
The regex pattern with ^ and $.
- Type
- string
doesMatch(name) → {boolean}
Check if the given name matches this filter. Match if name starts with this
filter's prefix. If this filter has the optional regexFilter then the
remaining components match the regexFilter regular expression.
For example, the following InterestFilter:
InterestFilter("/hello", "<>+")
will match all Interests, whose name has the prefix `/hello` which is
followed by a component `world` and has at least one more component after it.
Examples:
/hello/world/!
/hello/world/x/y/z
Note that the regular expression will need to match all remaining components
(e.g., there are implicit heading `^` and trailing `$` symbols in the
regular expression).
Parameters:
Name | Type | Description |
---|---|---|
name |
Name | The name to check against this filter. |
- Source:
Returns:
True if name matches this filter, otherwise false.
- Type
- boolean
getPrefix() → {Name}
Get the prefix given to the constructor.
- Source:
Returns:
The prefix Name which you should not modify.
- Type
- Name
getRegexFilter() → {string}
Get the regex filter. This is only valid if hasRegexFilter() is true.
- Source:
Returns:
The regular expression for matching the remaining name
components.
- Type
- string
hasRegexFilter() → {boolean}
Check if a regexFilter was supplied to the constructor.
- Source:
Returns:
True if a regexFilter was supplied to the constructor.
- Type
- boolean