Formatting
[jalview.git] / src / com / stevesoft / pat / StringLike.java
1 package //\r
2 // This software is now distributed according to\r
3 // the Lesser Gnu Public License.  Please see\r
4 // http://www.gnu.org/copyleft/lesser.txt for\r
5 // the details.\r
6 //    -- Happy Computing!\r
7 //\r
8     com.stevesoft.pat;\r
9 \r
10 /** Package pat can search anything that implements this\r
11     interface.  Package pat assumes the following:\r
12     <ul>\r
13     <li>The StringLike object will not change.  Calls to\r
14         charAt(int) will not vary with time.\r
15     <li>The length of the object being searched is known\r
16         before the search begins and does not vary with time.\r
17     </ul>\r
18     Note that searching String is probably faster than searching\r
19     other objects, so searching String is still preferred if\r
20     possible.\r
21  */\r
22 public interface StringLike\r
23 {\r
24   public char charAt(int i);\r
25 \r
26   public String toString();\r
27 \r
28   public int length();\r
29 \r
30   public String substring(int i1, int i2);\r
31 \r
32   /** Obtain the underlying object, be it a String, char[],\r
33       RandomAccessFile, whatever. */\r
34   public Object unwrap();\r
35 \r
36   /** By default, the result is put in a String or char[]\r
37       when a replace is done.  If you wish to save the result\r
38       in some other StringBufferLike then you can do this\r
39       by implementing this method, or over-riding it's behavior\r
40       from an existing class. */\r
41   public BasicStringBufferLike newStringBufferLike();\r
42 \r
43   public int indexOf(char c);\r
44 }\r