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/09/28 03:55:35 UTC
svn commit: r819444 [24/27] - in /struts/struts2/trunk/plugins/embeddedjsp:
./ src/main/java/org/apache/struts2/el/
src/main/java/org/apache/struts2/el/lang/
src/main/java/org/apache/struts2/el/parser/
src/main/java/org/apache/struts2/el/util/ src/main...
Added: struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Import.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Import.java?rev=819444&view=auto
==============================================================================
--- struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Import.java (added)
+++ struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Import.java Mon Sep 28 01:55:26 2009
@@ -0,0 +1,382 @@
+/*
+ * 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.tagplugins.jstl.core;
+
+import org.apache.struts2.jasper.compiler.tagplugin.TagPlugin;
+import org.apache.struts2.jasper.compiler.tagplugin.TagPluginContext;
+import org.apache.struts2.jasper.tagplugins.jstl.Util;
+
+public class Import implements TagPlugin {
+
+ public void doTag(TagPluginContext ctxt) {
+ boolean hasContext, hasVar, hasScope, hasVarReader, hasCharEncoding;
+
+ //flags
+ hasContext = ctxt.isAttributeSpecified("context");
+ hasVar = ctxt.isAttributeSpecified("var");
+ hasScope = ctxt.isAttributeSpecified("scope");
+ hasVarReader = ctxt.isAttributeSpecified("varReader");
+ hasCharEncoding = ctxt.isAttributeSpecified("charEncoding");
+
+ //variables' names
+ String urlName = ctxt.getTemporaryVariableName();
+ String contextName = ctxt.getTemporaryVariableName();
+ String iauName = ctxt.getTemporaryVariableName(); // is absolute url
+ String urlObjName = ctxt.getTemporaryVariableName(); //URL object
+ String ucName = ctxt.getTemporaryVariableName(); //URLConnection
+ String inputStreamName = ctxt.getTemporaryVariableName();
+ String tempReaderName = ctxt.getTemporaryVariableName();
+ String tempReaderName2 = ctxt.getTemporaryVariableName();
+ String charSetName = ctxt.getTemporaryVariableName();
+ String charEncodingName = ctxt.getTemporaryVariableName();
+ String contentTypeName = ctxt.getTemporaryVariableName();
+ String varReaderName = ctxt.getTemporaryVariableName();
+ String servletContextName = ctxt.getTemporaryVariableName();
+ String servletPathName = ctxt.getTemporaryVariableName();
+ String requestDispatcherName = ctxt.getTemporaryVariableName();
+ String irwName = ctxt.getTemporaryVariableName(); //ImportResponseWrapper name
+ String brName = ctxt.getTemporaryVariableName(); //BufferedReader name
+ String sbName = ctxt.getTemporaryVariableName(); //StringBuffer name
+ String tempStringName = ctxt.getTemporaryVariableName();
+
+ //is absolute url
+ ctxt.generateJavaSource("boolean " + iauName + ";");
+
+ //get the url value
+ ctxt.generateJavaSource("String " + urlName + " = ");
+ ctxt.generateAttribute("url");
+ ctxt.generateJavaSource(";");
+
+ //validate the url
+ ctxt.generateJavaSource("if(" + urlName + " == null || " + urlName + ".equals(\"\")){");
+ ctxt.generateJavaSource(" throw new JspTagException(\"The \\\"url\\\" attribute " +
+ "illegally evaluated to \\\"null\\\" or \\\"\\\" in <import>\");");
+ ctxt.generateJavaSource("}");
+
+ //initialize the is_absolute_url
+ ctxt.generateJavaSource(iauName + " = " +
+ "org.apache.struts2.jasper.tagplugins.jstl.Util.isAbsoluteUrl(" + urlName + ");");
+
+ //validate the context
+ if(hasContext){
+
+ ctxt.generateJavaSource("String " + contextName + " = ");
+ ctxt.generateAttribute("context");
+ ctxt.generateJavaSource(";");
+
+ ctxt.generateJavaSource("if((!" + contextName + ".startsWith(\"/\")) " +
+ "|| (!" + urlName + ".startsWith(\"/\"))){");
+ ctxt.generateJavaSource(" throw new JspTagException" +
+ "(\"In URL tags, when the \\\"context\\\" attribute is specified, " +
+ "values of both \\\"context\\\" and \\\"url\\\" must start with \\\"/\\\".\");");
+ ctxt.generateJavaSource("}");
+
+ }
+
+ //define charset
+ ctxt.generateJavaSource("String " + charSetName + " = null;");
+
+ //if the charEncoding attribute is specified
+ if(hasCharEncoding){
+
+ //initialize the charEncoding
+ ctxt.generateJavaSource("String " + charEncodingName + " = ");
+ ctxt.generateAttribute("charEncoding");
+ ctxt.generateJavaSource(";");
+
+ //assign appropriate value tp the charset
+ ctxt.generateJavaSource("if(null != " + charEncodingName + " " +
+ "&& !" + charEncodingName + ".equals(\"\")){");
+ ctxt.generateJavaSource(" " + charSetName + " = "
+ + charEncodingName + ";");
+ ctxt.generateJavaSource("}");
+ }
+
+ //reshape the url string
+ ctxt.generateJavaSource("if(!"+iauName+"){");
+ ctxt.generateJavaSource(" if(!" + urlName + ".startsWith(\"/\")){");
+ ctxt.generateJavaSource(" String " + servletPathName + " = " +
+ "((HttpServletRequest)pageContext.getRequest()).getServletPath();");
+ ctxt.generateJavaSource(" " + urlName + " = "
+ + servletPathName + ".substring(0," + servletPathName + ".lastIndexOf('/')) + '/' + " + urlName + ";");
+ ctxt.generateJavaSource(" }");
+ ctxt.generateJavaSource("}");
+
+ //if the varReader attribute specified
+ if(hasVarReader){
+
+ //get the String value of varReader
+ ctxt.generateJavaSource("String " + varReaderName + " = ");
+ ctxt.generateAttribute("varReader");
+ ctxt.generateJavaSource(";");
+
+ //if the url is absolute url
+ ctxt.generateJavaSource("if(" + iauName + "){");
+
+ //get the content of the target
+ ctxt.generateJavaSource(" java.net.URL " + urlObjName + " = new java.net.URL(" + urlName + ");");
+ ctxt.generateJavaSource(" java.net.URLConnection " + ucName + " = "
+ + urlObjName + ".openConnection();");
+ ctxt.generateJavaSource(" java.io.InputStream " + inputStreamName + " = "
+ + ucName + ".getInputStream();");
+
+ ctxt.generateJavaSource(" if(" + charSetName + " == null){");
+ ctxt.generateJavaSource(" String " + contentTypeName + " = "
+ + ucName + ".getContentType();");
+ ctxt.generateJavaSource(" if(null != " + contentTypeName + "){");
+ ctxt.generateJavaSource(" " + charSetName + " = " +
+ "org.apache.struts2.jasper.tagplugins.jstl.Util.getContentTypeAttribute(" + contentTypeName + ", \"charset\");");
+ ctxt.generateJavaSource(" if(" + charSetName + " == null) "
+ + charSetName + " = org.apache.struts2.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;");
+ ctxt.generateJavaSource(" }else{");
+ ctxt.generateJavaSource(" " + charSetName + " = org.apache.struts2.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;");
+ ctxt.generateJavaSource(" }");
+ ctxt.generateJavaSource(" }");
+
+ if(!hasCharEncoding){
+ ctxt.generateJavaSource(" String " + contentTypeName + " = " + ucName + ".getContentType();");
+ }
+
+ //define the Reader
+ ctxt.generateJavaSource(" java.io.Reader " + tempReaderName + " = null;");
+
+ //initialize the Reader object
+ ctxt.generateJavaSource(" try{");
+ ctxt.generateJavaSource(" " + tempReaderName + " = new java.io.InputStreamReader(" + inputStreamName + ", " + charSetName + ");");
+ ctxt.generateJavaSource(" }catch(Exception ex){");
+ ctxt.generateJavaSource(" " + tempReaderName + " = new java.io.InputStreamReader(" + inputStreamName + ", org.apache.struts2.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING);");
+ ctxt.generateJavaSource(" }");
+
+ //validate the response
+ ctxt.generateJavaSource(" if(" + ucName + " instanceof java.net.HttpURLConnection){");
+ ctxt.generateJavaSource(" int status = ((java.net.HttpURLConnection) " + ucName + ").getResponseCode();");
+ ctxt.generateJavaSource(" if(status < 200 || status > 299){");
+ ctxt.generateJavaSource(" throw new JspTagException(status + \" \" + " + urlName + ");");
+ ctxt.generateJavaSource(" }");
+ ctxt.generateJavaSource(" }");
+
+ //set attribute in the page context scope
+ ctxt.generateJavaSource(" pageContext.setAttribute(" + varReaderName + ", " + tempReaderName + ");");
+
+ //if the url is relative
+ ctxt.generateJavaSource("}else{");
+
+ //if the url is relative, http request is needed
+ ctxt.generateJavaSource(" if (!(pageContext.getRequest() instanceof HttpServletRequest " +
+ "&& pageContext.getResponse() instanceof HttpServletResponse)){");
+ ctxt.generateJavaSource(" throw new JspTagException(\"Relative <import> from non-HTTP request not allowed\");");
+ ctxt.generateJavaSource(" }");
+
+ //get the servlet context of the context defined in the context attribute
+ ctxt.generateJavaSource(" ServletContext " + servletContextName + " = null;");
+ if(hasContext){
+ ctxt.generateJavaSource(" if(null != " + contextName + "){");
+ ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext().getContext(" + contextName + ");" );
+ ctxt.generateJavaSource(" }else{");
+ ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext();");
+ ctxt.generateJavaSource(" }");
+ }else{
+ ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext();");
+ }
+
+ //
+ ctxt.generateJavaSource(" if(" + servletContextName + " == null){");
+ if(hasContext){
+ ctxt.generateJavaSource(" throw new JspTagException(\"Unable to get RequestDispatcher for Context: \\\" \"+" + contextName + "+\" \\\" and URL: \\\" \" +" + urlName + "+ \" \\\". Verify values and/or enable cross context access.\");");
+ }else{
+ ctxt.generateJavaSource(" throw new JspTagException(\"Unable to get RequestDispatcher for URL: \\\" \" +" + urlName + "+ \" \\\". Verify values and/or enable cross context access.\");");
+ }
+ ctxt.generateJavaSource(" }");
+
+ //get the request dispatcher
+ ctxt.generateJavaSource(" RequestDispatcher " + requestDispatcherName + " = " + servletContextName + ".getRequestDispatcher(org.apache.struts2.jasper.tagplugins.jstl.Util.stripSession("+urlName+"));");
+ ctxt.generateJavaSource(" if(" + requestDispatcherName + " == null) throw new JspTagException(org.apache.struts2.jasper.tagplugins.jstl.Util.stripSession("+urlName+"));");
+
+ //initialize a ImportResponseWrapper to include the resource
+ ctxt.generateJavaSource(" org.apache.struts2.jasper.tagplugins.jstl.Util.ImportResponseWrapper " + irwName + " = new org.apache.struts2.jasper.tagplugins.jstl.Util.ImportResponseWrapper((HttpServletResponse) pageContext.getResponse());");
+ ctxt.generateJavaSource(" if(" + charSetName + " == null){");
+ ctxt.generateJavaSource(" " + charSetName + " = org.apache.struts2.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;");
+ ctxt.generateJavaSource(" }");
+ ctxt.generateJavaSource(" " + irwName + ".setCharEncoding(" + charSetName + ");");
+ ctxt.generateJavaSource(" try{");
+ ctxt.generateJavaSource(" " + requestDispatcherName + ".include(pageContext.getRequest(), " + irwName + ");");
+ ctxt.generateJavaSource(" }catch(java.io.IOException ex){");
+ ctxt.generateJavaSource(" throw new JspException(ex);");
+ ctxt.generateJavaSource(" }catch(RuntimeException ex){");
+ ctxt.generateJavaSource(" throw new JspException(ex);");
+ ctxt.generateJavaSource(" }catch(ServletException ex){");
+ ctxt.generateJavaSource(" Throwable rc = ex.getRootCause();");
+ ctxt.generateJavaSource(" if (rc == null)");
+ ctxt.generateJavaSource(" throw new JspException(ex);");
+ ctxt.generateJavaSource(" else");
+ ctxt.generateJavaSource(" throw new JspException(rc);");
+ ctxt.generateJavaSource(" }");
+
+ //validate the response status
+ ctxt.generateJavaSource(" if(" + irwName + ".getStatus() < 200 || " + irwName + ".getStatus() > 299){");
+ ctxt.generateJavaSource(" throw new JspTagException(" + irwName + ".getStatus()+\" \" + org.apache.struts2.jasper.tagplugins.jstl.Util.stripSession(" + urlName + "));");
+ ctxt.generateJavaSource(" }");
+
+ //push in the page context
+ ctxt.generateJavaSource(" java.io.Reader " + tempReaderName + " = new java.io.StringReader(" + irwName + ".getString());");
+ ctxt.generateJavaSource(" pageContext.setAttribute(" + varReaderName + ", " + tempReaderName + ");");
+
+ ctxt.generateJavaSource("}");
+
+ //execute the body action
+ ctxt.generateBody();
+
+ //close the reader
+ ctxt.generateJavaSource("java.io.Reader " + tempReaderName2 + " = (java.io.Reader)pageContext.getAttribute(" + varReaderName + ");");
+ ctxt.generateJavaSource("if(" + tempReaderName2 + " != null) " + tempReaderName2 + ".close();");
+ ctxt.generateJavaSource("pageContext.removeAttribute(" + varReaderName + ",1);");
+ }
+
+ //if the varReader is not specified
+ else{
+
+ ctxt.generateJavaSource("pageContext.setAttribute(\"url_without_param\"," + urlName + ");");
+ ctxt.generateBody();
+ ctxt.generateJavaSource(urlName + " = (String)pageContext.getAttribute(\"url_without_param\");");
+ ctxt.generateJavaSource("pageContext.removeAttribute(\"url_without_param\");");
+ String strScope = "page";
+ if(hasScope){
+ strScope = ctxt.getConstantAttribute("scope");
+ }
+ int iScope = Util.getScope(strScope);
+
+ ctxt.generateJavaSource("String " + tempStringName + " = null;");
+
+ ctxt.generateJavaSource("if(" + iauName + "){");
+
+ //get the content of the target
+ ctxt.generateJavaSource(" java.net.URL " + urlObjName + " = new java.net.URL(" + urlName + ");");
+ ctxt.generateJavaSource(" java.net.URLConnection " + ucName + " = " + urlObjName + ".openConnection();");
+ ctxt.generateJavaSource(" java.io.InputStream " + inputStreamName + " = " + ucName + ".getInputStream();");
+ ctxt.generateJavaSource(" java.io.Reader " + tempReaderName + " = null;");
+
+ ctxt.generateJavaSource(" if(" + charSetName + " == null){");
+ ctxt.generateJavaSource(" String " + contentTypeName + " = "
+ + ucName + ".getContentType();");
+ ctxt.generateJavaSource(" if(null != " + contentTypeName + "){");
+ ctxt.generateJavaSource(" " + charSetName + " = " +
+ "org.apache.struts2.jasper.tagplugins.jstl.Util.getContentTypeAttribute(" + contentTypeName + ", \"charset\");");
+ ctxt.generateJavaSource(" if(" + charSetName + " == null) "
+ + charSetName + " = org.apache.struts2.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;");
+ ctxt.generateJavaSource(" }else{");
+ ctxt.generateJavaSource(" " + charSetName + " = org.apache.struts2.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;");
+ ctxt.generateJavaSource(" }");
+ ctxt.generateJavaSource(" }");
+
+ ctxt.generateJavaSource(" try{");
+ ctxt.generateJavaSource(" " + tempReaderName + " = new java.io.InputStreamReader(" + inputStreamName + "," + charSetName + ");");
+ ctxt.generateJavaSource(" }catch(Exception ex){");
+ //ctxt.generateJavaSource(" throw new JspTagException(ex.toString());");
+ ctxt.generateJavaSource(" " + tempReaderName + " = new java.io.InputStreamReader(" + inputStreamName + ",org.apache.struts2.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING);");
+ ctxt.generateJavaSource(" }");
+
+ //validate the response
+ ctxt.generateJavaSource(" if(" + ucName + " instanceof java.net.HttpURLConnection){");
+ ctxt.generateJavaSource(" int status = ((java.net.HttpURLConnection) " + ucName + ").getResponseCode();");
+ ctxt.generateJavaSource(" if(status < 200 || status > 299){");
+ ctxt.generateJavaSource(" throw new JspTagException(status + \" \" + " + urlName + ");");
+ ctxt.generateJavaSource(" }");
+ ctxt.generateJavaSource(" }");
+
+ ctxt.generateJavaSource(" java.io.BufferedReader " + brName + " = new java.io.BufferedReader(" + tempReaderName + ");");
+ ctxt.generateJavaSource(" StringBuffer " + sbName + " = new StringBuffer();");
+ String index = ctxt.getTemporaryVariableName();
+ ctxt.generateJavaSource(" int " + index + ";");
+ ctxt.generateJavaSource(" while(("+index+" = "+brName+".read()) != -1) "+sbName+".append((char)"+index+");");
+ ctxt.generateJavaSource(" " + tempStringName + " = " +sbName + ".toString();");
+
+ ctxt.generateJavaSource("}else{");
+
+ //if the url is relative, http request is needed.
+ ctxt.generateJavaSource(" if (!(pageContext.getRequest() instanceof HttpServletRequest " +
+ "&& pageContext.getResponse() instanceof HttpServletResponse)){");
+ ctxt.generateJavaSource(" throw new JspTagException(\"Relative <import> from non-HTTP request not allowed\");");
+ ctxt.generateJavaSource(" }");
+
+ //get the servlet context of the context defined in the context attribute
+ ctxt.generateJavaSource(" ServletContext " + servletContextName + " = null;");
+ if(hasContext){
+ ctxt.generateJavaSource(" if(null != " + contextName + "){");
+ ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext().getContext(" + contextName + ");" );
+ ctxt.generateJavaSource(" }else{");
+ ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext();");
+ ctxt.generateJavaSource(" }");
+ }else{
+ ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext();");
+ }
+
+ //
+ ctxt.generateJavaSource(" if(" + servletContextName + " == null){");
+ if(hasContext){
+ ctxt.generateJavaSource(" throw new JspTagException(\"Unable to get RequestDispatcher for Context: \\\" \" +" + contextName + "+ \" \\\" and URL: \\\" \" +" + urlName + "+ \" \\\". Verify values and/or enable cross context access.\");");
+ }else{
+ ctxt.generateJavaSource(" throw new JspTagException(\"Unable to get RequestDispatcher for URL: \\\" \" +" + urlName + "+ \" \\\". Verify values and/or enable cross context access.\");");
+ }
+ ctxt.generateJavaSource(" }");
+
+ //get the request dispatcher
+ ctxt.generateJavaSource(" RequestDispatcher " + requestDispatcherName + " = " + servletContextName + ".getRequestDispatcher(org.apache.struts2.jasper.tagplugins.jstl.Util.stripSession("+urlName+"));");
+ ctxt.generateJavaSource(" if(" + requestDispatcherName + " == null) throw new JspTagException(org.apache.struts2.jasper.tagplugins.jstl.Util.stripSession("+urlName+"));");
+
+ //initialize a ImportResponseWrapper to include the resource
+ ctxt.generateJavaSource(" org.apache.struts2.jasper.tagplugins.jstl.Util.ImportResponseWrapper " + irwName + " = new org.apache.struts2.jasper.tagplugins.jstl.Util.ImportResponseWrapper((HttpServletResponse) pageContext.getResponse());");
+ ctxt.generateJavaSource(" if(" + charSetName + " == null){");
+ ctxt.generateJavaSource(" " + charSetName + " = org.apache.struts2.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;");
+ ctxt.generateJavaSource(" }");
+ ctxt.generateJavaSource(" " + irwName + ".setCharEncoding(" + charSetName + ");");
+ ctxt.generateJavaSource(" try{");
+ ctxt.generateJavaSource(" " + requestDispatcherName + ".include(pageContext.getRequest(), " + irwName + ");");
+ ctxt.generateJavaSource(" }catch(java.io.IOException ex){");
+ ctxt.generateJavaSource(" throw new JspException(ex);");
+ ctxt.generateJavaSource(" }catch(RuntimeException ex){");
+ ctxt.generateJavaSource(" throw new JspException(ex);");
+ ctxt.generateJavaSource(" }catch(ServletException ex){");
+ ctxt.generateJavaSource(" Throwable rc = ex.getRootCause();");
+ ctxt.generateJavaSource(" if (rc == null)");
+ ctxt.generateJavaSource(" throw new JspException(ex);");
+ ctxt.generateJavaSource(" else");
+ ctxt.generateJavaSource(" throw new JspException(rc);");
+ ctxt.generateJavaSource(" }");
+
+ //validate the response status
+ ctxt.generateJavaSource(" if(" + irwName + ".getStatus() < 200 || " + irwName + ".getStatus() > 299){");
+ ctxt.generateJavaSource(" throw new JspTagException(" + irwName + ".getStatus()+\" \" + org.apache.struts2.jasper.tagplugins.jstl.Util.stripSession(" + urlName + "));");
+ ctxt.generateJavaSource(" }");
+
+ ctxt.generateJavaSource(" " + tempStringName + " = " + irwName + ".getString();");
+
+ ctxt.generateJavaSource("}");
+
+ if(hasVar){
+ String strVar = ctxt.getConstantAttribute("var");
+ ctxt.generateJavaSource("pageContext.setAttribute(\""+strVar+"\"," + tempStringName + "," + iScope + ");");
+ }else{
+ ctxt.generateJavaSource("pageContext.getOut().print(" + tempStringName + ");");
+ }
+ }
+ }
+
+
+
+}
Added: struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Otherwise.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Otherwise.java?rev=819444&view=auto
==============================================================================
--- struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Otherwise.java (added)
+++ struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Otherwise.java Mon Sep 28 01:55:26 2009
@@ -0,0 +1,32 @@
+/*
+ * 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.tagplugins.jstl.core;
+
+import org.apache.struts2.jasper.compiler.tagplugin.*;
+
+public final class Otherwise implements TagPlugin {
+
+ public void doTag(TagPluginContext ctxt) {
+
+ // See When.java for the reason whey "}" is need at the beginng and
+ // not at the end.
+ ctxt.generateJavaSource("} else {");
+ ctxt.generateBody();
+ }
+}
Added: struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Out.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Out.java?rev=819444&view=auto
==============================================================================
--- struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Out.java (added)
+++ struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Out.java Mon Sep 28 01:55:26 2009
@@ -0,0 +1,90 @@
+/*
+ * 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.tagplugins.jstl.core;
+
+import org.apache.struts2.jasper.compiler.tagplugin.TagPlugin;
+import org.apache.struts2.jasper.compiler.tagplugin.TagPluginContext;
+
+
+public final class Out implements TagPlugin {
+
+ public void doTag(TagPluginContext ctxt) {
+
+ //these two data member are to indicate
+ //whether the corresponding attribute is specified
+ boolean hasDefault=false, hasEscapeXml=false;
+ hasDefault = ctxt.isAttributeSpecified("default");
+ hasEscapeXml = ctxt.isAttributeSpecified("escapeXml");
+
+ //strValName, strEscapeXmlName & strDefName are two variables' name
+ //standing for value, escapeXml and default attribute
+ String strValName = ctxt.getTemporaryVariableName();
+ String strDefName = ctxt.getTemporaryVariableName();
+ String strEscapeXmlName = ctxt.getTemporaryVariableName();
+
+ //according to the tag file, the value attribute is mandatory.
+ ctxt.generateJavaSource("String " + strValName + " = null;");
+ ctxt.generateJavaSource("if(");
+ ctxt.generateAttribute("value");
+ ctxt.generateJavaSource("!=null){");
+ ctxt.generateJavaSource(" " + strValName + " = (");
+ ctxt.generateAttribute("value");
+ ctxt.generateJavaSource(").toString();");
+ ctxt.generateJavaSource("}");
+
+ //initiate the strDefName with null.
+ //if the default has been specified, then assign the value to it;
+ ctxt.generateJavaSource("String " + strDefName + " = null;\n");
+ if(hasDefault){
+ ctxt.generateJavaSource("if(");
+ ctxt.generateAttribute("default");
+ ctxt.generateJavaSource(" != null){");
+ ctxt.generateJavaSource(strDefName + " = (");
+ ctxt.generateAttribute("default");
+ ctxt.generateJavaSource(").toString();");
+ ctxt.generateJavaSource("}");
+ }
+
+ //initiate the strEscapeXmlName with true;
+ //if the escapeXml is specified, assign the value to it;
+ ctxt.generateJavaSource("boolean " + strEscapeXmlName + " = true;");
+ if(hasEscapeXml){
+ ctxt.generateJavaSource(strEscapeXmlName + " = Boolean.parseBoolean((");
+ ctxt.generateAttribute("default");
+ ctxt.generateJavaSource(").toString());");
+ }
+
+ //main part.
+ ctxt.generateJavaSource("if(null != " + strValName +"){");
+ ctxt.generateJavaSource(" if(" + strEscapeXmlName + "){");
+ ctxt.generateJavaSource(" " + strValName + " = org.apache.struts2.jasper.tagplugins.jstl.Util.escapeXml(" + strValName + ");");
+ ctxt.generateJavaSource(" }");
+ ctxt.generateJavaSource(" out.write(" + strValName + ");");
+ ctxt.generateJavaSource("}else{");
+ ctxt.generateJavaSource(" if(null != " + strDefName + "){");
+ ctxt.generateJavaSource(" if(" + strEscapeXmlName + "){");
+ ctxt.generateJavaSource(" " + strDefName + " = org.apache.struts2.jasper.tagplugins.jstl.Util.escapeXml(" + strDefName + ");");
+ ctxt.generateJavaSource(" }");
+ ctxt.generateJavaSource(" out.write(" + strDefName + ");");
+ ctxt.generateJavaSource(" }else{");
+ ctxt.generateBody();
+ ctxt.generateJavaSource(" }");
+ ctxt.generateJavaSource("}");
+ }
+}
Added: struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Param.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Param.java?rev=819444&view=auto
==============================================================================
--- struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Param.java (added)
+++ struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Param.java Mon Sep 28 01:55:26 2009
@@ -0,0 +1,77 @@
+/*
+ * 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.tagplugins.jstl.core;
+
+import org.apache.struts2.jasper.compiler.tagplugin.TagPlugin;
+import org.apache.struts2.jasper.compiler.tagplugin.TagPluginContext;
+
+public class Param implements TagPlugin {
+
+ public void doTag(TagPluginContext ctxt) {
+
+ //don't support the body content
+
+ //define names of all the temp variables
+ String nameName = ctxt.getTemporaryVariableName();
+ String valueName = ctxt.getTemporaryVariableName();
+ String urlName = ctxt.getTemporaryVariableName();
+ String encName = ctxt.getTemporaryVariableName();
+ String index = ctxt.getTemporaryVariableName();
+
+ //if the param tag has no parents, throw a exception
+ TagPluginContext parent = ctxt.getParentContext();
+ if(parent == null){
+ ctxt.generateJavaSource(" throw new JspTagExcption" +
+ "(\"<param> outside <import> or <urlEncode>\");");
+ return;
+ }
+
+ //get the url string before adding this param
+ ctxt.generateJavaSource("String " + urlName + " = " +
+ "(String)pageContext.getAttribute(\"url_without_param\");");
+
+ //get the value of "name"
+ ctxt.generateJavaSource("String " + nameName + " = ");
+ ctxt.generateAttribute("name");
+ ctxt.generateJavaSource(";");
+
+ //if the "name" is null then do nothing.
+ //else add such string "name=value" to the url.
+ //and the url should be encoded
+ ctxt.generateJavaSource("if(" + nameName + " != null && !" + nameName + ".equals(\"\")){");
+ ctxt.generateJavaSource(" String " + valueName + " = ");
+ ctxt.generateAttribute("value");
+ ctxt.generateJavaSource(";");
+ ctxt.generateJavaSource(" if(" + valueName + " == null) " + valueName + " = \"\";");
+ ctxt.generateJavaSource(" String " + encName + " = pageContext.getResponse().getCharacterEncoding();");
+ ctxt.generateJavaSource(" " + nameName + " = java.net.URLEncoder.encode(" + nameName + ", " + encName + ");");
+ ctxt.generateJavaSource(" " + valueName + " = java.net.URLEncoder.encode(" + valueName + ", " + encName + ");");
+ ctxt.generateJavaSource(" int " + index + ";");
+ ctxt.generateJavaSource(" " + index + " = " + urlName + ".indexOf(\'?\');");
+ //if the current param is the first one, add a "?" ahead of it
+ //else add a "&" ahead of it
+ ctxt.generateJavaSource(" if(" + index + " == -1){");
+ ctxt.generateJavaSource(" " + urlName + " = " + urlName + " + \"?\" + " + nameName + " + \"=\" + " + valueName + ";");
+ ctxt.generateJavaSource(" }else{");
+ ctxt.generateJavaSource(" " + urlName + " = " + urlName + " + \"&\" + " + nameName + " + \"=\" + " + valueName + ";");
+ ctxt.generateJavaSource(" }");
+ ctxt.generateJavaSource(" pageContext.setAttribute(\"url_without_param\"," + urlName + ");");
+ ctxt.generateJavaSource("}");
+ }
+}
Added: struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Redirect.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Redirect.java?rev=819444&view=auto
==============================================================================
--- struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Redirect.java (added)
+++ struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Redirect.java Mon Sep 28 01:55:26 2009
@@ -0,0 +1,83 @@
+/*
+ * 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.tagplugins.jstl.core;
+
+import org.apache.struts2.jasper.compiler.tagplugin.TagPlugin;
+import org.apache.struts2.jasper.compiler.tagplugin.TagPluginContext;
+
+public class Redirect implements TagPlugin {
+
+ public void doTag(TagPluginContext ctxt) {
+
+ //flag for the existence of the "context"
+ boolean hasContext = ctxt.isAttributeSpecified("context");
+
+ //names of the temp variables
+ String urlName = ctxt.getTemporaryVariableName();
+ String contextName = ctxt.getTemporaryVariableName();
+ String baseUrlName = ctxt.getTemporaryVariableName();
+ String resultName = ctxt.getTemporaryVariableName();
+ String responseName = ctxt.getTemporaryVariableName();
+
+ //get context
+ ctxt.generateJavaSource("String " + contextName + " = null;");
+ if(hasContext){
+ ctxt.generateJavaSource(contextName + " = ");
+ ctxt.generateAttribute("context");
+ ctxt.generateJavaSource(";");
+ }
+
+ //get the url
+ ctxt.generateJavaSource("String " + urlName + " = ");
+ ctxt.generateAttribute("url");
+ ctxt.generateJavaSource(";");
+
+ //get the raw url according to "url" and "context"
+ ctxt.generateJavaSource("String " + baseUrlName + " = " +
+ "org.apache.struts2.jasper.tagplugins.jstl.Util.resolveUrl(" + urlName + ", " + contextName + ", pageContext);");
+ ctxt.generateJavaSource("pageContext.setAttribute" +
+ "(\"url_without_param\", " + baseUrlName + ");");
+
+ //add params
+ ctxt.generateBody();
+
+ ctxt.generateJavaSource("String " + resultName + " = " +
+ "(String)pageContext.getAttribute(\"url_without_param\");");
+ ctxt.generateJavaSource("pageContext.removeAttribute" +
+ "(\"url_without_param\");");
+
+ //get the response object
+ ctxt.generateJavaSource("HttpServletResponse " + responseName + " = " +
+ "((HttpServletResponse) pageContext.getResponse());");
+
+ //if the url is relative, encode it
+ ctxt.generateJavaSource("if(!org.apache.struts2.jasper.tagplugins.jstl.Util.isAbsoluteUrl(" + resultName + ")){");
+ ctxt.generateJavaSource(" " + resultName + " = "
+ + responseName + ".encodeRedirectURL(" + resultName + ");");
+ ctxt.generateJavaSource("}");
+
+ //do redirect
+ ctxt.generateJavaSource("try{");
+ ctxt.generateJavaSource(" " + responseName + ".sendRedirect(" + resultName + ");");
+ ctxt.generateJavaSource("}catch(java.io.IOException ex){");
+ ctxt.generateJavaSource(" throw new JspTagException(ex.toString(), ex);");
+ ctxt.generateJavaSource("}");
+ }
+
+}
Added: struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Remove.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Remove.java?rev=819444&view=auto
==============================================================================
--- struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Remove.java (added)
+++ struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Remove.java Mon Sep 28 01:55:26 2009
@@ -0,0 +1,45 @@
+/*
+ * 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.tagplugins.jstl.core;
+
+import org.apache.struts2.jasper.compiler.tagplugin.TagPlugin;
+import org.apache.struts2.jasper.compiler.tagplugin.TagPluginContext;
+import org.apache.struts2.jasper.tagplugins.jstl.Util;
+
+public class Remove implements TagPlugin {
+
+ public void doTag(TagPluginContext ctxt) {
+
+ //scope flag
+ boolean hasScope = ctxt.isAttributeSpecified("scope");
+
+ //the value of the "var"
+ String strVar = ctxt.getConstantAttribute("var");
+
+ //remove attribute from certain scope.
+ //default scope is "page".
+ if(hasScope){
+ int iScope = Util.getScope(ctxt.getConstantAttribute("scope"));
+ ctxt.generateJavaSource("pageContext.removeAttribute(\"" + strVar + "\"," + iScope + ");");
+ }else{
+ ctxt.generateJavaSource("pageContext.removeAttribute(\"" + strVar + "\");");
+ }
+ }
+
+}
Added: struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Set.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Set.java?rev=819444&view=auto
==============================================================================
--- struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Set.java (added)
+++ struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Set.java Mon Sep 28 01:55:26 2009
@@ -0,0 +1,167 @@
+/*
+ * 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.tagplugins.jstl.core;
+
+import org.apache.struts2.jasper.compiler.tagplugin.TagPlugin;
+import org.apache.struts2.jasper.compiler.tagplugin.TagPluginContext;
+import org.apache.struts2.jasper.tagplugins.jstl.Util;
+
+public class Set implements TagPlugin {
+
+ public void doTag(TagPluginContext ctxt) {
+
+ //the flags to indicate whether the attributes have been specified
+ boolean hasValue = false, hasVar = false, hasScope = false,
+ hasTarget = false;
+
+ //the scope name
+ String strScope;
+ //the id of the scope
+ int iScope;
+
+ //initialize the flags
+ hasValue = ctxt.isAttributeSpecified("value");
+ hasVar = ctxt.isAttributeSpecified("var");
+ hasScope = ctxt.isAttributeSpecified("scope");
+ hasTarget = ctxt.isAttributeSpecified("target");
+
+ //the temp variables name
+ String resultName = ctxt.getTemporaryVariableName();
+ String targetName = ctxt.getTemporaryVariableName();
+ String propertyName = ctxt.getTemporaryVariableName();
+
+ //initialize the "result" which will be assigned to the var or target.property
+ ctxt.generateJavaSource("Object " + resultName + " = null;");
+ if(hasValue){
+ ctxt.generateJavaSource(resultName + " = ");
+ ctxt.generateAttribute("value");
+ ctxt.generateJavaSource(";");
+ }else{
+ ctxt.dontUseTagPlugin();
+ return;
+ }
+
+ //initialize the strScope
+ if(hasScope){
+ strScope = ctxt.getConstantAttribute("scope");
+ }else{
+ strScope = "page";
+ }
+
+ //get the iScope according to the strScope
+ iScope = Util.getScope(strScope);
+
+ //if the attribute var has been specified then assign the result to the var;
+ if(hasVar){
+ String strVar = ctxt.getConstantAttribute("var");
+ ctxt.generateJavaSource("if(null != " + resultName + "){");
+ ctxt.generateJavaSource(" pageContext.setAttribute(\"" + strVar + "\"," + resultName + "," + iScope + ");");
+ ctxt.generateJavaSource("} else {");
+ if(hasScope){
+ ctxt.generateJavaSource(" pageContext.removeAttribute(\"" + strVar + "\"," + iScope + ");");
+ }else{
+ ctxt.generateJavaSource(" pageContext.removeAttribute(\"" + strVar + "\");");
+ }
+ ctxt.generateJavaSource("}");
+
+ //else assign the result to the target.property
+ }else if(hasTarget){
+
+ //generate the temp variable name
+ String pdName = ctxt.getTemporaryVariableName();
+ String successFlagName = ctxt.getTemporaryVariableName();
+ String index = ctxt.getTemporaryVariableName();
+ String methodName = ctxt.getTemporaryVariableName();
+
+ //initialize the property
+ ctxt.generateJavaSource("String " + propertyName + " = null;");
+ ctxt.generateJavaSource("if(");
+ ctxt.generateAttribute("property");
+ ctxt.generateJavaSource(" != null){");
+ ctxt.generateJavaSource(" " + propertyName + " = (");
+ ctxt.generateAttribute("property");
+ ctxt.generateJavaSource(").toString();");
+ ctxt.generateJavaSource("}");
+
+ //initialize the target
+ ctxt.generateJavaSource("Object " + targetName + " = ");
+ ctxt.generateAttribute("target");
+ ctxt.generateJavaSource(";");
+
+ //the target is ok
+ ctxt.generateJavaSource("if(" + targetName + " != null){");
+
+ //if the target is a map, then put the result into the map with the key property
+ ctxt.generateJavaSource(" if(" + targetName + " instanceof java.util.Map){");
+ ctxt.generateJavaSource(" if(null != " + resultName + "){");
+ ctxt.generateJavaSource(" ((java.util.Map) " + targetName + ").put(" + propertyName + "," + resultName + ");");
+ ctxt.generateJavaSource(" }else{");
+ ctxt.generateJavaSource(" ((java.util.Map) " + targetName + ").remove(" + propertyName + ");");
+ ctxt.generateJavaSource(" }");
+
+ //else assign the result to the target.property
+ ctxt.generateJavaSource(" }else{");
+ ctxt.generateJavaSource(" try{");
+
+ //get all the property of the target
+ ctxt.generateJavaSource(" java.beans.PropertyDescriptor " + pdName + "[] = java.beans.Introspector.getBeanInfo(" + targetName + ".getClass()).getPropertyDescriptors();");
+
+ //the success flag is to imply whether the assign is successful
+ ctxt.generateJavaSource(" boolean " + successFlagName + " = false;");
+
+ //find the right property
+ ctxt.generateJavaSource(" for(int " + index + "=0;" + index + "<" + pdName + ".length;" + index + "++){");
+ ctxt.generateJavaSource(" if(" + pdName + "[" + index + "].getName().equals(" + propertyName + ")){");
+
+ //get the "set" method;
+ ctxt.generateJavaSource(" java.lang.reflect.Method " + methodName + " = " + pdName + "[" + index + "].getWriteMethod();");
+ ctxt.generateJavaSource(" if(null == " + methodName + "){");
+ ctxt.generateJavaSource(" throw new JspException(\"No setter method in <set> for property \"+" + propertyName + ");");
+ ctxt.generateJavaSource(" }");
+
+ //invoke the method through the reflection
+ ctxt.generateJavaSource(" if(" + resultName + " != null){");
+ ctxt.generateJavaSource(" " + methodName + ".invoke(" + targetName + ", new Object[]{(" + methodName + ".getParameterTypes()[0]).cast(" + resultName + ")});");
+ ctxt.generateJavaSource(" }else{");
+ ctxt.generateJavaSource(" " + methodName + ".invoke(" + targetName + ", new Object[]{null});");
+ ctxt.generateJavaSource(" }");
+ ctxt.generateJavaSource(" " + successFlagName + " = true;");
+ ctxt.generateJavaSource(" }");
+ ctxt.generateJavaSource(" }");
+ ctxt.generateJavaSource(" if(!" + successFlagName + "){");
+ ctxt.generateJavaSource(" throw new JspException(\"Invalid property in <set>:\"+" + propertyName + ");");
+ ctxt.generateJavaSource(" }");
+ ctxt.generateJavaSource(" }");
+
+ //catch the el exception and throw it as a JspException
+ ctxt.generateJavaSource(" catch (IllegalAccessException ex) {");
+ ctxt.generateJavaSource(" throw new JspException(ex);");
+ ctxt.generateJavaSource(" } catch (java.beans.IntrospectionException ex) {");
+ ctxt.generateJavaSource(" throw new JspException(ex);");
+ ctxt.generateJavaSource(" } catch (java.lang.reflect.InvocationTargetException ex) {");
+ ctxt.generateJavaSource(" throw new JspException(ex);");
+ ctxt.generateJavaSource(" }");
+ ctxt.generateJavaSource(" }");
+ ctxt.generateJavaSource("}else{");
+ ctxt.generateJavaSource(" throw new JspException();");
+ ctxt.generateJavaSource("}");
+ }
+ }
+
+}
Added: struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Url.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Url.java?rev=819444&view=auto
==============================================================================
--- struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Url.java (added)
+++ struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Url.java Mon Sep 28 01:55:26 2009
@@ -0,0 +1,101 @@
+/*
+ * 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.tagplugins.jstl.core;
+
+import org.apache.struts2.jasper.compiler.tagplugin.TagPlugin;
+import org.apache.struts2.jasper.compiler.tagplugin.TagPluginContext;
+import org.apache.struts2.jasper.tagplugins.jstl.Util;
+
+public class Url implements TagPlugin {
+
+ public void doTag(TagPluginContext ctxt) {
+
+ //flags
+ boolean hasVar, hasContext, hasScope;
+
+ //init flags
+ hasVar = ctxt.isAttributeSpecified("var");
+ hasContext = ctxt.isAttributeSpecified("context");
+ hasScope = ctxt.isAttributeSpecified("scope");
+
+ //define name of the temp variables
+ String valueName = ctxt.getTemporaryVariableName();
+ String contextName = ctxt.getTemporaryVariableName();
+ String baseUrlName = ctxt.getTemporaryVariableName();
+ String resultName = ctxt.getTemporaryVariableName();
+ String responseName = ctxt.getTemporaryVariableName();
+
+ //get the scope
+ String strScope = "page";
+ if(hasScope){
+ strScope = ctxt.getConstantAttribute("scope");
+ }
+ int iScope = Util.getScope(strScope);
+
+ //get the value
+ ctxt.generateJavaSource("String " + valueName + " = ");
+ ctxt.generateAttribute("value");
+ ctxt.generateJavaSource(";");
+
+ //get the context
+ ctxt.generateJavaSource("String " + contextName + " = null;");
+ if(hasContext){
+ ctxt.generateJavaSource(contextName + " = ");
+ ctxt.generateAttribute("context");
+ ctxt.generateJavaSource(";");
+ }
+
+ //get the raw url
+ ctxt.generateJavaSource("String " + baseUrlName + " = " +
+ "org.apache.struts2.jasper.tagplugins.jstl.Util.resolveUrl(" + valueName + ", " + contextName + ", pageContext);");
+ ctxt.generateJavaSource("pageContext.setAttribute" +
+ "(\"url_without_param\", " + baseUrlName + ");");
+
+ //add params
+ ctxt.generateBody();
+
+ ctxt.generateJavaSource("String " + resultName + " = " +
+ "(String)pageContext.getAttribute(\"url_without_param\");");
+ ctxt.generateJavaSource("pageContext.removeAttribute(\"url_without_param\");");
+
+ //if the url is relative, encode it
+ ctxt.generateJavaSource("if(!org.apache.struts2.jasper.tagplugins.jstl.Util.isAbsoluteUrl(" + resultName + ")){");
+ ctxt.generateJavaSource(" HttpServletResponse " + responseName + " = " +
+ "((HttpServletResponse) pageContext.getResponse());");
+ ctxt.generateJavaSource(" " + resultName + " = "
+ + responseName + ".encodeURL(" + resultName + ");");
+ ctxt.generateJavaSource("}");
+
+ //if "var" is specified, the url string store in the attribute var defines
+ if(hasVar){
+ String strVar = ctxt.getConstantAttribute("var");
+ ctxt.generateJavaSource("pageContext.setAttribute" +
+ "(\"" + strVar + "\", " + resultName + ", " + iScope + ");");
+
+ //if var is not specified, just print out the url string
+ }else{
+ ctxt.generateJavaSource("try{");
+ ctxt.generateJavaSource(" pageContext.getOut().print(" + resultName + ");");
+ ctxt.generateJavaSource("}catch(java.io.IOException ex){");
+ ctxt.generateJavaSource(" throw new JspTagException(ex.toString(), ex);");
+ ctxt.generateJavaSource("}");
+ }
+ }
+
+}
Added: struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/When.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/When.java?rev=819444&view=auto
==============================================================================
--- struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/When.java (added)
+++ struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/When.java Mon Sep 28 01:55:26 2009
@@ -0,0 +1,50 @@
+/*
+ * 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.tagplugins.jstl.core;
+
+import org.apache.struts2.jasper.compiler.tagplugin.*;
+
+public final class When implements TagPlugin {
+
+ public void doTag(TagPluginContext ctxt) {
+ // Get the parent context to determine if this is the first <c:when>
+ TagPluginContext parentContext = ctxt.getParentContext();
+ if (parentContext == null) {
+ ctxt.dontUseTagPlugin();
+ return;
+ }
+
+ if ("true".equals(parentContext.getPluginAttribute("hasBeenHere"))) {
+ ctxt.generateJavaSource("} else if(");
+ // See comment below for the reason we generate the extra "}" here.
+ }
+ else {
+ ctxt.generateJavaSource("if(");
+ parentContext.setPluginAttribute("hasBeenHere", "true");
+ }
+ ctxt.generateAttribute("test");
+ ctxt.generateJavaSource("){");
+ ctxt.generateBody();
+
+ // We don't generate the closing "}" for the "if" here because there
+ // may be whitespaces in between <c:when>'s. Instead we delay
+ // generating it until the next <c:when> or <c:otherwise> or
+ // <c:choose>
+ }
+}
Added: struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/tagPlugins.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/tagPlugins.xml?rev=819444&view=auto
==============================================================================
--- struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/tagPlugins.xml (added)
+++ struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/tagPlugins.xml Mon Sep 28 01:55:26 2009
@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<tag-plugins>
+ <tag-plugin>
+ <tag-class>org.apache.taglibs.standard.tag.rt.core.IfTag</tag-class>
+ <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.If</plugin-class>
+ </tag-plugin>
+ <tag-plugin>
+ <tag-class>org.apache.taglibs.standard.tag.common.core.ChooseTag</tag-class>
+ <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.Choose</plugin-class>
+ </tag-plugin>
+ <tag-plugin>
+ <tag-class>org.apache.taglibs.standard.tag.rt.core.WhenTag</tag-class>
+ <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.When</plugin-class>
+ </tag-plugin>
+ <tag-plugin>
+ <tag-class>org.apache.taglibs.standard.tag.common.core.OtherwiseTag</tag-class>
+ <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.Otherwise</plugin-class>
+ </tag-plugin>
+ <tag-plugin>
+ <tag-class>org.apache.taglibs.standard.tag.rt.core.ForEachTag</tag-class>
+ <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.ForEach</plugin-class>
+ </tag-plugin>
+ <tag-plugin>
+ <tag-class>org.apache.taglibs.standard.tag.rt.core.OutTag</tag-class>
+ <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.Out</plugin-class>
+ </tag-plugin>
+ <tag-plugin>
+ <tag-class>org.apache.taglibs.standard.tag.rt.core.SetTag</tag-class>
+ <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.Set</plugin-class>
+ </tag-plugin>
+ <tag-plugin>
+ <tag-class>org.apache.taglibs.standard.tag.common.core.RemoveTag</tag-class>
+ <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.Remove</plugin-class>
+ </tag-plugin>
+ <tag-plugin>
+ <tag-class>org.apache.taglibs.standard.tag.common.core.CatchTag</tag-class>
+ <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.Catch</plugin-class>
+ </tag-plugin>
+ <tag-plugin>
+ <tag-class>org.apache.taglibs.standard.tag.rt.core.ForTokensTag</tag-class>
+ <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.ForTokens</plugin-class>
+ </tag-plugin>
+ <tag-plugin>
+ <tag-class>org.apache.taglibs.standard.tag.rt.core.ImportTag</tag-class>
+ <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.Import</plugin-class>
+ </tag-plugin>
+</tag-plugins>
Added: struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/util/Enumerator.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/util/Enumerator.java?rev=819444&view=auto
==============================================================================
--- struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/util/Enumerator.java (added)
+++ struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/util/Enumerator.java Mon Sep 28 01:55:26 2009
@@ -0,0 +1,176 @@
+/*
+ * 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.util;
+
+
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+
+/**
+ * Adapter class that wraps an <code>Enumeration</code> around a Java2
+ * collection classes object <code>Iterator</code> so that existing APIs
+ * returning Enumerations can easily run on top of the new collections.
+ * Constructors are provided to easliy create such wrappers.
+ *
+ * @author Craig R. McClanahan
+ * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (Tue, 24 Oct 2006) $
+ */
+
+public final class Enumerator implements Enumeration {
+
+
+ // ----------------------------------------------------------- Constructors
+
+
+ /**
+ * Return an Enumeration over the values of the specified Collection.
+ *
+ * @param collection Collection whose values should be enumerated
+ */
+ public Enumerator(Collection collection) {
+
+ this(collection.iterator());
+
+ }
+
+
+ /**
+ * Return an Enumeration over the values of the specified Collection.
+ *
+ * @param collection Collection whose values should be enumerated
+ * @param clone true to clone iterator
+ */
+ public Enumerator(Collection collection, boolean clone) {
+
+ this(collection.iterator(), clone);
+
+ }
+
+
+ /**
+ * Return an Enumeration over the values returned by the
+ * specified Iterator.
+ *
+ * @param iterator Iterator to be wrapped
+ */
+ public Enumerator(Iterator iterator) {
+
+ super();
+ this.iterator = iterator;
+
+ }
+
+
+ /**
+ * Return an Enumeration over the values returned by the
+ * specified Iterator.
+ *
+ * @param iterator Iterator to be wrapped
+ * @param clone true to clone iterator
+ */
+ public Enumerator(Iterator iterator, boolean clone) {
+
+ super();
+ if (!clone) {
+ this.iterator = iterator;
+ } else {
+ List list = new ArrayList();
+ while (iterator.hasNext()) {
+ list.add(iterator.next());
+ }
+ this.iterator = list.iterator();
+ }
+
+ }
+
+
+ /**
+ * Return an Enumeration over the values of the specified Map.
+ *
+ * @param map Map whose values should be enumerated
+ */
+ public Enumerator(Map map) {
+
+ this(map.values().iterator());
+
+ }
+
+
+ /**
+ * Return an Enumeration over the values of the specified Map.
+ *
+ * @param map Map whose values should be enumerated
+ * @param clone true to clone iterator
+ */
+ public Enumerator(Map map, boolean clone) {
+
+ this(map.values().iterator(), clone);
+
+ }
+
+
+ // ----------------------------------------------------- Instance Variables
+
+
+ /**
+ * The <code>Iterator</code> over which the <code>Enumeration</code>
+ * represented by this class actually operates.
+ */
+ private Iterator iterator = null;
+
+
+ // --------------------------------------------------------- Public Methods
+
+
+ /**
+ * Tests if this enumeration contains more elements.
+ *
+ * @return <code>true</code> if and only if this enumeration object
+ * contains at least one more element to provide, <code>false</code>
+ * otherwise
+ */
+ public boolean hasMoreElements() {
+
+ return (iterator.hasNext());
+
+ }
+
+
+ /**
+ * Returns the next element of this enumeration if this enumeration
+ * has at least one more element to provide.
+ *
+ * @return the next element of this enumeration
+ *
+ * @exception NoSuchElementException if no more elements exist
+ */
+ public Object nextElement() throws NoSuchElementException {
+
+ return (iterator.next());
+
+ }
+
+
+}
Added: struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/xmlparser/ASCIIReader.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/xmlparser/ASCIIReader.java?rev=819444&view=auto
==============================================================================
--- struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/xmlparser/ASCIIReader.java (added)
+++ struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/xmlparser/ASCIIReader.java Mon Sep 28 01:55:26 2009
@@ -0,0 +1,204 @@
+/*
+ * 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.xmlparser;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.Reader;
+import org.apache.struts2.jasper.compiler.Localizer;
+
+/**
+ * A simple ASCII byte reader. This is an optimized reader for reading
+ * byte streams that only contain 7-bit ASCII characters.
+ *
+ * @author Andy Clark, IBM
+ *
+ * @version $Id: ASCIIReader.java 708125 2008-10-27 10:10:13Z markt $
+ */
+public class ASCIIReader
+ extends Reader {
+
+ //
+ // Constants
+ //
+
+ /** Default byte buffer size (2048). */
+ public static final int DEFAULT_BUFFER_SIZE = 2048;
+
+ //
+ // Data
+ //
+
+ /** Input stream. */
+ protected InputStream fInputStream;
+
+ /** Byte buffer. */
+ protected byte[] fBuffer;
+
+ //
+ // Constructors
+ //
+
+ /**
+ * Constructs an ASCII reader from the specified input stream
+ * and buffer size.
+ *
+ * @param inputStream The input stream.
+ * @param size The initial buffer size.
+ */
+ public ASCIIReader(InputStream inputStream, int size) {
+ fInputStream = inputStream;
+ fBuffer = new byte[size];
+ }
+
+ //
+ // Reader methods
+ //
+
+ /**
+ * Read a single character. This method will block until a character is
+ * available, an I/O error occurs, or the end of the stream is reached.
+ *
+ * <p> Subclasses that intend to support efficient single-character input
+ * should override this method.
+ *
+ * @return The character read, as an integer in the range 0 to 127
+ * (<tt>0x00-0x7f</tt>), or -1 if the end of the stream has
+ * been reached
+ *
+ * @exception IOException If an I/O error occurs
+ */
+ public int read() throws IOException {
+ int b0 = fInputStream.read();
+ if (b0 > 0x80) {
+ throw new IOException(Localizer.getMessage("jsp.error.xml.invalidASCII",
+ Integer.toString(b0)));
+ }
+ return b0;
+ } // read():int
+
+ /**
+ * Read characters into a portion of an array. This method will block
+ * until some input is available, an I/O error occurs, or the end of the
+ * stream is reached.
+ *
+ * @param ch Destination buffer
+ * @param offset Offset at which to start storing characters
+ * @param length Maximum number of characters to read
+ *
+ * @return The number of characters read, or -1 if the end of the
+ * stream has been reached
+ *
+ * @exception IOException If an I/O error occurs
+ */
+ public int read(char ch[], int offset, int length) throws IOException {
+ if (length > fBuffer.length) {
+ length = fBuffer.length;
+ }
+ int count = fInputStream.read(fBuffer, 0, length);
+ for (int i = 0; i < count; i++) {
+ int b0 = (0xff & fBuffer[i]); // Convert to unsigned
+ if (b0 > 0x80) {
+ throw new IOException(Localizer.getMessage("jsp.error.xml.invalidASCII",
+ Integer.toString(b0)));
+ }
+ ch[offset + i] = (char)b0;
+ }
+ return count;
+ } // read(char[],int,int)
+
+ /**
+ * Skip characters. This method will block until some characters are
+ * available, an I/O error occurs, or the end of the stream is reached.
+ *
+ * @param n The number of characters to skip
+ *
+ * @return The number of characters actually skipped
+ *
+ * @exception IOException If an I/O error occurs
+ */
+ public long skip(long n) throws IOException {
+ return fInputStream.skip(n);
+ } // skip(long):long
+
+ /**
+ * Tell whether this stream is ready to be read.
+ *
+ * @return True if the next read() is guaranteed not to block for input,
+ * false otherwise. Note that returning false does not guarantee that the
+ * next read will block.
+ *
+ * @exception IOException If an I/O error occurs
+ */
+ public boolean ready() throws IOException {
+ return false;
+ } // ready()
+
+ /**
+ * Tell whether this stream supports the mark() operation.
+ */
+ public boolean markSupported() {
+ return fInputStream.markSupported();
+ } // markSupported()
+
+ /**
+ * Mark the present position in the stream. Subsequent calls to reset()
+ * will attempt to reposition the stream to this point. Not all
+ * character-input streams support the mark() operation.
+ *
+ * @param readAheadLimit Limit on the number of characters that may be
+ * read while still preserving the mark. After
+ * reading this many characters, attempting to
+ * reset the stream may fail.
+ *
+ * @exception IOException If the stream does not support mark(),
+ * or if some other I/O error occurs
+ */
+ public void mark(int readAheadLimit) throws IOException {
+ fInputStream.mark(readAheadLimit);
+ } // mark(int)
+
+ /**
+ * Reset the stream. If the stream has been marked, then attempt to
+ * reposition it at the mark. If the stream has not been marked, then
+ * attempt to reset it in some way appropriate to the particular stream,
+ * for example by repositioning it to its starting point. Not all
+ * character-input streams support the reset() operation, and some support
+ * reset() without supporting mark().
+ *
+ * @exception IOException If the stream has not been marked,
+ * or if the mark has been invalidated,
+ * or if the stream does not support reset(),
+ * or if some other I/O error occurs
+ */
+ public void reset() throws IOException {
+ fInputStream.reset();
+ } // reset()
+
+ /**
+ * Close the stream. Once a stream has been closed, further read(),
+ * ready(), mark(), or reset() invocations will throw an IOException.
+ * Closing a previously-closed stream, however, has no effect.
+ *
+ * @exception IOException If an I/O error occurs
+ */
+ public void close() throws IOException {
+ fInputStream.close();
+ } // close()
+
+} // class ASCIIReader