Class RegExpMatcherImpl

    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.refcodes.mixin.PatternAccessor

        org.refcodes.mixin.PatternAccessor.PatternBuilder<B extends org.refcodes.mixin.PatternAccessor.PatternBuilder<?>>, org.refcodes.mixin.PatternAccessor.PatternMutator, org.refcodes.mixin.PatternAccessor.PatternProperty
    • Constructor Summary

      Constructors 
      Constructor Description
      RegExpMatcherImpl​(java.lang.String aRegExp)
      Constructs a Pattern matcher.
      RegExpMatcherImpl​(java.util.regex.Pattern aRegExp)
      Constructs a Pattern matcher.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)
      java.util.regex.Pattern getPattern​()
      Returns the path pattern being used by the RegExpMatcher.
      java.lang.String[] getWildcardNames​()
      Retrieves the list of wildcard names identifying the wildcards as specified by the pattern.
      int hashCode​()
      boolean isMatching​(java.lang.String aText)
      Tests whether the given event is matching the mathcer's criteria.
      java.lang.String toPattern​()
      For debugging purposes, retrieve the regex pattern created from the ANT path pattern.
      java.lang.String toWildcardReplacement​(java.lang.String aText, java.lang.String aWildcardName)
      Returns the wildcard substitute for the wildcards in your pattern compared to the actual text.
      java.lang.String toWildcardReplacementAt​(java.lang.String aText, int aIndex)
      Returns the wildcard substitute for the wildcards in your pattern compared to the actual text (as of WildcardMatcher.toWildcardSubstitutes(String)).
      java.lang.String[] toWildcardReplacements​(java.lang.String aText)
      Returns an array of the wildcard substitutes for the wildcards in your pattern compared to the actual text (as of WildcardMatcher.toWildcardSubstitutes(String)).
      java.lang.String[] toWildcardReplacements​(java.lang.String aText, java.lang.String... aWildcardNames)
      Returns the wildcard substitutes for the wildcards in your pattern compared to the actual text .
      java.lang.String[] toWildcardReplacementsAt​(java.lang.String aText, int... aIndexes)
      Returns the wildcard substitutes for the wildcards in your pattern compared to the actual text.
      WildcardSubstitutes toWildcardSubstitutes​(java.lang.String aText)
      Returns all available wildcard substitutes as well as the named wildcard substitutes.
      • Methods inherited from class java.lang.Object

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

      • RegExpMatcherImpl

        public RegExpMatcherImpl​(java.util.regex.Pattern aRegExp)
        Constructs a Pattern matcher.
        Parameters:
        aRegExp - The pattern to be used when matching a path via isMatching(String).
      • RegExpMatcherImpl

        public RegExpMatcherImpl​(java.lang.String aRegExp)
                          throws java.util.regex.PatternSyntaxException
        Constructs a Pattern matcher.
        Parameters:
        aRegExp - The pattern to be used when matching a path via isMatching(String).
        Throws:
        java.util.regex.PatternSyntaxException - Thrown if the expression's syntax is invalid
    • Method Detail

      • getWildcardNames

        public java.lang.String[] getWildcardNames​()
        Retrieves the list of wildcard names identifying the wildcards as specified by the pattern.
        Specified by:
        getWildcardNames in interface WildcardMatcher
        Returns:
        The wild card names or null of no wild card names have been defined.
      • getPattern

        public java.util.regex.Pattern getPattern​()
        Returns the path pattern being used by the RegExpMatcher.
        Specified by:
        getPattern in interface org.refcodes.mixin.PatternAccessor
        Specified by:
        getPattern in interface RegExpMatcher
        Returns:
        The path pattern being used.
      • isMatching

        public boolean isMatching​(java.lang.String aText)
        Tests whether the given event is matching the mathcer's criteria.
        Specified by:
        isMatching in interface Matcher<java.lang.String>
        Specified by:
        isMatching in interface RegExpMatcher
        Parameters:
        aText - The matchee used for testing matchability.
        Returns:
        True in case the matchee matches the matcher's criteria, else false.
      • toWildcardSubstitutes

        public WildcardSubstitutes toWildcardSubstitutes​(java.lang.String aText)
        Returns all available wildcard substitutes as well as the named wildcard substitutes.
        Specified by:
        toWildcardSubstitutes in interface WildcardMatcher
        Parameters:
        aText - Tex textfor which to retrieve the wildcard substitutes.
        Returns:
        The WildcardSubstitutes of the wildcards being substituted.
      • toWildcardReplacements

        public java.lang.String[] toWildcardReplacements​(java.lang.String aText)
        Returns an array of the wildcard substitutes for the wildcards in your pattern compared to the actual text (as of WildcardMatcher.toWildcardSubstitutes(String)). The order of the wildcard substitutes aligns to the order of the wildcards (from left to right) defined in your pattern.
        Specified by:
        toWildcardReplacements in interface WildcardMatcher
        Parameters:
        aText - Tex textfor which to retrieve the wildcard substitutes.
        Returns:
        The text substituting the wildcards in the order of the wildcards being substituted or null if there are none such substitutes.
      • toWildcardReplacementAt

        public java.lang.String toWildcardReplacementAt​(java.lang.String aText,
                                                        int aIndex)
        Returns the wildcard substitute for the wildcards in your pattern compared to the actual text (as of WildcardMatcher.toWildcardSubstitutes(String)). The text of the wildcard substitute aligns to the index of the wildcard (from left to right) as defined in your pattern.
        Specified by:
        toWildcardReplacementAt in interface WildcardMatcher
        Parameters:
        aText - Tex textfor which to retrieve the wildcard substitutes.
        aIndex - The index of the wildcard in question for which to retrieve the substitute.
        Returns:
        The text substituting the wildcard at the given pattern's wildcard index or null if there is none such substitute.
      • toWildcardReplacementsAt

        public java.lang.String[] toWildcardReplacementsAt​(java.lang.String aText,
                                                           int... aIndexes)
        Returns the wildcard substitutes for the wildcards in your pattern compared to the actual text. The text of the wildcard substitutes aligns to the indexes of the wildcard (from left to right) as defined in your pattern.
        Specified by:
        toWildcardReplacementsAt in interface WildcardMatcher
        Parameters:
        aText - Tex textfor which to retrieve the wildcard substitutes.
        aIndexes - The indexes of the wildcards in question for which to retrieve the substitutes.
        Returns:
        The text substituting the wildcards at the given pattern's wildcard indexes or null if there is none such substitute.
      • toWildcardReplacement

        public java.lang.String toWildcardReplacement​(java.lang.String aText,
                                                      java.lang.String aWildcardName)
        Returns the wildcard substitute for the wildcards in your pattern compared to the actual text. The text of the wildcard substitute aligns to the name of the wildcard (as defined in your pattern).
        Specified by:
        toWildcardReplacement in interface WildcardMatcher
        Parameters:
        aText - Tex textfor which to retrieve the wildcard substitutes.
        aWildcardName - The name of the wildcard in question for which to retrieve the substitute.
        Returns:
        The text substituting the wildcard with the given pattern's wildcard name or null if there is none such substitute.
      • toWildcardReplacements

        public java.lang.String[] toWildcardReplacements​(java.lang.String aText,
                                                         java.lang.String... aWildcardNames)
        Returns the wildcard substitutes for the wildcards in your pattern compared to the actual text . The text of the wildcard substitutes aligns to the order of the provided wildcard names (as defined in your pattern).
        Specified by:
        toWildcardReplacements in interface WildcardMatcher
        Parameters:
        aText - Tex textfor which to retrieve the wildcard substitutes.
        aWildcardNames - The names of the wildcards in question for which to retrieve the substitutes in the order of the provided names.
        Returns:
        The text substituting the wildcard with the given pattern's wildcard names or null if there are none such substitute.
      • toPattern

        public java.lang.String toPattern​()
        For debugging purposes, retrieve the regex pattern created from the ANT path pattern.
        Returns:
        Returns the regex created from the ANT path pattern.
      • 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