1 38 39 package com.sun.xml.fastinfoset.stax; 40 41 import javax.xml.namespace.QName ; 42 import javax.xml.stream.XMLStreamException; 43 import javax.xml.stream.XMLStreamReader; 44 import javax.xml.stream.XMLInputFactory; 45 import javax.xml.stream.StreamFilter; 46 import javax.xml.stream.events.XMLEvent; 47 import javax.xml.stream.StreamFilter; 48 import com.sun.xml.fastinfoset.CommonResourceBundle; 49 50 51 public class StAXFilteredParser extends StAXParserWrapper { 52 private StreamFilter _filter; 53 54 55 public StAXFilteredParser() { 56 } 57 public StAXFilteredParser(XMLStreamReader reader, StreamFilter filter) { 58 super(reader); 59 _filter = filter; 60 } 61 62 public void setFilter(StreamFilter filter) { 63 _filter = filter; 64 } 65 66 public int next() throws XMLStreamException 67 { 68 if (hasNext()) 69 return super.next(); 70 throw new IllegalStateException (CommonResourceBundle.getInstance().getString("message.noMoreItems")); 71 } 72 73 public boolean hasNext() throws XMLStreamException 74 { 75 while (super.hasNext()) { 76 if (_filter.accept(getReader())) return true; 77 super.next(); 78 } 79 return false; 80 } 81 82 } 83 | Popular Tags |