Class SegmentMatcher


  • public class SegmentMatcher
    extends Object
    A matcher for camel case matching supporting both the camel case as well as he underscore notation.
    Since:
    5.3
    Restriction:
    This class is not intended to be subclassed by clients.
    • Constructor Detail

      • SegmentMatcher

        public SegmentMatcher​(char[] pattern)
        Parameters:
        pattern - The camel case or underscore pattern.
    • Method Detail

      • match

        public boolean match​(char[] name)
        Matches the given name by prefix and segment matching.
        Returns:
        true if the associated pattern is a prefix-based or segment-based abbreviation of name.
      • matchPrefix

        public boolean matchPrefix​(char[] name)
        Matches the given name by prefix matching.
        Returns:
        true if the associated pattern is a prefix-based abbreviation of name.
      • matchSegments

        public boolean matchSegments​(char[] name)
        Matches the given name by segment matching.
        Returns:
        true if the associated pattern is a segment-based abbreviation of name.
      • match

        public static boolean match​(char[] pattern,
                                    char[] name)
        Matches pattern to name by prefix and segment matching. If you have to match against the same pattern repeatedly, create a SegmentMatcher instead and re-use it all the time, because this is much faster.
        Returns:
        true if pattern is a prefix-based or segment-based abbreviation of name
      • getPrefixForBinarySearch

        public char[] getPrefixForBinarySearch()
        The pattern used by this matcher is not suitable for binary searches (e.g. within the index). However, there can be calculated a string that can be used in the context of binary searches. In the compare method used by your binary search, return 0 for any string that starts with the returned string.
        Returns:
        Such a string.
      • matchRequiredAfterBinarySearch

        public boolean matchRequiredAfterBinarySearch()
        Returns:
        If false, calling match(char[]) can be skipped if a name survived a binary search using the prefix returned by getPrefixForBinarySearch() as key.