001: /*
002: * Copyright 1999-2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: /*
017: * $Id: GenerateEvent.java,v 1.12 2005/02/04 22:20:38 mcnamara Exp $
018: */
019: package org.apache.xalan.trace;
020:
021: import org.apache.xalan.transformer.TransformerImpl;
022: import org.xml.sax.Attributes;
023:
024: /**
025: * Event generated by the XSL processor after it generates a new node in the result tree.
026: * This event responds to and is modeled on the SAX events that are sent to the
027: * formatter listener FormatterToXXX)classes.
028: *
029: * @see org.apache.xml.utils.DOMBuilder
030: * @see org.apache.xml.serializer.ToHTMLStream
031: * @see org.apache.xml.serializer.ToTextStream
032: * @see org.apache.xml.serializer.ToXMLStream
033: *
034: * @xsl.usage advanced
035: */
036: public class GenerateEvent implements java.util.EventListener {
037:
038: /**
039: * The XSLT Transformer, which either directly or indirectly contains most needed information.
040: *
041: * @see org.apache.xalan.transformer.TransformerImpl
042: */
043: public TransformerImpl m_processor;
044:
045: /**
046: * The type of SAX event that was generated, as enumerated in the EVENTTYPE_XXX constants below.
047: */
048: public int m_eventtype;
049:
050: /**
051: * Character data from a character or cdata event.
052: */
053: public char m_characters[];
054:
055: /**
056: * The start position of the current data in m_characters.
057: */
058: public int m_start;
059:
060: /**
061: * The length of the current data in m_characters.
062: */
063: public int m_length;
064:
065: /**
066: * The name of the element or PI.
067: */
068: public String m_name;
069:
070: /**
071: * The string data in the element (comments and PIs).
072: */
073: public String m_data;
074:
075: /**
076: * The current attribute list.
077: */
078: public Attributes m_atts;
079:
080: /**
081: * Constructor for startDocument, endDocument events.
082: *
083: * @param processor The XSLT TransformerFactory instance.
084: * @param eventType One of the EVENTTYPE_XXX constants.
085: */
086: public GenerateEvent(TransformerImpl processor, int eventType) {
087: m_processor = processor;
088: m_eventtype = eventType;
089: }
090:
091: /**
092: * Constructor for startElement, endElement events.
093: *
094: * @param processor The XSLT TransformerFactory Instance.
095: * @param eventType One of the EVENTTYPE_XXX constants.
096: * @param name The name of the element.
097: * @param atts The SAX attribute list.
098: */
099: public GenerateEvent(TransformerImpl processor, int eventType,
100: String name, Attributes atts) {
101:
102: m_name = name;
103: m_atts = atts;
104: m_processor = processor;
105: m_eventtype = eventType;
106: }
107:
108: /**
109: * Constructor for characters, cdate events.
110: *
111: * @param processor The XSLT TransformerFactory instance.
112: * @param eventType One of the EVENTTYPE_XXX constants.
113: * @param ch The char array from the SAX event.
114: * @param start The start offset to be used in the char array.
115: * @param length The end offset to be used in the chara array.
116: */
117: public GenerateEvent(TransformerImpl processor, int eventType,
118: char ch[], int start, int length) {
119:
120: m_characters = ch;
121: m_start = start;
122: m_length = length;
123: m_processor = processor;
124: m_eventtype = eventType;
125: }
126:
127: /**
128: * Constructor for processingInstruction events.
129: *
130: * @param processor The instance of the XSLT processor.
131: * @param eventType One of the EVENTTYPE_XXX constants.
132: * @param name The name of the processing instruction.
133: * @param data The processing instruction data.
134: */
135: public GenerateEvent(TransformerImpl processor, int eventType,
136: String name, String data) {
137:
138: m_name = name;
139: m_data = data;
140: m_processor = processor;
141: m_eventtype = eventType;
142: }
143:
144: /**
145: * Constructor for comment and entity ref events.
146: *
147: * @param processor The XSLT processor instance.
148: * @param eventType One of the EVENTTYPE_XXX constants.
149: * @param data The comment or entity ref data.
150: */
151: public GenerateEvent(TransformerImpl processor, int eventType,
152: String data) {
153:
154: m_data = data;
155: m_processor = processor;
156: m_eventtype = eventType;
157: }
158: }
|