JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / src / com / stevesoft / pat / CustomEndpoint.java
1 //
2 // This software is now distributed according to
3 // the Lesser Gnu Public License.  Please see
4 // http://www.gnu.org/copyleft/lesser.txt for
5 // the details.
6 //    -- Happy Computing!
7 //
8 package com.stevesoft.pat;
9
10 import java.util.*;
11
12 /**
13  * This class is needed internally to make backtracking work correctly in
14  * user-defined patterns.
15  */
16 class CustomEndpoint extends Pattern
17 {
18   Custom c;
19
20   CustomEndpoint(Custom cm)
21   {
22     c = cm;
23   }
24
25   public int matchInternal(int pos, Pthings pt)
26   {
27     int npos = c.v.validate(pt.src, c.start, pos);
28     if (npos >= 0)
29     {
30       return nextMatch(npos, pt);
31     }
32     return -1;
33   }
34
35   public String toString()
36   {
37     return "";
38   }
39
40   Pattern clone1(Hashtable h)
41   {
42     return new CustomEndpoint((Custom) c.clone(h));
43   }
44 }