X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fcom%2Fstevesoft%2Fpat%2FSkip2.java;fp=src%2Fcom%2Fstevesoft%2Fpat%2FSkip2.java;h=f2b03cae4b007564ab36b1ceab0d2fcf2df579cb;hb=c40cf903f740a72ab63dd1abc10fa33450ce660d;hp=0000000000000000000000000000000000000000;hpb=5bcae030b489e670c6983aa97eb9b6d8a6bbbbd5;p=jalview.git diff --git a/src/com/stevesoft/pat/Skip2.java b/src/com/stevesoft/pat/Skip2.java new file mode 100755 index 0000000..f2b03ca --- /dev/null +++ b/src/com/stevesoft/pat/Skip2.java @@ -0,0 +1,38 @@ +// +// 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; + +/** This is the same as Skip, except it needs a minimum + of two characters in the initializing String. + @see com.stevesoft.pat.Skip + @see com.stevesoft.pat.SkipBMH + */ +public class Skip2 extends Skip { + int c1,mask1; + public Skip2(String s,boolean ign,int offset) { + super(s,ign,offset); + c1 = s.charAt(1); + m1 = 2==s.length(); + if(ign) { + mask1=mkmask(c1); + } else + mask1 = 0; + } + public int find(StringLike s,int start,int end) { + if(start > end) return -1; + start += offset; + int vend = min(s.length()-2,end+offset); + for(int i=start;i<=vend;i++) + if(0 == (s.charAt(i)&mask) && 0 == (s.charAt(i+1)&mask1)) { + //if(m1||s.regionMatches(ign,i,src,0,src.length()) ) + if(m1||CaseMgr.regionMatches(s,ign,i,src,0,src.length()) ) + return i-offset; + } + return -1; + } +}