01: /*
02: * Copyright 1999-2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: /*
17: * $Id: IncrementalSAXSource.java,v 1.6 2004/02/16 23:06:11 minchau Exp $
18: */
19:
20: package org.apache.xml.dtm.ref;
21:
22: import org.xml.sax.ContentHandler;
23: import org.xml.sax.InputSource;
24: import org.xml.sax.SAXException;
25:
26: /** <p>IncrementalSAXSource is an API that delivers a small number of
27: * SAX events each time a request is made from a "controller"
28: * coroutine. See IncrementalSAXFilter and IncrementalSAXFilter_Xerces
29: * for examples.
30: *
31: * Note that interaction is via the deliverMoreNodes
32: * method, and therefore coroutine support is not exposed
33: * here.</p>
34: * */
35: public interface IncrementalSAXSource {
36: // ------------------------------------------------------------------
37: // SAX Output API
38: // ------------------------------------------------------------------
39:
40: /** Register a SAX-style content handler for us to output to
41: */
42: public void setContentHandler(ContentHandler handler);
43:
44: /** Register a SAX-style lexical handler for us to output to
45: */
46: public void setLexicalHandler(org.xml.sax.ext.LexicalHandler handler);
47:
48: /** Register a SAX-style DTD handler for us to output to
49: */
50: public void setDTDHandler(org.xml.sax.DTDHandler handler);
51:
52: // ------------------------------------------------------------------
53: // Command Input API
54: // ------------------------------------------------------------------
55:
56: /** deliverMoreNodes() is a simple API which tells the thread in which the
57: * IncrementalSAXSource is running to deliver more events (true),
58: * or stop delivering events and close out its input (false).
59: *
60: * This is intended to be called from one of our partner coroutines,
61: * and serves to encapsulate the coroutine communication protocol.
62: *
63: * @param parsemore If true, tells the incremental SAX stream to deliver
64: * another chunk of events. If false, finishes out the stream.
65: *
66: * @return Boolean.TRUE if the IncrementalSAXSource believes more data
67: * may be available for further parsing. Boolean.FALSE if parsing
68: * ran to completion, or was ended by deliverMoreNodes(false).
69: * */
70: public Object deliverMoreNodes(boolean parsemore);
71:
72: // ------------------------------------------------------------------
73: // Parse Thread Convenience API
74: // ------------------------------------------------------------------
75:
76: /** Launch an XMLReader's parsing operation, feeding events to this
77: * IncrementalSAXSource. In some implementations, this may launch a
78: * thread which runs the previously supplied XMLReader's parse() operation.
79: * In others, it may do other forms of initialization.
80: *
81: * @throws SAXException is parse thread is already in progress
82: * or parsing can not be started.
83: * */
84: public void startParse(InputSource source) throws SAXException;
85:
86: } // class IncrementalSAXSource
|