/*
* 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.struts2.jasper.compiler;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import javax.el.MethodExpression;
import javax.el.ValueExpression;
import javax.servlet.jsp.tagext.TagAttributeInfo;
import javax.servlet.jsp.tagext.TagInfo;
import javax.servlet.jsp.tagext.TagVariableInfo;
import javax.servlet.jsp.tagext.VariableInfo;
import org.apache.struts2.jasper.Constants;
import org.apache.struts2.jasper.JasperException;
import org.apache.struts2.jasper.JspCompilationContext;
import org.apache.struts2.jasper.compiler.Node.NamedAttribute;
import org.apache.struts2.jasper.runtime.JspRuntimeLibrary;
import org.apache.struts2.JSPRuntime;
import org.xml.sax.Attributes;
/**
* Generate Java source from Nodes
*
* @author Anil K. Vijendran
* @author Danno Ferrin
* @author Mandar Raje
* @author Rajiv Mordani
* @author Pierre Delisle
*
* Tomcat 4.1.x and Tomcat 5:
* @author Kin-man Chung
* @author Jan Luehe
* @author Shawn Bayern
* @author Mark Roth
* @author Denis Benoit
*
* Tomcat 6.x
* @author Jacob Hookom
* @author Remy Maucherat
*/
class Generator {
private static final Class[] OBJECT_CLASS = { Object.class };
private static final String VAR_EXPRESSIONFACTORY =
System.getProperty("org.apache.struts2.jasper.compiler.Generator.VAR_EXPRESSIONFACTORY", "_el_expressionfactory");
private static final String VAR_ANNOTATIONPROCESSOR =
System.getProperty("org.apache.struts2.jasper.compiler.Generator.VAR_ANNOTATIONPROCESSOR", "_jsp_annotationprocessor");
private ServletWriter out;
private ArrayList methodsBuffered;
private FragmentHelperClass fragmentHelperClass;
private ErrorDispatcher err;
private BeanRepository beanInfo;
private JspCompilationContext ctxt;
private boolean isPoolingEnabled;
private boolean breakAtLF;
private String jspIdPrefix;
private int jspId;
private PageInfo pageInfo;
private Vector<String> tagHandlerPoolNames;
private GenBuffer charArrayBuffer;
/**
* @param s
* the input string
* @return quoted and escaped string, per Java rule
*/
static String quote(String s) {
if (s == null)
return "null";
return '"' + escape(s) + '"';
}
/**
* @param s
* the input string
* @return escaped string, per Java rule
*/
static String escape(String s) {
if (s == null)
return "";
StringBuffer b = new StringBuffer();
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '"')
b.append('\\').append('"');
else if (c == '\\')
b.append('\\').append('\\');
else if (c == '\n')
b.append('\\').append('n');
else if (c == '\r')
b.append('\\').append('r');
else
b.append(c);
}
return b.toString();
}
/**
* Single quote and escape a character
*/
static String quote(char c) {
StringBuffer b = new StringBuffer();
b.append('\'');
if (c == '\'')
b.append('\\').append('\'');
else if (c == '\\')
b.append('\\').append('\\');
else if (c == '\n')
b.append('\\').append('n');
else if (c == '\r')
b.append('\\').append('r');
else
b.append(c);
b.append('\'');
return b.toString();
}
private String createJspId() throws JasperException {
if (this.jspIdPrefix == null) {
StringBuffer sb = new StringBuffer(32);
String name = ctxt.getServletJavaFileName();
sb.append("jsp_").append(Math.abs(name.hashCode())).append('_');
this.jspIdPrefix = sb.toString();
}
return this.jspIdPrefix + (this.jspId++);
}
/**
* Generates declarations. This includes "info" of the page directive, and
* scriptlet declarations.
*/
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(new String(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());
}
/**
* Compiles list of tag handler pool names.
*/
private void compileTagHandlerPoolList(Node.Nodes page)
throws JasperException {
class TagHandlerPoolVisitor extends Node.Visitor {
private Vector names;
/*
* Constructor
*
* @param v Vector of tag handler pool names to populate
*/
TagHandlerPoolVisitor(Vector v) {
names = v;
}
/*
* Gets the name of the tag handler pool for the given cu
没有合适的资源?快使用搜索试试~ 我知道了~
STRUTS2源码解析
共3984个文件
java:1844个
js:476个
txt:276个
4星 · 超过85%的资源 需积分: 3 67 下载量 48 浏览量
2010-09-15
09:21:20
上传
评论
收藏 5.37MB RAR 举报
温馨提示
STRUTS2源码解析STRUTS2源码解析STRUTS2源码解析STRUTS2源码解析STRUTS2源码解析STRUTS2源码解析STRUTS2源码解析STRUTS2源码解析STRUTS2源码解析STRUTS2源码解析STRUTS2源码解析STRUTS2源码解析STRUTS2源码解析STRUTS2源码解析STRUTS2源码解析STRUTS2源码解析STRUTS2源码解析STRUTS2源码解析STRUTS2源码解析
资源推荐
资源详情
资源评论
收起资源包目录
STRUTS2源码解析 (3984个子文件)
DojoExternalInterface.as 8KB
DojoExternalInterface.as 7KB
Storage.as 4KB
ExpressInstall.as 3KB
.boom 0B
config-styles.css 12KB
EditorToolbar.css 4KB
TabContainer.css 3KB
TabContainerA11y.css 3KB
DatePicker.css 3KB
TimePicker.css 3KB
typo.css 3KB
layout.css 3KB
FloatingPane.css 2KB
ComboBox.css 2KB
Menu2.css 2KB
TreeV3.css 2KB
DocPane.css 2KB
nav-horizontal.css 2KB
forms.css 1KB
Wizard.css 1KB
ComboBox.css 1KB
MonthlyCalendar.css 1KB
domTT.css 1KB
TreeDocIcon.css 1KB
tree.css 1KB
webconsole.css 1KB
RemoteTabControl.css 1KB
styles.css 1KB
tools.css 1KB
styles.css 1KB
general.css 1KB
ButtonTemplate.css 1KB
Slider.css 993B
TabbedPanel.css 949B
DemoItem.css 947B
Menu.css 943B
Show.css 825B
Toolbar.css 816B
showtableborder_gecko.css 791B
PopUpButton.css 741B
SplitContainer.css 704B
layout-navtop-localleft.css 685B
mailreader.css 643B
Toaster.css 634B
layout-navtop-1col.css 625B
Spinner.css 586B
Checkbox.css 509B
DemoContainer.css 500B
AccordionPane.css 483B
Tree.css 472B
DemoNavigator.css 467B
FisheyeList.css 446B
TaskBar.css 445B
InlineEditBox.css 407B
Tree.css 397B
ProgressBar.css 394B
testng.css 312B
ResizableTextarea.css 295B
SourcePane.css 247B
DemoPane.css 238B
styles.css 231B
ResizeHandle.css 210B
Validate.css 192B
ShowSlide.css 180B
TooltipTemplate.css 176B
TreeDisableWrap.css 157B
main.css 138B
showtableborder_ie.css 126B
SlideShow.css 121B
validationExamplesStyles.css 103B
TreeEditor.css 65B
resource.css 5B
Thumbs.db 22KB
struts-2.1.7.dtd 4KB
struts-2.1.dtd 4KB
struts-2.0.dtd 3KB
xwork-2.1.3.dtd 3KB
xwork-2.1.dtd 3KB
xwork-2.0.dtd 2KB
xwork-1.1.2.dtd 2KB
xwork-1.1.1.dtd 2KB
xwork-1.1.dtd 2KB
xwork-1.0.dtd 2KB
xwork-validator-1.0.3.dtd 787B
xwork-validator-1.0.2.dtd 784B
xwork-validator-1.0.dtd 703B
xwork-validator-definition-1.0.dtd 427B
xwork-validator-config-1.0.dtd 409B
xwork-1.0.dtd 19B
storage_dialog.fla 336KB
flash6_gateway.fla 40KB
optiontransferselect.ftl 14KB
hangmanAjax.ftl 8KB
testIf.ftl 7KB
bind.ftl 7KB
form-close-validate.ftl 6KB
autocompleter.ftl 6KB
doubleselect.ftl 6KB
tree.ftl 5KB
共 3984 条
- 1
- 2
- 3
- 4
- 5
- 6
- 40
资源评论
- 钟瀚林2012-11-19struts源码,哈哈,关联了eclipse就可以看到了。
- nimeijian2012-11-09就是Struts2的源码,不是什么源码解析。
- GRANCY很冷静2012-03-06这是struts真正的源码,在eclipse关联后可以看struts的源码的。
- gougou8511292012-05-02struts-2.2.3.1版本,但是缺少archetypes子工程,mvn跑不起来。
haojia1985
- 粉丝: 0
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功