X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fcom%2Fstevesoft%2Fpat%2FlookAhead.java;h=5f2a1d0d8f4f341abeef2b10f41251538b4991d2;hb=02fdab3e44192d6227d7ce305d9b8ad6626932c2;hp=112db7cbeea15c19fc1bf4a4159b359b7430bff7;hpb=c40cf903f740a72ab63dd1abc10fa33450ce660d;p=jalview.git diff --git a/src/com/stevesoft/pat/lookAhead.java b/src/com/stevesoft/pat/lookAhead.java index 112db7c..5f2a1d0 100755 --- a/src/com/stevesoft/pat/lookAhead.java +++ b/src/com/stevesoft/pat/lookAhead.java @@ -1,46 +1,99 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; -import java.util.Hashtable; - -/** Implements "(?= )" and "(?! )" */ -class lookAhead extends Or { - boolean reverse; - lookAhead(boolean b) { reverse = b; } - public Pattern getNext() { return null; } - public int nextMatch(int pos,Pthings pt) { - Pattern p = super.getNext(); - if(p != null) return p.matchInternal(pos,pt); - else return pos; - } - public int matchInternal(int pos,Pthings pt) { - if(super.matchInternal(pos,pt) >= 0) { - if(reverse) return -1; - else return nextMatch(pos,pt); - } else { - if(reverse) return nextMatch(pos,pt); - else return -1; - } - } - String leftForm() { - if(reverse) - return "(?!"; - else - return "(?="; - } - public patInt minChars() { return new patInt(0); } - public patInt maxChars() { return new patInt(0); } - Pattern clone1(Hashtable h) { - lookAhead la=new lookAhead(reverse); - h.put(this,la); - h.put(la,la); - for(int i=0;i= 0) + { + if (reverse) + { + return -1; + } + else + { + return nextMatch(pos, pt); + } + } + else + { + if (reverse) + { + return nextMatch(pos, pt); + } + else + { + return -1; + } + } + } + + String leftForm() + { + if (reverse) + { + return "(?!"; + } + else + { + return "(?="; + } + } + + public patInt minChars() + { + return new patInt(0); + } + + public patInt maxChars() + { + return new patInt(0); + } + + Pattern clone1(Hashtable h) + { + lookAhead la = new lookAhead(reverse); + h.put(this, la); + h.put(la, la); + for (int i = 0; i < v.size(); i++) + { + la.v.addElement(((Pattern) v.elementAt(i)).clone(h)); + } + return la; + } +}