--- /dev/null
+//\r
+// This software is now distributed according to\r
+// the Lesser Gnu Public License. Please see\r
+// http://www.gnu.org/copyleft/lesser.txt for\r
+// the details.\r
+// -- Happy Computing!\r
+//\r
+package com.stevesoft.pat;\r
+import java.util.Hashtable;\r
+\r
+/** Simple custom patterns. See\r
+ <a href="http://javaregex.com/code/deriv2.java.html">deriv2.java</a>\r
+ and <a href="http://javaregex.com/code/deriv3.java.html">deriv3.java</a>\r
+ in the test directory.\r
+ @see com.stevesoft.pat.CustomEndpoint\r
+ */\r
+class Custom extends PatternSub {\r
+ String select;\r
+ Validator v;\r
+ int start;\r
+ Custom(String s) {\r
+ select = s;\r
+ v = (Validator)Regex.validators.get(s);\r
+ }\r
+ public int matchInternal(int pos,Pthings pt) {\r
+ start = pos;\r
+ return sub.matchInternal(pos,pt);\r
+ }\r
+ public String toString() {\r
+ String a = v.argsave == null ? "" : ":"+v.argsave;\r
+ return "(??"+select+a+")"+nextString();\r
+ }\r
+ public patInt minChars() { return v.minChars(); }\r
+ public patInt maxChars() { return v.maxChars(); }\r
+ Pattern clone1(Hashtable h) {\r
+ Custom c = new Custom(select);\r
+ h.put(c,c);\r
+ h.put(this,c);\r
+ c.sub = sub.clone(h);\r
+ return c;\r
+ }\r
+}\r