1. /*
  2. * Copyright 1999-2004 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  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. package com.sun.org.apache.xml.internal.dtm.ref;
  20. import org.xml.sax.ContentHandler;
  21. import org.xml.sax.InputSource;
  22. import org.xml.sax.SAXException;
  23. /** <p>IncrementalSAXSource is an API that delivers a small number of
  24. * SAX events each time a request is made from a "controller"
  25. * coroutine. See IncrementalSAXFilter and IncrementalSAXFilter_Xerces
  26. * for examples.
  27. *
  28. * Note that interaction is via the deliverMoreNodes
  29. * method, and therefore coroutine support is not exposed
  30. * here.</p>
  31. * */
  32. public interface IncrementalSAXSource
  33. {
  34. // ------------------------------------------------------------------
  35. // SAX Output API
  36. // ------------------------------------------------------------------
  37. /** Register a SAX-style content handler for us to output to
  38. */
  39. public void setContentHandler(ContentHandler handler);
  40. /** Register a SAX-style lexical handler for us to output to
  41. */
  42. public void setLexicalHandler(org.xml.sax.ext.LexicalHandler handler);
  43. /** Register a SAX-style DTD handler for us to output to
  44. */
  45. public void setDTDHandler(org.xml.sax.DTDHandler handler);
  46. // ------------------------------------------------------------------
  47. // Command Input API
  48. // ------------------------------------------------------------------
  49. /** deliverMoreNodes() is a simple API which tells the thread in which the
  50. * IncrementalSAXSource is running to deliver more events (true),
  51. * or stop delivering events and close out its input (false).
  52. *
  53. * This is intended to be called from one of our partner coroutines,
  54. * and serves to encapsulate the coroutine communication protocol.
  55. *
  56. * @param parsemore If true, tells the incremental SAX stream to deliver
  57. * another chunk of events. If false, finishes out the stream.
  58. *
  59. * @return Boolean.TRUE if the IncrementalSAXSource believes more data
  60. * may be available for further parsing. Boolean.FALSE if parsing
  61. * ran to completion, or was ended by deliverMoreNodes(false).
  62. * */
  63. public Object deliverMoreNodes (boolean parsemore);
  64. // ------------------------------------------------------------------
  65. // Parse Thread Convenience API
  66. // ------------------------------------------------------------------
  67. /** Launch an XMLReader's parsing operation, feeding events to this
  68. * IncrementalSAXSource. In some implementations, this may launch a
  69. * thread which runs the previously supplied XMLReader's parse() operation.
  70. * In others, it may do other forms of initialization.
  71. *
  72. * @throws SAXException is parse thread is already in progress
  73. * or parsing can not be started.
  74. * */
  75. public void startParse(InputSource source) throws SAXException;
  76. } // class IncrementalSAXSource