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: QueuedEvents.java 468645 2006-10-28 06:57:24Z minchau $
020 */
021 package org.apache.xalan.transformer;
022
023 import java.util.Vector;
024
025 import org.apache.xml.utils.MutableAttrListImpl;
026
027
028 /**
029 * This class acts as a base for ResultTreeHandler, and keeps
030 * queud stack events. In truth, we don't need a stack,
031 * so I may change this down the line a bit.
032 */
033 public abstract class QueuedEvents
034 {
035
036 /** The number of events queued */
037 protected int m_eventCount = 0;
038
039 /** Queued start document */
040 // QueuedStartDocument m_startDoc = new QueuedStartDocument();
041
042 /** Queued start element */
043 // QueuedStartElement m_startElement = new QueuedStartElement();
044
045 public boolean m_docPending = false;
046 protected boolean m_docEnded = false;
047
048 /** Flag indicating that an event is pending. Public for
049 * fast access by ElemForEach. */
050 public boolean m_elemIsPending = false;
051
052 /** Flag indicating that an event is ended */
053 public boolean m_elemIsEnded = false;
054
055 /**
056 * The pending attributes. We have to delay the call to
057 * m_flistener.startElement(name, atts) because of the
058 * xsl:attribute and xsl:copy calls. In other words,
059 * the attributes have to be fully collected before you
060 * can call startElement.
061 */
062 protected MutableAttrListImpl m_attributes = new MutableAttrListImpl();
063
064 /**
065 * Flag to try and get the xmlns decls to the attribute list
066 * before other attributes are added.
067 */
068 protected boolean m_nsDeclsHaveBeenAdded = false;
069
070 /**
071 * The pending element, namespace, and local name.
072 */
073 protected String m_name;
074
075 /** Namespace URL of the element */
076 protected String m_url;
077
078 /** Local part of qualified name of the element */
079 protected String m_localName;
080
081
082 /** Vector of namespaces for this element */
083 protected Vector m_namespaces = null;
084
085 // /**
086 // * Get the queued element.
087 // *
088 // * @return the queued element.
089 // */
090 // QueuedStartElement getQueuedElem()
091 // {
092 // return (m_eventCount > 1) ? m_startElement : null;
093 // }
094
095 /**
096 * To re-initialize the document and element events
097 *
098 */
099 protected void reInitEvents()
100 {
101 }
102
103 /**
104 * Push document event and re-initialize events
105 *
106 */
107 public void reset()
108 {
109 pushDocumentEvent();
110 reInitEvents();
111 }
112
113 /**
114 * Push the document event. This never gets popped.
115 */
116 void pushDocumentEvent()
117 {
118
119 // m_startDoc.setPending(true);
120 // initQSE(m_startDoc);
121 m_docPending = true;
122
123 m_eventCount++;
124 }
125
126 /**
127 * Pop element event
128 *
129 */
130 void popEvent()
131 {
132 m_elemIsPending = false;
133 m_attributes.clear();
134
135 m_nsDeclsHaveBeenAdded = false;
136 m_name = null;
137 m_url = null;
138 m_localName = null;
139 m_namespaces = null;
140
141 m_eventCount--;
142 }
143
144 /** Instance of a serializer */
145 private org.apache.xml.serializer.Serializer m_serializer;
146
147 /**
148 * This is only for use of object pooling, so that
149 * it can be reset.
150 *
151 * @param s non-null instance of a serializer
152 */
153 void setSerializer(org.apache.xml.serializer.Serializer s)
154 {
155 m_serializer = s;
156 }
157
158 /**
159 * This is only for use of object pooling, so the that
160 * it can be reset.
161 *
162 * @return The serializer
163 */
164 org.apache.xml.serializer.Serializer getSerializer()
165 {
166 return m_serializer;
167 }
168 }