X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fcom%2Fstevesoft%2Fpat%2FBoundary.java;fp=src%2Fcom%2Fstevesoft%2Fpat%2FBoundary.java;h=566b20ef9446600e0100486ec3035a349f234c14;hb=506d60f0e188723ddc91c26824b41ac7034df3fe;hp=d6481b4d307db8c684431dacd75aa0f14ff83f4a;hpb=60f2d6c034560415fd0139c8bc7df0c19cae1186;p=jalview.git diff --git a/src/com/stevesoft/pat/Boundary.java b/src/com/stevesoft/pat/Boundary.java index d6481b4..566b20e 100755 --- a/src/com/stevesoft/pat/Boundary.java +++ b/src/com/stevesoft/pat/Boundary.java @@ -1,92 +1,89 @@ -// -// 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.*; - -/** This class implements the word boundary pattern element: \b. */ -class Boundary - extends Pattern -{ - public String toString() - { - return "\\b" + nextString(); - } - - boolean isAChar(char c) - { - if (c >= 'a' && c <= 'z') - { - return true; - } - if (c >= 'A' && c <= 'Z') - { - return true; - } - if (c >= '0' && c <= '9') - { - return true; - } - if (c == '_') - { - return true; - } - return false; - } - - boolean matchLeft(int pos, Pthings pt) - { - if (pos <= 0) - { - return true; - } - if (isAChar(pt.src.charAt(pos)) - && isAChar(pt.src.charAt(pos - 1))) - { - return false; - } - return true; - } - - boolean matchRight(int pos, Pthings pt) - { - if (pos < 0) - { - return false; - } - if (pos + 1 >= pt.src.length()) - { - return true; - } - if (isAChar(pt.src.charAt(pos)) - && isAChar(pt.src.charAt(pos + 1))) - { - return false; - } - return true; - } - - public int matchInternal(int pos, Pthings pt) - { - if (matchRight(pos - 1, pt) || matchLeft(pos, pt)) - { - return nextMatch(pos, pt); - } - return -1; - } - - public patInt maxChars() - { - return new patInt(0); - } - - public Pattern clone1(Hashtable h) - { - return new Boundary(); - } -}; +// +// 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.*; + +/** This class implements the word boundary pattern element: \b. */ +class Boundary extends Pattern +{ + public String toString() + { + return "\\b" + nextString(); + } + + boolean isAChar(char c) + { + if (c >= 'a' && c <= 'z') + { + return true; + } + if (c >= 'A' && c <= 'Z') + { + return true; + } + if (c >= '0' && c <= '9') + { + return true; + } + if (c == '_') + { + return true; + } + return false; + } + + boolean matchLeft(int pos, Pthings pt) + { + if (pos <= 0) + { + return true; + } + if (isAChar(pt.src.charAt(pos)) && isAChar(pt.src.charAt(pos - 1))) + { + return false; + } + return true; + } + + boolean matchRight(int pos, Pthings pt) + { + if (pos < 0) + { + return false; + } + if (pos + 1 >= pt.src.length()) + { + return true; + } + if (isAChar(pt.src.charAt(pos)) && isAChar(pt.src.charAt(pos + 1))) + { + return false; + } + return true; + } + + public int matchInternal(int pos, Pthings pt) + { + if (matchRight(pos - 1, pt) || matchLeft(pos, pt)) + { + return nextMatch(pos, pt); + } + return -1; + } + + public patInt maxChars() + { + return new patInt(0); + } + + public Pattern clone1(Hashtable h) + { + return new Boundary(); + } +};