Class SearchPattern

java.lang.Object
org.eclipse.ui.dialogs.SearchPattern

public class SearchPattern extends Object
A search pattern defines how search results are found.

This class is intended to be subclassed by clients. A default behavior is provided for each of the methods above, that clients can override if they wish.

Since:
3.3
  • Field Details

    • RULE_EXACT_MATCH

      public static final int RULE_EXACT_MATCH
      Match rule: The search pattern matches exactly the search result, that is, the source of the search result equals the search pattern. Search pattern should start from lowerCase char.
      See Also:
    • RULE_PREFIX_MATCH

      public static final int RULE_PREFIX_MATCH
      Match rule: The search pattern is a prefix of the search result.
      See Also:
    • RULE_PATTERN_MATCH

      public static final int RULE_PATTERN_MATCH
      Match rule: The search pattern contains one or more wild cards ('*' or '?'). A '*' wild-card can replace 0 or more characters in the search result. A '?' wild-card replaces exactly 1 character in the search result.
      See Also:
    • RULE_CASE_SENSITIVE

      public static final int RULE_CASE_SENSITIVE
      Match rule: The search pattern matches the search result only if cases are the same. Can be combined with previous rules, e.g. RULE_EXACT_MATCH | RULE_CASE_SENSITIVE
      See Also:
    • RULE_BLANK_MATCH

      public static final int RULE_BLANK_MATCH
      Match rule: The search pattern is blank.
      See Also:
    • RULE_CAMELCASE_MATCH

      public static final int RULE_CAMELCASE_MATCH
      Match rule: The search pattern contains a Camel Case expression.
      Examples:
      • NPE type string pattern will match NullPointerException and NpPermissionException types,
      • NuPoEx type string pattern will only match NullPointerException type.

      Can be combined with RULE_PREFIX_MATCH match rule. For example, when prefix match rule is combined with Camel Case match rule, "nPE" pattern will match nPException.
      Match rule RULE_PATTERN_MATCH may also be combined but both rules will not be used simultaneously as they are mutually exclusive. Used match rule depends on whether string pattern contains specific pattern characters (e.g. '*' or '?') or not. If it does, then only Pattern match rule will be used, otherwise only Camel Case match will be used. For example, with "NPE" string pattern, search will only use Camel Case match rule, but with N*P*E* string pattern, it will use only Pattern match rule.
      See Also:
  • Constructor Details

  • Method Details

    • getPattern

      public String getPattern()
      Gets string pattern used by matcher
      Returns:
      pattern
    • setPattern

      public void setPattern(String stringPattern)
      Parameters:
      stringPattern - The stringPattern to set.
    • matches

      public boolean matches(String text)
      Matches text with pattern. matching is determine by matchKind.
      Parameters:
      text - the text to match
      Returns:
      true if search pattern was matched with text false in other way
    • isPatternCharAllowed

      protected boolean isPatternCharAllowed(char patternChar)
      Checks pattern's character is allowed for specified set. It could be override if you want change logic of camelCaseMatch methods.
      Parameters:
      patternChar - the char to check
      Returns:
      true if patternChar is in set of allowed characters for pattern
    • isNameCharAllowed

      protected boolean isNameCharAllowed(char nameChar)
      Checks character of element's name is allowed for specified set. It could be override if you want change logic of camelCaseMatch methods.
      Parameters:
      nameChar - - name of searched element
      Returns:
      if nameChar is in set of allowed characters for name of element
    • getMatchRule

      public final int getMatchRule()
      Returns the rule to apply for matching keys. Can be exact match, prefix match, pattern match or camelcase match. Rule can also be combined with a case sensitivity flag.
      Returns:
      one of RULE_EXACT_MATCH, RULE_PREFIX_MATCH, RULE_PATTERN_MATCH, RULE_CAMELCASE_MATCH, combined with RULE_CASE_SENSITIVE, e.g. RULE_EXACT_MATCH | RULE_CASE_SENSITIVE if an exact and case sensitive match is requested, or RULE_PREFIX_MATCH if a prefix non case sensitive match is requested.
    • isValidCamelCaseChar

      protected boolean isValidCamelCaseChar(char ch)
      Check if character is valid camelCase character
      Parameters:
      ch - character to be validated
      Returns:
      true if character is valid
    • equalsPattern

      public boolean equalsPattern(SearchPattern pattern)
      Tells whether the given SearchPattern equals this pattern.
      Parameters:
      pattern - pattern to be checked
      Returns:
      true if the given pattern equals this search pattern
    • isSubPattern

      public boolean isSubPattern(SearchPattern pattern)
      Tells whether the given SearchPattern is a sub-pattern of this pattern.

      WARNING: This method is not defined in reading order, i.e. a.isSubPattern(b) is true iff b is a sub-pattern of a, and not vice-versa.

      Parameters:
      pattern - pattern to be checked
      Returns:
      true if the given pattern is a sub pattern of this search pattern