Class URLPattern


  • class URLPattern
    extends java.lang.Object

    The representation of a URLPattern in the WebResourcePermission and WebUserDataPermission URLPatternSpecs.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  URLPattern.PatternType  
    • Constructor Summary

      Constructors 
      Constructor Description
      URLPattern​(java.lang.String pattern)
      Creates a URLPattern instance from the specified pattern String.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      (package private) java.lang.String getPattern()
      Obtains the String representation of this pattern.
      int hashCode()  
      (package private) boolean isDefault()
      Checks if this pattern is a default (i.e.
      (package private) boolean isExact()
      Checks if this pattern is an exact pattern.
      (package private) boolean isExtension()
      Checks if this pattern is an extension (i.e.
      (package private) boolean isPrefix()
      Checks if this pattern is a prefix (i.e.
      (package private) boolean matches​(java.lang.String urlPattern)
      Checks if this pattern matches the specified pattern String.
      (package private) boolean matches​(URLPattern url)
      Checks if this pattern matches the specified URLPattern.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • pattern

        private java.lang.String pattern
      • ext

        private java.lang.String ext
      • length

        private int length
    • Constructor Detail

      • URLPattern

        URLPattern​(java.lang.String pattern)

        Creates a URLPattern instance from the specified pattern String.

        Parameters:
        pattern - the pattern String.
    • Method Detail

      • matches

        boolean matches​(URLPattern url)

        Checks if this pattern matches the specified URLPattern.

        The matching rules from the WebResourcePermission#implies:

        1. their pattern values are String equivalent, or
        2. this pattern is the path-prefix pattern "/*", or
        3. 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
        4. 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.

        Parameters:
        url - the URLPattern instance to which this pattern is to be matched.
        Returns:
        true if this pattern matches the specified URLPattern; false otherwise.
      • matches

        boolean matches​(java.lang.String urlPattern)

        Checks if this pattern matches the specified pattern String.

        The matching rules from the WebResourcePermission#implies:

        1. their pattern values are String equivalent, or
        2. this pattern is the path-prefix pattern "/*", or
        3. 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
        4. 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.

        Parameters:
        urlPattern - a String representing the pattern to which this pattern is to be matched.
        Returns:
        true if this pattern matches the specified URLPattern; false otherwise.
      • getPattern

        java.lang.String getPattern()

        Obtains the String representation of this pattern.

        Returns:
        this pattern's String representation.
      • isDefault

        boolean isDefault()

        Checks if this pattern is a default (i.e. '/') pattern.

        Returns:
        true if this is a default pattern; false otherwise.
      • isExact

        boolean isExact()

        Checks if this pattern is an exact pattern.

        Returns:
        true if this is an exact pattern; false otherwise.
      • isExtension

        boolean isExtension()

        Checks if this pattern is an extension (i.e. '*.xxx') pattern.

        Returns:
        true if this is an extension pattern; false otherwise.
      • isPrefix

        boolean isPrefix()

        Checks if this pattern is a prefix (i.e. '/*' or '/.../*') pattern.

        Returns:
        true if this is a prefix pattern; false otherwise.
      • hashCode

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

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object