JAL-1807 still testing
[jalviewjs.git] / unused / com / stevesoft / pat / Custom.java
1 //\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 package com.stevesoft.pat;\r
9 \r
10 import java.util.*;\r
11 \r
12 /**\r
13  * Simple custom patterns. See <a\r
14  * href="http://javaregex.com/code/deriv2.java.html">deriv2.java</a> and <a\r
15  * href="http://javaregex.com/code/deriv3.java.html">deriv3.java</a> in the\r
16  * test directory.\r
17  * \r
18  * @see com.stevesoft.pat.CustomEndpoint\r
19  */\r
20 class Custom extends PatternSub\r
21 {\r
22   String select;\r
23 \r
24   Validator v;\r
25 \r
26   int start;\r
27 \r
28   Custom(String s)\r
29   {\r
30     select = s;\r
31     v = (Validator) Regex.validators.get(s);\r
32   }\r
33 \r
34   public int matchInternal(int pos, Pthings pt)\r
35   {\r
36     start = pos;\r
37     return sub.matchInternal(pos, pt);\r
38   }\r
39 \r
40   public String toString()\r
41   {\r
42     String a = v.argsave == null ? "" : ":" + v.argsave;\r
43     return "(??" + select + a + ")" + nextString();\r
44   }\r
45 \r
46   public patInt minChars()\r
47   {\r
48     return v.minChars();\r
49   }\r
50 \r
51   public patInt maxChars()\r
52   {\r
53     return v.maxChars();\r
54   }\r
55 \r
56   Pattern clone1(Hashtable h)\r
57   {\r
58     Custom c = new Custom(select);\r
59     h.put(c, c);\r
60     h.put(this, c);\r
61     c.sub = sub.clone(h);\r
62     return c;\r
63   }\r
64 }\r