--- src.org.eclipse.ui.internal.ide.StringMatcher.java	Thu Aug  6 14:14:44 2009
+++ src.org.eclipse.ui.views.navigator.StringMatcher.java	Thu Aug  6 14:13:45 2009
@@ -8,14 +8,14 @@
  * Contributors:
  *     IBM Corporation - initial API and implementation
  *******************************************************************************/
-package org.eclipse.ui.internal.ide;
+package org.eclipse.ui.views.navigator;
 
 import java.util.Vector;
 
 /**
- * A string pattern matcher suppporting &#39;*&#39; and &#39;&#63;&#39; wildcards.
+ * A string pattern matcher, suppporting ?*? and ??? wildcards.
  */
-public class StringMatcher {
+/* package */class StringMatcher {
     protected String fPattern;
 
     protected int fLength; // pattern length
@@ -56,18 +56,18 @@
 
     /**
      * StringMatcher constructor takes in a String object that is a simple 
-     * pattern which may contain &#39*&#39 for 0 and many characters and
-     * &#39;&#63;&#39; for exactly one character.  
+     * pattern which may contain '*' for 0 and many characters and
+     * '?' for exactly one character.  
      *
-     * Literal &#39;*&#39; and &#39;*&#39; characters must be escaped in the pattern 
-     * e.g. &quot;&#92;*&quot; means literal &quot;*&quot;, etc.
+     * 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. &quot;&#92;a&quot; means &quot;a&quot; and &quot;&#92;&#92;&quot; means &quot;&#92;&quot;
+     * e.g., "\a" means "a" and "\\" means "\"
      *
      * If invoking the StringMatcher with string literals in Java, don't forget
-     * escape characters are represented by &quot;&#92;&#92;&quot;.
+     * escape characters are represented by "\\".
      *
      * @param pattern the pattern to match text against
      * @param ignoreCase if true, case is ignored
@@ -94,15 +94,15 @@
     /**
      * Find the first occurrence of the pattern between <code>start</code)(inclusive) 
      * and <code>end</code>(exclusive).  
-     * @param text  the String object to search in 
-     * @param start  the starting index of the search range, inclusive
-     * @param end  the ending index of the search range, exclusive
+     * @param <code>text</code>, the String object to search in 
+     * @param <code>start</code>, the starting index of the search range, inclusive
+     * @param <code>end</code>, the ending index of the search range, exclusive
      * @return an <code>StringMatcher.Position</code> 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 &quot;*abc*&quot; with leading and trailing stars, position of &quot;abc&quot;
-     * is returned. For a pattern like&quot;*&#63;&#63;*&quot; in text &quot;abcdf&quot;, (1,3) is returned
+     * 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
      */
     public StringMatcher.Position find(String text, int start, int end) {
         if (text == null) {
@@ -158,19 +158,19 @@
     /**
      * match the given <code>text</code> with the pattern 
      * @return true if matched eitherwise false
-     * @param text  a String object 
+     * @param <code>text</code>, a String object 
      */
     public boolean match(String text) {
         return match(text, 0, text.length());
     }
 
     /**
-     * Given the starting (inclusive) and the ending (exclusive) positions in the   
+     * Given the starting (inclusive) and the ending (exclusive) poisitions in the   
      * <code>text</code>, determine if the given substring matches with aPattern  
      * @return true if the specified portion of the text matches the pattern
-     * @param text  a <code>String</code> object that contains the substring to match 
-     * @param start  marks the starting position (inclusive) of the substring
-     * @param end  marks the ending index (exclusive) of the substring 
+     * @param String <code>text</code>, a String object that contains the substring to match 
+     * @param int <code>start<code> marks the starting position (inclusive) of the substring
+     * @param int <code>end<code> marks the ending index (exclusive) of the substring 
      */
     public boolean match(String text, int start, int end) {
         if (null == text) {
@@ -229,7 +229,7 @@
             return tCurPos == end;
         }
         /* process middle segments */
-        while (i < segCount) {
+        for (; i < segCount && tCurPos <= bound; ++i) {
             current = fSegments[i];
             int currentMatch;
             int k = current.indexOf(fSingleWildCard);
@@ -245,7 +245,6 @@
 				}
             }
             tCurPos = currentMatch + current.length();
-            i++;
         }
 
         /* process final segment */
@@ -267,8 +266,8 @@
     }
 
     /**
-     * Parses the given pattern into segments seperated by wildcard &#39;*&#39; characters.
-     * @param p, a String object that is a simple regular expression with ?*? and/or &#39;&#63;&#39;
+     * Parses the given pattern into segments seperated by wildcard '*' characters.
+     * @param p, a String object that is a simple regular expression with '*' and/or '?'
      */
     private void parseWildCards() {
         if (fPattern.startsWith("*")) { //$NON-NLS-1$
@@ -331,9 +330,9 @@
     }
 
     /** 
-     * @param text  a string which contains no wildcard
-     * @param start  the starting index in the text for search, inclusive
-     * @param end  the stopping point of search, exclusive
+     * @param <code>text</code>, a string which contains no wildcard
+     * @param <code>start</code>, the starting index in the text for search, inclusive
+     * @param <code>end</code>, the stopping point of search, exclusive
      * @return the starting index in the text of the pattern , or -1 if not found 
      */
     protected int posIn(String text, int start, int end) {//no wild card in pattern
@@ -357,10 +356,11 @@
     }
 
     /** 
-     * @param text  a simple regular expression that may only contain '&#63;'(s)
-     * @param start  the starting index in the text for search, inclusive
-     * @param end  the stopping point of search, exclusive
-     * @param p  a simple regular expression that may contains '&#63;'
+     * @param <code>text</code>, a simple regular expression that may only contain '?'(s)
+     * @param <code>start</code>, the starting index in the text for search, inclusive
+     * @param <code>end</code>, the stopping point of search, exclusive
+     * @param <code>p</code>, a simple regular expression that may contains '?'
+     * @param <code>caseIgnored</code>, wether the pattern is not casesensitive
      * @return the starting index in the text of the pattern , or -1 if not found 
      */
     protected int regExpPosIn(String text, int start, int end, String p) {
@@ -378,11 +378,11 @@
     /**
      * 
      * @return boolean
-     * @param  text  a String to match
-     * @param tStart  int that indicates the starting index of match, inclusive
-     * @param p  String,  String, a simple regular expression that may contain '&#63;'
-     * @param pStart
-     * @param plen 	
+     * @param <code>text</code>, a String to match
+     * @param <code>start</code>, int that indicates the starting index of match, inclusive
+     * @param <code>end</code> int that indicates the ending index of match, exclusive
+     * @param <code>p</code>, String,  String, a simple regular expression that may contain '?'
+     * @param <code>ignoreCase</code>, boolean indicating wether code>p</code> is case sensitive
      */
     protected boolean regExpRegionMatches(String text, int tStart, String p,
             int pStart, int plen) {
@@ -418,10 +418,11 @@
     }
 
     /** 
-     * @param text  the string to match
-     * @param start  the starting index in the text for search, inclusive
-     * @param end  the stopping point of search, exclusive
-     * @param p  a string that has no wildcard
+     * @param <code>text</code>, the string to match
+     * @param <code>start</code>, the starting index in the text for search, inclusive
+     * @param <code>end</code>, the stopping point of search, exclusive
+     * @param code>p</code>, a string that has no wildcard
+     * @param <code>ignoreCase</code>, boolean indicating wether code>p</code> is case sensitive
      * @return the starting index in the text of the pattern , or -1 if not found 
      */
     protected int textPosIn(String text, int start, int end, String p) {
@@ -437,7 +438,7 @@
             return i;
         }
 
-        for (int i = start; i <= max; ++i) {
+        for (int i = 0; i <= max; ++i) {
             if (text.regionMatches(true, i, p, 0, plen)) {
 				return i;
 			}
