X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fcom%2Fstevesoft%2Fpat%2Fwrap%2FCharArrayWrap.java;fp=src%2Fcom%2Fstevesoft%2Fpat%2Fwrap%2FCharArrayWrap.java;h=bde9bd1e2236c4185c925c154903468822632e34;hb=506d60f0e188723ddc91c26824b41ac7034df3fe;hp=6de78cf56d909900399135205b944932c41fb88a;hpb=60f2d6c034560415fd0139c8bc7df0c19cae1186;p=jalview.git diff --git a/src/com/stevesoft/pat/wrap/CharArrayWrap.java b/src/com/stevesoft/pat/wrap/CharArrayWrap.java index 6de78cf..bde9bd1 100755 --- a/src/com/stevesoft/pat/wrap/CharArrayWrap.java +++ b/src/com/stevesoft/pat/wrap/CharArrayWrap.java @@ -1,74 +1,75 @@ -// -// 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.wrap; - -import com.stevesoft.pat.*; - -/** This provides a wrapper for a char array so that - it can be searched by Regex. */ -public class CharArrayWrap - implements StringLike -{ - char[] ca; - public char[] getCharArray() - { - return ca; - } - - public CharArrayWrap(char[] ca) - { - this.ca = ca; - } - - public String toString() - { - return new String(ca); - } - - public char charAt(int i) - { - return ca[i]; - } - - public int length() - { - return ca.length; - } - - public String substring(int i1, int i2) - { - StringBuffer sb = new StringBuffer(); - for (int i = i1; i < i2; i++) - { - sb.append(ca[i]); - } - return sb.toString(); - } - - public Object unwrap() - { - return ca; - } - - public BasicStringBufferLike newStringBufferLike() - { - return new CharArrayBufferWrap(); - } - - public int indexOf(char c) - { - for (int i = 0; i < ca.length; i++) - { - if (ca[i] == c) - { - return i; - } - } - return -1; - } -} +// +// 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.wrap; + +import com.stevesoft.pat.*; + +/** + * This provides a wrapper for a char array so that it can be searched by Regex. + */ +public class CharArrayWrap implements StringLike +{ + char[] ca; + + public char[] getCharArray() + { + return ca; + } + + public CharArrayWrap(char[] ca) + { + this.ca = ca; + } + + public String toString() + { + return new String(ca); + } + + public char charAt(int i) + { + return ca[i]; + } + + public int length() + { + return ca.length; + } + + public String substring(int i1, int i2) + { + StringBuffer sb = new StringBuffer(); + for (int i = i1; i < i2; i++) + { + sb.append(ca[i]); + } + return sb.toString(); + } + + public Object unwrap() + { + return ca; + } + + public BasicStringBufferLike newStringBufferLike() + { + return new CharArrayBufferWrap(); + } + + public int indexOf(char c) + { + for (int i = 0; i < ca.length; i++) + { + if (ca[i] == c) + { + return i; + } + } + return -1; + } +}