1 19 20 package gnu.regexp; 21 22 final class RETokenChar extends REToken { 23 private char[] ch; 24 private boolean insens; 25 26 RETokenChar(int subIndex, char c, boolean ins) { 27 super(subIndex); 28 ch = new char [1]; 29 ch[0] = (insens = ins) ? Character.toLowerCase(c) : c; 30 } 31 32 int getMinimumLength() { 33 return ch.length; 34 } 35 36 boolean match(CharIndexed input, REMatch mymatch) { 37 int z = ch.length; 38 char c; 39 for (int i=0; i<z; i++) { 40 c = input.charAt(mymatch.index+i); 41 if (( (insens) ? Character.toLowerCase(c) : c ) != ch[i]) { 42 return false; 43 } 44 } 45 mymatch.index += z; 46 47 return next(input, mymatch); 48 } 49 50 boolean chain(REToken next) { 52 if (next instanceof RETokenChar) { 53 RETokenChar cnext = (RETokenChar) next; 54 int newsize = ch.length + cnext.ch.length; 56 57 char[] chTemp = new char [newsize]; 58 59 System.arraycopy(ch,0,chTemp,0,ch.length); 60 System.arraycopy(cnext.ch,0,chTemp,ch.length,cnext.ch.length); 61 62 ch = chTemp; 63 return false; 64 } else return super.chain(next); 65 } 66 67 void dump(StringBuffer os) { 68 os.append(ch); 69 } 70 } 71 72 73 | Popular Tags |