X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcom%2Fstevesoft%2Fpat%2FlookAhead.java;fp=src%2Fcom%2Fstevesoft%2Fpat%2FlookAhead.java;h=73be36a796c6cc68aadeee26164cb513242a4864;hb=7bc226b58110fa26d9dbd3f0c78095d06909ffc3;hp=112db7cbeea15c19fc1bf4a4159b359b7430bff7;hpb=dd74fc4938723fe5ec48d4e5fdcfbe58ac42a48d;p=jalview.git diff --git a/src/com/stevesoft/pat/lookAhead.java b/src/com/stevesoft/pat/lookAhead.java index 112db7c..73be36a 100755 --- a/src/com/stevesoft/pat/lookAhead.java +++ b/src/com/stevesoft/pat/lookAhead.java @@ -6,41 +6,94 @@ // -- Happy Computing! // package com.stevesoft.pat; -import java.util.Hashtable; + +import java.util.*; /** 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; +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); } - 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; - } + else + { + return pos; } - String leftForm() { - if(reverse) - return "(?!"; - else - return "(?="; + } + + 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; + } } - 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