Package org.jppf.job

Class RegexJobSelector

java.lang.Object
org.jppf.job.RegexJobSelector
All Implemented Interfaces:
Serializable, JobSelector

public class RegexJobSelector extends Object
Performs a regular expression match on either a job name or a job metadata value specified by its key. If the specified metadata key is null, is not part of a job's metadata, or is not a string, then this selector's accepts() method will return false.
Since:
6.2
Author:
Laurent Cohen
See Also:
  • Constructor Details

    • RegexJobSelector

      public RegexJobSelector(String regex)
      Initialize this selector with a regular expression to match against job names.
      This constructor is equivalent to calling new RegexJobSelector(null, regex, 0).
      Parameters:
      regex - the regular expression to match against.
    • RegexJobSelector

      public RegexJobSelector(String regex, int flags)
      Initialize this selector with a regular expression to match against job names.
      This constructor is equivalent to calling new RegexJobSelector(null, regex, flags).
      Parameters:
      regex - the regular expression to match against.
      flags - the regex flags, as defined in Pattern.
    • RegexJobSelector

      public RegexJobSelector(Object key, String regex)
      Initialize this selector with a job metadata key and a regular expression.
      This constructor is equivalent to calling new RegexJobSelector(key, regex, 0).
      Parameters:
      key - the metadata key of the value to compare with.
      regex - the regular expression to match against.
    • RegexJobSelector

      public RegexJobSelector(Object key, String regex, int flags) throws IllegalArgumentException, PatternSyntaxException
      Initialize this selector with a job metadata key and a regular expression.
      This constructor will compile the regex into a Pattern instance, and throw one of the declared exceptions if that fails.
      Parameters:
      key - the metadata key of the value to compare with.
      regex - the regular expression to match against.
      flags - the regex flags, as defined in Pattern.
      Throws:
      IllegalArgumentException - if the flags contain undefined bits.
      PatternSyntaxException - if the regex syntax is invalid.
  • Method Details

    • accepts

      public boolean accepts(JPPFDistributedJob job)
      Description copied from interface: JobSelector
      Determine whether the specified job is accepted by this selector.
      Parameters:
      job - the job to check.
      Returns:
      true if the job is acepted, false otherwise.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object