You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by mu...@apache.org on 2009/08/14 23:02:36 UTC
svn commit: r804373 [11/19] - in /struts/sandbox/trunk/struts2-jsp-plugin:
./ src/main/java/org/apache/struts2/ src/main/java/org/apache/struts2/jasper/
src/main/java/org/apache/struts2/jasper/compiler/
src/main/java/org/apache/struts2/jasper/compiler/...
Modified: struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspContextWrapper.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspContextWrapper.java?rev=804373&r1=804372&r2=804373&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspContextWrapper.java (original)
+++ struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspContextWrapper.java Fri Aug 14 21:02:33 2009
@@ -36,7 +36,7 @@
/**
* Implementation of a JSP Context Wrapper.
- *
+ * <p/>
* The JSP Context Wrapper is a JspContext created and maintained by a tag
* handler implementation. It wraps the Invoking JSP Context, that is, the
* JspContext instance passed to the tag handler by the invoking page via
@@ -46,12 +46,12 @@
* @author Jan Luehe
*/
public class JspContextWrapper
- extends PageContext implements VariableResolver {
+ extends PageContext implements VariableResolver {
// Invoking JSP context
private PageContext invokingJspCtxt;
- private transient Hashtable pageAttributes;
+ private transient Hashtable pageAttributes;
// ArrayList of NESTED scripting variables
private ArrayList nestedVars;
@@ -70,225 +70,222 @@
* The variable resolver, for evaluating EL expressions.
*/
private VariableResolverImpl variableResolver
- = new VariableResolverImpl(this);
+ = new VariableResolverImpl(this);
public JspContextWrapper(JspContext jspContext, ArrayList nestedVars,
- ArrayList atBeginVars, ArrayList atEndVars,
- Map aliases) {
+ ArrayList atBeginVars, ArrayList atEndVars,
+ Map aliases) {
this.invokingJspCtxt = (PageContext) jspContext;
- this.nestedVars = nestedVars;
- this.atBeginVars = atBeginVars;
- this.atEndVars = atEndVars;
- this.pageAttributes = new Hashtable(16);
- this.aliases = aliases;
-
- if (nestedVars != null) {
- this.originalNestedVars = new Hashtable(nestedVars.size());
- }
- syncBeginTagFile();
+ this.nestedVars = nestedVars;
+ this.atBeginVars = atBeginVars;
+ this.atEndVars = atEndVars;
+ this.pageAttributes = new Hashtable(16);
+ this.aliases = aliases;
+
+ if (nestedVars != null) {
+ this.originalNestedVars = new Hashtable(nestedVars.size());
+ }
+ syncBeginTagFile();
}
public void initialize(Servlet servlet, ServletRequest request,
ServletResponse response, String errorPageURL,
boolean needsSession, int bufferSize,
boolean autoFlush)
- throws IOException, IllegalStateException, IllegalArgumentException
- {
+ throws IOException, IllegalStateException, IllegalArgumentException {
}
-
+
public Object getAttribute(String name) {
- if (name == null) {
- throw new NullPointerException(
- Localizer.getMessage("jsp.error.attribute.null_name"));
- }
+ if (name == null) {
+ throw new NullPointerException(
+ Localizer.getMessage("jsp.error.attribute.null_name"));
+ }
- return pageAttributes.get(name);
+ return pageAttributes.get(name);
}
public Object getAttribute(String name, int scope) {
- if (name == null) {
- throw new NullPointerException(
- Localizer.getMessage("jsp.error.attribute.null_name"));
- }
-
- if (scope == PAGE_SCOPE) {
- return pageAttributes.get(name);
- }
+ if (name == null) {
+ throw new NullPointerException(
+ Localizer.getMessage("jsp.error.attribute.null_name"));
+ }
+
+ if (scope == PAGE_SCOPE) {
+ return pageAttributes.get(name);
+ }
- return invokingJspCtxt.getAttribute(name, scope);
+ return invokingJspCtxt.getAttribute(name, scope);
}
public void setAttribute(String name, Object value) {
- if (name == null) {
- throw new NullPointerException(
- Localizer.getMessage("jsp.error.attribute.null_name"));
- }
-
- if (value != null) {
- pageAttributes.put(name, value);
- } else {
- removeAttribute(name, PAGE_SCOPE);
- }
+ if (name == null) {
+ throw new NullPointerException(
+ Localizer.getMessage("jsp.error.attribute.null_name"));
+ }
+
+ if (value != null) {
+ pageAttributes.put(name, value);
+ } else {
+ removeAttribute(name, PAGE_SCOPE);
+ }
}
public void setAttribute(String name, Object value, int scope) {
- if (name == null) {
- throw new NullPointerException(
- Localizer.getMessage("jsp.error.attribute.null_name"));
- }
-
- if (scope == PAGE_SCOPE) {
- if (value != null) {
- pageAttributes.put(name, value);
- } else {
- removeAttribute(name, PAGE_SCOPE);
- }
- } else {
- invokingJspCtxt.setAttribute(name, value, scope);
- }
+ if (name == null) {
+ throw new NullPointerException(
+ Localizer.getMessage("jsp.error.attribute.null_name"));
+ }
+
+ if (scope == PAGE_SCOPE) {
+ if (value != null) {
+ pageAttributes.put(name, value);
+ } else {
+ removeAttribute(name, PAGE_SCOPE);
+ }
+ } else {
+ invokingJspCtxt.setAttribute(name, value, scope);
+ }
}
public Object findAttribute(String name) {
- if (name == null) {
- throw new NullPointerException(
- Localizer.getMessage("jsp.error.attribute.null_name"));
- }
+ if (name == null) {
+ throw new NullPointerException(
+ Localizer.getMessage("jsp.error.attribute.null_name"));
+ }
Object o = pageAttributes.get(name);
if (o == null) {
- o = invokingJspCtxt.getAttribute(name, REQUEST_SCOPE);
- if (o == null) {
- if (getSession() != null) {
- o = invokingJspCtxt.getAttribute(name, SESSION_SCOPE);
- }
- if (o == null) {
- o = invokingJspCtxt.getAttribute(name, APPLICATION_SCOPE);
- }
- }
- }
+ o = invokingJspCtxt.getAttribute(name, REQUEST_SCOPE);
+ if (o == null) {
+ if (getSession() != null) {
+ o = invokingJspCtxt.getAttribute(name, SESSION_SCOPE);
+ }
+ if (o == null) {
+ o = invokingJspCtxt.getAttribute(name, APPLICATION_SCOPE);
+ }
+ }
+ }
- return o;
+ return o;
}
public void removeAttribute(String name) {
- if (name == null) {
- throw new NullPointerException(
- Localizer.getMessage("jsp.error.attribute.null_name"));
- }
-
- pageAttributes.remove(name);
- invokingJspCtxt.removeAttribute(name, REQUEST_SCOPE);
- if (getSession() != null) {
- invokingJspCtxt.removeAttribute(name, SESSION_SCOPE);
- }
- invokingJspCtxt.removeAttribute(name, APPLICATION_SCOPE);
+ if (name == null) {
+ throw new NullPointerException(
+ Localizer.getMessage("jsp.error.attribute.null_name"));
+ }
+
+ pageAttributes.remove(name);
+ invokingJspCtxt.removeAttribute(name, REQUEST_SCOPE);
+ if (getSession() != null) {
+ invokingJspCtxt.removeAttribute(name, SESSION_SCOPE);
+ }
+ invokingJspCtxt.removeAttribute(name, APPLICATION_SCOPE);
}
public void removeAttribute(String name, int scope) {
- if (name == null) {
- throw new NullPointerException(
- Localizer.getMessage("jsp.error.attribute.null_name"));
- }
-
- if (scope == PAGE_SCOPE){
- pageAttributes.remove(name);
- } else {
- invokingJspCtxt.removeAttribute(name, scope);
- }
+ if (name == null) {
+ throw new NullPointerException(
+ Localizer.getMessage("jsp.error.attribute.null_name"));
+ }
+
+ if (scope == PAGE_SCOPE) {
+ pageAttributes.remove(name);
+ } else {
+ invokingJspCtxt.removeAttribute(name, scope);
+ }
}
public int getAttributesScope(String name) {
- if (name == null) {
- throw new NullPointerException(
- Localizer.getMessage("jsp.error.attribute.null_name"));
- }
-
- if (pageAttributes.get(name) != null) {
- return PAGE_SCOPE;
- } else {
- return invokingJspCtxt.getAttributesScope(name);
- }
+ if (name == null) {
+ throw new NullPointerException(
+ Localizer.getMessage("jsp.error.attribute.null_name"));
+ }
+
+ if (pageAttributes.get(name) != null) {
+ return PAGE_SCOPE;
+ } else {
+ return invokingJspCtxt.getAttributesScope(name);
+ }
}
public Enumeration getAttributeNamesInScope(int scope) {
if (scope == PAGE_SCOPE) {
return pageAttributes.keys();
- }
+ }
- return invokingJspCtxt.getAttributeNamesInScope(scope);
+ return invokingJspCtxt.getAttributeNamesInScope(scope);
}
public void release() {
- invokingJspCtxt.release();
+ invokingJspCtxt.release();
}
public JspWriter getOut() {
- return invokingJspCtxt.getOut();
+ return invokingJspCtxt.getOut();
}
public HttpSession getSession() {
- return invokingJspCtxt.getSession();
+ return invokingJspCtxt.getSession();
}
public Object getPage() {
- return invokingJspCtxt.getPage();
+ return invokingJspCtxt.getPage();
}
public ServletRequest getRequest() {
- return invokingJspCtxt.getRequest();
+ return invokingJspCtxt.getRequest();
}
public ServletResponse getResponse() {
- return invokingJspCtxt.getResponse();
+ return invokingJspCtxt.getResponse();
}
public Exception getException() {
- return invokingJspCtxt.getException();
+ return invokingJspCtxt.getException();
}
public ServletConfig getServletConfig() {
- return invokingJspCtxt.getServletConfig();
+ return invokingJspCtxt.getServletConfig();
}
public ServletContext getServletContext() {
- return invokingJspCtxt.getServletContext();
+ return invokingJspCtxt.getServletContext();
}
public void forward(String relativeUrlPath)
- throws ServletException, IOException
- {
- invokingJspCtxt.forward(relativeUrlPath);
+ throws ServletException, IOException {
+ invokingJspCtxt.forward(relativeUrlPath);
}
public void include(String relativeUrlPath)
- throws ServletException, IOException
- {
- invokingJspCtxt.include(relativeUrlPath);
+ throws ServletException, IOException {
+ invokingJspCtxt.include(relativeUrlPath);
}
- public void include(String relativeUrlPath, boolean flush)
- throws ServletException, IOException {
- include(relativeUrlPath, false); // XXX
+ public void include(String relativeUrlPath, boolean flush)
+ throws ServletException, IOException {
+ include(relativeUrlPath, false); // XXX
}
public VariableResolver getVariableResolver() {
- return this;
+ return this;
}
public BodyContent pushBody() {
- return invokingJspCtxt.pushBody();
+ return invokingJspCtxt.pushBody();
}
public JspWriter pushBody(Writer writer) {
- return invokingJspCtxt.pushBody(writer);
+ return invokingJspCtxt.pushBody(writer);
}
public JspWriter popBody() {
@@ -296,28 +293,25 @@
}
public ExpressionEvaluator getExpressionEvaluator() {
- return invokingJspCtxt.getExpressionEvaluator();
+ return invokingJspCtxt.getExpressionEvaluator();
}
public void handlePageException(Exception ex)
- throws IOException, ServletException
- {
- // Should never be called since handleException() called with a
- // Throwable in the generated servlet.
- handlePageException((Throwable) ex);
+ throws IOException, ServletException {
+ // Should never be called since handleException() called with a
+ // Throwable in the generated servlet.
+ handlePageException((Throwable) ex);
}
public void handlePageException(Throwable t)
- throws IOException, ServletException
- {
- invokingJspCtxt.handlePageException(t);
+ throws IOException, ServletException {
+ invokingJspCtxt.handlePageException(t);
}
/**
* VariableResolver interface
*/
- public Object resolveVariable( String pName ) throws ELException
- {
+ public Object resolveVariable(String pName) throws ELException {
return variableResolver.resolveVariable(pName);
}
@@ -325,24 +319,24 @@
* Synchronize variables at begin of tag file
*/
public void syncBeginTagFile() {
- saveNestedVariables();
+ saveNestedVariables();
}
/**
* Synchronize variables before fragment invokation
*/
public void syncBeforeInvoke() {
- copyTagToPageScope(VariableInfo.NESTED);
- copyTagToPageScope(VariableInfo.AT_BEGIN);
+ copyTagToPageScope(VariableInfo.NESTED);
+ copyTagToPageScope(VariableInfo.AT_BEGIN);
}
/**
* Synchronize variables at end of tag file
*/
public void syncEndTagFile() {
- copyTagToPageScope(VariableInfo.AT_BEGIN);
- copyTagToPageScope(VariableInfo.AT_END);
- restoreNestedVariables();
+ copyTagToPageScope(VariableInfo.AT_BEGIN);
+ copyTagToPageScope(VariableInfo.AT_END);
+ restoreNestedVariables();
}
/**
@@ -352,36 +346,36 @@
* @param scope variable scope (one of NESTED, AT_BEGIN, or AT_END)
*/
private void copyTagToPageScope(int scope) {
- Iterator iter = null;
+ Iterator iter = null;
- switch (scope) {
- case VariableInfo.NESTED:
- if (nestedVars != null) {
- iter = nestedVars.iterator();
- }
- break;
- case VariableInfo.AT_BEGIN:
- if (atBeginVars != null) {
- iter = atBeginVars.iterator();
- }
- break;
- case VariableInfo.AT_END:
- if (atEndVars != null) {
- iter = atEndVars.iterator();
- }
- break;
- }
-
- while ((iter != null) && iter.hasNext()) {
- String varName = (String) iter.next();
- Object obj = getAttribute(varName);
- varName = findAlias(varName);
- if (obj != null) {
- invokingJspCtxt.setAttribute(varName, obj);
- } else {
- invokingJspCtxt.removeAttribute(varName, PAGE_SCOPE);
- }
- }
+ switch (scope) {
+ case VariableInfo.NESTED:
+ if (nestedVars != null) {
+ iter = nestedVars.iterator();
+ }
+ break;
+ case VariableInfo.AT_BEGIN:
+ if (atBeginVars != null) {
+ iter = atBeginVars.iterator();
+ }
+ break;
+ case VariableInfo.AT_END:
+ if (atEndVars != null) {
+ iter = atEndVars.iterator();
+ }
+ break;
+ }
+
+ while ((iter != null) && iter.hasNext()) {
+ String varName = (String) iter.next();
+ Object obj = getAttribute(varName);
+ varName = findAlias(varName);
+ if (obj != null) {
+ invokingJspCtxt.setAttribute(varName, obj);
+ } else {
+ invokingJspCtxt.removeAttribute(varName, PAGE_SCOPE);
+ }
+ }
}
/**
@@ -389,17 +383,17 @@
* the invoking JSP context, so they can later be restored.
*/
private void saveNestedVariables() {
- if (nestedVars != null) {
- Iterator iter = nestedVars.iterator();
- while (iter.hasNext()) {
- String varName = (String) iter.next();
- varName = findAlias(varName);
- Object obj = invokingJspCtxt.getAttribute(varName);
- if (obj != null) {
- originalNestedVars.put(varName, obj);
- }
- }
- }
+ if (nestedVars != null) {
+ Iterator iter = nestedVars.iterator();
+ while (iter.hasNext()) {
+ String varName = (String) iter.next();
+ varName = findAlias(varName);
+ Object obj = invokingJspCtxt.getAttribute(varName);
+ if (obj != null) {
+ originalNestedVars.put(varName, obj);
+ }
+ }
+ }
}
/**
@@ -407,19 +401,19 @@
* context.
*/
private void restoreNestedVariables() {
- if (nestedVars != null) {
- Iterator iter = nestedVars.iterator();
- while (iter.hasNext()) {
- String varName = (String) iter.next();
- varName = findAlias(varName);
- Object obj = originalNestedVars.get(varName);
- if (obj != null) {
- invokingJspCtxt.setAttribute(varName, obj);
- } else {
- invokingJspCtxt.removeAttribute(varName, PAGE_SCOPE);
- }
- }
- }
+ if (nestedVars != null) {
+ Iterator iter = nestedVars.iterator();
+ while (iter.hasNext()) {
+ String varName = (String) iter.next();
+ varName = findAlias(varName);
+ Object obj = originalNestedVars.get(varName);
+ if (obj != null) {
+ invokingJspCtxt.setAttribute(varName, obj);
+ } else {
+ invokingJspCtxt.removeAttribute(varName, PAGE_SCOPE);
+ }
+ }
+ }
}
/**
@@ -428,18 +422,18 @@
*
* @param varName The variable name to check
* @return The variable name for which varName is used as an alias, or
- * varName if it is not being used as an alias
+ * varName if it is not being used as an alias
*/
private String findAlias(String varName) {
- if (aliases == null)
- return varName;
+ if (aliases == null)
+ return varName;
- String alias = (String) aliases.get(varName);
- if (alias == null) {
- return varName;
- }
- return alias;
+ String alias = (String) aliases.get(varName);
+ if (alias == null) {
+ return varName;
+ }
+ return alias;
}
}
Modified: struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspFactoryImpl.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspFactoryImpl.java?rev=804373&r1=804372&r2=804373&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspFactoryImpl.java (original)
+++ struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspFactoryImpl.java Fri Aug 14 21:02:33 2009
@@ -16,8 +16,8 @@
*/
package org.apache.struts2.jasper.runtime;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.struts2.jasper.util.SimplePool;
import javax.servlet.Servlet;
@@ -37,72 +37,72 @@
public class JspFactoryImpl extends JspFactory {
// Logger
- private Log log = LogFactory.getLog(JspFactoryImpl.class);
+ private Logger log = LoggerFactory.getLogger(JspFactoryImpl.class);
private static final String SPEC_VERSION = "2.0";
- private static final boolean USE_POOL =
- Boolean.valueOf(System.getProperty("org.apache.struts2.jasper.runtime.JspFactoryImpl.USE_POOL", "true")).booleanValue();
+ private static final boolean USE_POOL =
+ Boolean.valueOf(System.getProperty("org.apache.struts2.jasper.runtime.JspFactoryImpl.USE_POOL", "true")).booleanValue();
private SimplePool pool = new SimplePool(100);
-
+
public PageContext getPageContext(Servlet servlet,
- ServletRequest request,
+ ServletRequest request,
ServletResponse response,
- String errorPageURL,
+ String errorPageURL,
boolean needsSession,
- int bufferSize,
+ int bufferSize,
boolean autoflush) {
- if( System.getSecurityManager() != null ) {
- PrivilegedGetPageContext dp = new PrivilegedGetPageContext(
- (JspFactoryImpl)this, servlet, request, response, errorPageURL,
- needsSession, bufferSize, autoflush);
- return (PageContext)AccessController.doPrivileged(dp);
- } else {
- return internalGetPageContext(servlet, request, response,
- errorPageURL, needsSession,
- bufferSize, autoflush);
- }
+ if (System.getSecurityManager() != null) {
+ PrivilegedGetPageContext dp = new PrivilegedGetPageContext(
+ (JspFactoryImpl) this, servlet, request, response, errorPageURL,
+ needsSession, bufferSize, autoflush);
+ return (PageContext) AccessController.doPrivileged(dp);
+ } else {
+ return internalGetPageContext(servlet, request, response,
+ errorPageURL, needsSession,
+ bufferSize, autoflush);
+ }
}
public void releasePageContext(PageContext pc) {
- if( pc == null )
- return;
- if( System.getSecurityManager() != null ) {
+ if (pc == null)
+ return;
+ if (System.getSecurityManager() != null) {
PrivilegedReleasePageContext dp = new PrivilegedReleasePageContext(
- (JspFactoryImpl)this,pc);
+ (JspFactoryImpl) this, pc);
AccessController.doPrivileged(dp);
} else {
internalReleasePageContext(pc);
- }
+ }
}
public JspEngineInfo getEngineInfo() {
return new JspEngineInfo() {
- public String getSpecificationVersion() {
- return SPEC_VERSION;
- }
- };
+ public String getSpecificationVersion() {
+ return SPEC_VERSION;
+ }
+ };
}
private PageContext internalGetPageContext(Servlet servlet,
- ServletRequest request,
- ServletResponse response,
- String errorPageURL,
- boolean needsSession,
- int bufferSize,
- boolean autoflush) {
+ ServletRequest request,
+ ServletResponse response,
+ String errorPageURL,
+ boolean needsSession,
+ int bufferSize,
+ boolean autoflush) {
try {
- PageContext pc;
- if( USE_POOL ) {
+ PageContext pc;
+ if (USE_POOL) {
pc = (PageContext) pool.get();
- if( pc == null ) {
- pc= new PageContextImpl(this);
- }
- } else {
- pc = new PageContextImpl(this);
- }
- pc.initialize(servlet, request, response, errorPageURL,
- needsSession, bufferSize, autoflush);
+ if (pc == null) {
+ pc = new PageContextImpl(this);
+ }
+ } else {
+ pc = new PageContextImpl(this);
+ }
+ pc.initialize(servlet, request, response, errorPageURL,
+ needsSession, bufferSize, autoflush);
return pc;
} catch (Throwable ex) {
/* FIXME: need to do something reasonable here!! */
@@ -113,65 +113,65 @@
private void internalReleasePageContext(PageContext pc) {
pc.release();
- if (USE_POOL && (pc instanceof PageContextImpl)) {
- pool.put( pc );
- }
+ if (USE_POOL && (pc instanceof PageContextImpl)) {
+ pool.put(pc);
+ }
}
private class PrivilegedGetPageContext implements PrivilegedAction {
- private JspFactoryImpl factory;
- private Servlet servlet;
- private ServletRequest request;
- private ServletResponse response;
- private String errorPageURL;
- private boolean needsSession;
- private int bufferSize;
- private boolean autoflush;
-
- PrivilegedGetPageContext(JspFactoryImpl factory,
- Servlet servlet,
- ServletRequest request,
- ServletResponse response,
- String errorPageURL,
- boolean needsSession,
- int bufferSize,
- boolean autoflush) {
- this.factory = factory;
- this.servlet = servlet;
- this.request = request;
- this.response = response;
- this.errorPageURL = errorPageURL;
- this.needsSession = needsSession;
- this.bufferSize = bufferSize;
- this.autoflush = autoflush;
- }
-
- public Object run() {
- return factory.internalGetPageContext(servlet,
- request,
- response,
- errorPageURL,
- needsSession,
- bufferSize,
- autoflush);
- }
+ private JspFactoryImpl factory;
+ private Servlet servlet;
+ private ServletRequest request;
+ private ServletResponse response;
+ private String errorPageURL;
+ private boolean needsSession;
+ private int bufferSize;
+ private boolean autoflush;
+
+ PrivilegedGetPageContext(JspFactoryImpl factory,
+ Servlet servlet,
+ ServletRequest request,
+ ServletResponse response,
+ String errorPageURL,
+ boolean needsSession,
+ int bufferSize,
+ boolean autoflush) {
+ this.factory = factory;
+ this.servlet = servlet;
+ this.request = request;
+ this.response = response;
+ this.errorPageURL = errorPageURL;
+ this.needsSession = needsSession;
+ this.bufferSize = bufferSize;
+ this.autoflush = autoflush;
+ }
+
+ public Object run() {
+ return factory.internalGetPageContext(servlet,
+ request,
+ response,
+ errorPageURL,
+ needsSession,
+ bufferSize,
+ autoflush);
+ }
}
private class PrivilegedReleasePageContext implements PrivilegedAction {
private JspFactoryImpl factory;
- private PageContext pageContext;
+ private PageContext pageContext;
PrivilegedReleasePageContext(JspFactoryImpl factory,
- PageContext pageContext) {
+ PageContext pageContext) {
this.factory = factory;
this.pageContext = pageContext;
}
public Object run() {
factory.internalReleasePageContext(pageContext);
- return null;
+ return null;
}
}
}
Modified: struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspFragmentHelper.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspFragmentHelper.java?rev=804373&r1=804372&r2=804373&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspFragmentHelper.java (original)
+++ struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspFragmentHelper.java Fri Aug 14 21:02:33 2009
@@ -27,39 +27,37 @@
* This class allows for the emulation of numerous fragments within
* a single class, which in turn reduces the load on the class loader
* since there are potentially many JspFragments in a single page.
- * <p>
+ * <p/>
* The class also provides various utility methods for JspFragment
* implementations.
*
* @author Mark Roth
*/
-public abstract class JspFragmentHelper
- extends JspFragment
-{
-
+public abstract class JspFragmentHelper
+ extends JspFragment {
+
protected int discriminator;
protected JspContext jspContext;
protected PageContext _jspx_page_context;
protected JspTag parentTag;
- public JspFragmentHelper( int discriminator, JspContext jspContext,
- JspTag parentTag )
- {
+ public JspFragmentHelper(int discriminator, JspContext jspContext,
+ JspTag parentTag) {
this.discriminator = discriminator;
this.jspContext = jspContext;
this._jspx_page_context = null;
- if( jspContext instanceof PageContext ) {
- _jspx_page_context = (PageContext)jspContext;
+ if (jspContext instanceof PageContext) {
+ _jspx_page_context = (PageContext) jspContext;
}
this.parentTag = parentTag;
}
-
+
public JspContext getJspContext() {
return this.jspContext;
}
-
+
public JspTag getParentTag() {
return this.parentTag;
}
-
+
}
Modified: struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspRuntimeLibrary.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspRuntimeLibrary.java?rev=804373&r1=804372&r2=804373&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspRuntimeLibrary.java (original)
+++ struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspRuntimeLibrary.java Fri Aug 14 21:02:33 2009
@@ -41,8 +41,8 @@
/**
* Bunch of util methods that are used by code generated for useBean,
- * getProperty and setProperty.
- *
+ * getProperty and setProperty.
+ * <p/>
* The __begin, __end stuff is there so that the JSP engine can
* actually parse this file and inline them if people don't want
* runtime dependencies on this class. However, I'm not sure if that
@@ -52,14 +52,14 @@
* @author Shawn Bayern
*/
public class JspRuntimeLibrary {
-
+
private static final String SERVLET_EXCEPTION
- = "javax.servlet.error.exception";
+ = "javax.servlet.error.exception";
private static final String JSP_EXCEPTION
- = "javax.servlet.jsp.jspException";
+ = "javax.servlet.jsp.jspException";
protected static class PrivilegedIntrospectHelper
- implements PrivilegedExceptionAction {
+ implements PrivilegedExceptionAction {
private Object bean;
private String prop;
@@ -70,8 +70,7 @@
PrivilegedIntrospectHelper(Object bean, String prop,
String value, ServletRequest request,
- String param, boolean ignoreMethodNF)
- {
+ String param, boolean ignoreMethodNF) {
this.bean = bean;
this.prop = prop;
this.value = value;
@@ -79,10 +78,10 @@
this.param = param;
this.ignoreMethodNF = ignoreMethodNF;
}
-
+
public Object run() throws JasperException {
internalIntrospecthelper(
- bean,prop,value,request,param,ignoreMethodNF);
+ bean, prop, value, request, param, ignoreMethodNF);
return null;
}
}
@@ -91,7 +90,7 @@
* Returns the value of the javax.servlet.error.exception request
* attribute value, if present, otherwise the value of the
* javax.servlet.jsp.jspException request attribute value.
- *
+ * <p/>
* This method is called at the beginning of the generated servlet code
* for a JSP error page, when the "exception" implicit scripting language
* variable is initialized.
@@ -134,7 +133,7 @@
return (char) 0;
} else {
// this trick avoids escaping issues
- return (char)(int) s.charAt(0);
+ return (char) (int) s.charAt(0);
}
}
@@ -190,7 +189,7 @@
} else if (target == Character.class) {
if (isNullOrEmpty)
return new Character((char) 0);
- else
+ else
return new Character(s.charAt(0));
} else if (target == Double.class) {
if (isNullOrEmpty)
@@ -222,11 +221,10 @@
}
}
- // __begin convertMethod
+ // __begin convertMethod
public static Object convert(String propertyName, String s, Class t,
- Class propertyEditorClass)
- throws JasperException
- {
+ Class propertyEditorClass)
+ throws JasperException {
try {
if (s == null) {
if (t.equals(Boolean.class) || t.equals(Boolean.TYPE))
@@ -236,36 +234,36 @@
}
if (propertyEditorClass != null) {
return getValueFromBeanInfoPropertyEditor(
- t, propertyName, s, propertyEditorClass);
- } else if ( t.equals(Boolean.class) || t.equals(Boolean.TYPE) ) {
+ t, propertyName, s, propertyEditorClass);
+ } else if (t.equals(Boolean.class) || t.equals(Boolean.TYPE)) {
if (s.equalsIgnoreCase("on") || s.equalsIgnoreCase("true"))
s = "true";
else
s = "false";
return new Boolean(s);
- } else if ( t.equals(Byte.class) || t.equals(Byte.TYPE) ) {
+ } else if (t.equals(Byte.class) || t.equals(Byte.TYPE)) {
return new Byte(s);
} else if (t.equals(Character.class) || t.equals(Character.TYPE)) {
return s.length() > 0 ? new Character(s.charAt(0)) : null;
- } else if ( t.equals(Short.class) || t.equals(Short.TYPE) ) {
+ } else if (t.equals(Short.class) || t.equals(Short.TYPE)) {
return new Short(s);
- } else if ( t.equals(Integer.class) || t.equals(Integer.TYPE) ) {
+ } else if (t.equals(Integer.class) || t.equals(Integer.TYPE)) {
return new Integer(s);
- } else if ( t.equals(Float.class) || t.equals(Float.TYPE) ) {
+ } else if (t.equals(Float.class) || t.equals(Float.TYPE)) {
return new Float(s);
- } else if ( t.equals(Long.class) || t.equals(Long.TYPE) ) {
+ } else if (t.equals(Long.class) || t.equals(Long.TYPE)) {
return new Long(s);
- } else if ( t.equals(Double.class) || t.equals(Double.TYPE) ) {
+ } else if (t.equals(Double.class) || t.equals(Double.TYPE)) {
return new Double(s);
- } else if ( t.equals(String.class) ) {
+ } else if (t.equals(String.class)) {
return s;
- } else if ( t.equals(java.io.File.class) ) {
+ } else if (t.equals(java.io.File.class)) {
return new java.io.File(s);
} else if (t.getName().equals("java.lang.Object")) {
- return new Object[] {s};
+ return new Object[]{s};
} else {
return getValueFromPropertyEditorManager(
- t, propertyName, s);
+ t, propertyName, s);
}
} catch (Exception ex) {
throw new JasperException(ex);
@@ -274,84 +272,83 @@
// __end convertMethod
// __begin introspectMethod
+
public static void introspect(Object bean, ServletRequest request)
- throws JasperException
- {
+ throws JasperException {
Enumeration e = request.getParameterNames();
- while ( e.hasMoreElements() ) {
- String name = (String) e.nextElement();
+ while (e.hasMoreElements()) {
+ String name = (String) e.nextElement();
String value = request.getParameter(name);
introspecthelper(bean, name, value, request, name, true);
}
}
// __end introspectMethod
-
+
// __begin introspecthelperMethod
+
public static void introspecthelper(Object bean, String prop,
String value, ServletRequest request,
String param, boolean ignoreMethodNF)
- throws JasperException
- {
- if( System.getSecurityManager() != null ) {
+ throws JasperException {
+ if (System.getSecurityManager() != null) {
try {
PrivilegedIntrospectHelper dp =
- new PrivilegedIntrospectHelper(
- bean,prop,value,request,param,ignoreMethodNF);
+ new PrivilegedIntrospectHelper(
+ bean, prop, value, request, param, ignoreMethodNF);
AccessController.doPrivileged(dp);
- } catch( PrivilegedActionException pe) {
+ } catch (PrivilegedActionException pe) {
Exception e = pe.getException();
- throw (JasperException)e;
+ throw (JasperException) e;
}
} else {
internalIntrospecthelper(
- bean,prop,value,request,param,ignoreMethodNF);
+ bean, prop, value, request, param, ignoreMethodNF);
}
}
private static void internalIntrospecthelper(Object bean, String prop,
- String value, ServletRequest request,
- String param, boolean ignoreMethodNF)
- throws JasperException
- {
+ String value, ServletRequest request,
+ String param, boolean ignoreMethodNF)
+ throws JasperException {
Method method = null;
Class type = null;
Class propertyEditorClass = null;
try {
java.beans.BeanInfo info
- = java.beans.Introspector.getBeanInfo(bean.getClass());
- if ( info != null ) {
+ = java.beans.Introspector.getBeanInfo(bean.getClass());
+ if (info != null) {
java.beans.PropertyDescriptor pd[]
- = info.getPropertyDescriptors();
- for (int i = 0 ; i < pd.length ; i++) {
- if ( pd[i].getName().equals(prop) ) {
+ = info.getPropertyDescriptors();
+ for (int i = 0; i < pd.length; i++) {
+ if (pd[i].getName().equals(prop)) {
method = pd[i].getWriteMethod();
- type = pd[i].getPropertyType();
+ type = pd[i].getPropertyType();
propertyEditorClass = pd[i].getPropertyEditorClass();
break;
}
}
}
- if ( method != null ) {
+ if (method != null) {
if (type.isArray()) {
if (request == null) {
throw new JasperException(
- Localizer.getMessage("jsp.error.beans.setproperty.noindexset"));
+ Localizer.getMessage("jsp.error.beans.setproperty.noindexset"));
}
Class t = type.getComponentType();
String[] values = request.getParameterValues(param);
//XXX Please check.
- if(values == null) return;
- if(t.equals(String.class)) {
- method.invoke(bean, new Object[] { values });
+ if (values == null) return;
+ if (t.equals(String.class)) {
+ method.invoke(bean, new Object[]{values});
} else {
- createTypedArray (prop, bean, method, values, t,
- propertyEditorClass);
+ createTypedArray(prop, bean, method, values, t,
+ propertyEditorClass);
}
} else {
- if(value == null || (param != null && value.equals(""))) return;
+ if (value == null || (param != null && value.equals(""))) return;
Object oval = convert(prop, value, type, propertyEditorClass);
- if ( oval != null )
- method.invoke(bean, new Object[] { oval });
+ if (oval != null)
+ method.invoke(bean, new Object[]{oval});
}
}
} catch (Exception ex) {
@@ -360,24 +357,25 @@
if (!ignoreMethodNF && (method == null)) {
if (type == null) {
throw new JasperException(
- Localizer.getMessage("jsp.error.beans.noproperty",
- prop,
- bean.getClass().getName()));
+ Localizer.getMessage("jsp.error.beans.noproperty",
+ prop,
+ bean.getClass().getName()));
} else {
throw new JasperException(
- Localizer.getMessage("jsp.error.beans.nomethod.setproperty",
- prop,
- type.getName(),
- bean.getClass().getName()));
+ Localizer.getMessage("jsp.error.beans.nomethod.setproperty",
+ prop,
+ type.getName(),
+ bean.getClass().getName()));
}
}
}
// __end introspecthelperMethod
-
+
//-------------------------------------------------------------------
// functions to convert builtin Java data types to string.
//-------------------------------------------------------------------
// __begin toStringMethod
+
public static String toString(Object o) {
return String.valueOf(o);
}
@@ -427,174 +425,176 @@
String[] values,
Class t,
Class propertyEditorClass)
- throws JasperException {
+ throws JasperException {
try {
if (propertyEditorClass != null) {
Object[] tmpval = new Integer[values.length];
- for (int i=0; i<values.length; i++) {
+ for (int i = 0; i < values.length; i++) {
tmpval[i] = getValueFromBeanInfoPropertyEditor(
t, propertyName, values[i], propertyEditorClass);
}
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(Integer.class)) {
- Integer []tmpval = new Integer[values.length];
- for (int i = 0 ; i < values.length; i++)
- tmpval[i] = new Integer (values[i]);
- method.invoke (bean, new Object[] {tmpval});
+ Integer[] tmpval = new Integer[values.length];
+ for (int i = 0; i < values.length; i++)
+ tmpval[i] = new Integer(values[i]);
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(Byte.class)) {
Byte[] tmpval = new Byte[values.length];
- for (int i = 0 ; i < values.length; i++)
- tmpval[i] = new Byte (values[i]);
- method.invoke (bean, new Object[] {tmpval});
+ for (int i = 0; i < values.length; i++)
+ tmpval[i] = new Byte(values[i]);
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(Boolean.class)) {
Boolean[] tmpval = new Boolean[values.length];
- for (int i = 0 ; i < values.length; i++)
- tmpval[i] = new Boolean (values[i]);
- method.invoke (bean, new Object[] {tmpval});
+ for (int i = 0; i < values.length; i++)
+ tmpval[i] = new Boolean(values[i]);
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(Short.class)) {
Short[] tmpval = new Short[values.length];
- for (int i = 0 ; i < values.length; i++)
- tmpval[i] = new Short (values[i]);
- method.invoke (bean, new Object[] {tmpval});
+ for (int i = 0; i < values.length; i++)
+ tmpval[i] = new Short(values[i]);
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(Long.class)) {
Long[] tmpval = new Long[values.length];
- for (int i = 0 ; i < values.length; i++)
- tmpval[i] = new Long (values[i]);
- method.invoke (bean, new Object[] {tmpval});
+ for (int i = 0; i < values.length; i++)
+ tmpval[i] = new Long(values[i]);
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(Double.class)) {
Double[] tmpval = new Double[values.length];
- for (int i = 0 ; i < values.length; i++)
- tmpval[i] = new Double (values[i]);
- method.invoke (bean, new Object[] {tmpval});
+ for (int i = 0; i < values.length; i++)
+ tmpval[i] = new Double(values[i]);
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(Float.class)) {
Float[] tmpval = new Float[values.length];
- for (int i = 0 ; i < values.length; i++)
- tmpval[i] = new Float (values[i]);
- method.invoke (bean, new Object[] {tmpval});
+ for (int i = 0; i < values.length; i++)
+ tmpval[i] = new Float(values[i]);
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(Character.class)) {
Character[] tmpval = new Character[values.length];
- for (int i = 0 ; i < values.length; i++)
+ for (int i = 0; i < values.length; i++)
tmpval[i] = new Character(values[i].charAt(0));
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(int.class)) {
- int []tmpval = new int[values.length];
- for (int i = 0 ; i < values.length; i++)
- tmpval[i] = Integer.parseInt (values[i]);
- method.invoke (bean, new Object[] {tmpval});
+ int[] tmpval = new int[values.length];
+ for (int i = 0; i < values.length; i++)
+ tmpval[i] = Integer.parseInt(values[i]);
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(byte.class)) {
byte[] tmpval = new byte[values.length];
- for (int i = 0 ; i < values.length; i++)
- tmpval[i] = Byte.parseByte (values[i]);
- method.invoke (bean, new Object[] {tmpval});
+ for (int i = 0; i < values.length; i++)
+ tmpval[i] = Byte.parseByte(values[i]);
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(boolean.class)) {
boolean[] tmpval = new boolean[values.length];
- for (int i = 0 ; i < values.length; i++)
+ for (int i = 0; i < values.length; i++)
tmpval[i] = (Boolean.valueOf(values[i])).booleanValue();
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(short.class)) {
short[] tmpval = new short[values.length];
- for (int i = 0 ; i < values.length; i++)
- tmpval[i] = Short.parseShort (values[i]);
- method.invoke (bean, new Object[] {tmpval});
+ for (int i = 0; i < values.length; i++)
+ tmpval[i] = Short.parseShort(values[i]);
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(long.class)) {
long[] tmpval = new long[values.length];
- for (int i = 0 ; i < values.length; i++)
- tmpval[i] = Long.parseLong (values[i]);
- method.invoke (bean, new Object[] {tmpval});
+ for (int i = 0; i < values.length; i++)
+ tmpval[i] = Long.parseLong(values[i]);
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(double.class)) {
double[] tmpval = new double[values.length];
- for (int i = 0 ; i < values.length; i++)
+ for (int i = 0; i < values.length; i++)
tmpval[i] = Double.valueOf(values[i]).doubleValue();
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(float.class)) {
float[] tmpval = new float[values.length];
- for (int i = 0 ; i < values.length; i++)
+ for (int i = 0; i < values.length; i++)
tmpval[i] = Float.valueOf(values[i]).floatValue();
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(char.class)) {
char[] tmpval = new char[values.length];
- for (int i = 0 ; i < values.length; i++)
+ for (int i = 0; i < values.length; i++)
tmpval[i] = values[i].charAt(0);
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[]{tmpval});
} else {
Object[] tmpval = new Integer[values.length];
- for (int i=0; i<values.length; i++) {
- tmpval[i] =
- getValueFromPropertyEditorManager(
- t, propertyName, values[i]);
+ for (int i = 0; i < values.length; i++) {
+ tmpval[i] =
+ getValueFromPropertyEditorManager(
+ t, propertyName, values[i]);
}
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[]{tmpval});
}
} catch (Exception ex) {
- throw new JasperException ("error in invoking method", ex);
+ throw new JasperException("error in invoking method", ex);
}
}
/**
* Escape special shell characters.
+ *
* @param unescString The string to shell-escape
* @return The escaped shell string.
*/
public static String escapeQueryString(String unescString) {
- if ( unescString == null )
- return null;
-
- String escString = "";
- String shellSpChars = "&;`'\"|*?~<>^()[]{}$\\\n";
-
- for(int index=0; index<unescString.length(); index++) {
- char nextChar = unescString.charAt(index);
+ if (unescString == null)
+ return null;
- if( shellSpChars.indexOf(nextChar) != -1 )
- escString += "\\";
+ String escString = "";
+ String shellSpChars = "&;`'\"|*?~<>^()[]{}$\\\n";
- escString += nextChar;
- }
- return escString;
+ for (int index = 0; index < unescString.length(); index++) {
+ char nextChar = unescString.charAt(index);
+
+ if (shellSpChars.indexOf(nextChar) != -1)
+ escString += "\\";
+
+ escString += nextChar;
+ }
+ return escString;
}
/**
* Decode an URL formatted string.
+ *
* @param encoded The string to decode.
* @return The decoded string.
*/
public static String decode(String encoded) {
// speedily leave if we're not needed
- if (encoded == null) return null;
+ if (encoded == null) return null;
if (encoded.indexOf('%') == -1 && encoded.indexOf('+') == -1)
- return encoded;
+ return encoded;
- //allocate the buffer - use byte[] to avoid calls to new.
+ //allocate the buffer - use byte[] to avoid calls to new.
byte holdbuffer[] = new byte[encoded.length()];
int bufcount = 0;
for (int count = 0; count < encoded.length(); count++) {
- char cur = encoded.charAt(count);
+ char cur = encoded.charAt(count);
if (cur == '%') {
- holdbuffer[bufcount++] =
- (byte)Integer.parseInt(encoded.substring(count+1,count+3),16);
+ holdbuffer[bufcount++] =
+ (byte) Integer.parseInt(encoded.substring(count + 1, count + 3), 16);
if (count + 2 >= encoded.length())
count = encoded.length();
else
count += 2;
} else if (cur == '+') {
- holdbuffer[bufcount++] = (byte) ' ';
- } else {
- holdbuffer[bufcount++] = (byte) cur;
+ holdbuffer[bufcount++] = (byte) ' ';
+ } else {
+ holdbuffer[bufcount++] = (byte) cur;
}
}
// REVISIT -- remedy for Deprecated warning.
- //return new String(holdbuffer,0,0,bufcount);
- return new String(holdbuffer,0,bufcount);
+ //return new String(holdbuffer,0,0,bufcount);
+ return new String(holdbuffer, 0, bufcount);
}
// __begin lookupReadMethodMethod
public static Object handleGetProperty(Object o, String prop)
- throws JasperException {
+ throws JasperException {
if (o == null) {
throw new JasperException(
Localizer.getMessage("jsp.error.beans.nullbean"));
@@ -604,48 +604,49 @@
Method method = getReadMethod(o.getClass(), prop);
value = method.invoke(o, null);
} catch (Exception ex) {
- throw new JasperException (ex);
+ throw new JasperException(ex);
}
return value;
}
// __end lookupReadMethodMethod
// handles <jsp:setProperty> with EL expression for 'value' attribute
-/** Use proprietaryEvaluate
- public static void handleSetPropertyExpression(Object bean,
- String prop, String expression, PageContext pageContext,
- VariableResolver variableResolver, FunctionMapper functionMapper )
- throws JasperException
- {
- try {
- Method method = getWriteMethod(bean.getClass(), prop);
- method.invoke(bean, new Object[] {
- pageContext.getExpressionEvaluator().evaluate(
- expression,
- method.getParameterTypes()[0],
- variableResolver,
- functionMapper,
- null )
- });
- } catch (Exception ex) {
- throw new JasperException(ex);
- }
- }
-**/
+
+ /**
+ * Use proprietaryEvaluate
+ * public static void handleSetPropertyExpression(Object bean,
+ * String prop, String expression, PageContext pageContext,
+ * VariableResolver variableResolver, FunctionMapper functionMapper )
+ * throws JasperException
+ * {
+ * try {
+ * Method method = getWriteMethod(bean.getClass(), prop);
+ * method.invoke(bean, new Object[] {
+ * pageContext.getExpressionEvaluator().evaluate(
+ * expression,
+ * method.getParameterTypes()[0],
+ * variableResolver,
+ * functionMapper,
+ * null )
+ * });
+ * } catch (Exception ex) {
+ * throw new JasperException(ex);
+ * }
+ * }
+ */
public static void handleSetPropertyExpression(Object bean,
- String prop, String expression, PageContext pageContext,
- ProtectedFunctionMapper functionMapper )
- throws JasperException
- {
+ String prop, String expression, PageContext pageContext,
+ ProtectedFunctionMapper functionMapper)
+ throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
- method.invoke(bean, new Object[] {
- PageContextImpl.proprietaryEvaluate(
- expression,
- method.getParameterTypes()[0],
- pageContext,
- functionMapper,
- false )
+ method.invoke(bean, new Object[]{
+ PageContextImpl.proprietaryEvaluate(
+ expression,
+ method.getParameterTypes()[0],
+ pageContext,
+ functionMapper,
+ false)
});
} catch (Exception ex) {
throw new JasperException(ex);
@@ -654,150 +655,141 @@
public static void handleSetProperty(Object bean, String prop,
Object value)
- throws JasperException
- {
+ throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
- method.invoke(bean, new Object[] { value });
+ method.invoke(bean, new Object[]{value});
} catch (Exception ex) {
throw new JasperException(ex);
}
}
-
+
public static void handleSetProperty(Object bean, String prop,
int value)
- throws JasperException
- {
+ throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
- method.invoke(bean, new Object[] { new Integer(value) });
+ method.invoke(bean, new Object[]{new Integer(value)});
} catch (Exception ex) {
throw new JasperException(ex);
- }
+ }
}
-
+
public static void handleSetProperty(Object bean, String prop,
short value)
- throws JasperException
- {
+ throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
- method.invoke(bean, new Object[] { new Short(value) });
+ method.invoke(bean, new Object[]{new Short(value)});
} catch (Exception ex) {
throw new JasperException(ex);
- }
+ }
}
-
+
public static void handleSetProperty(Object bean, String prop,
long value)
- throws JasperException
- {
+ throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
- method.invoke(bean, new Object[] { new Long(value) });
+ method.invoke(bean, new Object[]{new Long(value)});
} catch (Exception ex) {
throw new JasperException(ex);
- }
- }
-
+ }
+ }
+
public static void handleSetProperty(Object bean, String prop,
double value)
- throws JasperException
- {
+ throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
- method.invoke(bean, new Object[] { new Double(value) });
+ method.invoke(bean, new Object[]{new Double(value)});
} catch (Exception ex) {
throw new JasperException(ex);
- }
+ }
}
-
+
public static void handleSetProperty(Object bean, String prop,
float value)
- throws JasperException
- {
+ throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
- method.invoke(bean, new Object[] { new Float(value) });
+ method.invoke(bean, new Object[]{new Float(value)});
} catch (Exception ex) {
throw new JasperException(ex);
- }
+ }
}
-
+
public static void handleSetProperty(Object bean, String prop,
char value)
- throws JasperException
- {
+ throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
- method.invoke(bean, new Object[] { new Character(value) });
+ method.invoke(bean, new Object[]{new Character(value)});
} catch (Exception ex) {
throw new JasperException(ex);
- }
+ }
}
public static void handleSetProperty(Object bean, String prop,
byte value)
- throws JasperException
- {
+ throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
- method.invoke(bean, new Object[] { new Byte(value) });
+ method.invoke(bean, new Object[]{new Byte(value)});
} catch (Exception ex) {
throw new JasperException(ex);
- }
+ }
}
-
+
public static void handleSetProperty(Object bean, String prop,
boolean value)
- throws JasperException
- {
+ throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
- method.invoke(bean, new Object[] { new Boolean(value) });
+ method.invoke(bean, new Object[]{new Boolean(value)});
} catch (Exception ex) {
throw new JasperException(ex);
- }
+ }
}
-
+
public static Method getWriteMethod(Class beanClass, String prop)
- throws JasperException {
- Method method = null;
+ throws JasperException {
+ Method method = null;
Class type = null;
try {
java.beans.BeanInfo info
- = java.beans.Introspector.getBeanInfo(beanClass);
- if ( info != null ) {
+ = java.beans.Introspector.getBeanInfo(beanClass);
+ if (info != null) {
java.beans.PropertyDescriptor pd[]
- = info.getPropertyDescriptors();
- for (int i = 0 ; i < pd.length ; i++) {
- if ( pd[i].getName().equals(prop) ) {
+ = info.getPropertyDescriptors();
+ for (int i = 0; i < pd.length; i++) {
+ if (pd[i].getName().equals(prop)) {
method = pd[i].getWriteMethod();
- type = pd[i].getPropertyType();
+ type = pd[i].getPropertyType();
break;
}
}
- } else {
+ } else {
// just in case introspection silently fails.
throw new JasperException(
- Localizer.getMessage("jsp.error.beans.nobeaninfo",
- beanClass.getName()));
+ Localizer.getMessage("jsp.error.beans.nobeaninfo",
+ beanClass.getName()));
}
} catch (Exception ex) {
- throw new JasperException (ex);
+ throw new JasperException(ex);
}
if (method == null) {
if (type == null) {
throw new JasperException(
Localizer.getMessage("jsp.error.beans.noproperty",
- prop,
- beanClass.getName()));
+ prop,
+ beanClass.getName()));
} else {
throw new JasperException(
- Localizer.getMessage("jsp.error.beans.nomethod.setproperty",
- prop,
- type.getName(),
- beanClass.getName()));
+ Localizer.getMessage("jsp.error.beans.nomethod.setproperty",
+ prop,
+ type.getName(),
+ beanClass.getName()));
}
}
return method;
@@ -806,39 +798,39 @@
public static Method getReadMethod(Class beanClass, String prop)
throws JasperException {
- Method method = null;
+ Method method = null;
Class type = null;
try {
java.beans.BeanInfo info
- = java.beans.Introspector.getBeanInfo(beanClass);
- if ( info != null ) {
+ = java.beans.Introspector.getBeanInfo(beanClass);
+ if (info != null) {
java.beans.PropertyDescriptor pd[]
- = info.getPropertyDescriptors();
- for (int i = 0 ; i < pd.length ; i++) {
- if ( pd[i].getName().equals(prop) ) {
+ = info.getPropertyDescriptors();
+ for (int i = 0; i < pd.length; i++) {
+ if (pd[i].getName().equals(prop)) {
method = pd[i].getReadMethod();
- type = pd[i].getPropertyType();
+ type = pd[i].getPropertyType();
break;
}
}
- } else {
+ } else {
// just in case introspection silently fails.
throw new JasperException(
- Localizer.getMessage("jsp.error.beans.nobeaninfo",
- beanClass.getName()));
+ Localizer.getMessage("jsp.error.beans.nobeaninfo",
+ beanClass.getName()));
}
} catch (Exception ex) {
- throw new JasperException (ex);
+ throw new JasperException(ex);
}
if (method == null) {
if (type == null) {
throw new JasperException(
- Localizer.getMessage("jsp.error.beans.noproperty", prop,
- beanClass.getName()));
+ Localizer.getMessage("jsp.error.beans.noproperty", prop,
+ beanClass.getName()));
} else {
throw new JasperException(
- Localizer.getMessage("jsp.error.beans.nomethod", prop,
- beanClass.getName()));
+ Localizer.getMessage("jsp.error.beans.nomethod", prop,
+ beanClass.getName()));
}
}
@@ -849,41 +841,39 @@
// PropertyEditor Support
public static Object getValueFromBeanInfoPropertyEditor(
- Class attrClass, String attrName, String attrValue,
- Class propertyEditorClass)
- throws JasperException
- {
+ Class attrClass, String attrName, String attrValue,
+ Class propertyEditorClass)
+ throws JasperException {
try {
- PropertyEditor pe = (PropertyEditor)propertyEditorClass.newInstance();
+ PropertyEditor pe = (PropertyEditor) propertyEditorClass.newInstance();
pe.setAsText(attrValue);
return pe.getValue();
} catch (Exception ex) {
throw new JasperException(
- Localizer.getMessage("jsp.error.beans.property.conversion",
- attrValue, attrClass.getName(), attrName,
- ex.getMessage()));
+ Localizer.getMessage("jsp.error.beans.property.conversion",
+ attrValue, attrClass.getName(), attrName,
+ ex.getMessage()));
}
}
public static Object getValueFromPropertyEditorManager(
- Class attrClass, String attrName, String attrValue)
- throws JasperException
- {
+ Class attrClass, String attrName, String attrValue)
+ throws JasperException {
try {
- PropertyEditor propEditor =
- PropertyEditorManager.findEditor(attrClass);
+ PropertyEditor propEditor =
+ PropertyEditorManager.findEditor(attrClass);
if (propEditor != null) {
propEditor.setAsText(attrValue);
return propEditor.getValue();
} else {
throw new IllegalArgumentException(
- Localizer.getMessage("jsp.error.beans.propertyeditor.notregistered"));
+ Localizer.getMessage("jsp.error.beans.propertyeditor.notregistered"));
}
} catch (IllegalArgumentException ex) {
throw new JasperException(
- Localizer.getMessage("jsp.error.beans.property.conversion",
- attrValue, attrClass.getName(), attrName,
- ex.getMessage()));
+ Localizer.getMessage("jsp.error.beans.property.conversion",
+ attrValue, attrClass.getName(), attrName,
+ ex.getMessage()));
}
}
@@ -897,7 +887,7 @@
* Convert a possibly relative resource path into a context-relative
* resource path that starts with a '/'.
*
- * @param request The servlet request we are processing
+ * @param request The servlet request we are processing
* @param relativePath The possibly relative resource path
*/
public static String getContextRelativePath(ServletRequest request,
@@ -909,18 +899,17 @@
return (relativePath);
HttpServletRequest hrequest = (HttpServletRequest) request;
String uri = (String)
- request.getAttribute("javax.servlet.include.servlet_path");
+ request.getAttribute("javax.servlet.include.servlet_path");
if (uri != null) {
String pathInfo = (String)
- request.getAttribute("javax.servlet.include.path_info");
+ request.getAttribute("javax.servlet.include.path_info");
if (pathInfo == null) {
- if (uri.lastIndexOf('/') >= 0)
+ if (uri.lastIndexOf('/') >= 0)
uri = uri.substring(0, uri.lastIndexOf('/'));
}
- }
- else {
+ } else {
uri = hrequest.getServletPath();
- if (uri.lastIndexOf('/') >= 0)
+ if (uri.lastIndexOf('/') >= 0)
uri = uri.substring(0, uri.lastIndexOf('/'));
}
return uri + '/' + relativePath;
@@ -932,21 +921,20 @@
* Perform a RequestDispatcher.include() operation, with optional flushing
* of the response beforehand.
*
- * @param request The servlet request we are processing
- * @param response The servlet response we are processing
+ * @param request The servlet request we are processing
+ * @param response The servlet response we are processing
* @param relativePath The relative path of the resource to be included
- * @param out The Writer to whom we are currently writing
- * @param flush Should we flush before the include is processed?
- *
- * @exception IOException if thrown by the included servlet
- * @exception ServletException if thrown by the included servlet
+ * @param out The Writer to whom we are currently writing
+ * @param flush Should we flush before the include is processed?
+ * @throws IOException if thrown by the included servlet
+ * @throws ServletException if thrown by the included servlet
*/
public static void include(ServletRequest request,
ServletResponse response,
String relativePath,
JspWriter out,
boolean flush)
- throws IOException, ServletException {
+ throws IOException, ServletException {
if (flush && !(out instanceof BodyContent))
out.flush();
@@ -962,7 +950,7 @@
RequestDispatcher rd = request.getRequestDispatcher(resourcePath);
rd.include(request,
- new ServletResponseWrapperInclude(response, out));
+ new ServletResponseWrapperInclude(response, out));
}
@@ -971,8 +959,9 @@
* This performs the same function as java.next.URLEncode.encode
* in J2SDK1.4, and should be removed if the only platform supported
* is 1.4 or higher.
- * @param s The String to be URL encoded.
- * @param enc The character encoding
+ *
+ * @param s The String to be URL encoded.
+ * @param enc The character encoding
* @return The URL encoded String
*/
public static String URLEncode(String s, String enc) {
@@ -994,19 +983,19 @@
// Use the default encoding?
writer = new OutputStreamWriter(buf);
}
-
+
for (int i = 0; i < s.length(); i++) {
int c = s.charAt(i);
if (c == ' ') {
out.append('+');
} else if (isSafeChar(c)) {
- out.append((char)c);
+ out.append((char) c);
} else {
// convert to external encoding before hex conversion
try {
writer.write(c);
writer.flush();
- } catch(IOException e) {
+ } catch (IOException e) {
buf.reset();
continue;
}
@@ -1014,7 +1003,7 @@
for (int j = 0; j < ba.length; j++) {
out.append('%');
// Converting each byte in the buffer
- out.append(Character.forDigit((ba[j]>>4) & 0xf, 16));
+ out.append(Character.forDigit((ba[j] >> 4) & 0xf, 16));
out.append(Character.forDigit(ba[j] & 0xf, 16));
}
buf.reset();
@@ -1034,7 +1023,7 @@
return true;
}
if (c == '-' || c == '_' || c == '.' || c == '!' ||
- c == '~' || c == '*' || c == '\'' || c == '(' || c == ')') {
+ c == '~' || c == '*' || c == '\'' || c == '(' || c == ')') {
return true;
}
return false;
Modified: struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspSourceDependent.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspSourceDependent.java?rev=804373&r1=804372&r2=804373&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspSourceDependent.java (original)
+++ struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspSourceDependent.java Fri Aug 14 21:02:33 2009
@@ -28,10 +28,10 @@
public interface JspSourceDependent {
- /**
- * Returns a list of files names that the current page has a source
- * dependency on.
- */
+ /**
+ * Returns a list of files names that the current page has a source
+ * dependency on.
+ */
// FIXME: Type used is Object due to very weird behavior
// with Eclipse JDT 3.1 in Java 5 mode
public Object getDependants();