KickJava   Java API By Example, From Geeks To Geeks.

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


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.java.LineMap;
33 import com.caucho.log.Log;
34 import com.caucho.util.L10N;
35 import com.caucho.vfs.Path;
36 import com.caucho.vfs.PersistentDependency;
37
38 import javax.servlet.jsp.tagext.TagInfo JavaDoc;
39 import javax.servlet.jsp.tagext.TagLibraryInfo JavaDoc;
40 import java.util.ArrayList JavaDoc;
41 import java.util.logging.Logger JavaDoc;
42
43 /**
44  * Generates JSP code. JavaGenerator, JavaScriptGenerator, and
45  * StaticGenerator specialize the JspGenerator for language-specific
46  * requirements.
47  *
48  * <p>JspParser parses the JSP file into an XML-DOM tree. JspGenerator
49  * generates code from that tree.
50  */

51 abstract public class JspGenerator {
52   static final L10N L = new L10N(JspGenerator.class);
53   static final Logger JavaDoc log = Log.open(JspGenerator.class);
54
55   protected JspParser _jspParser;
56   protected JspCompiler _jspCompiler;
57   protected JspCompilerInstance _jspCompilerInstance;
58   
59   // maps lines in the generated code back to lines in
60
// the JSP file.
61
protected LineMap _lineMap;
62   
63   public void setJspCompiler(JspCompiler compiler)
64   {
65     _jspCompiler = compiler;
66   }
67   
68   public JspCompiler getJspCompiler()
69   {
70     return _jspCompiler;
71   }
72   
73   public void setJspCompilerInstance(JspCompilerInstance compiler)
74   {
75     _jspCompilerInstance = compiler;
76   }
77   
78   public JspCompilerInstance getJspCompilerInstance()
79   {
80     return _jspCompilerInstance;
81   }
82   
83   abstract protected void setParseState(ParseState parseState);
84   
85   abstract protected ParseState getParseState();
86   
87   public void setJspParser(JspParser parser)
88   {
89     _jspParser = parser;
90   }
91
92   public JspParser getJspParser()
93   {
94     return _jspParser;
95   }
96   
97   public LineMap getLineMap()
98   {
99     return _lineMap;
100   }
101
102   public boolean isELIgnore()
103   {
104     return getParseState().isELIgnored();
105   }
106
107   public void addDepend(PersistentDependency depend)
108   {
109   }
110
111   public ArrayList JavaDoc<PersistentDependency> getDependList()
112   {
113     return null;
114   }
115
116   /**
117    * Returns true if the JSP compilation has produced a static file.
118    */

119   public boolean isStatic()
120   {
121     return false;
122   }
123
124   /**
125    * Returns the tags taginfo.
126    */

127   public TagInfo JavaDoc generateTagInfo(String JavaDoc className, TagLibraryInfo JavaDoc tag)
128   {
129     throw new IllegalStateException JavaDoc();
130   }
131
132   /**
133    * Validates the page.
134    */

135   abstract public void validate()
136     throws Exception JavaDoc;
137   
138   /**
139    * Generates the JSP page.
140    */

141   abstract protected void generate(Path path, String JavaDoc className)
142     throws Exception JavaDoc;
143
144   public String JavaDoc getSourceLines(Path source, int errorLine)
145   {
146     return "";
147   }
148 }
149
Popular Tags