1 package net.sf.saxon.instruct; 2 import net.sf.saxon.expr.*; 3 import net.sf.saxon.om.Item; 4 import net.sf.saxon.om.NamePool; 5 import net.sf.saxon.om.SequenceIterator; 6 import net.sf.saxon.trans.DynamicError; 7 import net.sf.saxon.trans.StaticError; 8 import net.sf.saxon.trans.XPathException; 9 import net.sf.saxon.type.ItemType; 10 11 import java.io.PrintStream ; 12 import java.util.Collections ; 13 import java.util.Iterator ; 14 15 19 20 public class DeferredError extends Instruction { 21 22 private StaticError error; 23 private int nameCode; 24 25 public DeferredError(int nameCode, StaticError error) { 26 if (error==null) { 27 throw new NullPointerException ("Deferred Error: no error value supplied"); 28 } 29 this.error = error; 30 this.nameCode = nameCode; 31 } 32 33 36 37 public int getInstructionNameCode() { 38 return nameCode; 39 }; 40 41 49 50 public Expression simplify(StaticContext env) throws XPathException { 51 return this; 52 } 53 54 public Expression typeCheck(StaticContext env, ItemType contextItemType) throws XPathException { 55 return this; 56 } 57 58 75 76 public Expression optimize(Optimizer opt, StaticContext env, ItemType contextItemType) throws XPathException { 77 return this; 78 } 79 80 85 86 protected void promoteInst(PromotionOffer offer) throws XPathException { 87 } 88 89 94 95 public Iterator iterateSubExpressions() { 96 return Collections.EMPTY_LIST.iterator(); 97 } 98 99 public TailCall processLeavingTail(XPathContext context) throws XPathException { 100 throw DynamicError.makeDynamicError(error); 101 } 102 103 117 118 public Item evaluateItem(XPathContext context) throws XPathException { 119 throw DynamicError.makeDynamicError(error); 120 } 121 122 138 139 public SequenceIterator iterate(XPathContext context) throws XPathException { 140 evaluateItem(context); 141 return null; 142 } 143 144 151 152 public void display(int level, NamePool pool, PrintStream out) { 153 out.println(ExpressionTool.indent(level) + "error: " + error.getMessage()); 154 } 155 } 156 157 | Popular Tags |