本文整理汇总了Java中org.eclipse.ui.dialogs.SearchPattern.RULE_PREFIX_MATCH属性的典型用法代码示例。如果您正苦于以下问题:Java SearchPattern.RULE_PREFIX_MATCH属性的具体用法?Java SearchPattern.RULE_PREFIX_MATCH怎么用?Java SearchPattern.RULE_PREFIX_MATCH使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.ui.dialogs.SearchPattern
的用法示例。
在下文中一共展示了SearchPattern.RULE_PREFIX_MATCH属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isTextMatchingSearchPattern
protected boolean isTextMatchingSearchPattern(String text, String searchPattern) {
SearchPattern matcher = new SearchPattern(SearchPattern.RULE_PATTERN_MATCH
| SearchPattern.RULE_EXACT_MATCH | SearchPattern.RULE_PREFIX_MATCH
| SearchPattern.RULE_BLANK_MATCH);
matcher.setPattern("*" + searchPattern);
return matcher.matches(text);
}
示例2: isTextMatchingSearchPattern
protected boolean isTextMatchingSearchPattern(String text) {
SearchPattern matcher = new SearchPattern(SearchPattern.RULE_PATTERN_MATCH
| SearchPattern.RULE_EXACT_MATCH | SearchPattern.RULE_PREFIX_MATCH
| SearchPattern.RULE_BLANK_MATCH);
matcher.setPattern("*" + searchPattern);
return matcher.matches(text);
}
示例3: getMatchingRegions
private final int[] getMatchingRegions(String pattern, String name, int matchRule) {
if (name == null)
return null;
final int nameLength = name.length();
if (pattern == null) {
return new int[] { 0, nameLength };
}
final int patternLength = pattern.length();
switch (matchRule) {
case SearchPattern.RULE_EXACT_MATCH:
if (patternLength == nameLength && pattern.equalsIgnoreCase(name)) {
return new int[] { 0, patternLength };
}
break;
case SearchPattern.RULE_EXACT_MATCH | SearchPattern.RULE_CASE_SENSITIVE:
if (patternLength == nameLength && pattern.equals(name)) {
return new int[] { 0, patternLength };
}
break;
case SearchPattern.RULE_PREFIX_MATCH:
if (patternLength <= nameLength && name.substring(0, patternLength).equalsIgnoreCase(pattern)) {
return new int[] { 0, patternLength };
}
break;
case SearchPattern.RULE_PREFIX_MATCH | SearchPattern.RULE_CASE_SENSITIVE:
if (name.startsWith(pattern)) {
return new int[] { 0, patternLength };
}
break;
case SearchPattern.RULE_PATTERN_MATCH:
return StringUtils.getPatternMatchingRegions(pattern, 0, patternLength, name, 0, nameLength, false);
case SearchPattern.RULE_PATTERN_MATCH | SearchPattern.RULE_CASE_SENSITIVE:
return StringUtils.getPatternMatchingRegions(pattern, 0, patternLength, name, 0, nameLength, true);
}
return null;
}