code: boolean matches(String urlPattern)
     {
        // 2 or 5
        if (type == PatternType.DEFAULT || type == PatternType.THE_PATH_PREFIX)
           return true;
  
        // 4, extension pattern
        if (type == PatternType.EXTENSION && urlPattern.endsWith(ext))
           return true;
  
        // 3. a path-prefix pattern
        if (type == PatternType.PATH_PREFIX)
        {
           if (urlPattern.regionMatches(0, pattern, 0, length - 2))
           {
              int last = length - 2;
              if (urlPattern.length() > last && urlPattern.charAt(last) != '/')
                 return false;
              return true;
           }
           return false;
        }
  
        // 1. pattern values are String equivalent for exact pattern
        if (pattern.equals(urlPattern))
           return true;
  
        return false;
     }
docs: <p>
  Checks if this pattern matches the specified pattern String.
  </p>
  
  <p>
  The matching rules from the {@code WebResourcePermission#implies}:
  <ol>
  <li>their pattern values are {@code String} equivalent, or</li>
  <li>this pattern is the path-prefix pattern "/*", or</li>
  <li>this pattern is a path-prefix pattern (that is, it starts with "/" and ends with "/*") and the argument
  pattern starts with the substring of this pattern, minus its last 2 characters, and the next character of the
  argument pattern, if there is one, is "/", or</li>
  <li>this pattern is an extension pattern (that is, it starts with "*.") and the argument pattern ends with this
  pattern, or 5. the reference pattern is the special default pattern, "/", which matches all argument patterns.</li>
  </ol>
  </p>
  
  @param urlPattern
  a {@code String} representing the pattern to which this pattern is to be matched.
  @return {@code true} if this pattern matches the specified {@code URLPattern}; {@code false} otherwise.