Class SearchPattern


  • public class SearchPattern
    extends java.lang.Object

    Parses pattern into pieces and provides methods to check whether a certain directory can contain useful files or whether a file matches the pattern.

    Also offers a way to check whether a certain pattern is a super-pattern of this one (any file matching this pattern will always match the super-pattern). isSubPatternOf(SearchPattern)

    Author:
    Sergey.Pak Date: 6/24/13 Time: 7:19 PM
    • Method Detail

      • patternFromString

        @Nullable
        public static SearchPattern patternFromString​(java.lang.String patternString)
        Initializes a pattern, catches wrong patterns and returns null
        Parameters:
        patternString - string to create a pattern from
        Returns:
        SearchPattern, if string is properly formatted
        false otherwise
      • wildcardMatch

        public static boolean wildcardMatch​(@NotNull
                                            java.lang.String dirOrSubpattern,
                                            @NotNull
                                            java.lang.String pattern)
        Checks whether subpattern's match area lays completely in pattern's one. This method is also used to check whether the directory matches against the pattern (wildcard)
        Parameters:
        dirOrSubpattern - subpattern or directory to match against
        pattern - pattern to match against
        Returns:
        true if subpattern or directory matches against the pattern
        false otherwise
      • getFullPatternString

        public java.lang.String getFullPatternString()
        Returns:
        The string (normalized) the pattern was created from
      • getFullPatternPath

        public java.lang.String[] getFullPatternPath()
        Returns:
        The string (normalized) the pattern was created from
      • getRuleType

        public jetbrains.buildServer.util.pathMatcher.RuleType getRuleType()
        Returns:
        rule type (INCLUDE or EXCLUDE. See RuleType)
      • hashCode

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

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isSubPatternOf

        public boolean isSubPatternOf​(SearchPattern widePattern)
        checks whether this pattern is a subpattern (more narrow) than given one
        Parameters:
        widePattern - super-pattern candidate
        Returns:
        true, when candidate matches all this pattern can match.
        Also returns true when candidate is the same as this.
        false otherwise
      • getInitialState

        public SearchPattern.PatternPart getInitialState()
        Returns the initial state with given index
        Returns:
        the initial state