public class SearchPattern extends Object
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.
Modifier and Type | Field and Description |
---|---|
static int |
RULE_BLANK_MATCH
Match rule: The search pattern is blank.
|
static int |
RULE_CAMELCASE_MATCH
Match rule: The search pattern contains a Camel Case expression.
|
static int |
RULE_CASE_SENSITIVE
Match rule: The search pattern matches the search result only if cases
are the same.
|
static 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.
|
static int |
RULE_PATTERN_MATCH
Match rule: The search pattern contains one or more wild cards ('*' or
'?').
|
static int |
RULE_PREFIX_MATCH
Match rule: The search pattern is a prefix of the search result.
|
Constructor and Description |
---|
SearchPattern()
Creates new instance of SearchPattern Default allowedRules for it is
result of belong logic operation: ( RULE_EXACT_MATCH | RULE_PREFIX_MATCH |
RULE_PATTERN_MATCH | RULE_CAMELCASE_MATCH )
|
SearchPattern(int allowedRules)
Creates a search pattern with the rule to apply for matching index keys.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equalsPattern(SearchPattern pattern)
Tells whether the given
SearchPattern equals this pattern. |
int |
getMatchRule()
Returns the rule to apply for matching keys.
|
String |
getPattern()
Gets string pattern used by matcher
|
protected boolean |
isNameCharAllowed(char nameChar)
Checks character of element's name is allowed for specified set.
|
protected boolean |
isPatternCharAllowed(char patternChar)
Checks pattern's character is allowed for specified set.
|
boolean |
isSubPattern(SearchPattern pattern)
Tells whether the given
SearchPattern is a sub-pattern of
this pattern. |
protected boolean |
isValidCamelCaseChar(char ch)
Check if character is valid camelCase character
|
boolean |
matches(String text)
Matches text with pattern. matching is determine by matchKind.
|
void |
setPattern(String stringPattern) |
public static final int RULE_EXACT_MATCH
public static final int RULE_PREFIX_MATCH
public static final int RULE_PATTERN_MATCH
public static final int RULE_CASE_SENSITIVE
RULE_EXACT_MATCH
| RULE_CASE_SENSITIVE
public static final int RULE_BLANK_MATCH
public static final int RULE_CAMELCASE_MATCH
NPE
type string pattern will match
NullPointerException
and
NpPermissionException
types,NuPoEx
type string pattern will only match
NullPointerException
type.RULE_PREFIX_MATCH
match rule. For example,
when prefix match rule is combined with Camel Case match rule,
"nPE"
pattern will match nPException
. 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.public SearchPattern()
public SearchPattern(int allowedRules)
allowedRules
- one of RULE_EXACT_MATCH
, RULE_PREFIX_MATCH
,
RULE_PATTERN_MATCH
, RULE_CASE_SENSITIVE
,
RULE_CAMELCASE_MATCH
combined with one of following
values: RULE_EXACT_MATCH
, RULE_PREFIX_MATCH
,
RULE_PATTERN_MATCH
or RULE_CAMELCASE_MATCH
.
e.g. RULE_EXACT_MATCH
| RULE_CASE_SENSITIVE
if an exact and case sensitive match is requested,
RULE_PREFIX_MATCH
if a prefix non case sensitive
match is requested or RULE_EXACT_MATCH
if a non case
sensitive and erasure match is requested.public String getPattern()
public void setPattern(String stringPattern)
stringPattern
- The stringPattern to set.public boolean matches(String text)
text
- protected boolean isPatternCharAllowed(char patternChar)
patternChar
- protected boolean isNameCharAllowed(char nameChar)
nameChar
- -
name of searched elementpublic final int getMatchRule()
protected boolean isValidCamelCaseChar(char ch)
ch
- character to be validatedpublic boolean equalsPattern(SearchPattern pattern)
SearchPattern
equals this pattern.pattern
- pattern to be checkedpublic boolean isSubPattern(SearchPattern pattern)
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.
pattern
- pattern to be checked
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.