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: GenerateEvent.java 468644 2006-10-28 06:56:42Z minchau $
020     */
021    package org.apache.xalan.trace;
022    
023    import org.apache.xalan.transformer.TransformerImpl;
024    import org.xml.sax.Attributes;
025    
026    /**
027     * Event generated by the XSL processor after it generates a new node in the result tree.
028     * This event responds to and is modeled on the SAX events that are sent to the
029     * formatter listener FormatterToXXX)classes.
030     *
031     * @see org.apache.xml.utils.DOMBuilder
032     * @see org.apache.xml.serializer.ToHTMLStream
033     * @see org.apache.xml.serializer.ToTextStream
034     * @see org.apache.xml.serializer.ToXMLStream
035     *
036     * @xsl.usage advanced
037     */
038    public class GenerateEvent implements java.util.EventListener
039    {
040    
041      /**
042       * The XSLT Transformer, which either directly or indirectly contains most needed information.
043       *
044       * @see org.apache.xalan.transformer.TransformerImpl
045       */
046      public TransformerImpl m_processor;
047    
048      /**
049       * The type of SAX event that was generated, as enumerated in the EVENTTYPE_XXX constants below.
050       */
051      public int m_eventtype;
052    
053    
054      /**
055       * Character data from a character or cdata event.
056       */
057      public char m_characters[];
058    
059      /**
060       * The start position of the current data in m_characters.
061       */
062      public int m_start;
063    
064      /**
065       * The length of the current data in m_characters.
066       */
067      public int m_length;
068    
069      /**
070       * The name of the element or PI.
071       */
072      public String m_name;
073    
074      /**
075       * The string data in the element (comments and PIs).
076       */
077      public String m_data;
078    
079      /**
080       * The current attribute list.
081       */
082      public Attributes m_atts;
083    
084      /**
085       * Constructor for startDocument, endDocument events.
086       *
087       * @param processor The XSLT TransformerFactory instance.
088       * @param eventType One of the EVENTTYPE_XXX constants.
089       */
090      public GenerateEvent(TransformerImpl processor, int eventType)
091      {
092        m_processor = processor;
093        m_eventtype = eventType;
094      }
095    
096      /**
097       * Constructor for startElement, endElement events.
098       *
099       * @param processor The XSLT TransformerFactory Instance.
100       * @param eventType One of the EVENTTYPE_XXX constants.
101       * @param name The name of the element.
102       * @param atts The SAX attribute list.
103       */
104      public GenerateEvent(TransformerImpl processor, int eventType, String name,
105                           Attributes atts)
106      {
107    
108        m_name = name;
109        m_atts = atts;
110        m_processor = processor;
111        m_eventtype = eventType;
112      }
113    
114      /**
115       * Constructor for characters, cdate events.
116       *
117       * @param processor The XSLT TransformerFactory instance.
118       * @param eventType One of the EVENTTYPE_XXX constants.
119       * @param ch The char array from the SAX event.
120       * @param start The start offset to be used in the char array.
121       * @param length The end offset to be used in the chara array.
122       */
123      public GenerateEvent(TransformerImpl processor, int eventType, char ch[],
124                           int start, int length)
125      {
126    
127        m_characters = ch;
128        m_start = start;
129        m_length = length;
130        m_processor = processor;
131        m_eventtype = eventType;
132      }
133    
134      /**
135       * Constructor for processingInstruction events.
136       *
137       * @param processor The instance of the XSLT processor.
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 GenerateEvent(TransformerImpl processor, int eventType, String name,
143                           String data)
144      {
145    
146        m_name = name;
147        m_data = data;
148        m_processor = processor;
149        m_eventtype = eventType;
150      }
151    
152      /**
153       * Constructor for comment and entity ref events.
154       *
155       * @param processor The XSLT processor instance.
156       * @param eventType One of the EVENTTYPE_XXX constants.
157       * @param data The comment or entity ref data.
158       */
159      public GenerateEvent(TransformerImpl processor, int eventType, String data)
160      {
161    
162        m_data = data;
163        m_processor = processor;
164        m_eventtype = eventType;
165      }
166    }