Package org.apache.jasper.compiler
Class Generator.GenerateVisitor
java.lang.Object
org.apache.jasper.compiler.Node.Visitor
org.apache.jasper.compiler.Generator.GenerateVisitor
- Enclosing class:
Generator
A visitor that generates codes for the elements in the page.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private static final String
private Generator.FragmentHelperClass
private HashMap
<String, HashMap<String, Generator.TagHandlerInfo>> private boolean
private boolean
private boolean
private boolean
private int
private ArrayList
<Generator.GenBuffer> private ServletWriter
private String
private String
private String
private static final String
-
Constructor Summary
ConstructorsConstructorDescriptionGenerateVisitor
(boolean isTagFile, ServletWriter out, ArrayList<Generator.GenBuffer> methodsBuffered, Generator.FragmentHelperClass fragmentHelperClass) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate String
attributeValue
(Node.JspAttribute attr, boolean encode, Class expectedType) Returns an attribute value, optionally URL encoded.private String
convertString
(Class<?> c, String s, String attrName, Class<?> propEditorClass, boolean isNamedAttribute) private String
createTagVarName
(String fullName, String prefix, String shortName) private void
declareScriptingVars
(Node.CustomTag n, int scope) private String
evaluateAttribute
(Generator.TagHandlerInfo handlerInfo, Node.JspAttribute attr, Node.CustomTag n, String tagHandlerVar) private Node.JspBody
findJspBody
(Node parent) Finds the invalid input: '<'jsp:body> subelement of the given parent node.private String
generateAliasMap
(Node.CustomTag n, String tagHandlerVar) Generate code to create a map for the alias variablesprivate void
generateCustomDoTag
(Node.CustomTag n, Generator.TagHandlerInfo handlerInfo, String tagHandlerVar) private void
generateCustomEnd
(Node.CustomTag n, String tagHandlerVar, String tagEvalVar, String tagPushBodyCountVar) private void
generateCustomStart
(Node.CustomTag n, Generator.TagHandlerInfo handlerInfo, String tagHandlerVar, String tagEvalVar, String tagPushBodyCountVar) private void
generateJspFragment
(Node n, String tagHandlerVar) Generates anonymous JspFragment inner class which is passed as an argument to SimpleTag.setJspBody().generateNamedAttributeJspFragment
(Node.NamedAttribute n, String tagHandlerVar) Similar to generateNamedAttributeValue, but create a JspFragment instead.Generate the code required to obtain the runtime value of the given named attribute.private void
generateSetters
(Node.CustomTag n, String tagHandlerVar, Generator.TagHandlerInfo handlerInfo, boolean simpleTag) private void
private String
getScopeConstant
(String scope) private Generator.TagHandlerInfo
private String
private void
prepareParams
(Node parent) Scans through all child nodes of the given parent for subelements.private void
printParams
(Node n, String pageParam, boolean literal) Prints the attribute value specified in the param action, in the form of name=value string.private void
restoreScriptingVars
(Node.CustomTag n, int scope) private void
saveScriptingVars
(Node.CustomTag n, int scope) private void
syncScriptingVars
(Node.CustomTag n, int scope) void
void
void
void
void
void
void
void
void
void
void
void
void
visit
(Node.PlugIn n) void
void
void
void
void
-
Field Details
-
handlerInfos
-
tagVarNumbers
-
parent
-
isSimpleTagParent
private boolean isSimpleTagParent -
pushBodyCountVar
-
simpleTagHandlerVar
-
isSimpleTagHandler
private boolean isSimpleTagHandler -
isFragment
private boolean isFragment -
isTagFile
private boolean isTagFile -
out
-
methodsBuffered
-
fragmentHelperClass
-
methodNesting
private int methodNesting -
arrayCount
private int arrayCount -
textMap
-
SINGLE_QUOTE
- See Also:
-
DOUBLE_QUOTE
- See Also:
-
-
Constructor Details
-
GenerateVisitor
public GenerateVisitor(boolean isTagFile, ServletWriter out, ArrayList<Generator.GenBuffer> methodsBuffered, Generator.FragmentHelperClass fragmentHelperClass) Constructor.
-
-
Method Details
-
attributeValue
Returns an attribute value, optionally URL encoded. If the value is a runtime expression, the result is the expression itself, as a string. If the result is an EL expression, we insert a call to the interpreter. If the result is a Named Attribute we insert the generated variable name. Otherwise the result is a string literal, quoted and escaped.- Parameters:
attr
- An JspAttribute objectencode
- true if to be URL encodedexpectedType
- the expected type for an EL evaluation (ignored for attributes that aren't EL expressions)
-
printParams
Prints the attribute value specified in the param action, in the form of name=value string.- Parameters:
n
- the parent node for the param action nodes.- Throws:
JasperException
-
visit
- Overrides:
visit
in classNode.Visitor
- Throws:
JasperException
-
visit
- Overrides:
visit
in classNode.Visitor
- Throws:
JasperException
-
visit
- Overrides:
visit
in classNode.Visitor
- Throws:
JasperException
-
visit
- Overrides:
visit
in classNode.Visitor
- Throws:
JasperException
-
prepareParams
Scans through all child nodes of the given parent for subelements. For each element, if its value is specified via a Named Attribute (invalid input: '<'jsp:attribute>), generate the code to evaluate those bodies first.If parent is null, simply returns.
- Throws:
JasperException
-
findJspBody
Finds the invalid input: '<'jsp:body> subelement of the given parent node. If not found, null is returned.- Throws:
JasperException
-
visit
- Overrides:
visit
in classNode.Visitor
- Throws:
JasperException
-
visit
- Overrides:
visit
in classNode.Visitor
- Throws:
JasperException
-
visit
- Overrides:
visit
in classNode.Visitor
- Throws:
JasperException
-
visit
- Overrides:
visit
in classNode.Visitor
- Throws:
JasperException
-
makeAttr
- Returns:
- a string for the form 'attr = "value"'
-
visit
- Overrides:
visit
in classNode.Visitor
- Throws:
JasperException
-
visit
- Overrides:
visit
in classNode.Visitor
- Throws:
JasperException
-
visit
- Overrides:
visit
in classNode.Visitor
- Throws:
JasperException
-
visit
- Overrides:
visit
in classNode.Visitor
- Throws:
JasperException
-
visit
- Overrides:
visit
in classNode.Visitor
- Throws:
JasperException
-
visit
- Overrides:
visit
in classNode.Visitor
- Throws:
JasperException
-
visit
- Overrides:
visit
in classNode.Visitor
- Throws:
JasperException
-
visit
- Overrides:
visit
in classNode.Visitor
- Throws:
JasperException
-
visit
- Overrides:
visit
in classNode.Visitor
- Throws:
JasperException
-
visit
- Overrides:
visit
in classNode.Visitor
- Throws:
JasperException
-
getTagHandlerInfo
- Throws:
JasperException
-
generateTagPlugin
- Throws:
JasperException
-
generateCustomStart
private void generateCustomStart(Node.CustomTag n, Generator.TagHandlerInfo handlerInfo, String tagHandlerVar, String tagEvalVar, String tagPushBodyCountVar) throws JasperException - Throws:
JasperException
-
generateCustomEnd
private void generateCustomEnd(Node.CustomTag n, String tagHandlerVar, String tagEvalVar, String tagPushBodyCountVar) -
generateCustomDoTag
private void generateCustomDoTag(Node.CustomTag n, Generator.TagHandlerInfo handlerInfo, String tagHandlerVar) throws JasperException - Throws:
JasperException
-
declareScriptingVars
-
saveScriptingVars
-
restoreScriptingVars
-
syncScriptingVars
-
createTagVarName
-
evaluateAttribute
private String evaluateAttribute(Generator.TagHandlerInfo handlerInfo, Node.JspAttribute attr, Node.CustomTag n, String tagHandlerVar) throws JasperException - Throws:
JasperException
-
generateAliasMap
Generate code to create a map for the alias variables- Returns:
- the name of the map
- Throws:
JasperException
-
generateSetters
private void generateSetters(Node.CustomTag n, String tagHandlerVar, Generator.TagHandlerInfo handlerInfo, boolean simpleTag) throws JasperException - Throws:
JasperException
-
convertString
private String convertString(Class<?> c, String s, String attrName, Class<?> propEditorClass, boolean isNamedAttribute) throws JasperException - Throws:
JasperException
-
getScopeConstant
-
generateJspFragment
Generates anonymous JspFragment inner class which is passed as an argument to SimpleTag.setJspBody().- Throws:
JasperException
-
generateNamedAttributeValue
Generate the code required to obtain the runtime value of the given named attribute.- Returns:
- The name of the temporary variable the result is stored in.
- Throws:
JasperException
-
generateNamedAttributeJspFragment
public String generateNamedAttributeJspFragment(Node.NamedAttribute n, String tagHandlerVar) throws JasperException Similar to generateNamedAttributeValue, but create a JspFragment instead.- Parameters:
n
- The parent node of the named attributetagHandlerVar
- The variable the tag handler is stored in, so the fragment knows its parent tag.- Returns:
- The name of the temporary variable the fragment is stored in.
- Throws:
JasperException
-