2 // This software is now distributed according to
\r
3 // the Lesser Gnu Public License. Please see
\r
4 // http://www.gnu.org/copyleft/lesser.txt for
\r
6 // -- Happy Computing!
\r
8 package com.stevesoft.pat;
\r
9 import java.util.Hashtable;
\r
11 /** Implements "(?= )" and "(?! )" */
\r
12 class lookAhead extends Or {
\r
14 lookAhead(boolean b) { reverse = b; }
\r
15 public Pattern getNext() { return null; }
\r
16 public int nextMatch(int pos,Pthings pt) {
\r
17 Pattern p = super.getNext();
\r
18 if(p != null) return p.matchInternal(pos,pt);
\r
21 public int matchInternal(int pos,Pthings pt) {
\r
22 if(super.matchInternal(pos,pt) >= 0) {
\r
23 if(reverse) return -1;
\r
24 else return nextMatch(pos,pt);
\r
26 if(reverse) return nextMatch(pos,pt);
\r
36 public patInt minChars() { return new patInt(0); }
\r
37 public patInt maxChars() { return new patInt(0); }
\r
38 Pattern clone1(Hashtable h) {
\r
39 lookAhead la=new lookAhead(reverse);
\r
42 for(int i=0;i<v.size();i++)
\r
43 la.v.addElement( ((Pattern)v.elementAt(i)).clone(h) );
\r