1 5 6 package com.hp.hpl.jena.rdf.arp; 7 8 import java.io.InterruptedIOException ; 9 import java.util.*; 10 11 15 class PullingTokenPipe extends TokenPipe { 16 17 static PullingTokenPipe lastMade; 18 private int position = 0; 19 private boolean atEOF = false; 20 final XMLHandler arp; 21 final List pipe; 22 23 PullingTokenPipe(XMLHandler arp) { 24 this.arp = arp; 25 pipe = createPipe(); 26 if (Token.COUNT) 27 lastMade = this; 28 else 29 lastMade = null; 30 } 31 32 void putNextToken(Token t) { 33 pipe.add(t); 35 } 36 37 public Token getNextToken() { 38 while (true) { 39 if (getPosition() < pipe.size()) { 40 int p = position++; 41 Token rslt = (Token) pipe.get(p); 42 pipe.set(p,null); 43 setLast(rslt); 44 return rslt; 45 } 46 if (atEOF) 47 return new Token(RDFParserConstants.EOF, null); 48 if (Thread.interrupted()) 49 throw new WrappedException(new InterruptedIOException ("ARP interrupted")); 50 position=0; 51 pipe.clear(); 54 while (pipe.size() == 0) 55 if (!((SingleThreadedParser)arp).parseSome()) { 56 atEOF = true; 57 break; 58 } 59 } 60 } 61 private List createPipe() { 62 return new ArrayList(); 63 } 64 private int getPosition() { 65 return position; 66 } 67 } 68 69 70 96 97 | Popular Tags |