org.eclipse.cdt.internal.ui.util
Class StringMatcher

java.lang.Object
  extended by org.eclipse.cdt.internal.ui.util.StringMatcher

public class StringMatcher
extends java.lang.Object


Nested Class Summary
static class StringMatcher.Position
           
 
Constructor Summary
StringMatcher(java.lang.String aPattern, boolean ignoreCase)
          Deprecated. Use StringMatcher(pattern, ignoreCase, ignoreWildCards).
StringMatcher(java.lang.String aPattern, boolean ignoreCase, boolean ignoreWildCards)
          StringMatcher constructor takes in a String object that is a simple pattern which may contain *  for 0 and many characters and ?
 
Method Summary
 StringMatcher.Position find(java.lang.String text, int start, int end)
          Find the first occurrence of the pattern between startend(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) poisitions in the text, determine if the given substring matches with aPattern
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringMatcher

public StringMatcher(java.lang.String aPattern,
                     boolean ignoreCase)
Deprecated. Use StringMatcher(pattern, ignoreCase, ignoreWildCards).

StringMatcher constructor takes in a String object that is a simple pattern which may contain *  for 0 and many characters and ?  for exactly one character. Also takes as parameter a boolean object specifying if case should be ignored


StringMatcher

public StringMatcher(java.lang.String aPattern,
                     boolean ignoreCase,
                     boolean ignoreWildCards)
StringMatcher constructor takes in a String object that is a simple pattern which may contain *  for 0 and many characters and ?  for exactly one character. Literal '*' and '?' 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 "\\".

Parameters:
aPattern - the pattern to match text against
ignoreCase - if true, case is ignored
ignoreWildCards - if true, wild cards and their escape sequences are ignored (everything is taken literally).
Method Detail

find

public StringMatcher.Position find(java.lang.String text,
                                   int start,
                                   int end)
Find the first occurrence of the pattern between startend(exclusive).

Parameters:
text - the String object to search in
start - the starting index of the search range, inclusive
end - the ending index of the search range, exclusive
Returns:
an 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 returned

match

public boolean match(java.lang.String text,
                     int start,
                     int end)
Given the starting (inclusive) and the ending (exclusive) poisitions in the text, determine if the given substring matches with aPattern

Parameters:
text - a String object that contains the substring to match
start - marks the starting position (inclusive) of the substring
end - marks the ending index (exclusive) of the substring
Returns:
true if the specified portion of the text matches the pattern

match

public boolean match(java.lang.String text)
match the given text with the pattern

Parameters:
text - a String object
Returns:
true if matched eitherwise false