com.caucho.jsp.java
Class JavaJspGenerator

java.lang.Object
  extended by com.caucho.jsp.JspGenerator
      extended by com.caucho.jsp.java.JavaJspGenerator
Direct Known Subclasses:
JavaTagGenerator

public class JavaJspGenerator
extends JspGenerator

Generates JSP code. JavaGenerator, JavaScriptGenerator, and StaticGenerator specialize the JspGenerator for language-specific requirements.

JspParser parses the JSP file into an XML-DOM tree. JspGenerator generates code from that tree.


Field Summary
protected  java.util.ArrayList<Depend> _cacheDepends
           
protected  java.lang.String _className
           
protected  JspPageConfig _config
           
protected  java.util.ArrayList<JspDeclaration> _declarations
           
protected  java.util.ArrayList<PersistentDependency> _depends
           
protected  java.lang.String _fullClassName
           
protected  boolean _ideHack
           
protected  boolean _isCacheable
           
protected  boolean _isUncacheable
           
protected  ParseState _parseState
           
protected  java.lang.String _pkg
           
protected  JspNode _rootNode
           
protected  IntMap _strings
           
protected  int _tagId
           
protected  ParseTagManager _tagManager
           
protected  TagInstance _topTag
           
 
Fields inherited from class com.caucho.jsp.JspGenerator
_jspBuilder, _jspCompiler, _jspCompilerInstance, _jspParser, _lineMap
 
Constructor Summary
JavaJspGenerator(ParseTagManager tagManager)
           
 
Method Summary
 void addBeanClass(java.lang.String id, java.lang.String typeName)
          Saves a bean's class for later introspection.
 void addDeclaration(JspDeclaration decl)
          Adds a new Java declaration to the list.
 void addDeclared(java.lang.String var)
          Adds a declared variable.
 void addDepend(java.lang.Class<?> cl)
          Adds a dependency based on a class.
 void addDepend(Path path)
           
 void addDepend(PersistentDependency depend)
           
 int addExpr(java.lang.String expr)
          Adds an expression to the expression list.
 int addFragment(JspFragmentNode node)
           
protected  void addImport(java.lang.String name)
           
 int addMethodExpr(java.lang.String value, java.lang.String sigString)
          Adds an expression to the expression list.
 void addOptionalTaglib(java.lang.String prefix, java.lang.String uri)
          Adds a taglib.
 int addString(java.lang.String string)
           
 Taglib addTaglib(QName qname)
           
 void addTaglib(java.lang.String prefix, java.lang.String uri)
          Adds a taglib.
 Taglib addTaglib(java.lang.String prefix, java.lang.String uri, boolean isOptional)
          Adds a taglib.
 void addTaglibDir(java.lang.String prefix, java.lang.String tagdir)
          Adds a taglib.
 int addValueExpr(java.lang.String value, java.lang.String type)
          Adds an expression to the expression list.
 java.lang.String addXPathExpr(Expr expr)
          Adds an expression to the expression list.
 java.lang.String addXPathExpr(java.lang.String value, NamespaceContext ns)
          Adds an expression to the expression list.
 JspParseException error(java.lang.Exception e)
           
 JspParseException error(java.lang.String message)
           
protected  void fillSingleTaglibImports()
          As a convenience, when the Tag isn't in a package, import it automatically.
protected  void generate(JspJavaWriter out)
          Generates the Java code.
protected  void generate(Path path, java.lang.String className)
          Generates the JSP page.
protected  void generateClassFooter(JspJavaWriter out)
          Completes the generated class: closing the main method, generating the dependencies and generating the constant strings.
protected  void generateClassHeader(JspJavaWriter out)
          Generates the class header.
 int generateJspId()
           
protected  void generatePageFooter(JspJavaWriter out)
           
protected  void generatePageHeader(JspJavaWriter out)
          Prints the _jspService header
protected  void generateStatic()
          Generates a static file.
 Expr genExpr(java.lang.String value)
           
 java.lang.Class<?> getBeanClass(java.lang.String typeName)
          Loads a bean based on the class name.
 java.lang.Class<?> getClass(java.lang.String id)
           
 JspPageConfig getConfig()
           
 java.util.ArrayList<PersistentDependency> getDependList()
           
 ELContext getELContext()
           
 JspFragmentNode getFragment(int index)
           
 PageData getPageData()
          Returns the page's XML view.
 ParseState getParseState()
           
 boolean getRecycleTags()
           
 TagInstance getRootTag()
           
 java.lang.String getSourceLines(Path source, int errorLine)
           
 TagInfo getTag(QName qname)
          Returns the tag with the given qname.
 java.lang.Class<?> getTagClass(QName qname)
          Returns the tag with the given qname.
 ParseTagManager getTagManager()
          Returns the taglib manager.
 boolean hasScripting()
           
 void init()
           
protected  void init(java.lang.String className)
           
 boolean isDeclared(java.lang.String var)
          True if it's a declared variable.
 boolean isJsfPrologueInit()
           
 boolean isPre21()
          True for a pre jsp21 tag
 boolean isPrototype()
           
 boolean isStatic()
          Returns true if the JSP compilation has produced a static file.
 boolean isStaticEncoding()
           
 boolean isTag()
           
 void setJsfPrologueInit(boolean isInit)
           
 void setPageConfig(JspPageConfig pageConfig)
           
protected  void setParseState(ParseState parseState)
           
 void setRootNode(JspNode node)
          Sets the root JSP node.
 void setTagManager(ParseTagManager tagManager)
          Sets the taglib manager.
 int uniqueId()
           
 void validate()
          Validates the JSP page.
 
Methods inherited from class com.caucho.jsp.JspGenerator
generateTagInfo, getJspBuilder, getJspCompiler, getJspCompilerInstance, getJspParser, getLineMap, isELIgnore, isTagDependent, setJspBuilder, setJspCompiler, setJspCompilerInstance, setJspParser
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_rootNode

protected JspNode _rootNode

_parseState

protected ParseState _parseState

_ideHack

protected boolean _ideHack

_isCacheable

protected boolean _isCacheable

_isUncacheable

protected boolean _isUncacheable

_cacheDepends

protected java.util.ArrayList<Depend> _cacheDepends

_depends

protected java.util.ArrayList<PersistentDependency> _depends

_topTag

protected TagInstance _topTag

_tagId

protected int _tagId

_tagManager

protected ParseTagManager _tagManager

_config

protected JspPageConfig _config

_fullClassName

protected java.lang.String _fullClassName

_className

protected java.lang.String _className

_strings

protected IntMap _strings

_pkg

protected java.lang.String _pkg

_declarations

protected java.util.ArrayList<JspDeclaration> _declarations
Constructor Detail

JavaJspGenerator

public JavaJspGenerator(ParseTagManager tagManager)
Method Detail

getRootTag

public TagInstance getRootTag()

setParseState

protected void setParseState(ParseState parseState)
Specified by:
setParseState in class JspGenerator

getParseState

public ParseState getParseState()
Specified by:
getParseState in class JspGenerator

setPageConfig

public void setPageConfig(JspPageConfig pageConfig)

setRootNode

public void setRootNode(JspNode node)
Sets the root JSP node.


getConfig

public JspPageConfig getConfig()

isTag

public boolean isTag()

init

public void init()

hasScripting

public boolean hasScripting()

isJsfPrologueInit

public boolean isJsfPrologueInit()

setJsfPrologueInit

public void setJsfPrologueInit(boolean isInit)

addTaglib

public void addTaglib(java.lang.String prefix,
                      java.lang.String uri)
               throws JspParseException
Adds a taglib.

Throws:
JspParseException

isPre21

public boolean isPre21()
True for a pre jsp21 tag


isPrototype

public boolean isPrototype()

addOptionalTaglib

public void addOptionalTaglib(java.lang.String prefix,
                              java.lang.String uri)
                       throws JspParseException
Adds a taglib.

Throws:
JspParseException

addTaglib

public Taglib addTaglib(java.lang.String prefix,
                        java.lang.String uri,
                        boolean isOptional)
                 throws JspParseException
Adds a taglib.

Throws:
JspParseException

addTaglibDir

public void addTaglibDir(java.lang.String prefix,
                         java.lang.String tagdir)
                  throws JspParseException
Adds a taglib.

Throws:
JspParseException

isStatic

public boolean isStatic()
Returns true if the JSP compilation has produced a static file.

Overrides:
isStatic in class JspGenerator

getPageData

public PageData getPageData()
                     throws java.io.IOException
Returns the page's XML view.

Throws:
java.io.IOException

getELContext

public ELContext getELContext()

validate

public void validate()
              throws java.lang.Exception
Validates the JSP page.

Specified by:
validate in class JspGenerator
Throws:
java.lang.Exception

generate

protected void generate(Path path,
                        java.lang.String className)
                 throws java.lang.Exception
Generates the JSP page.

Specified by:
generate in class JspGenerator
Throws:
java.lang.Exception

addDepend

public void addDepend(Path path)

addDepend

public void addDepend(java.lang.Class<?> cl)
Adds a dependency based on a class.


addDepend

public void addDepend(PersistentDependency depend)
Overrides:
addDepend in class JspGenerator

getDependList

public java.util.ArrayList<PersistentDependency> getDependList()
Overrides:
getDependList in class JspGenerator

isStaticEncoding

public boolean isStaticEncoding()

getRecycleTags

public boolean getRecycleTags()

addDeclaration

public void addDeclaration(JspDeclaration decl)
Adds a new Java declaration to the list.


setTagManager

public void setTagManager(ParseTagManager tagManager)
Sets the taglib manager.


getTagManager

public ParseTagManager getTagManager()
Returns the taglib manager.


init

protected void init(java.lang.String className)

isDeclared

public boolean isDeclared(java.lang.String var)
True if it's a declared variable.


addDeclared

public void addDeclared(java.lang.String var)
Adds a declared variable.


generate

protected void generate(JspJavaWriter out)
                 throws java.lang.Exception
Generates the Java code.

Throws:
java.lang.Exception

generateStatic

protected void generateStatic()
                       throws java.lang.Exception
Generates a static file.

Throws:
java.lang.Exception

generateClassHeader

protected void generateClassHeader(JspJavaWriter out)
                            throws java.io.IOException,
                                   JspParseException
Generates the class header.

Parameters:
doc - the XML document representing the JSP page.
Throws:
java.io.IOException
JspParseException

fillSingleTaglibImports

protected void fillSingleTaglibImports()
                                throws JspParseException
As a convenience, when the Tag isn't in a package, import it automatically.

Throws:
JspParseException

generatePageHeader

protected void generatePageHeader(JspJavaWriter out)
                           throws java.lang.Exception
Prints the _jspService header

Throws:
java.lang.Exception

addString

public int addString(java.lang.String string)

addBeanClass

public void addBeanClass(java.lang.String id,
                         java.lang.String typeName)
                  throws java.lang.Exception
Saves a bean's class for later introspection.

Parameters:
id - the bean id
typeName - the bean's type
Throws:
java.lang.Exception

getBeanClass

public java.lang.Class<?> getBeanClass(java.lang.String typeName)
                                throws java.lang.ClassNotFoundException
Loads a bean based on the class name.

Throws:
java.lang.ClassNotFoundException

getClass

public java.lang.Class<?> getClass(java.lang.String id)

generatePageFooter

protected void generatePageFooter(JspJavaWriter out)
                           throws java.io.IOException
Throws:
java.io.IOException

generateClassFooter

protected void generateClassFooter(JspJavaWriter out)
                            throws java.lang.Exception
Completes the generated class: closing the main method, generating the dependencies and generating the constant strings.

Parameters:
doc - the XML document representing the JSP page.
Throws:
java.lang.Exception

addFragment

public int addFragment(JspFragmentNode node)

getFragment

public JspFragmentNode getFragment(int index)

genExpr

public Expr genExpr(java.lang.String value)
             throws JspParseException,
                    ELException
Throws:
JspParseException
ELException

addExpr

public int addExpr(java.lang.String expr)
            throws JspParseException,
                   ELException
Adds an expression to the expression list.

Throws:
JspParseException
ELException

addValueExpr

public int addValueExpr(java.lang.String value,
                        java.lang.String type)
                 throws JspParseException,
                        ELException
Adds an expression to the expression list.

Throws:
JspParseException
ELException

addMethodExpr

public int addMethodExpr(java.lang.String value,
                         java.lang.String sigString)
                  throws JspParseException,
                         ELException
Adds an expression to the expression list.

Throws:
JspParseException
ELException

addXPathExpr

public java.lang.String addXPathExpr(java.lang.String value,
                                     NamespaceContext ns)
                              throws JspParseException,
                                     XPathParseException
Adds an expression to the expression list.

Throws:
JspParseException
XPathParseException

addXPathExpr

public java.lang.String addXPathExpr(Expr expr)
                              throws JspParseException
Adds an expression to the expression list.

Throws:
JspParseException

uniqueId

public int uniqueId()
Specified by:
uniqueId in class JspGenerator

generateJspId

public int generateJspId()

addImport

protected void addImport(java.lang.String name)

getTag

public TagInfo getTag(QName qname)
               throws JspParseException
Returns the tag with the given qname.

Throws:
JspParseException

getTagClass

public java.lang.Class<?> getTagClass(QName qname)
                               throws java.lang.Exception
Returns the tag with the given qname.

Throws:
java.lang.Exception

addTaglib

public Taglib addTaglib(QName qname)
                 throws JspParseException
Throws:
JspParseException

getSourceLines

public java.lang.String getSourceLines(Path source,
                                       int errorLine)
Overrides:
getSourceLines in class JspGenerator

error

public JspParseException error(java.lang.String message)

error

public JspParseException error(java.lang.Exception e)