KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > jsp > JspBuilder


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.jsp;
31
32 import com.caucho.jsp.cfg.JspPropertyGroup;
33 import com.caucho.jsp.java.JspNode;
34 import com.caucho.vfs.Path;
35 import com.caucho.xml.QName;
36
37 /**
38  * Generates the nodes for JSP code.
39  */

40 abstract public class JspBuilder {
41   // The current source
42
protected Path _sourcePath;
43   
44   // The current filename
45
protected String JavaDoc _filename;
46   
47   // The current line
48
protected int _line;
49
50   // The parse state
51
protected ParseState _parseState;
52   
53   // The parser
54
protected JspParser _jspParser;
55   
56   // The compiler configuration
57
protected JspCompiler _jspCompiler;
58   
59   // The jsp property
60
private JspPropertyGroup _jspPropertyGroup;
61   
62   // The tag manager
63
protected ParseTagManager _tagManager;
64
65   /**
66    * Returns the generator.
67    */

68   abstract public JspGenerator getGenerator();
69
70   /**
71    * Returns the top node.
72    */

73   abstract public JspNode getRootNode();
74
75   /**
76    * Sets the parse state.
77    */

78   public void setParseState(ParseState parseState)
79   {
80     _parseState = parseState;
81   }
82
83   /**
84    * Returns the parse state.
85    */

86   public ParseState getParseState()
87   {
88     return _parseState;
89   }
90
91   /**
92    * Sets the page config?
93    */

94   public void setPageConfig(JspPageConfig pageConfig)
95   {
96   }
97
98   /**
99    * Sets the compiler
100    */

101   public void setJspCompiler(JspCompiler compiler)
102   {
103     _jspCompiler = compiler;
104   }
105
106   /**
107    * Returns the parse state.
108    */

109   public JspCompiler getJspCompiler()
110   {
111     return _jspCompiler;
112   }
113
114   /**
115    * Sets the parser
116    */

117   public void setJspParser(JspParser parser)
118   {
119     _jspParser = parser;
120   }
121
122   /**
123    * Returns the parse state.
124    */

125   public JspParser getJspParser()
126   {
127     return _jspParser;
128   }
129   
130   /**
131    * Sets the tag manager
132    */

133   public void setTagManager(ParseTagManager manager)
134   {
135     _tagManager = manager;
136   }
137
138   /**
139    * Returns the tag manager
140    */

141   public ParseTagManager getTagManager()
142   {
143     return _tagManager;
144   }
145   
146   /**
147    * Sets the jsp-property-group
148    */

149   public void setJspPropertyGroup(JspPropertyGroup jsp)
150   {
151     _jspPropertyGroup = jsp;
152   }
153   
154   /**
155    * Gets the jsp-property-group
156    */

157   public JspPropertyGroup getJspPropertyGroup()
158   {
159     return _jspPropertyGroup;
160   }
161
162   /**
163    * Returns true if fast-jstl is enabled.
164    */

165   public boolean isFastJstl()
166   {
167     JspPropertyGroup jsp = getJspPropertyGroup();
168
169     if (jsp == null)
170       return true;
171     else
172       return jsp.isFastJstl();
173   }
174
175   /**
176    * Returns true if require source is enabled.
177    */

178   public boolean getRequireSource()
179   {
180     JspPropertyGroup jsp = getJspPropertyGroup();
181
182     if (jsp == null)
183       return false;
184     else
185       return jsp.getRequireSource();
186   }
187
188   /**
189    * Set for prototype builder.
190    */

191   public void setPrototype(boolean isPrototype)
192   {
193   }
194
195   /**
196    * Sets the source line number.
197    */

198   public void setLocation(Path sourcePath, String JavaDoc filename, int line)
199   {
200     _sourcePath = sourcePath;
201     _filename = filename;
202     _line = line;
203   }
204   
205   /**
206    * Starts the document
207    */

208   abstract public void startDocument()
209     throws JspParseException;
210   
211   /**
212    * Starts the document
213    */

214   abstract public void endDocument()
215     throws JspParseException;
216
217   /**
218    * Starts an element.
219    *
220    * @param qname the name of the element to start
221    */

222   abstract public void startElement(QName qname)
223     throws JspParseException;
224
225   /**
226    * Starts a prefix mapping.
227    *
228    * @param prefix the xml prefix
229    * @param uri the namespace uri
230    */

231   abstract public void startPrefixMapping(String JavaDoc prefix, String JavaDoc uri)
232     throws JspParseException;
233   
234   /**
235    * Adds an attribute to the element.
236    *
237    * @param name the attribute name
238    * @param value the attribute value
239    */

240   abstract public void attribute(QName name, String JavaDoc value)
241     throws JspParseException;
242
243   /**
244    * Called after the attributes end.
245    */

246   abstract public void endAttributes()
247     throws JspParseException;
248   
249   /**
250    * Ends an element.
251    *
252    * @param name the name of the element to end
253    */

254   abstract public void endElement(String JavaDoc name)
255     throws JspParseException;
256   
257   /**
258    * Adds text.
259    *
260    * @param text the text to add
261    */

262   abstract public void text(String JavaDoc text)
263     throws JspParseException;
264   
265   /**
266    * Adds text.
267    *
268    * @param text the text to add
269    */

270   public void text(String JavaDoc text, String JavaDoc filename, int startLine, int endLine)
271     throws JspParseException
272   {
273     text(text);
274   }
275
276   /**
277    * Returns the current node.
278    */

279   abstract public JspNode getCurrentNode();
280 }
281
Popular Tags