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 intprivate static final Stringprivate Generator.FragmentHelperClassprivate HashMap<String, HashMap<String, Generator.TagHandlerInfo>> private booleanprivate booleanprivate booleanprivate booleanprivate intprivate ArrayList<Generator.GenBuffer> private ServletWriterprivate Stringprivate Stringprivate Stringprivate static final String -
Constructor Summary
ConstructorsConstructorDescriptionGenerateVisitor(boolean isTagFile, ServletWriter out, ArrayList<Generator.GenBuffer> methodsBuffered, Generator.FragmentHelperClass fragmentHelperClass) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate StringattributeValue(Node.JspAttribute attr, boolean encode, Class expectedType) Returns an attribute value, optionally URL encoded.private StringconvertString(Class<?> c, String s, String attrName, Class<?> propEditorClass, boolean isNamedAttribute) private StringcreateTagVarName(String fullName, String prefix, String shortName) private voiddeclareScriptingVars(Node.CustomTag n, int scope) private StringevaluateAttribute(Generator.TagHandlerInfo handlerInfo, Node.JspAttribute attr, Node.CustomTag n, String tagHandlerVar) private Node.JspBodyfindJspBody(Node parent) Finds the invalid input: '<'jsp:body> subelement of the given parent node.private StringgenerateAliasMap(Node.CustomTag n, String tagHandlerVar) Generate code to create a map for the alias variablesprivate voidgenerateCustomDoTag(Node.CustomTag n, Generator.TagHandlerInfo handlerInfo, String tagHandlerVar) private voidgenerateCustomEnd(Node.CustomTag n, String tagHandlerVar, String tagEvalVar, String tagPushBodyCountVar) private voidgenerateCustomStart(Node.CustomTag n, Generator.TagHandlerInfo handlerInfo, String tagHandlerVar, String tagEvalVar, String tagPushBodyCountVar) private voidgenerateJspFragment(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 voidgenerateSetters(Node.CustomTag n, String tagHandlerVar, Generator.TagHandlerInfo handlerInfo, boolean simpleTag) private voidprivate StringgetScopeConstant(String scope) private Generator.TagHandlerInfoprivate Stringprivate voidprepareParams(Node parent) Scans through all child nodes of the given parent for subelements.private voidprintParams(Node n, String pageParam, boolean literal) Prints the attribute value specified in the param action, in the form of name=value string.private voidrestoreScriptingVars(Node.CustomTag n, int scope) private voidsaveScriptingVars(Node.CustomTag n, int scope) private voidsyncScriptingVars(Node.CustomTag n, int scope) voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvisit(Node.PlugIn n) voidvoidvoidvoidvoid
-
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:
visitin classNode.Visitor- Throws:
JasperException
-
visit
- Overrides:
visitin classNode.Visitor- Throws:
JasperException
-
visit
- Overrides:
visitin classNode.Visitor- Throws:
JasperException
-
visit
- Overrides:
visitin 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:
visitin classNode.Visitor- Throws:
JasperException
-
visit
- Overrides:
visitin classNode.Visitor- Throws:
JasperException
-
visit
- Overrides:
visitin classNode.Visitor- Throws:
JasperException
-
visit
- Overrides:
visitin classNode.Visitor- Throws:
JasperException
-
makeAttr
-
visit
- Overrides:
visitin classNode.Visitor- Throws:
JasperException
-
visit
- Overrides:
visitin classNode.Visitor- Throws:
JasperException
-
visit
- Overrides:
visitin classNode.Visitor- Throws:
JasperException
-
visit
- Overrides:
visitin classNode.Visitor- Throws:
JasperException
-
visit
- Overrides:
visitin classNode.Visitor- Throws:
JasperException
-
visit
- Overrides:
visitin classNode.Visitor- Throws:
JasperException
-
visit
- Overrides:
visitin classNode.Visitor- Throws:
JasperException
-
visit
- Overrides:
visitin classNode.Visitor- Throws:
JasperException
-
visit
- Overrides:
visitin classNode.Visitor- Throws:
JasperException
-
visit
- Overrides:
visitin 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
-