14c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson/* 24c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Licensed to the Apache Software Foundation (ASF) under one 34c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * or more contributor license agreements. See the NOTICE file 44c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * distributed with this work for additional information 54c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * regarding copyright ownership. The ASF licenses this file 64c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * to you under the Apache License, Version 2.0 (the "License"); 74c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * you may not use this file except in compliance with the License. 84c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * You may obtain a copy of the License at 94c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * http://www.apache.org/licenses/LICENSE-2.0 114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Unless required by applicable law or agreed to in writing, software 134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS, 144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * See the License for the specific language governing permissions and 164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * limitations under the License. 174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson/* 194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * $Id: IncrementalSAXSource.java 468653 2006-10-28 07:07:05Z minchau $ 204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonpackage org.apache.xml.dtm.ref; 234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport org.xml.sax.ContentHandler; 254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport org.xml.sax.InputSource; 264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport org.xml.sax.SAXException; 274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson/** <p>IncrementalSAXSource is an API that delivers a small number of 294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * SAX events each time a request is made from a "controller" 304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * coroutine. See IncrementalSAXFilter and IncrementalSAXFilter_Xerces 314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * for examples. 324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Note that interaction is via the deliverMoreNodes 344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * method, and therefore coroutine support is not exposed 354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * here.</p> 364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * */ 374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonpublic interface IncrementalSAXSource 384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson{ 394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // ------------------------------------------------------------------ 404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // SAX Output API 414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // ------------------------------------------------------------------ 424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** Register a SAX-style content handler for us to output to 444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void setContentHandler(ContentHandler handler); 464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** Register a SAX-style lexical handler for us to output to 484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void setLexicalHandler(org.xml.sax.ext.LexicalHandler handler); 504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** Register a SAX-style DTD handler for us to output to 524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void setDTDHandler(org.xml.sax.DTDHandler handler); 544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // ------------------------------------------------------------------ 564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Command Input API 574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // ------------------------------------------------------------------ 584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** deliverMoreNodes() is a simple API which tells the thread in which the 604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * IncrementalSAXSource is running to deliver more events (true), 614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * or stop delivering events and close out its input (false). 624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * This is intended to be called from one of our partner coroutines, 644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * and serves to encapsulate the coroutine communication protocol. 654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param parsemore If true, tells the incremental SAX stream to deliver 674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * another chunk of events. If false, finishes out the stream. 684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return Boolean.TRUE if the IncrementalSAXSource believes more data 704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * may be available for further parsing. Boolean.FALSE if parsing 714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * ran to completion, or was ended by deliverMoreNodes(false). 724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * */ 734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public Object deliverMoreNodes (boolean parsemore); 744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // ------------------------------------------------------------------ 764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Parse Thread Convenience API 774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // ------------------------------------------------------------------ 784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** Launch an XMLReader's parsing operation, feeding events to this 804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * IncrementalSAXSource. In some implementations, this may launch a 814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * thread which runs the previously supplied XMLReader's parse() operation. 824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * In others, it may do other forms of initialization. 834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @throws SAXException is parse thread is already in progress 854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * or parsing can not be started. 864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * */ 874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void startParse(InputSource source) throws SAXException; 884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson} // class IncrementalSAXSource 90