001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements. See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership. The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the  "License");
007     * you may not use this file except in compliance with the License.
008     * You may obtain a copy of the License at
009     *
010     *     http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing, software
013     * distributed under the License is distributed on an "AS IS" BASIS,
014     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015     * See the License for the specific language governing permissions and
016     * limitations under the License.
017     */
018    /*
019     * $Id: SerializerTrace.java 468654 2006-10-28 07:09:23Z minchau $
020     */
021    package org.apache.xml.serializer;
022    
023    import org.xml.sax.Attributes;
024    
025    /**
026     * This interface defines a set of integer constants that identify trace event
027     * types.
028     * 
029     * @xsl.usage internal
030     */
031    
032    public interface SerializerTrace {
033        
034      /**
035       * Event type generated when a document begins.
036       *
037       */
038      public static final int EVENTTYPE_STARTDOCUMENT = 1;
039    
040      /**
041       * Event type generated when a document ends.
042       */
043      public static final int EVENTTYPE_ENDDOCUMENT = 2;
044    
045      /**
046       * Event type generated when an element begins (after the attributes have been processed but before the children have been added).
047       */
048      public static final int EVENTTYPE_STARTELEMENT = 3;
049    
050      /**
051       * Event type generated when an element ends, after it's children have been added.
052       */
053      public static final int EVENTTYPE_ENDELEMENT = 4;
054    
055      /**
056       * Event type generated for character data (CDATA and Ignorable Whitespace have their own events).
057       */
058      public static final int EVENTTYPE_CHARACTERS = 5;
059    
060      /**
061       * Event type generated for ignorable whitespace (I'm not sure how much this is actually called.
062       */
063      public static final int EVENTTYPE_IGNORABLEWHITESPACE = 6;
064    
065      /**
066       * Event type generated for processing instructions.
067       */
068      public static final int EVENTTYPE_PI = 7;
069    
070      /**
071       * Event type generated after a comment has been added.
072       */
073      public static final int EVENTTYPE_COMMENT = 8;
074    
075      /**
076       * Event type generate after an entity ref is created.
077       */
078      public static final int EVENTTYPE_ENTITYREF = 9;
079    
080      /**
081       * Event type generated after CDATA is generated.
082       */
083      public static final int EVENTTYPE_CDATA = 10;
084      
085      /**
086       * Event type generated when characters might be written to an output stream,
087       *  but  these characters never are. They will ultimately be written out via
088       * EVENTTYPE_OUTPUT_CHARACTERS. This type is used as attributes are collected.
089       * Whenever the attributes change this event type is fired. At the very end
090       * however, when the attributes do not change anymore and are going to be
091       * ouput to the document the real characters will be written out using the
092       * EVENTTYPE_OUTPUT_CHARACTERS.
093       */
094      public static final int EVENTTYPE_OUTPUT_PSEUDO_CHARACTERS = 11;
095      
096      /**
097       * Event type generated when characters are written to an output stream.
098       */
099      public static final int EVENTTYPE_OUTPUT_CHARACTERS = 12;
100        
101    
102      /**
103       * Tell if trace listeners are present.
104       *
105       * @return True if there are trace listeners
106       */
107      public boolean hasTraceListeners();
108      
109      /**
110       * Fire startDocument, endDocument events.
111       *
112       * @param eventType One of the EVENTTYPE_XXX constants.
113       */
114      public void fireGenerateEvent(int eventType);
115      
116      /**
117       * Fire startElement, endElement events.
118       *
119       * @param eventType One of the EVENTTYPE_XXX constants.
120       * @param name The name of the element.
121       * @param atts The SAX attribute list.
122       */
123      public void fireGenerateEvent(int eventType, String name, Attributes atts);
124      
125      /**
126       * Fire characters, cdata events.
127       *
128       * @param eventType One of the EVENTTYPE_XXX constants.
129       * @param ch The char array from the SAX event.
130       * @param start The start offset to be used in the char array.
131       * @param length The end offset to be used in the chara array.
132       */
133      public void fireGenerateEvent(int eventType, char ch[], int start, int length);
134      
135      /**
136       * Fire processingInstruction events.
137       *
138       * @param eventType One of the EVENTTYPE_XXX constants.
139       * @param name The name of the processing instruction.
140       * @param data The processing instruction data.
141       */
142      public void fireGenerateEvent(int eventType, String name, String data);
143      
144    
145      /**
146       * Fire comment and entity ref events.
147       *
148       * @param eventType One of the EVENTTYPE_XXX constants.
149       * @param data The comment or entity ref data.
150       */
151      public void fireGenerateEvent(int eventType, String data);
152      
153    }