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