Class Generator
java.lang.Object
org.apache.jasper.compiler.Generator
Generate Java source from Nodes
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classKeeps track of the generated Fragment Helper Classprivate static classA class for generating codes to a buffer.(package private) classA visitor that generates codes for the elements in the page.private static classClass storing the result of introspecting a custom tag handler. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Generator.GenBufferprivate BeanRepositoryprivate booleanprivate JspCompilationContextprivate ErrorDispatcherprivate Generator.FragmentHelperClassprivate booleanprivate booleanprivate ArrayList<Generator.GenBuffer> private static final Class[]private ServletWriterprivate PageInfo -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidCompiles list of tag handler pool names.(package private) static Stringprivate voidCommon part of postamble, shared by both servlets and tag files.static voidgenerate(ServletWriter out, Compiler compiler, Node.Nodes page) The main entry for Generator.private voidgenerateConstructor(String className) private voidGenerates declarations.private static voidgenerateLocalVariables(ServletWriter out, Node n, boolean genBytes) private voidgeneratePageScopedVariables(JasperTagInfo tagInfo) private voidgeneratePostamble(Node.Nodes page) Generates the ending part of the static portion of the servlet.private voidgeneratePreamble(Node.Nodes page) Generates the beginning of the static portion of the servlet.voidprivate voidgenerateSetJspContext(javax.servlet.jsp.tagext.TagInfo tagInfo) private voidgenerateTagHandlerAttributes(javax.servlet.jsp.tagext.TagInfo tagInfo) Generates declarations for tag handler attributes, and defines the getter and setter methods for each.private voidGenerates the _jspDestroy() method which is responsible for calling the release() method on every tag handler in any of the tag handler pools.private voidGenerates the _jspInit() method for instantiating the tag handler pools.private voidgenerateTagHandlerPostamble(javax.servlet.jsp.tagext.TagInfo tagInfo) private voidgenerateTagHandlerPreamble(JasperTagInfo tagInfo, Node.Nodes tag) private voidgenerateXmlProlog(Node.Nodes page) Generates an XML Prolog, which includes an XML declaration and an XML doctype declaration.private voidgenPreambleClassVariableDeclarations(String className) Declare tag handler pools (tags of the same type and with the same attribute set share the same tag handler pool) (shared by servlet and tag handler preamble generation)private voidGenerate preamble imports (shared by servlet and tag handler preamble generation)private voidDeclare general-purpose methods (shared by servlet and tag handler preamble generation)private voidgenPreamblePackage(String packageName) Generate preamble package name (shared by servlet and tag handler preamble generation)private voidGeneration of static initializers in preamble.(package private) static Stringquote(char c) Single quote and escape a character(package private) static Stringprivate StringtoGetterMethod(String attrName) private StringtoSetterMethodName(String attrName)
-
Field Details
-
OBJECT_CLASS
-
out
-
methodsBuffered
-
fragmentHelperClass
-
err
-
beanInfo
-
ctxt
-
isPoolingEnabled
private boolean isPoolingEnabled -
breakAtLF
private boolean breakAtLF -
genBytes
private boolean genBytes -
pageInfo
-
tagHandlerPoolNames
-
arrayBuffer
-
-
Constructor Details
-
Generator
Generator(ServletWriter out, Compiler compiler) Constructor.
-
-
Method Details
-
quote
-
escape
-
quote
Single quote and escape a character -
generateDeclarations
Generates declarations. This includes "info" of the page directive, and scriptlet declarations.- Throws:
JasperException
-
compileTagHandlerPoolList
Compiles list of tag handler pool names.- Throws:
JasperException
-
generateTagHandlerInit
private void generateTagHandlerInit()Generates the _jspInit() method for instantiating the tag handler pools. For tag file, _jspInit has to be invoked manually, and the ServletConfig object explicitly passed. -
generateTagHandlerDestroy
private void generateTagHandlerDestroy()Generates the _jspDestroy() method which is responsible for calling the release() method on every tag handler in any of the tag handler pools. -
genPreamblePackage
Generate preamble package name (shared by servlet and tag handler preamble generation)- Throws:
JasperException
-
genPreambleImports
Generate preamble imports (shared by servlet and tag handler preamble generation)- Throws:
JasperException
-
genPreambleStaticInitializers
Generation of static initializers in preamble. For example, dependant list, el function map, prefix map. (shared by servlet and tag handler preamble generation)- Throws:
JasperException
-
genPreambleClassVariableDeclarations
Declare tag handler pools (tags of the same type and with the same attribute set share the same tag handler pool) (shared by servlet and tag handler preamble generation)- Throws:
JasperException
-
genPreambleMethods
Declare general-purpose methods (shared by servlet and tag handler preamble generation)- Throws:
JasperException
-
generatePreamble
Generates the beginning of the static portion of the servlet.- Throws:
JasperException
-
generateXmlProlog
Generates an XML Prolog, which includes an XML declaration and an XML doctype declaration. -
generateConstructor
-
generateLocalVariables
private static void generateLocalVariables(ServletWriter out, Node n, boolean genBytes) throws JasperException - Throws:
JasperException
-
genCommonPostamble
private void genCommonPostamble()Common part of postamble, shared by both servlets and tag files. -
generatePostamble
Generates the ending part of the static portion of the servlet. -
generate
public static void generate(ServletWriter out, Compiler compiler, Node.Nodes page) throws JasperException The main entry for Generator.- Parameters:
out- The servlet output writercompiler- The compilerpage- The input page- Throws:
JasperException
-
generateTagHandlerPreamble
private void generateTagHandlerPreamble(JasperTagInfo tagInfo, Node.Nodes tag) throws JasperException - Throws:
JasperException
-
generateTagHandlerPostamble
private void generateTagHandlerPostamble(javax.servlet.jsp.tagext.TagInfo tagInfo) -
generateTagHandlerAttributes
private void generateTagHandlerAttributes(javax.servlet.jsp.tagext.TagInfo tagInfo) throws JasperException Generates declarations for tag handler attributes, and defines the getter and setter methods for each.- Throws:
JasperException
-
generateSetJspContext
private void generateSetJspContext(javax.servlet.jsp.tagext.TagInfo tagInfo) -
generateSetDynamicAttribute
public void generateSetDynamicAttribute() -
generatePageScopedVariables
-
toGetterMethod
-
toSetterMethodName
-