X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fcom%2Fstevesoft%2Fpat%2FlookAhead.java;h=5f2a1d0d8f4f341abeef2b10f41251538b4991d2;hb=02fdab3e44192d6227d7ce305d9b8ad6626932c2;hp=73be36a796c6cc68aadeee26164cb513242a4864;hpb=7bc226b58110fa26d9dbd3f0c78095d06909ffc3;p=jalview.git diff --git a/src/com/stevesoft/pat/lookAhead.java b/src/com/stevesoft/pat/lookAhead.java index 73be36a..5f2a1d0 100755 --- a/src/com/stevesoft/pat/lookAhead.java +++ b/src/com/stevesoft/pat/lookAhead.java @@ -1,99 +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.*; - -/** 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 < v.size(); i++) - { - la.v.addElement( ( (Pattern) v.elementAt(i)).clone(h)); - } - return la; - } -} +// +// 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 < v.size(); i++) + { + la.v.addElement(((Pattern) v.elementAt(i)).clone(h)); + } + return la; + } +}