KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xalan > transformer > QueuedEvents


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: QueuedEvents.java,v 1.14 2004/02/16 20:41:29 minchau Exp $
18  */

19 package org.apache.xalan.transformer;
20
21 import java.util.Vector JavaDoc;
22
23 import org.apache.xml.utils.MutableAttrListImpl;
24
25
26 /**
27  * This class acts as a base for ResultTreeHandler, and keeps
28  * queud stack events. In truth, we don't need a stack,
29  * so I may change this down the line a bit.
30  */

31 public abstract class QueuedEvents
32 {
33
34   /** The number of events queued */
35   protected int m_eventCount = 0;
36
37   /** Queued start document */
38   // QueuedStartDocument m_startDoc = new QueuedStartDocument();
39

40   /** Queued start element */
41   // QueuedStartElement m_startElement = new QueuedStartElement();
42

43   public boolean m_docPending = false;
44   protected boolean m_docEnded = false;
45   
46   /** Flag indicating that an event is pending. Public for
47    * fast access by ElemForEach. */

48   public boolean m_elemIsPending = false;
49
50   /** Flag indicating that an event is ended */
51   public boolean m_elemIsEnded = false;
52   
53   /**
54    * The pending attributes. We have to delay the call to
55    * m_flistener.startElement(name, atts) because of the
56    * xsl:attribute and xsl:copy calls. In other words,
57    * the attributes have to be fully collected before you
58    * can call startElement.
59    */

60   protected MutableAttrListImpl m_attributes = new MutableAttrListImpl();
61
62   /**
63    * Flag to try and get the xmlns decls to the attribute list
64    * before other attributes are added.
65    */

66   protected boolean m_nsDeclsHaveBeenAdded = false;
67
68   /**
69    * The pending element, namespace, and local name.
70    */

71   protected String JavaDoc m_name;
72
73   /** Namespace URL of the element */
74   protected String JavaDoc m_url;
75
76   /** Local part of qualified name of the element */
77   protected String JavaDoc m_localName;
78   
79   
80   /** Vector of namespaces for this element */
81   protected Vector JavaDoc m_namespaces = null;
82
83 // /**
84
// * Get the queued element.
85
// *
86
// * @return the queued element.
87
// */
88
// QueuedStartElement getQueuedElem()
89
// {
90
// return (m_eventCount > 1) ? m_startElement : null;
91
// }
92

93   /**
94    * To re-initialize the document and element events
95    *
96    */

97   protected void reInitEvents()
98   {
99   }
100
101   /**
102    * Push document event and re-initialize events
103    *
104    */

105   public void reset()
106   {
107     pushDocumentEvent();
108     reInitEvents();
109   }
110
111   /**
112    * Push the document event. This never gets popped.
113    */

114   void pushDocumentEvent()
115   {
116
117     // m_startDoc.setPending(true);
118
// initQSE(m_startDoc);
119
m_docPending = true;
120
121     m_eventCount++;
122   }
123
124   /**
125    * Pop element event
126    *
127    */

128   void popEvent()
129   {
130     m_elemIsPending = false;
131     m_attributes.clear();
132
133     m_nsDeclsHaveBeenAdded = false;
134     m_name = null;
135     m_url = null;
136     m_localName = null;
137     m_namespaces = null;
138
139     m_eventCount--;
140   }
141
142   /** Instance of a serializer */
143   private org.apache.xml.serializer.Serializer m_serializer;
144
145   /**
146    * This is only for use of object pooling, so that
147    * it can be reset.
148    *
149    * @param s non-null instance of a serializer
150    */

151   void setSerializer(org.apache.xml.serializer.Serializer s)
152   {
153     m_serializer = s;
154   }
155
156   /**
157    * This is only for use of object pooling, so the that
158    * it can be reset.
159    *
160    * @return The serializer
161    */

162   org.apache.xml.serializer.Serializer getSerializer()
163   {
164     return m_serializer;
165   }
166 }
167
Popular Tags