X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fcom%2Fstevesoft%2Fpat%2FStringBufferLike.java;h=d125758574366dfd7c0aae988eb9344110736535;hb=506d60f0e188723ddc91c26824b41ac7034df3fe;hp=96d21789a2614df08872cd62a15e2df04ba05bc1;hpb=60f2d6c034560415fd0139c8bc7df0c19cae1186;p=jalview.git diff --git a/src/com/stevesoft/pat/StringBufferLike.java b/src/com/stevesoft/pat/StringBufferLike.java index 96d2178..d125758 100755 --- a/src/com/stevesoft/pat/StringBufferLike.java +++ b/src/com/stevesoft/pat/StringBufferLike.java @@ -1,90 +1,92 @@ -package // -// 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! -// - com.stevesoft.pat; - -/** A tool that is used to make the \E, \U, \L, and \Q - elements of a substitution. */ -public class StringBufferLike - implements BasicStringBufferLike -{ - BasicStringBufferLike sbl; - public StringBufferLike(BasicStringBufferLike sbl) - { - this.sbl = sbl; - } - - char mode = 'E', altMode = ' '; - public StringLike toStringLike() - { - return sbl.toStringLike(); - } - - public String toString() - { - return sbl.toString(); - } - - public void append(char c) - { - - switch (mode) - { - case 'u': - mode = altMode; - altMode = ' '; - case 'U': - sbl.append(CaseMgr.toUpperCase(c)); - break; - case 'l': - mode = altMode; - altMode = ' '; - case 'L': - sbl.append(CaseMgr.toLowerCase(c)); - break; - case 'Q': - if ( (c >= 'a' && c <= 'z') - || (c >= 'A' && c <= 'Z') - || (c >= '0' && c <= '9')) - { - ; - } - else - { - sbl.append('\\'); - } - default: - sbl.append(c); - break; - } - } - - public void append(String s) - { - for (int i = 0; i < s.length(); i++) - { - append(s.charAt(i)); - } - } - - public void setMode(char c) - { - if (c == 'u' || c == 'l') - { - if (altMode == ' ') - { - altMode = mode; - } - } - mode = c; - } - - public Object unwrap() - { - return sbl.unwrap(); - } -} +package // +// 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! +// +com.stevesoft.pat; + +/** + * A tool that is used to make the \E, \U, \L, and \Q elements of a + * substitution. + */ +public class StringBufferLike implements BasicStringBufferLike +{ + BasicStringBufferLike sbl; + + public StringBufferLike(BasicStringBufferLike sbl) + { + this.sbl = sbl; + } + + char mode = 'E', altMode = ' '; + + public StringLike toStringLike() + { + return sbl.toStringLike(); + } + + public String toString() + { + return sbl.toString(); + } + + public void append(char c) + { + + switch (mode) + { + case 'u': + mode = altMode; + altMode = ' '; + case 'U': + sbl.append(CaseMgr.toUpperCase(c)); + break; + case 'l': + mode = altMode; + altMode = ' '; + case 'L': + sbl.append(CaseMgr.toLowerCase(c)); + break; + case 'Q': + if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') + || (c >= '0' && c <= '9')) + { + ; + } + else + { + sbl.append('\\'); + } + default: + sbl.append(c); + break; + } + } + + public void append(String s) + { + for (int i = 0; i < s.length(); i++) + { + append(s.charAt(i)); + } + } + + public void setMode(char c) + { + if (c == 'u' || c == 'l') + { + if (altMode == ' ') + { + altMode = mode; + } + } + mode = c; + } + + public Object unwrap() + { + return sbl.unwrap(); + } +}