1. /*
  2. * Copyright 2003-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: SerializationHandler.java,v 1.4 2004/02/17 04:18:18 minchau Exp $
  18. */
  19. package com.sun.org.apache.xml.internal.serializer;
  20. import java.io.IOException;
  21. import java.io.OutputStream;
  22. import java.io.Writer;
  23. import java.util.Properties;
  24. import java.util.Vector;
  25. import javax.xml.transform.Transformer;
  26. import com.sun.org.apache.xml.internal.serializer.Serializer;
  27. import org.w3c.dom.Node;
  28. import org.xml.sax.ContentHandler;
  29. import org.xml.sax.ErrorHandler;
  30. import org.xml.sax.SAXException;
  31. import org.xml.sax.ext.DeclHandler;
  32. /**
  33. * This interface is the one that a serializer implements. It is a group of
  34. * other interfaces, such as ExtendedContentHandler, ExtendedLexicalHandler etc.
  35. * In addition there are other methods, such as reset().
  36. */
  37. public interface SerializationHandler
  38. extends
  39. ExtendedContentHandler,
  40. ExtendedLexicalHandler,
  41. XSLOutputAttributes,
  42. DeclHandler,
  43. ErrorHandler,
  44. DOMSerializer,
  45. Serializer
  46. {
  47. /**
  48. * Set the SAX Content handler that the serializer sends its output to. This
  49. * method only applies to a ToSAXHandler, not to a ToStream serializer.
  50. *
  51. * @see com.sun.org.apache.xml.internal.serializer.Serializer#asContentHandler()
  52. * @see com.sun.org.apache.xml.internal.serializer.ToSAXHandler
  53. */
  54. public void setContentHandler(ContentHandler ch);
  55. public void close();
  56. /**
  57. * Notify that the serializer should take this DOM node as input to be
  58. * serialized.
  59. *
  60. * @param node the DOM node to be serialized.
  61. * @throws IOException
  62. */
  63. public void serialize(Node node) throws IOException;
  64. /**
  65. * Turns special character escaping on/off.
  66. *
  67. * Note that characters will
  68. * never, even if this option is set to 'true', be escaped within
  69. * CDATA sections in output XML documents.
  70. *
  71. * @param true if escaping is to be set on.
  72. */
  73. public boolean setEscaping(boolean escape) throws SAXException;
  74. /**
  75. * Set the number of spaces to indent for each indentation level.
  76. * @param spaces the number of spaces to indent for each indentation level.
  77. */
  78. public void setIndentAmount(int spaces);
  79. /**
  80. * Set the transformer associated with the serializer.
  81. * @param transformer the transformer associated with the serializer.
  82. */
  83. public void setTransformer(Transformer transformer);
  84. /**
  85. * Get the transformer associated with the serializer.
  86. * @return Transformer the transformer associated with the serializer.
  87. */
  88. public Transformer getTransformer();
  89. /**
  90. * Used only by TransformerSnapshotImpl to restore the serialization
  91. * to a previous state.
  92. *
  93. * @param NamespaceMappings
  94. */
  95. public void setNamespaceMappings(NamespaceMappings mappings);
  96. /**
  97. * Flush any pending events currently queued up in the serializer. This will
  98. * flush any input that the serializer has which it has not yet sent as
  99. * output.
  100. */
  101. public void flushPending() throws SAXException;
  102. }