Package org.eclipse.jdt.core.search

## Class SearchPattern

- java.lang.Object
- - org.eclipse.jdt.core.search.SearchPattern

    public abstract class SearchPattern
    extends Object

A search pattern defines how search results are found. Use `SearchPattern.createPattern` to create a search pattern.

Search patterns are used during the search phase to decode index entries that were added during the indexing phase (see `SearchDocument.addIndexEntry(char[], char[])`). When an index is queried, the index categories and keys to consider are retrieved from the search pattern using `getIndexCategories()` and `getIndexKey()`, as well as the match rule (see `getMatchRule()`). A blank pattern is then created (see `getBlankPattern()`). This blank pattern is used as a record as follows. For each index entry in the given index categories and that starts with the given key, the blank pattern is fed using `decodeIndexKey(char[])`. The original pattern is then asked if it matches the decoded key using `matchesDecodedKey(SearchPattern)`. If it matches, a search document is created for this index entry using `SearchParticipant.getDocument(String)`.

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

Since:
  3.0
See Also:
  `createPattern(org.eclipse.jdt.core.IJavaElement, int)`, `createPattern(String, int, int, int)`

### Field Summary

Fields
`IJavaElement` `focus` The focus element (used for reference patterns)
`char[]` `indexQualifierQuery` The encoded index qualifier query which is used to narrow down number of indexes to search based on the qualifier.
`int` `kind`
`boolean` `mustResolve`
`static int` `R_CAMELCASE_MATCH` Match rule: The search pattern contains a Camel Case expression.
`static int` `R_CAMELCASE_SAME_PART_COUNT_MATCH` Match rule: The search pattern contains a Camel Case expression with a strict expected number of parts.
`static int` `R_CASE_SENSITIVE` Match rule: The search pattern matches the search result only if cases are the same.
`static int` `R_EQUIVALENT_MATCH` Match rule: The search pattern matches search results as raw/parameterized types/methods with equivalent type parameters.
`static int` `R_ERASURE_MATCH` Match rule: The search pattern matches search results as raw/parameterized types/methods with same erasure.
`static int` `R_EXACT_MATCH` Match rule: The search pattern matches exactly the search result, that is, the source of the search result equals the search pattern.
`static int` `R_FULL_MATCH` Match rule: The search pattern matches exactly the search result, that is, the source of the search result equals the search pattern.
`static int` `R_PATTERN_MATCH` Match rule: The search pattern contains one or more wild cards ('*' or '?').
`static int` `R_PREFIX_MATCH` Match rule: The search pattern is a prefix of the search result.
`static int` `R_REGEXP_MATCH` Match rule: The search pattern contains a regular expression.
`static int` `R_SUBSTRING_MATCH` Match rule: The search pattern contains a substring expression in a case-insensitive way.
`static int` `R_SUBWORD_MATCH` Match rule: The search pattern contains a subword expression in a case-insensitive way.

### Constructor Summary

Constructors
`SearchPattern​(int matchRule)` Creates a search pattern with the rule to apply for matching index keys.

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods
`void` `acceptMatch​(String relativePath, String containerPath, char separator, SearchPattern pattern, org.eclipse.jdt.internal.core.search.IndexQueryRequestor requestor, SearchParticipant participant, IJavaSearchScope scope)`
`void` `acceptMatch​(String relativePath, String containerPath, char separator, SearchPattern pattern, org.eclipse.jdt.internal.core.search.IndexQueryRequestor requestor, SearchParticipant participant, IJavaSearchScope scope, IProgressMonitor monitor)`
`static boolean` `camelCaseMatch​(String pattern, int patternStart, int patternEnd, String name, int nameStart, int nameEnd)` Answers true if a sub-pattern matches the sub-part of the given name using CamelCase rules, or false otherwise.
`static boolean` `camelCaseMatch​(String pattern, int patternStart, int patternEnd, String name, int nameStart, int nameEnd, boolean samePartCount)` Answers true if a sub-pattern matches the sub-part of the given name using CamelCase rules, or false otherwise.
`static boolean` `camelCaseMatch​(String pattern, String name)` Answers true if the pattern matches the given name using CamelCase rules, or false otherwise. char[] CamelCase matching does NOT accept explicit wild-cards '*' and '?'
`static boolean` `camelCaseMatch​(String pattern, String name, boolean samePartCount)` Answers true if the pattern matches the given name using CamelCase rules, or false otherwise. char[] CamelCase matching does NOT accept explicit wild-cards '*' and '?'
`SearchPattern` `clone()`
`static SearchPattern` `createAndPattern​(SearchPattern leftPattern, SearchPattern rightPattern)` Deprecated. Unfortunately, this functionality is not fully supported yet (see "https://bugs.eclipse.org/bugs/show_bug.cgi?
`static SearchPattern` `createOrPattern​(SearchPattern leftPattern, SearchPattern rightPattern)` Returns a search pattern that combines the given two patterns into an "or" pattern.
`static SearchPattern` `createPattern​(String stringPattern, int searchFor, int limitTo, int matchRule)` Returns a search pattern based on a given string pattern.
`static SearchPattern` `createPattern​(IJavaElement element, int limitTo)` Returns a search pattern based on a given Java element.
`static SearchPattern` `createPattern​(IJavaElement element, int limitTo, int matchRule)` Returns a search pattern based on a given Java element.
`SearchPattern` `currentPattern()`
`void` `decodeIndexKey​(char[] key)` Decode the given index key in this pattern.
`void` `findIndexMatches​(org.eclipse.jdt.internal.core.index.Index index, org.eclipse.jdt.internal.core.search.IndexQueryRequestor requestor, SearchParticipant participant, IJavaSearchScope scope, boolean resolveDocumentName, IProgressMonitor monitor)` Query a given index for matching entries.
`void` `findIndexMatches​(org.eclipse.jdt.internal.core.index.Index index, org.eclipse.jdt.internal.core.search.IndexQueryRequestor requestor, SearchParticipant participant, IJavaSearchScope scope, IProgressMonitor monitor)` Query a given index for matching entries.
`abstract SearchPattern` `getBlankPattern()` Returns a blank pattern that can be used as a record to decode an index key.
`char[][]` `getIndexCategories()` Returns an array of index categories to consider for this index query.
`char[]` `getIndexKey()` Returns a key to find in relevant index categories, if null then all index entries are matched.
`static int[]` `getMatchingRegions​(String pattern, String name, int matchRule)` Answers all the regions in a given name matching a given pattern using a specified match rule.
`int` `getMatchRule()` Returns the rule to apply for matching index keys.
`boolean` `isPolymorphicSearch()`
`boolean` `matchesDecodedKey​(SearchPattern decodedPattern)` Returns whether this pattern matches the given pattern (representing a decoded index key).
`boolean` `matchesName​(char[] pattern, char[] name)` Returns whether the given name matches the given pattern.
`org.eclipse.jdt.internal.core.index.EntryResult[]` `queryIn​(org.eclipse.jdt.internal.core.index.Index index)`
`String` `toString()`
`static int` `validateMatchRule​(String stringPattern, int matchRule)` Validate compatibility between given string pattern and match rule.

### Methods inherited from class java.lang.Object

`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### R_EXACT_MATCH

    public static final int R_EXACT_MATCH

Match rule: The search pattern matches exactly the search result, that is, the source of the search result equals the search pattern.

See Also:
  Constant Field Values

#### R_PREFIX_MATCH

    public static final int R_PREFIX_MATCH

Match rule: The search pattern is a prefix of the search result.

See Also:
  Constant Field Values

#### R_PATTERN_MATCH

    public static final int R_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:
  Constant Field Values

#### R_REGEXP_MATCH

    public static final int R_REGEXP_MATCH

Match rule: The search pattern contains a regular expression.

Warning: Implemented only for module declaration search. The support for this rule is not yet implemented for others

See Also:
  Constant Field Values

#### R_CASE_SENSITIVE

    public static final int R_CASE_SENSITIVE

Match rule: The search pattern matches the search result only if cases are the same. Can be combined to previous rules, e.g. `R_EXACT_MATCH` | `R_CASE_SENSITIVE`

See Also:
  Constant Field Values

#### R_ERASURE_MATCH

    public static final int R_ERASURE_MATCH

Match rule: The search pattern matches search results as raw/parameterized types/methods with same erasure. This mode has no effect on other java elements search.
Type search example:

- pattern: `List<Exception>`
- match: `List<Object>`

Method search example:

- declaration: `<T>foo(T t)`
- pattern: `<Exception>foo(new Exception())`
- match: `<Object>foo(new Object())`

Can be combined to all other match rules, e.g. `R_CASE_SENSITIVE` | `R_ERASURE_MATCH` This rule is not activated by default, so raw types or parameterized types with same erasure will not be found for pattern List<String>, Note that with this pattern, the match selection will be only on the erasure even for parameterized types.

Since:
  3.1
See Also:
  Constant Field Values

#### R_EQUIVALENT_MATCH

    public static final int R_EQUIVALENT_MATCH

Match rule: The search pattern matches search results as raw/parameterized types/methods with equivalent type parameters. This mode has no effect on other java elements search.
Type search example:

- pattern: `List<Exception>`
- match:
  - `List<? extends Throwable>`
  - `List<? super RuntimeException>`
  - `List<?>`

Method search example:

- declaration: `<T>foo(T t)`
- pattern: `<Exception>foo(new Exception())`
- match:
  - `<? extends Throwable>foo(new Exception())`
  - `<? super RuntimeException>foo(new Exception())`
  - `foo(new Exception())`

Can be combined to all other match rules, e.g. `R_CASE_SENSITIVE` | `R_EQUIVALENT_MATCH` This rule is not activated by default, so raw types or equivalent parameterized types will not be found for pattern List<String>, This mode is overridden by `R_ERASURE_MATCH` as erasure matches obviously include equivalent ones. That means that pattern with rule set to `R_EQUIVALENT_MATCH` | `R_ERASURE_MATCH` will return same results than rule only set with `R_ERASURE_MATCH`.

Since:
  3.1
See Also:
  Constant Field Values

#### R_FULL_MATCH

    public static final int R_FULL_MATCH

Match rule: The search pattern matches exactly the search result, that is, the source of the search result equals the search pattern.

Since:
  3.1
See Also:
  Constant Field Values

#### R_CAMELCASE_MATCH

    public static final int R_CAMELCASE_MATCH

Match rule: The search pattern contains a Camel Case expression.

Examples:

- 'NPE' type string pattern will match 'NullPointerException' and 'NoPermissionException' types,
- 'NuPoEx' type string pattern will only match 'NullPointerException' type.

This rule is not intended to be combined with any other match rule. In case of other match rule flags are combined with this one, then match rule validation will return a modified rule in order to perform a better appropriate search request (see `validateMatchRule(String, int)` for more details).

Since:
  3.2
See Also:
  `for a detailed explanation of Camel Case matching.`, Constant Field Values

#### R_CAMELCASE_SAME_PART_COUNT_MATCH

    public static final int R_CAMELCASE_SAME_PART_COUNT_MATCH

Match rule: The search pattern contains a Camel Case expression with a strict expected number of parts.
Examples:

- 'HM' type string pattern will match 'HashMap' and 'HtmlMapper' types, but not 'HashMapEntry'
- 'HMap' type string pattern will still match previous 'HashMap' and 'HtmlMapper' types, but not 'HighMagnitude'

This rule is not intended to be combined with any other match rule. In case of other match rule flags are combined with this one, then match rule validation will return a modified rule in order to perform a better appropriate search request (see `validateMatchRule(String, int)` for more details).

Since:
  3.4
See Also:
  `for a detailed explanation of Camel Case matching.` , Constant Field Values

#### R_SUBSTRING_MATCH

    public static final int R_SUBSTRING_MATCH

Match rule: The search pattern contains a substring expression in a case-insensitive way.

Examples:

- 'bar' string pattern will match 'bar1', 'Bar' and 'removeBar' types,

This rule is not intended to be combined with any other match rule. In case of other match rule flags are combined with this one, then match rule validation will return a modified rule in order to perform a better appropriate search request (see `validateMatchRule(String, int)` for more details).

This is implemented only for code assist and not available for normal search.

Since:
  3.12
See Also:
  Constant Field Values

#### R_SUBWORD_MATCH

    public static final int R_SUBWORD_MATCH

Match rule: The search pattern contains a subword expression in a case-insensitive way.

Examples:

- 'addlist' string pattern will match 'addListener' and 'addChangeListener'

This rule is not intended to be combined with any other match rule. In case of other match rule flags are combined with this one, then match rule validation will return a modified rule in order to perform a better appropriate search request (see `validateMatchRule(String, int)` for more details).

This is implemented only for code assist and not available for normal search.

Since:
  3.21
See Also:
  Constant Field Values
Restriction:
  This is not intended to be referenced by clients as it is a part of Java preview feature.

#### focus

    public IJavaElement focus

The focus element (used for reference patterns)

Restriction:
  This field is not intended to be referenced by clients.

#### indexQualifierQuery

    public char[] indexQualifierQuery

The encoded index qualifier query which is used to narrow down number of indexes to search based on the qualifier. This is optional. In absence all indexes provided by scope will be searched.
The encoded query format is as following

     CATEGORY1[,CATEGORY2]:SIMPLE_KEY:QUALIFIED_KEY

if the category is not provided, then the index qualifier search will be done for all type of qualifiers.

See Also:
  `QualifierQuery.encodeQuery(org.eclipse.jdt.internal.core.search.indexing.QualifierQuery.QueryCategory[], char[], char[])`
Restriction:
  This field is not intended to be referenced by clients.

#### kind

    public int kind

Restriction:
  This field is not intended to be referenced by clients.

#### mustResolve

    public boolean mustResolve

Restriction:
  This field is not intended to be referenced by clients.

### Constructor Detail

#### SearchPattern

    public SearchPattern​(int matchRule)

Creates a search pattern with the rule to apply for matching index keys. It can be exact match, prefix match, pattern match or regexp match. Rule can also be combined with a case sensitivity flag.

Parameters:
  `matchRule` - one of following match rule
  - `R_EXACT_MATCH`
  - `R_PREFIX_MATCH`
  - `R_PATTERN_MATCH`
  - `R_REGEXP_MATCH`
  - `R_CAMELCASE_MATCH`
  - `R_CAMELCASE_SAME_PART_COUNT_MATCH`
  which may be also combined with one of following flag:
  - `R_CASE_SENSITIVE`
  - `R_ERASURE_MATCH`
  - `R_EQUIVALENT_MATCH`
  For example,
  - `R_EXACT_MATCH` | `R_CASE_SENSITIVE`: if an exact and case sensitive match is requested,
  - `R_PREFIX_MATCH` if a case insensitive prefix match is requested
  - `R_EXACT_MATCH` | `R_ERASURE_MATCH`: if a case insensitive and erasure match is requested.
  Note that `R_ERASURE_MATCH` or `R_EQUIVALENT_MATCH` has no effect on non-generic types/methods search.

  Note also that default behavior for generic types/methods search is to find exact matches.

### Method Detail

#### acceptMatch

    public void acceptMatch​(String relativePath,
                            String containerPath,
                            char separator,
                            SearchPattern pattern,
                            org.eclipse.jdt.internal.core.search.IndexQueryRequestor requestor,
                            SearchParticipant participant,
                            IJavaSearchScope scope)

Restriction:
  This method is not intended to be referenced by clients.
Restriction:
  This method is not intended to be re-implemented or extended by clients.

#### acceptMatch

    public void acceptMatch​(String relativePath,
                            String containerPath,
                            char separator,
                            SearchPattern pattern,
                            org.eclipse.jdt.internal.core.search.IndexQueryRequestor requestor,
                            SearchParticipant participant,
                            IJavaSearchScope scope,
                            IProgressMonitor monitor)

Restriction:
  This method is not intended to be referenced by clients.
Restriction:
  This method is not intended to be re-implemented or extended by clients.

#### currentPattern

    public SearchPattern currentPattern()

Restriction:
  This method is not intended to be referenced by clients.
Restriction:
  This method is not intended to be re-implemented or extended by clients.

#### camelCaseMatch

    public static final boolean camelCaseMatch​(String pattern,
                                               String name)

Answers true if the pattern matches the given name using CamelCase rules, or false otherwise. char[] CamelCase matching does NOT accept explicit wild-cards '*' and '?' and is inherently case sensitive.

CamelCase denotes the convention of writing compound names without spaces, and capitalizing every term. This function recognizes both upper and lower CamelCase, depending whether the leading character is capitalized or not. The leading part of an upper CamelCase pattern is assumed to contain a sequence of capitals which are appearing in the matching name; e.g. 'NPE' will match 'NullPointerException', but not 'NewPerfData'. A lower CamelCase pattern uses a lowercase first character. In Java, type names follow the upper CamelCase convention, whereas method or field names follow the lower CamelCase convention.

The pattern may contain lowercase characters, which will be matched in a case sensitive way. These characters must appear in sequence in the name. For instance, 'NPExcep' will match 'NullPointerException', but not 'NullPointerExCEPTION' or 'NuPoEx' will match 'NullPointerException', but not 'NoPointerException'.

Digit characters are treated in a special way. They can be used in the pattern but are not always considered as leading character. For instance, both 'UTF16DSS' and 'UTFDSS' patterns will match 'UTF16DocumentScannerSupport'.

Using this method allows matching names to have more parts than the specified pattern (see `camelCaseMatch(String, String, boolean)`).
For instance, 'HM' , 'HaMa' and 'HMap' patterns will match 'HashMap', 'HatMapper' and also 'HashMapEntry'.

Examples:

1. pattern = "NPE" name = NullPointerException / NoPermissionException result => true
2. pattern = "NuPoEx" name = NullPointerException result => true
3. pattern = "npe" name = NullPointerException result => false
4. pattern = "IPL3" name = "IPerspectiveListener3" result => true
5. pattern = "HM" name = "HashMapEntry" result => true
6. pattern = "HMap" name = "HatMapper" result => true

Parameters:
  `pattern` - the given pattern
  `name` - the given name
Returns:
  true if the pattern matches the given name, false otherwise
Since:
  3.2
See Also:
  `for algorithm implementation`

#### camelCaseMatch

    public static final boolean camelCaseMatch​(String pattern,
                                               String name,
                                               boolean samePartCount)

Answers true if the pattern matches the given name using CamelCase rules, or false otherwise. char[] CamelCase matching does NOT accept explicit wild-cards '*' and '?' and is inherently case sensitive.

CamelCase denotes the convention of writing compound names without spaces, and capitalizing every term. This function recognizes both upper and lower CamelCase, depending whether the leading character is capitalized or not. The leading part of an upper CamelCase pattern is assumed to contain a sequence of capitals which are appearing in the matching name; e.g. 'NPE' will match 'NullPointerException', but not 'NewPerfData'. A lower CamelCase pattern uses a lowercase first character. In Java, type names follow the upper CamelCase convention, whereas method or field names follow the lower CamelCase convention.

The pattern may contain lowercase characters, which will be matched in a case sensitive way. These characters must appear in sequence in the name. For instance, 'NPExcep' will match 'NullPointerException', but not 'NullPointerExCEPTION' or 'NuPoEx' will match 'NullPointerException', but not 'NoPointerException'.

Digit characters are treated in a special way. They can be used in the pattern but are not always considered as leading character. For instance, both 'UTF16DSS' and 'UTFDSS' patterns will match 'UTF16DocumentScannerSupport'.

CamelCase can be restricted to match only the same count of parts. When this restriction is specified the given pattern and the given name must have exactly the same number of parts (i.e. the same number of uppercase characters).
For instance, 'HM' , 'HaMa' and 'HMap' patterns will match 'HashMap' and 'HatMapper' but not 'HashMapEntry'.

Examples:

1. pattern = "NPE" name = NullPointerException / NoPermissionException result => true
2. pattern = "NuPoEx" name = NullPointerException result => true
3. pattern = "npe" name = NullPointerException result => false
4. pattern = "IPL3" name = "IPerspectiveListener3" result => true
5. pattern = "HM" name = "HashMapEntry" result => (samePartCount == false)

Parameters:
  `pattern` - the given pattern
  `name` - the given name
  `samePartCount` - flag telling whether the pattern and the name should have the same count of parts or not.
  For example:
  - 'HM' type string pattern will match 'HashMap' and 'HtmlMapper' types, but not 'HashMapEntry'
  - 'HMap' type string pattern will still match previous 'HashMap' and 'HtmlMapper' types, but not 'HighMagnitude'
Returns:
  true if the pattern matches the given name, false otherwise
Since:
  3.4
See Also:
  `for algorithm implementation`

#### camelCaseMatch

    public static final boolean camelCaseMatch​(String pattern,
                                               int patternStart,
                                               int patternEnd,
                                               String name,
                                               int nameStart,
                                               int nameEnd)

Answers true if a sub-pattern matches the sub-part of the given name using CamelCase rules, or false otherwise. char[] CamelCase matching does NOT accept explicit wild-cards '*' and '?' and is inherently case sensitive. Can match only subset of name/pattern, considering end positions as non-inclusive. The sub-pattern is defined by the patternStart and patternEnd positions.

CamelCase denotes the convention of writing compound names without spaces, and capitalizing every term. This function recognizes both upper and lower CamelCase, depending whether the leading character is capitalized or not. The leading part of an upper CamelCase pattern is assumed to contain a sequence of capitals which are appearing in the matching name; e.g. 'NPE' will match 'NullPointerException', but not 'NewPerfData'. A lower CamelCase pattern uses a lowercase first character. In Java, type names follow the upper CamelCase convention, whereas method or field names follow the lower CamelCase convention.

The pattern may contain lowercase characters, which will be matched in a case sensitive way. These characters must appear in sequence in the name. For instance, 'NPExcep' will match 'NullPointerException', but not 'NullPointerExCEPTION' or 'NuPoEx' will match 'NullPointerException', but not 'NoPointerException'.

Digit characters are treated in a special way. They can be used in the pattern but are not always considered as leading character. For instance, both 'UTF16DSS' and 'UTFDSS' patterns will match 'UTF16DocumentScannerSupport'.

Digit characters are treated in a special way. They can be used in the pattern but are not always considered as leading character. For instance, both 'UTF16DSS' and 'UTFDSS' patterns will match 'UTF16DocumentScannerSupport'.

Using this method allows matching names to have more parts than the specified pattern (see `camelCaseMatch(String, int, int, String, int, int, boolean)`).
For instance, 'HM' , 'HaMa' and 'HMap' patterns will match 'HashMap', 'HatMapper' and also 'HashMapEntry'.

1. pattern = "NPE" patternStart = 0 patternEnd = 3 name = NullPointerException nameStart = 0 nameEnd = 20 result => true
2. pattern = "NPE" patternStart = 0 patternEnd = 3 name = NoPermissionException nameStart = 0 nameEnd = 21 result => true
3. pattern = "NuPoEx" patternStart = 0 patternEnd = 6 name = NullPointerException nameStart = 0 nameEnd = 20 result => true
4. pattern = "NuPoEx" patternStart = 0 patternEnd = 6 name = NoPermissionException nameStart = 0 nameEnd = 21 result => false
5. pattern = "npe" patternStart = 0 patternEnd = 3 name = NullPointerException nameStart = 0 nameEnd = 20 result => false
6. pattern = "IPL3" patternStart = 0 patternEnd = 3 name = "IPerspectiveListener3" nameStart = 0 nameEnd = 21 result => true
7. pattern = "HM" patternStart = 0 patternEnd = 2 name = "HashMapEntry" nameStart = 0 nameEnd = 12 result => true
8. pattern = "HMap" patternStart = 0 patternEnd = 4 name = "HatMapper" nameStart = 0 nameEnd = 9 result => true

Parameters:
  `pattern` - the given pattern
  `patternStart` - the start index of the pattern, inclusive
  `patternEnd` - the end index of the pattern, exclusive
  `name` - the given name
  `nameStart` - the start index of the name, inclusive
  `nameEnd` - the end index of the name, exclusive
Returns:
  true if a sub-pattern matches the sub-part of the given name, false otherwise
Since:
  3.2

#### camelCaseMatch

    public static final boolean camelCaseMatch​(String pattern,
                                               int patternStart,
                                               int patternEnd,
                                               String name,
                                               int nameStart,
                                               int nameEnd,
                                               boolean samePartCount)

Answers true if a sub-pattern matches the sub-part of the given name using CamelCase rules, or false otherwise. char[] CamelCase matching does NOT accept explicit wild-cards '*' and '?' and is inherently case sensitive. Can match only subset of name/pattern, considering end positions as non-inclusive. The sub-pattern is defined by the patternStart and patternEnd positions.

CamelCase denotes the convention of writing compound names without spaces, and capitalizing every term. This function recognizes both upper and lower CamelCase, depending whether the leading character is capitalized or not. The leading part of an upper CamelCase pattern is assumed to contain a sequence of capitals which are appearing in the matching name; e.g. 'NPE' will match 'NullPointerException', but not 'NewPerfData'. A lower CamelCase pattern uses a lowercase first character. In Java, type names follow the upper CamelCase convention, whereas method or field names follow the lower CamelCase convention.

The pattern may contain lowercase characters, which will be matched in a case sensitive way. These characters must appear in sequence in the name. For instance, 'NPExcep' will match 'NullPointerException', but not 'NullPointerExCEPTION' or 'NuPoEx' will match 'NullPointerException', but not 'NoPointerException'.

Digit characters are treated in a special way. They can be used in the pattern but are not always considered as leading character. For instance, both 'UTF16DSS' and 'UTFDSS' patterns will match 'UTF16DocumentScannerSupport'.

CamelCase can be restricted to match only the same count of parts. When this restriction is specified the given pattern and the given name must have exactly the same number of parts (i.e. the same number of uppercase characters).
For instance, 'HM' , 'HaMa' and 'HMap' patterns will match 'HashMap' and 'HatMapper' but not 'HashMapEntry'.

Examples:

1. pattern = "NPE" patternStart = 0 patternEnd = 3 name = NullPointerException nameStart = 0 nameEnd = 20 result => true
2. pattern = "NPE" patternStart = 0 patternEnd = 3 name = NoPermissionException nameStart = 0 nameEnd = 21 result => true
3. pattern = "NuPoEx" patternStart = 0 patternEnd = 6 name = NullPointerException nameStart = 0 nameEnd = 20 result => true
4. pattern = "NuPoEx" patternStart = 0 patternEnd = 6 name = NoPermissionException nameStart = 0 nameEnd = 21 result => false
5. pattern = "npe" patternStart = 0 patternEnd = 3 name = NullPointerException nameStart = 0 nameEnd = 20 result => false
6. pattern = "IPL3" patternStart = 0 patternEnd = 3 name = "IPerspectiveListener3" nameStart = 0 nameEnd = 21 result => true
7. pattern = "HM" patternStart = 0 patternEnd = 2 name = "HashMapEntry" nameStart = 0 nameEnd = 12 result => (samePartCount == false)

Parameters:
  `pattern` - the given pattern
  `patternStart` - the start index of the pattern, inclusive
  `patternEnd` - the end index of the pattern, exclusive
  `name` - the given name
  `nameStart` - the start index of the name, inclusive
  `nameEnd` - the end index of the name, exclusive
  `samePartCount` - flag telling whether the pattern and the name should have the same count of parts or not.
  For example:
  - 'HM' type string pattern will match 'HashMap' and 'HtmlMapper' types, but not 'HashMapEntry'
  - 'HMap' type string pattern will still match previous 'HashMap' and 'HtmlMapper' types, but not 'HighMagnitude'
Returns:
  true if a sub-pattern matches the sub-part of the given name, false otherwise
Since:
  3.4
See Also:
  `from which algorithm implementation has been entirely copied.`

#### getMatchingRegions

    public static final int[] getMatchingRegions​(String pattern,
                                                 String name,
                                                 int matchRule)

Answers all the regions in a given name matching a given pattern using a specified match rule.

Each of these regions is made of its starting index and its length in the given name. They are all concatenated in a single array of `int` which therefore always has an even length.

All returned regions are disjointed from each other. That means that the end of a region is always different than the start of the following one.
For example, if two regions are returned:
`{ start1, length1, start2, length2 }`
then `start1+length1` will always be smaller than `start2`.

The possible comparison rules between the name and the pattern are:

- `exact matching`
- `prefix matching`
- `pattern matching`
- `camel case matching`
- `camel case matching with same parts count`

Each of these rules may be combined with the `case sensitive flag` if the match comparison should respect the case.

Examples:

1. pattern = "NPE" name = NullPointerException / NoPermissionException matchRule = `R_CAMELCASE_MATCH` result: { 0, 1, 4, 1, 11, 1 } / { 0, 1, 2, 1, 12, 1 }
2. pattern = "NuPoEx" name = NullPointerException matchRule = `R_CAMELCASE_MATCH` result: { 0, 2, 4, 2, 11, 2 }
3. pattern = "IPL3" name = "IPerspectiveListener3" matchRule = `R_CAMELCASE_MATCH` result: { 0, 2, 12, 1, 20, 1 }
4. pattern = "HashME" name = "HashMapEntry" matchRule = `R_CAMELCASE_MATCH` result: { 0, 5, 7, 1 }
5. pattern = "N???Po*Ex?eption" name = NullPointerException matchRule = `R_PATTERN_MATCH` | `R_CASE_SENSITIVE` result: { 0, 1, 4, 2, 11, 2, 14, 6 }
6. pattern = "Ha*M*ent*" name = "HashMapEntry" matchRule = `R_PATTERN_MATCH` result: { 0, 2, 4, 1, 7, 3 }

Parameters:
  `pattern` - the given pattern. If `null`, then an empty region (`new int[0]`) will be returned showing that the name matches the pattern but no common character has been found.
  `name` - the given name
  `matchRule` - the rule to apply for the comparison.
  The following values are accepted:
  - `R_EXACT_MATCH`
  - `R_PREFIX_MATCH`
  - `R_PATTERN_MATCH`
  - `R_CAMELCASE_MATCH`
  - `R_CAMELCASE_SAME_PART_COUNT_MATCH`

  Each of these valid values may be also combined with the `R_CASE_SENSITIVE` flag.

  Some examples:
  - `R_EXACT_MATCH` | `R_CASE_SENSITIVE`: if an exact case sensitive match is expected,
  - `R_PREFIX_MATCH`: if a case insensitive prefix match is expected,
  - `R_CAMELCASE_MATCH`: if a case insensitive camel case match is expected,
  - `R_CAMELCASE_SAME_PART_COUNT_MATCH` | `R_CASE_SENSITIVE`: if a case sensitive camel case with same parts count match is expected,
  - etc.
Returns:
  an array of `int` having two slots per returned regions (the first one is the region starting index and the second one is the region length or `null` if the given name does not match the given pattern).

  The returned regions may be empty (`new int[0]`) if the pattern is `null` (whatever the match rule is). The returned regions will also be empty if the pattern is only made of `'?'` and/or `'*'` character(s) (e.g. `'*'`, `'?*'`, `'???'`, etc.) when using a pattern match rule.

Since:
  3.5
See Also:
  `for more details on the camel case behavior`, `for more details on the pattern match behavior`

#### createAndPattern

    public static SearchPattern createAndPattern​(SearchPattern leftPattern,
                                                 SearchPattern rightPattern)

Deprecated.
Unfortunately, this functionality is not fully supported yet (see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=142044" for more details). This might be done in a further version...
Returns a search pattern that combines the given two patterns into an "and" pattern. The search result will match both the left pattern and the right pattern.

Parameters:
  `leftPattern` - the left pattern
  `rightPattern` - the right pattern
Returns:
  an "and" pattern

#### createOrPattern

    public static SearchPattern createOrPattern​(SearchPattern leftPattern,
                                                SearchPattern rightPattern)

Returns a search pattern that combines the given two patterns into an "or" pattern. The search result will match either the left pattern or the right pattern.

Parameters:
  `leftPattern` - the left pattern
  `rightPattern` - the right pattern
Returns:
  an "or" pattern

#### createPattern

    public static SearchPattern createPattern​(String stringPattern,
                                              int searchFor,
                                              int limitTo,
                                              int matchRule)

Returns a search pattern based on a given string pattern. The string patterns support '*' wild-cards. The remaining parameters are used to narrow down the type of expected results.
Examples:

- search for case insensitive references to `Object`: `createSearchPattern("Object", IJavaSearchConstants.TYPE, IJavaSearchConstants.REFERENCES, false);`
- search for case sensitive references to exact `Object()` constructor: `createSearchPattern("java.lang.Object()", IJavaSearchConstants.CONSTRUCTOR, IJavaSearchConstants.REFERENCES, true);`
- search for implementers of `java.lang.Runnable`: `createSearchPattern("java.lang.Runnable", IJavaSearchConstants.TYPE, IJavaSearchConstants.IMPLEMENTORS, true);`

Parameters:
  `stringPattern` - the given pattern
  - Type patterns have the following syntax:

    `[qualification '.']typeName ['<' typeArguments '>']`

    Examples:

    - `java.lang.Object`
    - `Runnable`
    - `List<String>`

    Type arguments can be specified to search for references to parameterized types using following syntax:

    `'<' { [ '?' {'extends'|'super'} ] type ( ',' [ '?' {'extends'|'super'} ] type )* | '?' } '>'`

    Note that:
    - '*' is not valid inside type arguments definition <>
    - '?' is treated as a wildcard when it is inside <> (i.e. it must be put on first position of the type argument)
    Since 3.14 for Java 9, Type Declaration Patterns can have module names also embedded with the following syntax

    `[moduleName1[,moduleName2,..]]/[qualification '.']typeName ['<' typeArguments '>']`

    Unnamed modules can also be included and are represented either by an absence of module name implicitly or explicitly by specifying ALL-UNNAMED for module name. Module graph search is also supported with the limitTo option set to `IJavaSearchConstants.MODULE_GRAPH`. In the module graph case, the given type is searched in all the modules required directly as well as indirectly by the given module(s).

    Note that whitespaces are ignored in between module names. It is an error to give multiple module separators - in such cases a null pattern will be returned.

    Examples:

    - `java.base/java.lang.Object`
    - `mod.one, mod.two/pack.X` find declaration in the list of given modules.
    - `/pack.X` find in the unnamed module.
    - `ALL-UNNAMED/pack.X` find in the unnamed module.

  - Method patterns have the following syntax:

    `[declaringType '.'] ['<' typeArguments '>'] methodName ['(' parameterTypes ')'] [returnType]`

    Type arguments have the same syntax as explained in the type patterns section.

    Examples:

    - `java.lang.Runnable.run() void`
    - `main(*)`
    - `<String>toArray(String[])`
  - Constructor patterns have the following syntax:

    `['<' typeArguments '>'] [declaringQualification '.'] typeName ['(' parameterTypes ')']`

    Type arguments have the same syntax as explained in the type patterns section.

    Note that the constructor name should not be entered as it is always the same as the type name.

    Examples:

    - `java.lang.Object()`
    - `Test(*)`
    - `<Exception>Sample(Exception)`
  - Field patterns have the following syntax:

    `[declaringType '.'] fieldName [fieldType]`

    Examples:

    - `java.lang.String.serialVersionUID long`
    - `field*`
  - Package patterns have the following syntax:

    `packageNameSegment {'.' packageNameSegment}`

    Examples:

    - `java.lang`
    - `org.e*.jdt.c*e`
  `searchFor` - determines the nature of the searched elements
  - `IJavaSearchConstants.CLASS`: only look for classes
  - `IJavaSearchConstants.INTERFACE`: only look for interfaces
  - `IJavaSearchConstants.ENUM`: only look for enumeration
  - `IJavaSearchConstants.ANNOTATION_TYPE`: only look for annotation type
  - `IJavaSearchConstants.CLASS_AND_ENUM`: only look for classes and enumerations
  - `IJavaSearchConstants.CLASS_AND_INTERFACE`: only look for classes and interfaces
  - `IJavaSearchConstants.TYPE`: look for all types (i.e. classes, interfaces, enum and annotation types)
  - `IJavaSearchConstants.FIELD`: look for fields
  - `IJavaSearchConstants.METHOD`: look for methods
  - `IJavaSearchConstants.CONSTRUCTOR`: look for constructors
  - `IJavaSearchConstants.PACKAGE`: look for packages
  - `IJavaSearchConstants.MODULE`: look for modules
  `limitTo` - determines the nature of the expected matches
  - `DECLARATIONS`: will search declarations matching with the corresponding element. In case the element is a method, declarations of matching methods in sub-types will also be found, allowing to find declarations of abstract methods, etc.
    Note that additional flags `IGNORE_DECLARING_TYPE` and `IGNORE_RETURN_TYPE` are ignored for string patterns. This is due to the fact that client may omit to define them in string pattern to have same behavior.
  - `REFERENCES`: will search references to the given element.
  - `ALL_OCCURRENCES`: will search for either declarations or references as specified above.
  - `IMPLEMENTORS`: for types, will find all types which directly implement/extend a given interface. Note that types may be only classes or only interfaces if `CLASS` or `INTERFACE` is respectively used instead of `TYPE`.
  - `MODULE_GRAPH`: for types with a module prefix, will find all types present in required modules (directly or indirectly required) ie in any module present in the module graph of the given module.
  - All other fine grain constants defined in the limitTo category of the `IJavaSearchConstants` are also accepted nature:

    Fine grain constant | Meaning
    --- | ---
    `FIELD_DECLARATION_TYPE_REFERENCE` | Return only type references used as the type of a field declaration.
    `LOCAL_VARIABLE_DECLARATION_TYPE_REFERENCE` | Return only type references used as the type of a local variable declaration.
    `PARAMETER_DECLARATION_TYPE_REFERENCE` | Return only type references used as the type of a method parameter declaration.
    `SUPERTYPE_TYPE_REFERENCE` | Return only type references used as a super type or as a super interface.
    `THROWS_CLAUSE_TYPE_REFERENCE` | Return only type references used in a throws clause.
    `CAST_TYPE_REFERENCE` | Return only type references used in a cast expression.
    `CATCH_TYPE_REFERENCE` | Return only type references used in a catch header.
    `CLASS_INSTANCE_CREATION_TYPE_REFERENCE` | Return only type references used in class instance creation.
    `RETURN_TYPE_REFERENCE` | Return only type references used as a method return type.
    `IMPORT_DECLARATION_TYPE_REFERENCE` | Return only type references used in an import declaration.
    `ANNOTATION_TYPE_REFERENCE` | Return only type references used as an annotation.
    `TYPE_ARGUMENT_TYPE_REFERENCE` | Return only type references used as a type argument in a parameterized type or a parameterized method.
    `TYPE_VARIABLE_BOUND_TYPE_REFERENCE` | Return only type references used as a type variable bound.
    `WILDCARD_BOUND_TYPE_REFERENCE` | Return only type references used as a wildcard bound.
    `INSTANCEOF_TYPE_REFERENCE` | Return only type references used as a type of an `instanceof` expression.
    `SUPER_REFERENCE` | Return only super field accesses or super method invocations (e.g. using the `super` qualifier).
    `QUALIFIED_REFERENCE` | Return only qualified field accesses or qualified method invocations.
    `THIS_REFERENCE` | Return only primary field accesses or primary method invocations (e.g. using the `this` qualifier).
    `IMPLICIT_THIS_REFERENCE` | Return only field accesses or method invocations without any qualification.
    `METHOD_REFERENCE_EXPRESSION` | Return only method reference expressions (e.g. `A :: foo`).

  `matchRule` - one of the following match rules
  - `R_EXACT_MATCH`
  - `R_PREFIX_MATCH`
  - `R_PATTERN_MATCH`
  - `R_CAMELCASE_MATCH`
  - `R_CAMELCASE_SAME_PART_COUNT_MATCH`
  , which may be also combined with one of the following flags:
  - `R_CASE_SENSITIVE`
  - `R_ERASURE_MATCH`
  - `R_EQUIVALENT_MATCH`
  For example,
  - `R_EXACT_MATCH` | `R_CASE_SENSITIVE`: if an exact and case sensitive match is requested,
  - `R_PREFIX_MATCH` if a case insensitive prefix match is requested
  - `R_EXACT_MATCH` | `R_ERASURE_MATCH`: if a case insensitive and erasure match is requested.

  Note that `R_ERASURE_MATCH` or `R_EQUIVALENT_MATCH` has no effect on non-generic types/methods search.

  Note that `R_REGEXP_MATCH` is supported since 3.14 for the special case of `DECLARATIONS` search of `MODULE`

  Note also that the default behavior for generic types/methods search is to find exact matches.

Returns:
  a search pattern on the given string pattern, or `null` if the string pattern is ill-formed

#### createPattern

    public static SearchPattern createPattern​(IJavaElement element,
                                              int limitTo)

Returns a search pattern based on a given Java element. The pattern is used to trigger the appropriate search.
Note that for generic searches, the returned pattern consider `R_ERASURE_MATCH` matches. If other kind of generic matches (i.e. `R_EXACT_MATCH` or `R_EQUIVALENT_MATCH`) are expected, `createPattern(IJavaElement, int, int)` method need to be used instead with the explicit match rule specified.
The pattern can be parameterized as follows:

Parameters:
  `element` - the Java element the search pattern is based on
  `limitTo` - determines the nature of the expected matches
  - `DECLARATIONS`: will search declarations matching with the corresponding element. In case the element is a method, declarations of matching methods in sub-types will also be found, allowing to find declarations of abstract methods, etc. Some additional flags may be specified while searching declaration:
    - `IGNORE_DECLARING_TYPE`: declaring type will be ignored during the search.
      For example using following test case:

                            class A { A method() { return null; } }
                            class B extends A { B method() { return null; } }
                            class C { A method() { return null; } }

      search for `method` declaration with this flag will return 2 matches: in A and in C
    - `IGNORE_RETURN_TYPE`: return type will be ignored during the search.
      Using same example, search for `method` declaration with this flag will return 2 matches: in A and in B.
    Note that these two flags may be combined and both declaring and return types can be ignored during the search. Then, using same example, search for `method` declaration with these 2 flags will return 3 matches: in A, in B and in C
  - `REFERENCES`: will search references to the given element.
  - `ALL_OCCURRENCES`: will search for either declarations or references as specified above.
  - All other fine grain constants defined in the limitTo category of the `IJavaSearchConstants` are also accepted nature:

    Fine grain constant | Meaning
    --- | ---
    `FIELD_DECLARATION_TYPE_REFERENCE` | Return only type references used as the type of a field declaration.
    `LOCAL_VARIABLE_DECLARATION_TYPE_REFERENCE` | Return only type references used as the type of a local variable declaration.
    `PARAMETER_DECLARATION_TYPE_REFERENCE` | Return only type references used as the type of a method parameter declaration.
    `SUPERTYPE_TYPE_REFERENCE` | Return only type references used as a super type or as a super interface.
    `THROWS_CLAUSE_TYPE_REFERENCE` | Return only type references used in a throws clause.
    `CAST_TYPE_REFERENCE` | Return only type references used in a cast expression.
    `CATCH_TYPE_REFERENCE` | Return only type references used in a catch header.
    `CLASS_INSTANCE_CREATION_TYPE_REFERENCE` | Return only type references used in class instance creation.
    `RETURN_TYPE_REFERENCE` | Return only type references used as a method return type.
    `IMPORT_DECLARATION_TYPE_REFERENCE` | Return only type references used in an import declaration.
    `ANNOTATION_TYPE_REFERENCE` | Return only type references used as an annotation.
    `TYPE_ARGUMENT_TYPE_REFERENCE` | Return only type references used as a type argument in a parameterized type or a parameterized method.
    `TYPE_VARIABLE_BOUND_TYPE_REFERENCE` | Return only type references used as a type variable bound.
    `WILDCARD_BOUND_TYPE_REFERENCE` | Return only type references used as a wildcard bound.
    `INSTANCEOF_TYPE_REFERENCE` | Return only type references used as a type of an `instanceof` expression.
    `SUPER_REFERENCE` | Return only super field accesses or super method invocations (e.g. using the `super` qualifier).
    `QUALIFIED_REFERENCE` | Return only qualified field accesses or qualified method invocations.
    `THIS_REFERENCE` | Return only primary field accesses or primary method invocations (e.g. using the `this` qualifier).
    `IMPLICIT_THIS_REFERENCE` | Return only field accesses or method invocations without any qualification.
    `METHOD_REFERENCE_EXPRESSION` | Return only method reference expressions (e.g. `A :: foo`).

Returns:
  a search pattern for a Java element or `null` if the given element is ill-formed

#### createPattern

    public static SearchPattern createPattern​(IJavaElement element,
                                              int limitTo,
                                              int matchRule)

Returns a search pattern based on a given Java element. The pattern is used to trigger the appropriate search, and can be parameterized as follows:

Parameters:
  `element` - the Java element the search pattern is based on
  `limitTo` - determines the nature of the expected matches
  - `DECLARATIONS`: will search declarations matching with the corresponding element. In case the element is a method, declarations of matching methods in sub-types will also be found, allowing to find declarations of abstract methods, etc. Some additional flags may be specified while searching declaration:
    - `IGNORE_DECLARING_TYPE`: declaring type will be ignored during the search.
      For example using following test case:

                            class A { A method() { return null; } }
                            class B extends A { B method() { return null; } }
                            class C { A method() { return null; } }

      search for `method` declaration with this flag will return 2 matches: in A and in C
    - `IGNORE_RETURN_TYPE`: return type will be ignored during the search.
      Using same example, search for `method` declaration with this flag will return 2 matches: in A and in B.
    Note that these two flags may be combined and both declaring and return types can be ignored during the search. Then, using same example, search for `method` declaration with these 2 flags will return 3 matches: in A, in B and in C
  - `REFERENCES`: will search references to the given element.
  - `ALL_OCCURRENCES`: will search for either declarations or references as specified above.
  - All other fine grain constants defined in the limitTo category of the `IJavaSearchConstants` are also accepted nature:

    Fine grain constant | Meaning
    --- | ---
    `FIELD_DECLARATION_TYPE_REFERENCE` | Return only type references used as the type of a field declaration.
    `LOCAL_VARIABLE_DECLARATION_TYPE_REFERENCE` | Return only type references used as the type of a local variable declaration.
    `PARAMETER_DECLARATION_TYPE_REFERENCE` | Return only type references used as the type of a method parameter declaration.
    `SUPERTYPE_TYPE_REFERENCE` | Return only type references used as a super type or as a super interface.
    `THROWS_CLAUSE_TYPE_REFERENCE` | Return only type references used in a throws clause.
    `CAST_TYPE_REFERENCE` | Return only type references used in a cast expression.
    `CATCH_TYPE_REFERENCE` | Return only type references used in a catch header.
    `CLASS_INSTANCE_CREATION_TYPE_REFERENCE` | Return only type references used in class instance creation.
    `RETURN_TYPE_REFERENCE` | Return only type references used as a method return type.
    `IMPORT_DECLARATION_TYPE_REFERENCE` | Return only type references used in an import declaration.
    `ANNOTATION_TYPE_REFERENCE` | Return only type references used as an annotation.
    `TYPE_ARGUMENT_TYPE_REFERENCE` | Return only type references used as a type argument in a parameterized type or a parameterized method.
    `TYPE_VARIABLE_BOUND_TYPE_REFERENCE` | Return only type references used as a type variable bound.
    `WILDCARD_BOUND_TYPE_REFERENCE` | Return only type references used as a wildcard bound.
    `INSTANCEOF_TYPE_REFERENCE` | Return only type references used as a type of an `instanceof` expression.
    `SUPER_REFERENCE` | Return only super field accesses or super method invocations (e.g. using the `super` qualifier).
    `QUALIFIED_REFERENCE` | Return only qualified field accesses or qualified method invocations.
    `THIS_REFERENCE` | Return only primary field accesses or primary method invocations (e.g. using the `this` qualifier).
    `IMPLICIT_THIS_REFERENCE` | Return only field accesses or method invocations without any qualification.
    `METHOD_REFERENCE_EXPRESSION` | Return only method reference expressions (e.g. `A :: foo`).
    `PERMITTYPE_TYPE_REFERENCE` | Return only type references used as a permit type.

  `matchRule` - one of the following match rules:
  - `R_EXACT_MATCH`
  - `R_PREFIX_MATCH`
  - `R_PATTERN_MATCH`
  - `R_CAMELCASE_MATCH`
  - `R_CAMELCASE_SAME_PART_COUNT_MATCH`
  , which may be also combined with one of the following flags:
  - `R_CASE_SENSITIVE`
  - `R_ERASURE_MATCH`
  - `R_EQUIVALENT_MATCH`
  For example,
  - `R_EXACT_MATCH` | `R_CASE_SENSITIVE`: if an exact and case sensitive match is requested,
  - `R_PREFIX_MATCH` if a case insensitive prefix match is requested
  - `R_EXACT_MATCH` | `R_ERASURE_MATCH`: if a case insensitive and erasure match is requested.
  Note that `R_ERASURE_MATCH` or `R_EQUIVALENT_MATCH` has no effect on non-generic types/methods search.

  Note also that default behavior for generic types/methods search is to find exact matches.

Returns:
  a search pattern for a Java element or `null` if the given element is ill-formed
Since:
  3.1

#### decodeIndexKey

    public void decodeIndexKey​(char[] key)

Decode the given index key in this pattern. The decoded index key is used by `matchesDecodedKey(SearchPattern)` to find out if the corresponding index entry should be considered.

This method should be re-implemented in subclasses that need to decode an index key.

Parameters:
  `key` - the given index key

#### findIndexMatches

    public void findIndexMatches​(org.eclipse.jdt.internal.core.index.Index index,
                                 org.eclipse.jdt.internal.core.search.IndexQueryRequestor requestor,
                                 SearchParticipant participant,
                                 IJavaSearchScope scope,
                                 IProgressMonitor monitor)
                          throws IOException

Query a given index for matching entries. Assumes the sender has opened the index and will close when finished.

Throws:
  `IOException`
Restriction:
  This method is not intended to be referenced by clients.
Restriction:
  This method is not intended to be re-implemented or extended by clients.

#### findIndexMatches

    public void findIndexMatches​(org.eclipse.jdt.internal.core.index.Index index,
                                 org.eclipse.jdt.internal.core.search.IndexQueryRequestor requestor,
                                 SearchParticipant participant,
                                 IJavaSearchScope scope,
                                 boolean resolveDocumentName,
                                 IProgressMonitor monitor)
                          throws IOException

Query a given index for matching entries. Assumes the sender has opened the index and will close when finished. This API provides a flag to control whether to skip resolving document name for the matching entries. If a SearchPattern subclass has a different implementation of index matching, they have to override this API to support document name resolving feature.

Parameters:
  `index` - the target index to query
  `requestor` - the search requestor
  `participant` - the search participant
  `scope` - the search scope where the search results should be found
  `resolveDocumentName` - whether to skip the document name resolving for the matching entries
  `monitor` - a progress monitor
Throws:
  `IOException`
Restriction:
  This method is not intended to be referenced by clients.
Restriction:
  This method is not intended to be re-implemented or extended by clients.

#### getBlankPattern

    public abstract SearchPattern getBlankPattern()

Returns a blank pattern that can be used as a record to decode an index key.

Implementors of this method should return a new search pattern that is going to be used to decode index keys.

Returns:
  a new blank pattern
See Also:
  `decodeIndexKey(char[])`

#### getIndexKey

    public char[] getIndexKey()

Returns a key to find in relevant index categories, if null then all index entries are matched. The key will be matched according to some match rule. These potential matches will be further narrowed by the match locator, but precise match locating can be expensive, and index query should be as accurate as possible so as to eliminate obvious false hits.

This method should be re-implemented in subclasses that need to narrow down the index query.

Returns:
  an index key from this pattern, or `null` if all index entries are matched.

#### getIndexCategories

    public char[][] getIndexCategories()

Returns an array of index categories to consider for this index query. These potential matches will be further narrowed by the match locator, but precise match locating can be expensive, and index query should be as accurate as possible so as to eliminate obvious false hits.

This method should be re-implemented in subclasses that need to narrow down the index query.

Returns:
  an array of index categories

#### getMatchRule

    public final int getMatchRule()

Returns the rule to apply for matching index keys. Can be exact match, prefix match, pattern match or regexp match. Rule can also be combined with a case sensitivity flag.

Returns:
  one of R_EXACT_MATCH, R_PREFIX_MATCH, R_PATTERN_MATCH, R_REGEXP_MATCH combined with R_CASE_SENSITIVE, e.g. R_EXACT_MATCH | R_CASE_SENSITIVE if an exact and case sensitive match is requested, or R_PREFIX_MATCH if a prefix non case sensitive match is requested.

#### isPolymorphicSearch

    public boolean isPolymorphicSearch()

Restriction:
  This method is not intended to be referenced by clients.
Restriction:
  This method is not intended to be re-implemented or extended by clients.

#### matchesDecodedKey

    public boolean matchesDecodedKey​(SearchPattern decodedPattern)

Returns whether this pattern matches the given pattern (representing a decoded index key).

This method should be re-implemented in subclasses that need to narrow down the index query.

Parameters:
  `decodedPattern` - a pattern representing a decoded index key
Returns:
  whether this pattern matches the given pattern

#### matchesName

    public boolean matchesName​(char[] pattern,
                               char[] name)

Returns whether the given name matches the given pattern.

This method should be re-implemented in subclasses that need to define how a name matches a pattern.

Parameters:
  `pattern` - the given pattern, or `null` to represent "*"
  `name` - the given name
Returns:
  whether the given name matches the given pattern

#### validateMatchRule

    public static int validateMatchRule​(String stringPattern,
                                        int matchRule)

Validate compatibility between given string pattern and match rule.
In certain circumstances described in the table below, the returned match rule is modified in order to provide a more efficient search pattern:

1. when the `R_REGEXP_MATCH` flag is set, then the pattern is rejected as this kind of match is not supported yet and `-1` is returned).
2. when the string pattern has no pattern characters (e.g. '*' or '?') and the pattern match flag is set (i.e. the match rule has the `R_PATTERN_MATCH` flag), then the pattern match flag is reset.
   Reversely, when the string pattern has pattern characters and the pattern match flag is not set, then the pattern match flag is set.
3. when the `R_PATTERN_MATCH` flag is set then, other `R_PREFIX_MATCH`, `R_CAMELCASE_MATCH` or `R_CAMELCASE_SAME_PART_COUNT_MATCH` flags are reset if they are tentatively combined.
4. when the `R_CAMELCASE_MATCH` flag is set, then other `R_PREFIX_MATCH` or `R_CAMELCASE_SAME_PART_COUNT_MATCH` flags are reset if they are tentatively combined.
   Reversely, if the string pattern cannot be a camel case pattern (i.e. contains invalid Java identifier characters or does not have at least two uppercase characters - one for method camel case patterns), then the CamelCase match flag is replaced with a prefix match flag.
5. when the `R_CAMELCASE_SAME_PART_COUNT_MATCH` flag is set, then (`R_PREFIX_MATCH` flag is reset if it's tentatively combined.
   Reversely, if the string pattern cannot be a camel case pattern (i.e. contains invalid Java identifier characters or does not have at least two uppercase characters - one for method camel case patterns), then the CamelCase part count match flag is reset.

Note: the rules are validated in the documented order. For example, it means that as soon as the string pattern contains one pattern character, the pattern match flag will be set and all other match flags reset: validation of rule 2) followed by rule 3)...

Parameters:
  `stringPattern` - The string pattern
  `matchRule` - The match rule
Returns:
  Optimized valid match rule or -1 if an incompatibility was detected.
Since:
  3.2

#### queryIn

    public org.eclipse.jdt.internal.core.index.EntryResult[] queryIn​(org.eclipse.jdt.internal.core.index.Index index)
                                                              throws IOException

Throws:
  `IOException`
Restriction:
  This method is not intended to be referenced by clients.
Restriction:
  This method is not intended to be re-implemented or extended by clients.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`
See Also:
  `Object.toString()`

#### clone

    public SearchPattern clone()
                        throws CloneNotSupportedException

Overrides:
  `clone` in class `Object`
Throws:
  `CloneNotSupportedException`
Since:
  3.25