org.apache.nutch.urlfilter.api

## Class RegexRule

- java.lang.Object
- - org.apache.nutch.urlfilter.api.RegexRule

-     public abstract class RegexRule
      extends java.lang.Object

  A generic regular expression rule.
  Author:
    Jérôme Charron

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `RegexRule(boolean sign, java.lang.String regex)` Constructs a new regular expression rule.
    `protected` | `RegexRule(boolean sign, java.lang.String regex, java.lang.String hostOrDomain)` Constructs a new regular expression rule.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected boolean` | `accept()` Return if this rule is used for filtering-in or out.
    `protected java.lang.String` | `hostOrDomain()` Return if this rule is used for filtering-in or out.
    `protected abstract boolean` | `match(java.lang.String url)` Checks if a url matches this rule.
    `protected java.lang.String` | `regex()` Return if this rule's regex.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### RegexRule

          protected RegexRule(boolean sign,
                              java.lang.String regex)

      Constructs a new regular expression rule.
      Parameters:
        `sign` - specifies if this rule must filter-in or filter-out. A `true` value means that any url matching this rule must be accepted, a `false` value means that any url matching this rule must be rejected.
        `regex` - is the regular expression used for matching (see `match(String)` method).

    - #### RegexRule

          protected RegexRule(boolean sign,
                              java.lang.String regex,
                              java.lang.String hostOrDomain)

      Constructs a new regular expression rule.
      Parameters:
        `sign` - specifies if this rule must filter-in or filter-out. A `true` value means that any url matching this rule must be accepted, a `false` value means that any url matching this rule must be rejected.
        `regex` - is the regular expression used for matching (see `match(String)` method).
        `hostOrDomain` - the host or domain to which this regex belongs

  - ### Method Detail

    - #### accept

          protected boolean accept()

      Return if this rule is used for filtering-in or out.
      Returns:
        `true` if any url matching this rule must be accepted, otherwise `false`.

    - #### hostOrDomain

          protected java.lang.String hostOrDomain()

      Return if this rule is used for filtering-in or out.
      Returns:
        host or domain this regex rule belongs to

    - #### regex

          protected java.lang.String regex()

      Return if this rule's regex.
      Returns:
        this regex

    - #### match

          protected abstract boolean match(java.lang.String url)

      Checks if a url matches this rule.
      Parameters:
        `url` - is the url to check.
      Returns:
        `true` if the specified url matches this rule, otherwise `false`.

Copyright © 2019 The Apache Software Foundation