ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/jasper/compiler/Collector.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/jasper/compiler/Collector.java
Status
scanned
Type
file
Name
Collector.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
7222 (7.1 KB)
MD5
df82cd7c023aca27d9327f70d7f291b1
SHA1
bed7c6393e66862e14227e8ca1327d6a0a90af9e
SHA256
968eecb1c412a331617f043fa7f449fe3fcb2de0f2d71d41a972b23755725b49
SHA512

      
    
SHA1_git
1c94112177367d37bb438b075753395cd4d6d0bc
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
Collector.java | 7.1 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.jasper.compiler; import org.apache.jasper.JasperException; /** * Collect info about the page and nodes, and make them available through the PageInfo object. */ class Collector { /** * A visitor for collecting information on the page and the body of the custom tags. */ private static class CollectVisitor extends Node.Visitor { private boolean scriptingElementSeen = false; private boolean usebeanSeen = false; private boolean includeActionSeen = false; private boolean paramActionSeen = false; private boolean setPropertySeen = false; private boolean hasScriptingVars = false; @Override public void visit(Node.ParamAction n) throws JasperException { if (n.getValue().isExpression()) { scriptingElementSeen = true; } paramActionSeen = true; } @Override public void visit(Node.IncludeAction n) throws JasperException { if (n.getPage().isExpression()) { scriptingElementSeen = true; } includeActionSeen = true; visitBody(n); } @Override public void visit(Node.ForwardAction n) throws JasperException { if (n.getPage().isExpression()) { scriptingElementSeen = true; } visitBody(n); } @Override public void visit(Node.SetProperty n) throws JasperException { if (n.getValue() != null && n.getValue().isExpression()) { scriptingElementSeen = true; } setPropertySeen = true; } @Override public void visit(Node.UseBean n) throws JasperException { if (n.getBeanName() != null && n.getBeanName().isExpression()) { scriptingElementSeen = true; } usebeanSeen = true; visitBody(n); } @Override public void visit(Node.CustomTag n) throws JasperException { // Check to see what kinds of element we see as child elements checkSeen(n.getChildInfo(), n); } /** * Check all child nodes for various elements and update the given ChildInfo object accordingly. Visits body in * the process. */ private void checkSeen(Node.ChildInfo ci, Node n) throws JasperException { // save values collected so far boolean scriptingElementSeenSave = scriptingElementSeen; scriptingElementSeen = false; boolean usebeanSeenSave = usebeanSeen; usebeanSeen = false; boolean includeActionSeenSave = includeActionSeen; includeActionSeen = false; boolean paramActionSeenSave = paramActionSeen; paramActionSeen = false; boolean setPropertySeenSave = setPropertySeen; setPropertySeen = false; boolean hasScriptingVarsSave = hasScriptingVars; hasScriptingVars = false; // Scan attribute list for expressions if (n instanceof Node.CustomTag ct) { Node.JspAttribute[] attrs = ct.getJspAttributes(); for (int i = 0; attrs != null && i < attrs.length; i++) { if (attrs[i].isExpression()) { scriptingElementSeen = true; break; } } } visitBody(n); if ((n instanceof Node.CustomTag ct) && !hasScriptingVars) { hasScriptingVars = ct.getVariableInfos().length > 0 || ct.getTagVariableInfos().length > 0; } // Record if the tag element and its body contains any scriptlet. ci.setScriptless(!scriptingElementSeen); ci.setHasUseBean(usebeanSeen); ci.setHasIncludeAction(includeActionSeen); ci.setHasParamAction(paramActionSeen); ci.setHasSetProperty(setPropertySeen); ci.setHasScriptingVars(hasScriptingVars); // Propagate value of scriptingElementSeen up. scriptingElementSeen = scriptingElementSeen || scriptingElementSeenSave; usebeanSeen = usebeanSeen || usebeanSeenSave; setPropertySeen = setPropertySeen || setPropertySeenSave; includeActionSeen = includeActionSeen || includeActionSeenSave; paramActionSeen = paramActionSeen || paramActionSeenSave; hasScriptingVars = hasScriptingVars || hasScriptingVarsSave; } @Override public void visit(Node.JspElement n) throws JasperException { if (n.getNameAttribute().isExpression()) { scriptingElementSeen = true; } Node.JspAttribute[] attrs = n.getJspAttributes(); for (Node.JspAttribute attr : attrs) { if (attr.isExpression()) { scriptingElementSeen = true; break; } } visitBody(n); } @Override public void visit(Node.JspBody n) throws JasperException { checkSeen(n.getChildInfo(), n); } @Override public void visit(Node.NamedAttribute n) throws JasperException { checkSeen(n.getChildInfo(), n); } @Override public void visit(Node.Declaration n) throws JasperException { scriptingElementSeen = true; } @Override public void visit(Node.Expression n) throws JasperException { scriptingElementSeen = true; } @Override public void visit(Node.Scriptlet n) throws JasperException { scriptingElementSeen = true; } private void updatePageInfo(PageInfo pageInfo) { pageInfo.setScriptless(!scriptingElementSeen); } } public static void collect(Compiler compiler, Node.Nodes page) throws JasperException { CollectVisitor collectVisitor = new CollectVisitor(); page.visit(collectVisitor); collectVisitor.updatePageInfo(compiler.getPageInfo()); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
20.0
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9