1 8 9 package net.sourceforge.chaperon.process.extended; 10 11 import net.sourceforge.chaperon.model.extended.Pattern; 12 import net.sourceforge.chaperon.common.Decoder; 13 14 public abstract class StackNode 15 { 16 public Pattern pattern = null; 17 public StackNode last = null; 18 public StackNode ancestor = null; 19 public StackNode sibling = null; 20 private static int internalNodeCount = 0; 21 public final int index = internalNodeCount++; 22 23 public abstract String getText(); 24 25 public String toString() 26 { 27 return pattern.toString()+Decoder.toString(getText()); 28 } 29 30 public String dump() 31 { 32 return dump(""); 33 } 34 35 public String dump(String rest) 36 { 37 if (this==sibling) 38 throw new IllegalStateException (); 39 if (this==ancestor) 40 throw new IllegalStateException (); 41 42 44 if (ancestor!=null) 45 { 46 if (sibling!=null) 47 return ancestor.dump("->"+toString()+rest)+sibling.dump(rest); 48 else 49 return ancestor.dump("->"+toString()+rest); 50 } 51 52 if (sibling!=null) 53 return toString()+rest+"\n"+sibling.dump(rest); 54 else 55 return toString()+rest+"\n"; 56 } 57 } 58 | Popular Tags |