Class PathPattern

java.lang.Object
org.refcodes.internal.PathPattern

public class PathPattern extends Object
The PathPattern provides Pattern instances to be applied on paths.

Note: This class is intended for internal use only as there is an official PathMatcher type in the artifact refcodes-matcher which provides official path matching functionality and where this functionality is tested.

  • Constructor Details

    • PathPattern

      public PathPattern(String aPath, char aDelimiter)
      This constructor builds a regular expression for matching paths: The resulting Pattern matches its ANT like path pattern against the path provided. The Pattern implements the following rules from the ANT path pattern to the path provided: A single asterisk ("*") matches zero or more characters within a path name. A double asterisk ("**") matches zero or more characters across directory levels. A question mark ("?") matches exactly one character within a path name. The single asterisk ("*"), the double asterisk ("**") and the question mark ("?") we refer to as wildcards: You may name a wildcard by prefixing it with "${someWildcardName}=". For example a named wildcard may look as follows: "${arg1}=*" or "${arg2}=**" or "${arg3}=?". A placeholder "${arg1}" with no wildcard assignment "=" is equivalent to "${arg1}=*".

      The regular expression pattern construction is inspired by: "http://stackoverflow.com/questions/33171025/regex-matching-an-ant-path"

      Note: This class is the internal implementation of the PathMatcher type in the artifact refcodes-matcher!

      Parameters:
      aPath - the path
      aDelimiter - The delimiter separating the path elements from each other and must not be one of the following chars: '?', '*', '|'.
      Throws:
      IllegalArgumentException - thrown in case the delimiter provided was one of the following chars: '?', '*', '|'.
  • Method Details

    • getPattern

      public Pattern getPattern()
      Returns the generated Pattern.
      Returns:
      The according Pattern.
    • getWildcardNames

      public String[] getWildcardNames()
      Returns an array of the detected wildcard names.
      Returns:
      The according wildcard names or null if there were no named wildcards