private void generateDeclarations ( Node . Nodes page ) throws JasperException { class DeclarationVisitor extends Node . Visitor { private boolean getServletInfoGenerated = false ; /* * Generates getServletInfo() method that returns the value of the * page directive's 'info' attribute, if present. * * The Validator has already ensured that if the translation unit * contains more than one page directive with an 'info' attribute, * their values match. */ public void visit ( Node . PageDirective n ) throws JasperException { if ( getServletInfoGenerated ) { return ; } String info = n . getAttributeValue ( "info" ) ; if ( info == null ) return ; getServletInfoGenerated = true ; out . printil ( "public String getServletInfo() {" ) ; out . pushIndent ( ) ; out . printin ( "return " ) ; out . print ( quote ( info ) ) ; out . println ( ";" ) ; out . popIndent ( ) ; out . printil ( "}" ) ; out . println ( ) ; } public void visit ( Node . Declaration n ) throws JasperException { n . setBeginJavaLine ( out . getJavaLine ( ) ) ; out . printMultiLn ( n . getText ( ) ) ; out . println ( ) ; n . setEndJavaLine ( out . getJavaLine ( ) ) ; } // Custom Tags may contain declarations from tag plugins. public void visit ( Node . CustomTag n ) throws JasperException { if ( n . useTagPlugin ( ) ) { if ( n . getAtSTag ( ) != null ) { n . getAtSTag ( ) . visit ( this ) ; } visitBody ( n ) ; if ( n . getAtETag ( ) != null ) { n . getAtETag ( ) . visit ( this ) ; } } else { visitBody ( n ) ; } } } out . println ( ) ; page . visit ( new DeclarationVisitor ( ) ) ; }
Generates declarations . This includes info of the page directive and scriptlet declarations .