1 4 package gnu.kawa.xml; 5 import gnu.bytecode.Type; 6 import gnu.lists.*; 7 import gnu.mapping.*; 8 import gnu.expr.*; 9 import java.io.*; 10 11 18 19 public abstract class TreeScanner extends MethodProc 20 implements Externalizable, CanInline 21 { 22 public NodePredicate type; 23 24 public NodePredicate getNodePredicate () { return type; } 25 26 public abstract void scan (AbstractSequence seq, int ipos, 27 PositionConsumer out); 28 29 public int numArgs() { return 0x1001; } 30 31 public void apply (CallContext ctx) throws Throwable 32 { 33 PositionConsumer out = (PositionConsumer) ctx.consumer; 34 Object node = ctx.getNextArg(); 35 ctx.lastArg(); 36 KNode spos = (KNode) node; 37 scan(spos.sequence, spos.getPos(), out); 38 } 39 40 public void writeExternal(ObjectOutput out) throws IOException 41 { 42 out.writeObject(type); 43 } 44 45 public void readExternal(ObjectInput in) 46 throws IOException, ClassNotFoundException 47 { 48 type = (NodePredicate) in.readObject(); 49 } 50 51 public String toString () 52 { 53 return "#<" + getClass().getName() + ' ' + type + '>'; 54 } 55 56 public Expression inline (ApplyExp exp, ExpWalker walker) 57 { 58 if (exp.getTypeRaw() == null && type instanceof Type) 59 exp.setType(NodeSetType.getInstance((Type) type)); 60 return exp; 61 } 62 } 63 | Popular Tags |