|
Runtime | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.gmf.runtime.common.core.util.StringMatcher
public class StringMatcher
A string pattern matcher, supporting wildcard characters. This class is cloned from org.eclipse.ui.internal.misc.StringMatcher
Nested Class Summary | |
---|---|
static class |
StringMatcher.Position
Keeps track of the internal position of the matcher. |
Field Summary | |
---|---|
protected int |
fBound
Boundary value beyond which we don't need to search in the text |
protected boolean |
fHasLeadingStar
Has a leading wildcard |
protected boolean |
fHasTrailingStar
Has a trailing wildcard |
protected boolean |
fIgnoreCase
Ignore case |
protected boolean |
fIgnoreWildCards
Ignore wildcards |
protected int |
fLength
The pattern length |
protected java.lang.String |
fPattern
The pattern |
protected java.lang.String[] |
fSegments
The given pattern is split into * separated segments |
protected static char |
fSingleWildCard
The single wildcard character |
Constructor Summary | |
---|---|
StringMatcher(java.lang.String pattern,
boolean ignoreCase,
boolean ignoreWildCards)
StringMatcher constructor takes in a String object that is a simple pattern which may contain '*' for 0 or more characters and '?' |
Method Summary | |
---|---|
StringMatcher.Position |
find(java.lang.String text,
int start,
int end)
Find the first occurrence of the pattern between start end(exclusive). |
boolean |
match(java.lang.String text)
match the given text with the pattern |
boolean |
match(java.lang.String text,
int start,
int end)
Given the starting (inclusive) and the ending (exclusive) positions in the text , determine if the given substring matches with
aPattern |
protected int |
posIn(java.lang.String text,
int start,
int end)
|
protected int |
regExpPosIn(java.lang.String text,
int start,
int end,
java.lang.String p)
Return the position of regulat expression in specified string. |
protected boolean |
regExpRegionMatches(java.lang.String text,
int tStart,
java.lang.String p,
int pStart,
int plen)
Check if the specified regular expression matches string. |
protected int |
textPosIn(java.lang.String text,
int start,
int end,
java.lang.String p)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.String fPattern
protected int fLength
protected boolean fIgnoreWildCards
protected boolean fIgnoreCase
protected boolean fHasLeadingStar
protected boolean fHasTrailingStar
protected java.lang.String[] fSegments
protected int fBound
protected static final char fSingleWildCard
Constructor Detail |
---|
public StringMatcher(java.lang.String pattern, boolean ignoreCase, boolean ignoreWildCards)
'*'
for 0 or more characters and '?'
for exactly one character.
Literal characters must be escaped in the pattern e.g., "\*"
means literal "*"
, etc.
Escaping any other character (including the escape character itself),
just results in that character in the pattern. e.g., "\a"
means "a"
and "\\"
means "\"
If invoking the StringMatcher with string literals in Java, don't forget
escape characters are represented by "\\"
.
pattern
- the pattern to match text againstignoreCase
- if true, case is ignoredignoreWildCards
- if true, wild cards and their escape sequences are ignored
(everything is taken literally).Method Detail |
---|
public StringMatcher.Position find(java.lang.String text, int start, int end)
start
end(exclusive).
text
- String
the String object to search instart
- int
, the starting index of the search range, inclusiveend
- int
, the ending index of the search range, exclusive
StringMatcher.Position
object that keeps the starting
(inclusive) and ending positions (exclusive) of the first occurrence of the
pattern in the specified range of the text; return null if not found or subtext
is empty (start==end). A pair of zeros is returned if pattern is empty string
Note that for pattern like "*abc*" with leading and trailing stars, position of "abc"
is returned. For a pattern like"*??*" in text "abcdf", (1,3) is returnedpublic boolean match(java.lang.String text)
text
with the pattern
text
- String
, a String object
public boolean match(java.lang.String text, int start, int end)
text
, determine if the given substring matches with
aPattern
text
- String
a String object that contains the
substring to matchstart
- int
marks the starting position (inclusive) of
the substringend
- int
marks the ending index (exclusive) of the
substring
protected int posIn(java.lang.String text, int start, int end)
text
- a string which contains no wildcardstart
- the starting index in the text for search, inclusiveend
- the stopping point of search, exclusive
protected int regExpPosIn(java.lang.String text, int start, int end, java.lang.String p)
text
- a simple regular expression that may only contain '?'(s)start
- the starting index in the text for search, inclusiveend
- the stopping point of search, exclusivep
- a simple regular expression that may contains '?'
protected boolean regExpRegionMatches(java.lang.String text, int tStart, java.lang.String p, int pStart, int plen)
text
- a simple regular expressiontStart
- the starting index in the text for search, inclusivep
- a simple regular expression that may contains '?'pStart
- plen
-
protected int textPosIn(java.lang.String text, int start, int end, java.lang.String p)
text
- the string to matchstart
- the starting index in the text for search, inclusiveend
- the stopping point of search, exclusivep
- a string that has no wildcard
|
Runtime | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.