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: SerializerTrace.java,v 1.2 2004/02/17 04:18:18 minchau Exp $
  18. */
  19. package com.sun.org.apache.xml.internal.serializer;
  20. import org.xml.sax.Attributes;
  21. /**
  22. * This interface defines a set of integer constants that identify trace event
  23. * types.
  24. */
  25. public interface SerializerTrace {
  26. /**
  27. * Event type generated when a document begins.
  28. *
  29. */
  30. public static final int EVENTTYPE_STARTDOCUMENT = 1;
  31. /**
  32. * Event type generated when a document ends.
  33. */
  34. public static final int EVENTTYPE_ENDDOCUMENT = 2;
  35. /**
  36. * Event type generated when an element begins (after the attributes have been processed but before the children have been added).
  37. */
  38. public static final int EVENTTYPE_STARTELEMENT = 3;
  39. /**
  40. * Event type generated when an element ends, after it's children have been added.
  41. */
  42. public static final int EVENTTYPE_ENDELEMENT = 4;
  43. /**
  44. * Event type generated for character data (CDATA and Ignorable Whitespace have their own events).
  45. */
  46. public static final int EVENTTYPE_CHARACTERS = 5;
  47. /**
  48. * Event type generated for ignorable whitespace (I'm not sure how much this is actually called.
  49. */
  50. public static final int EVENTTYPE_IGNORABLEWHITESPACE = 6;
  51. /**
  52. * Event type generated for processing instructions.
  53. */
  54. public static final int EVENTTYPE_PI = 7;
  55. /**
  56. * Event type generated after a comment has been added.
  57. */
  58. public static final int EVENTTYPE_COMMENT = 8;
  59. /**
  60. * Event type generate after an entity ref is created.
  61. */
  62. public static final int EVENTTYPE_ENTITYREF = 9;
  63. /**
  64. * Event type generated after CDATA is generated.
  65. */
  66. public static final int EVENTTYPE_CDATA = 10;
  67. /**
  68. * Event type generated when characters might be written to an output stream,
  69. * but these characters never are. They will ultimately be written out via
  70. * EVENTTYPE_OUTPUT_CHARACTERS. This type is used as attributes are collected.
  71. * Whenever the attributes change this event type is fired. At the very end
  72. * however, when the attributes do not change anymore and are going to be
  73. * ouput to the document the real characters will be written out using the
  74. * EVENTTYPE_OUTPUT_CHARACTERS.
  75. */
  76. public static final int EVENTTYPE_OUTPUT_PSEUDO_CHARACTERS = 11;
  77. /**
  78. * Event type generated when characters are written to an output stream.
  79. */
  80. public static final int EVENTTYPE_OUTPUT_CHARACTERS = 12;
  81. /**
  82. * Tell if trace listeners are present.
  83. *
  84. * @return True if there are trace listeners
  85. */
  86. public boolean hasTraceListeners();
  87. /**
  88. * Fire startDocument, endDocument events.
  89. *
  90. * @param eventType One of the EVENTTYPE_XXX constants.
  91. */
  92. public void fireGenerateEvent(int eventType);
  93. /**
  94. * Fire startElement, endElement events.
  95. *
  96. * @param eventType One of the EVENTTYPE_XXX constants.
  97. * @param name The name of the element.
  98. * @param atts The SAX attribute list.
  99. */
  100. public void fireGenerateEvent(int eventType, String name, Attributes atts);
  101. /**
  102. * Fire characters, cdata events.
  103. *
  104. * @param eventType One of the EVENTTYPE_XXX constants.
  105. * @param ch The char array from the SAX event.
  106. * @param start The start offset to be used in the char array.
  107. * @param length The end offset to be used in the chara array.
  108. */
  109. public void fireGenerateEvent(int eventType, char ch[], int start, int length);
  110. /**
  111. * Fire processingInstruction events.
  112. *
  113. * @param eventType One of the EVENTTYPE_XXX constants.
  114. * @param name The name of the processing instruction.
  115. * @param data The processing instruction data.
  116. */
  117. public void fireGenerateEvent(int eventType, String name, String data);
  118. /**
  119. * Fire comment and entity ref events.
  120. *
  121. * @param eventType One of the EVENTTYPE_XXX constants.
  122. * @param data The comment or entity ref data.
  123. */
  124. public void fireGenerateEvent(int eventType, String data);
  125. }