コード例 #1
0
 /**
  * tries to find <code>this</code> in <code>s</code> starting at position <code>start</code>.
  *
  * @return the position of the match within <code>s</code>, i.e. <b>not</b> relative to <code>
  *     start</code>. If not match can be found, -1 is returned.
  */
 public int find(CharSequence s, int start) {
   analyzed = false;
   in.setSource(s, start);
   out.setLength(0);
   int l = s.length();
   while (start < l) {
     try {
       a = dfa.match(in, out, smd);
     } catch (java.io.IOException e) {
       throw new Error("impossible", e);
     }
     if (a != null && a != DfaRun.EOF) return start;
     start += 1;
     in.read();
   }
   return -1;
 }
コード例 #2
0
 /**
  * checks if the whole input sequence starting at position <code>pos</code> can be matched.
  *
  * @return <code>true</code> iff the whole input sequence starting at position <code>pos</code>
  *     and ending at <code>s.length()</code> can be matched.
  */
 public boolean matches(CharSequence s, int pos) {
   return atStartOf(s, pos) != -1 && out.length() == s.length() - pos;
 }