tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject svn commit: r1037279 [2/10] - in /tomcat/taglibs/standard/trunk/impl: ./ src/main/java/org/apache/taglibs/standard/ src/main/java/org/apache/taglibs/standard/functions/ src/main/java/org/apache/taglibs/standard/tag/common/core/ src/main/java/org/apache...
Date Sat, 20 Nov 2010 17:57:49 GMT
Modified: tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/ImportSupport.java
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/ImportSupport.java?rev=1037279&r1=1037278&r2=1037279&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/ImportSupport.java (original)
+++ tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/ImportSupport.java Sat Nov 20 17:57:45 2010
@@ -13,7 +13,7 @@
  * 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.taglibs.standard.tag.common.core;
 
@@ -56,60 +56,63 @@ import org.apache.taglibs.standard.resou
  * @author Shawn Bayern
  */
 
-public abstract class ImportSupport extends BodyTagSupport 
+public abstract class ImportSupport extends BodyTagSupport
         implements TryCatchFinally, ParamParent {
 
     //*********************************************************************
     // Public constants
-    
-    /** <p>Valid characters in a scheme.</p>
-     *  <p>RFC 1738 says the following:</p>
-     *  <blockquote>
-     *   Scheme names consist of a sequence of characters. The lower
-     *   case letters "a"--"z", digits, and the characters plus ("+"),
-     *   period ("."), and hyphen ("-") are allowed. For resiliency,
-     *   programs interpreting URLs should treat upper case letters as
-     *   equivalent to lower case in scheme names (e.g., allow "HTTP" as
-     *   well as "http").
-     *  </blockquote>
+
+    /**
+     * <p>Valid characters in a scheme.</p>
+     * <p>RFC 1738 says the following:</p>
+     * <blockquote>
+     * Scheme names consist of a sequence of characters. The lower
+     * case letters "a"--"z", digits, and the characters plus ("+"),
+     * period ("."), and hyphen ("-") are allowed. For resiliency,
+     * programs interpreting URLs should treat upper case letters as
+     * equivalent to lower case in scheme names (e.g., allow "HTTP" as
+     * well as "http").
+     * </blockquote>
      * <p>We treat as absolute any URL that begins with such a scheme name,
      * followed by a colon.</p>
      */
     public static final String VALID_SCHEME_CHARS =
-	"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+.-";
+            "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+.-";
 
-    /** Default character encoding for response. */
+    /**
+     * Default character encoding for response.
+     */
     public static final String DEFAULT_ENCODING = "ISO-8859-1";
 
     //*********************************************************************
     // Protected state
 
     protected String url;                         // 'url' attribute
-    protected String context;			  // 'context' attribute
+    protected String context;              // 'context' attribute
     protected String charEncoding;                // 'charEncoding' attrib.
 
     //*********************************************************************
     // Private state (implementation details)
 
     private String var;                 // 'var' attribute
-    private int scope;			// processed 'scope' attribute
+    private int scope;            // processed 'scope' attribute
     private String varReader;           // 'varReader' attribute
-    private Reader r;	 		// exposed reader, if relevant
-    private boolean isAbsoluteUrl;	// is our URL absolute?
+    private Reader r;             // exposed reader, if relevant
+    private boolean isAbsoluteUrl;    // is our URL absolute?
     private ParamSupport.ParamManager params;    // parameters
-    private String urlWithParams;	// URL with parameters, if applicable
+    private String urlWithParams;    // URL with parameters, if applicable
 
     //*********************************************************************
     // Constructor and initialization
 
     public ImportSupport() {
-	super();
-	init();
+        super();
+        init();
     }
 
     private void init() {
-	url = var = varReader = context = charEncoding = urlWithParams = null;
-	params = null;
+        url = var = varReader = context = charEncoding = urlWithParams = null;
+        params = null;
         scope = PageContext.PAGE_SCOPE;
     }
 
@@ -118,82 +121,91 @@ public abstract class ImportSupport exte
     // Tag logic
 
     // determines what kind of import and variable exposure to perform 
+
     @Override
     public int doStartTag() throws JspException {
-	// Sanity check
-	if (context != null
-	        && (!context.startsWith("/") || !url.startsWith("/"))) {
-	    throw new JspTagException(
-		Resources.getMessage("IMPORT_BAD_RELATIVE"));
-	}
-
-	// reset parameter-related state
-	urlWithParams = null;
-	params = new ParamSupport.ParamManager();
-
-	// check the URL
-	if (url == null || url.equals(""))
-	    throw new NullAttributeException("import", "url");
-
-	// Record whether our URL is absolute or relative
-	isAbsoluteUrl = isAbsoluteUrl();
-
-	try {
-	    // If we need to expose a Reader, we've got to do it right away
-	    if  (varReader != null) {
-	        r = acquireReader();
-	        pageContext.setAttribute(varReader, r);
-	    }
-	} catch (IOException ex) {
-	    throw new JspTagException(ex.toString(), ex);
-	}
+        // Sanity check
+        if (context != null
+                && (!context.startsWith("/") || !url.startsWith("/"))) {
+            throw new JspTagException(
+                    Resources.getMessage("IMPORT_BAD_RELATIVE"));
+        }
+
+        // reset parameter-related state
+        urlWithParams = null;
+        params = new ParamSupport.ParamManager();
+
+        // check the URL
+        if (url == null || url.equals("")) {
+            throw new NullAttributeException("import", "url");
+        }
+
+        // Record whether our URL is absolute or relative
+        isAbsoluteUrl = isAbsoluteUrl();
+
+        try {
+            // If we need to expose a Reader, we've got to do it right away
+            if (varReader != null) {
+                r = acquireReader();
+                pageContext.setAttribute(varReader, r);
+            }
+        } catch (IOException ex) {
+            throw new JspTagException(ex.toString(), ex);
+        }
 
-	return EVAL_BODY_INCLUDE;
+        return EVAL_BODY_INCLUDE;
     }
 
     // manages connections as necessary (creating or destroying)
+
     @Override
     public int doEndTag() throws JspException {
         try {
-	    // If we didn't expose a Reader earlier...
-	    if (varReader == null) {
-	        // ... store it in 'var', if available ...
-	        if (var != null)
-	            pageContext.setAttribute(var, acquireString(), scope);
+            // If we didn't expose a Reader earlier...
+            if (varReader == null) {
+                // ... store it in 'var', if available ...
+                if (var != null) {
+                    pageContext.setAttribute(var, acquireString(), scope);
+                }
                 // ... or simply output it, if we have nowhere to expose it
-	        else
-	            pageContext.getOut().print(acquireString());
-	    }
-	    return EVAL_PAGE;
+                else {
+                    pageContext.getOut().print(acquireString());
+                }
+            }
+            return EVAL_PAGE;
         } catch (IOException ex) {
-	    throw new JspTagException(ex.toString(), ex);
+            throw new JspTagException(ex.toString(), ex);
         }
     }
 
     // simply rethrows its exception
+
     public void doCatch(Throwable t) throws Throwable {
-	throw t;
+        throw t;
     }
 
     // cleans up if appropriate
-    public void doFinally() { 
+
+    public void doFinally() {
         try {
-	    // If we exposed a Reader in doStartTag(), close it.
-	    if (varReader != null) {
-		// 'r' can be null if an exception was thrown...
-	        if (r != null)
-		    r.close();
-		pageContext.removeAttribute(varReader, PageContext.PAGE_SCOPE);
-	    }
+            // If we exposed a Reader in doStartTag(), close it.
+            if (varReader != null) {
+                // 'r' can be null if an exception was thrown...
+                if (r != null) {
+                    r.close();
+                }
+                pageContext.removeAttribute(varReader, PageContext.PAGE_SCOPE);
+            }
         } catch (IOException ex) {
-	    // ignore it; close() failed, but there's nothing more we can do
+            // ignore it; close() failed, but there's nothing more we can do
         }
     }
 
     // Releases any resources we may have (or inherit)
+
     @Override
     public void release() {
-	init();
+        init();
         super.release();
     }
 
@@ -201,15 +213,15 @@ public abstract class ImportSupport exte
     // Tag attributes known at translation time
 
     public void setVar(String var) {
-	this.var = var;
+        this.var = var;
     }
 
     public void setVarReader(String varReader) {
-	this.varReader = varReader;
+        this.varReader = varReader;
     }
 
     public void setScope(String scope) {
-	this.scope = Util.getScope(scope);
+        this.scope = Util.getScope(scope);
     }
 
 
@@ -217,8 +229,9 @@ public abstract class ImportSupport exte
     // Collaboration with subtags
 
     // inherit Javadoc
+
     public void addParameter(String name, String value) {
-	params.addParameter(name, value);
+        params.addParameter(name, value);
     }
 
     //*********************************************************************
@@ -241,118 +254,124 @@ public abstract class ImportSupport exte
      */
 
     private String acquireString() throws IOException, JspException {
-	if (isAbsoluteUrl) {
-	    // for absolute URLs, delegate to our peer
-	    BufferedReader r = new BufferedReader(acquireReader());
-	    StringBuffer sb = new StringBuffer();
-	    int i;
-
-	    // under JIT, testing seems to show this simple loop is as fast
-	    // as any of the alternatives
-	    while ((i = r.read()) != -1)
-	        sb.append((char)i);
-
-	    return sb.toString();
-	} else { 
-	    // handle relative URLs ourselves
-
-	    // URL is relative, so we must be an HTTP request
-	    if (!(pageContext.getRequest() instanceof HttpServletRequest
-		  && pageContext.getResponse() instanceof HttpServletResponse))
-		throw new JspTagException(
-		    Resources.getMessage("IMPORT_REL_WITHOUT_HTTP"));
-
-	    // retrieve an appropriate ServletContext
-	    ServletContext c = null;
-	    String targetUrl = targetUrl();
-	    if (context != null)
-	        c = pageContext.getServletContext().getContext(context);
-	    else {
-	        c = pageContext.getServletContext();
-
-		// normalize the URL if we have an HttpServletRequest
-		if (!targetUrl.startsWith("/")) {
-		    String sp = ((HttpServletRequest) 
-			pageContext.getRequest()).getServletPath();
-		    targetUrl = sp.substring(0, sp.lastIndexOf('/'))
-			+ '/' + targetUrl;
-		}
-	    }
+        if (isAbsoluteUrl) {
+            // for absolute URLs, delegate to our peer
+            BufferedReader r = new BufferedReader(acquireReader());
+            StringBuffer sb = new StringBuffer();
+            int i;
+
+            // under JIT, testing seems to show this simple loop is as fast
+            // as any of the alternatives
+            while ((i = r.read()) != -1) {
+                sb.append((char) i);
+            }
+
+            return sb.toString();
+        } else {
+            // handle relative URLs ourselves
+
+            // URL is relative, so we must be an HTTP request
+            if (!(pageContext.getRequest() instanceof HttpServletRequest
+                    && pageContext.getResponse() instanceof HttpServletResponse)) {
+                throw new JspTagException(
+                        Resources.getMessage("IMPORT_REL_WITHOUT_HTTP"));
+            }
+
+            // retrieve an appropriate ServletContext
+            ServletContext c = null;
+            String targetUrl = targetUrl();
+            if (context != null) {
+                c = pageContext.getServletContext().getContext(context);
+            } else {
+                c = pageContext.getServletContext();
+
+                // normalize the URL if we have an HttpServletRequest
+                if (!targetUrl.startsWith("/")) {
+                    String sp = ((HttpServletRequest)
+                            pageContext.getRequest()).getServletPath();
+                    targetUrl = sp.substring(0, sp.lastIndexOf('/'))
+                            + '/' + targetUrl;
+                }
+            }
 
             if (c == null) {
                 throw new JspTagException(
-                    Resources.getMessage(
-                        "IMPORT_REL_WITHOUT_DISPATCHER", context, targetUrl));
+                        Resources.getMessage(
+                                "IMPORT_REL_WITHOUT_DISPATCHER", context, targetUrl));
+            }
+
+            // from this context, get a dispatcher
+            RequestDispatcher rd =
+                    c.getRequestDispatcher(stripSession(targetUrl));
+            if (rd == null) {
+                throw new JspTagException(stripSession(targetUrl));
+            }
+
+            // include the resource, using our custom wrapper
+            ImportResponseWrapper irw =
+                    new ImportResponseWrapper(
+                            (HttpServletResponse) pageContext.getResponse());
+
+            ImportRequestWrapper wrappedRequest =
+                    new ImportRequestWrapper(
+                            (HttpServletRequest) pageContext.getRequest());
+
+            // spec mandates specific error handling form include()
+            try {
+                rd.include(wrappedRequest, irw);
+            } catch (IOException ex) {
+                throw new JspException(ex);
+            } catch (RuntimeException ex) {
+                throw new JspException(ex);
+            } catch (ServletException ex) {
+                Throwable rc = ex.getRootCause();
+                while (rc instanceof ServletException) {
+                    rc = ((ServletException) rc).getRootCause();
+                }
+                if (rc == null) {
+                    throw new JspException(ex);
+                } else {
+                    throw new JspException(rc);
+                }
             }
 
-	    // from this context, get a dispatcher
-	    RequestDispatcher rd =
-                c.getRequestDispatcher(stripSession(targetUrl));
-	    if (rd == null)
-		throw new JspTagException(stripSession(targetUrl));
-
-	    // include the resource, using our custom wrapper
-	    ImportResponseWrapper irw = 
-		new ImportResponseWrapper(
-		    (HttpServletResponse) pageContext.getResponse());
-
-            ImportRequestWrapper wrappedRequest = 
-		new ImportRequestWrapper(
-		    (HttpServletRequest) pageContext.getRequest());
-
-	    // spec mandates specific error handling form include()
-	    try {
-	        rd.include(wrappedRequest, irw);
-	    } catch (IOException ex) {
-		throw new JspException(ex);
-	    } catch (RuntimeException ex) {
-		throw new JspException(ex);
-	    } catch (ServletException ex) {
-		Throwable rc = ex.getRootCause();
-        while (rc instanceof ServletException) {
-            rc = ((ServletException) rc).getRootCause();
-        }
-		if (rc == null)
-		    throw new JspException(ex);
-		else
-		    throw new JspException(rc);
-	    }
-
-	    // disallow inappropriate response codes per JSTL spec
-	    if (irw.getStatus() < 200 || irw.getStatus() > 299) {
-		throw new JspTagException(irw.getStatus() + " " +
-		    stripSession(targetUrl));
-	    }
-
-	    // recover the response String from our wrapper
-	    return irw.getString();
-	}
+            // disallow inappropriate response codes per JSTL spec
+            if (irw.getStatus() < 200 || irw.getStatus() > 299) {
+                throw new JspTagException(irw.getStatus() + " " +
+                        stripSession(targetUrl));
+            }
+
+            // recover the response String from our wrapper
+            return irw.getString();
+        }
     }
 
     private Reader acquireReader() throws IOException, JspException {
-	if (!isAbsoluteUrl) {
-	    // for relative URLs, delegate to our peer
-	    return new StringReader(acquireString());
-	} else {
+        if (!isAbsoluteUrl) {
+            // for relative URLs, delegate to our peer
+            return new StringReader(acquireString());
+        } else {
             // absolute URL
             String target = targetUrl();
-	    try {
-	        // handle absolute URLs ourselves, using java.net.URL
-	        URL u = new URL(target);
+            try {
+                // handle absolute URLs ourselves, using java.net.URL
+                URL u = new URL(target);
                 URLConnection uc = u.openConnection();
                 InputStream i = uc.getInputStream();
 
-	        // okay, we've got a stream; encode it appropriately
-	        Reader r = null;
-                String charSet; 
-	        if (charEncoding != null && !charEncoding.equals("")) {
+                // okay, we've got a stream; encode it appropriately
+                Reader r = null;
+                String charSet;
+                if (charEncoding != null && !charEncoding.equals("")) {
                     charSet = charEncoding;
                 } else {
                     // charSet extracted according to RFC 2045, section 5.1
-		    String contentType = uc.getContentType();
-		    if (contentType != null) {
+                    String contentType = uc.getContentType();
+                    if (contentType != null) {
                         charSet = Util.getContentTypeAttribute(contentType, "charset");
-                        if (charSet == null) charSet = DEFAULT_ENCODING;
+                        if (charSet == null) {
+                            charSet = DEFAULT_ENCODING;
+                        }
                     } else {
                         charSet = DEFAULT_ENCODING;
                     }
@@ -363,32 +382,35 @@ public abstract class ImportSupport exte
                     r = new InputStreamReader(i, DEFAULT_ENCODING);
                 }
 
-		// check response code for HTTP URLs before returning, per spec,
-		// before returning
-		if (uc instanceof HttpURLConnection) {
-		    int status = ((HttpURLConnection) uc).getResponseCode();
-		    if (status < 200 || status > 299)
-			throw new JspTagException(status + " " + target);
-		}
-
-	        return r;
-	    } catch (IOException ex) {
-		throw new JspException(
-                    Resources.getMessage("IMPORT_ABS_ERROR", target, ex), ex);
-	    } catch (RuntimeException ex) {  // because the spec makes us
-		throw new JspException(
-                    Resources.getMessage("IMPORT_ABS_ERROR", target, ex), ex);
-	    }
-	}
+                // check response code for HTTP URLs before returning, per spec,
+                // before returning
+                if (uc instanceof HttpURLConnection) {
+                    int status = ((HttpURLConnection) uc).getResponseCode();
+                    if (status < 200 || status > 299) {
+                        throw new JspTagException(status + " " + target);
+                    }
+                }
+
+                return r;
+            } catch (IOException ex) {
+                throw new JspException(
+                        Resources.getMessage("IMPORT_ABS_ERROR", target, ex), ex);
+            } catch (RuntimeException ex) {  // because the spec makes us
+                throw new JspException(
+                        Resources.getMessage("IMPORT_ABS_ERROR", target, ex), ex);
+            }
+        }
     }
 
-    /** Wraps requests to allow us to enforce the method to be GET */
+    /**
+     * Wraps requests to allow us to enforce the method to be GET
+     */
     private class ImportRequestWrapper extends HttpServletRequestWrapper {
 
         public ImportRequestWrapper(HttpServletRequest request) {
             super(request);
         }
-        
+
         @Override
         public String getMethod() {
             return "GET";
@@ -396,134 +418,165 @@ public abstract class ImportSupport exte
 
     }
 
-    /** Wraps responses to allow us to retrieve results as Strings. */
+    /**
+     * Wraps responses to allow us to retrieve results as Strings.
+     */
     private class ImportResponseWrapper extends HttpServletResponseWrapper {
 
-	//************************************************************
-	// Overview
+        //************************************************************
+        // Overview
 
-	/*
-	 * We provide either a Writer or an OutputStream as requested.
-	 * We actually have a true Writer and an OutputStream backing
-	 * both, since we don't want to use a character encoding both
-	 * ways (Writer -> OutputStream -> Writer).  So we use no
-	 * encoding at all (as none is relevant) when the target resource
-	 * uses a Writer.  And we decode the OutputStream's bytes
-	 * using OUR tag's 'charEncoding' attribute, or ISO-8859-1
-	 * as the default.  We thus ignore setLocale() and setContentType()
-	 * in this wrapper.
-	 *
-	 * In other words, the target's asserted encoding is used
-	 * to convert from a Writer to an OutputStream, which is typically
-	 * the medium through with the target will communicate its
-	 * ultimate response.  Since we short-circuit that mechanism
-	 * and read the target's characters directly if they're offered
-	 * as such, we simply ignore the target's encoding assertion.
-	 */
-
-	//************************************************************
-	// Data
-
-	/** The Writer we convey. */
-	private StringWriter sw = new StringWriter();
-
-	/** A buffer, alternatively, to accumulate bytes. */
-	private ByteArrayOutputStream bos = new ByteArrayOutputStream();
-
-	/** A ServletOutputStream we convey, tied to this Writer. */
-	private ServletOutputStream sos = new ServletOutputStream() {
-	    @Override
-        public void write(int b) throws IOException {
-		bos.write(b);
-	    }
-	};
-
-	/** 'True' if getWriter() was called; false otherwise. */
-	private boolean isWriterUsed;
-
-	/** 'True if getOutputStream() was called; false otherwise. */
-	private boolean isStreamUsed;
-
-	/** The HTTP status set by the target. */
-	private int status = 200;
-	
-	//************************************************************
-	// Constructor and methods
-
-	/** Constructs a new ImportResponseWrapper. */
-	public ImportResponseWrapper(HttpServletResponse response) {
-	    super(response);
-	}
-	
-	/** Returns a Writer designed to buffer the output. */
-	@Override
-    public PrintWriter getWriter() {
-	    if (isStreamUsed)
-		throw new IllegalStateException(
-		    Resources.getMessage("IMPORT_ILLEGAL_STREAM"));
-	    isWriterUsed = true;
-	    return new PrintWriter(sw);
-	}
-	
-	/** Returns a ServletOutputStream designed to buffer the output. */
-	@Override
-    public ServletOutputStream getOutputStream() {
-	    if (isWriterUsed)
-		throw new IllegalStateException(
-		    Resources.getMessage("IMPORT_ILLEGAL_WRITER"));
-	    isStreamUsed = true;
-	    return sos;
-	}
-
-	/** Has no effect. */
-	@Override
-    public void setContentType(String x) {
-	    // ignore
-	}
-
-	/** Has no effect. */
-	@Override
-    public void setLocale(Locale x) {
-	    // ignore
-	}
-
-	@Override
-    public void setStatus(int status) {
-	    this.status = status;
-	}
-
-	public int getStatus() {
-	    return status;
-	}
-
-	/** 
-	 * Retrieves the buffered output, using the containing tag's 
-	 * 'charEncoding' attribute, or the tag's default encoding,
-	 * <b>if necessary</b>.
-         */
-	// not simply toString() because we need to throw
-	// UnsupportedEncodingException
-	public String getString() throws UnsupportedEncodingException {
-	    if (isWriterUsed)
-		return sw.toString();
-	    else if (isStreamUsed) {
-		if (charEncoding != null && !charEncoding.equals(""))
-		    return bos.toString(charEncoding);
-		else
-		    return bos.toString(DEFAULT_ENCODING);
-	    } else
-		return "";		// target didn't write anything
-	}
+        /*
+       * We provide either a Writer or an OutputStream as requested.
+       * We actually have a true Writer and an OutputStream backing
+       * both, since we don't want to use a character encoding both
+       * ways (Writer -> OutputStream -> Writer).  So we use no
+       * encoding at all (as none is relevant) when the target resource
+       * uses a Writer.  And we decode the OutputStream's bytes
+       * using OUR tag's 'charEncoding' attribute, or ISO-8859-1
+       * as the default.  We thus ignore setLocale() and setContentType()
+       * in this wrapper.
+       *
+       * In other words, the target's asserted encoding is used
+       * to convert from a Writer to an OutputStream, which is typically
+       * the medium through with the target will communicate its
+       * ultimate response.  Since we short-circuit that mechanism
+       * and read the target's characters directly if they're offered
+       * as such, we simply ignore the target's encoding assertion.
+       */
+
+        //************************************************************
+        // Data
+
+        /**
+         * The Writer we convey.
+         */
+        private StringWriter sw = new StringWriter();
+
+        /**
+         * A buffer, alternatively, to accumulate bytes.
+         */
+        private ByteArrayOutputStream bos = new ByteArrayOutputStream();
+
+        /**
+         * A ServletOutputStream we convey, tied to this Writer.
+         */
+        private ServletOutputStream sos = new ServletOutputStream() {
+            @Override
+            public void write(int b) throws IOException {
+                bos.write(b);
+            }
+        };
+
+        /**
+         * 'True' if getWriter() was called; false otherwise.
+         */
+        private boolean isWriterUsed;
+
+        /**
+         * 'True if getOutputStream() was called; false otherwise.
+         */
+        private boolean isStreamUsed;
+
+        /**
+         * The HTTP status set by the target.
+         */
+        private int status = 200;
+
+        //************************************************************
+        // Constructor and methods
+
+        /**
+         * Constructs a new ImportResponseWrapper.
+         */
+        public ImportResponseWrapper(HttpServletResponse response) {
+            super(response);
+        }
+
+        /**
+         * Returns a Writer designed to buffer the output.
+         */
+        @Override
+        public PrintWriter getWriter() {
+            if (isStreamUsed) {
+                throw new IllegalStateException(
+                        Resources.getMessage("IMPORT_ILLEGAL_STREAM"));
+            }
+            isWriterUsed = true;
+            return new PrintWriter(sw);
+        }
+
+        /**
+         * Returns a ServletOutputStream designed to buffer the output.
+         */
+        @Override
+        public ServletOutputStream getOutputStream() {
+            if (isWriterUsed) {
+                throw new IllegalStateException(
+                        Resources.getMessage("IMPORT_ILLEGAL_WRITER"));
+            }
+            isStreamUsed = true;
+            return sos;
+        }
+
+        /**
+         * Has no effect.
+         */
+        @Override
+        public void setContentType(String x) {
+            // ignore
+        }
+
+        /**
+         * Has no effect.
+         */
+        @Override
+        public void setLocale(Locale x) {
+            // ignore
+        }
+
+        @Override
+        public void setStatus(int status) {
+            this.status = status;
+        }
+
+        public int getStatus() {
+            return status;
+        }
+
+        /**
+         * Retrieves the buffered output, using the containing tag's
+         * 'charEncoding' attribute, or the tag's default encoding,
+         * <b>if necessary</b>.
+         */
+        // not simply toString() because we need to throw
+        // UnsupportedEncodingException
+        public String getString() throws UnsupportedEncodingException {
+            if (isWriterUsed) {
+                return sw.toString();
+            } else if (isStreamUsed) {
+                if (charEncoding != null && !charEncoding.equals("")) {
+                    return bos.toString(charEncoding);
+                } else {
+                    return bos.toString(DEFAULT_ENCODING);
+                }
+            } else {
+                return "";
+            }        // target didn't write anything
+        }
     }
 
     //*********************************************************************
     // Some private utility methods
 
-    /** Returns our URL (potentially with parameters) */
+    /**
+     * Returns our URL (potentially with parameters)
+     */
     private String targetUrl() {
-	if (urlWithParams == null)
-	    urlWithParams = params.aggregateParams(url);
-	return urlWithParams;
+        if (urlWithParams == null) {
+            urlWithParams = params.aggregateParams(url);
+        }
+        return urlWithParams;
     }
 
     /**
@@ -543,23 +596,27 @@ public abstract class ImportSupport exte
      * <tt>false</tt> otherwise.
      */
     public static boolean isAbsoluteUrl(String url) {
-	// a null URL is not absolute, by our definition
-	if (url == null)
-	    return false;
-
-	// do a fast, simple check first
-	int colonPos;
-	if ((colonPos = url.indexOf(":")) == -1)
-	    return false;
-
-	// if we DO have a colon, make sure that every character
-	// leading up to it is a valid scheme character
-	for (int i = 0; i < colonPos; i++)
-	    if (VALID_SCHEME_CHARS.indexOf(url.charAt(i)) == -1)
-		return false;
+        // a null URL is not absolute, by our definition
+        if (url == null) {
+            return false;
+        }
 
-	// if so, we've got an absolute url
-	return true;
+        // do a fast, simple check first
+        int colonPos;
+        if ((colonPos = url.indexOf(":")) == -1) {
+            return false;
+        }
+
+        // if we DO have a colon, make sure that every character
+        // leading up to it is a valid scheme character
+        for (int i = 0; i < colonPos; i++) {
+            if (VALID_SCHEME_CHARS.indexOf(url.charAt(i)) == -1) {
+                return false;
+            }
+        }
+
+        // if so, we've got an absolute url
+        return true;
     }
 
     /**
@@ -569,14 +626,17 @@ public abstract class ImportSupport exte
      * and either EOS or a subsequent ';' (exclusive).
      */
     public static String stripSession(String url) {
-	StringBuffer u = new StringBuffer(url);
+        StringBuffer u = new StringBuffer(url);
         int sessionStart;
         while ((sessionStart = u.toString().indexOf(";jsessionid=")) != -1) {
             int sessionEnd = u.toString().indexOf(";", sessionStart + 1);
-            if (sessionEnd == -1)
-		sessionEnd = u.toString().indexOf("?", sessionStart + 1);
-	    if (sessionEnd == -1) 				// still
+            if (sessionEnd == -1) {
+                sessionEnd = u.toString().indexOf("?", sessionStart + 1);
+            }
+            if (sessionEnd == -1)                 // still
+            {
                 sessionEnd = u.length();
+            }
             u.delete(sessionStart, sessionEnd);
         }
         return u.toString();

Modified: tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/NullAttributeException.java
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/NullAttributeException.java?rev=1037279&r1=1037278&r2=1037279&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/NullAttributeException.java (original)
+++ tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/NullAttributeException.java Sat Nov 20 17:57:45 2010
@@ -13,7 +13,7 @@
  * 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.taglibs.standard.tag.common.core;
 
@@ -38,6 +38,6 @@ public class NullAttributeException exte
      * @param att The attribute value for which the error occurred.
      */
     public NullAttributeException(String tag, String att) {
-	super(Resources.getMessage("TAG_NULL_ATTRIBUTE", att, tag));
+        super(Resources.getMessage("TAG_NULL_ATTRIBUTE", att, tag));
     }
 }

Modified: tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/OtherwiseTag.java
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/OtherwiseTag.java?rev=1037279&r1=1037278&r2=1037279&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/OtherwiseTag.java (original)
+++ tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/OtherwiseTag.java Sat Nov 20 17:57:45 2010
@@ -13,7 +13,7 @@
  * 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.taglibs.standard.tag.common.core;
 
@@ -32,6 +32,7 @@ public class OtherwiseTag extends WhenTa
      */
 
     // Don't let the condition stop us... :-)
+
     @Override
     protected boolean condition() {
         return true;

Modified: tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/OutSupport.java
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/OutSupport.java?rev=1037279&r1=1037278&r2=1037279&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/OutSupport.java (original)
+++ tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/OutSupport.java Sat Nov 20 17:57:45 2010
@@ -13,18 +13,18 @@
  * 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.taglibs.standard.tag.common.core;
 
-import org.apache.taglibs.standard.util.EscapeXML;
-
 import java.io.IOException;
 
 import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.JspTagException;
 import javax.servlet.jsp.tagext.BodyTagSupport;
 
+import org.apache.taglibs.standard.util.EscapeXML;
+
 /**
  * <p>Support for handlers of the &lt;out&gt; tag, which simply evalutes and
  * prints the result of the expression it's passed.  If the result is
@@ -59,6 +59,7 @@ public abstract class OutSupport extends
     }
 
     // Releases any resources we may have (or inherit)
+
     @Override
     public void release() {
         output = null;
@@ -82,7 +83,7 @@ public abstract class OutSupport extends
 
         // output default if supplied
         output = evalDefault();
-        if (output != null ) {
+        if (output != null) {
             return SKIP_BODY;
         }
 

Modified: tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/ParamParent.java
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/ParamParent.java?rev=1037279&r1=1037278&r2=1037279&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/ParamParent.java (original)
+++ tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/ParamParent.java Sat Nov 20 17:57:45 2010
@@ -13,7 +13,7 @@
  * 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.taglibs.standard.tag.common.core;
 

Modified: tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/ParamSupport.java
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/ParamSupport.java?rev=1037279&r1=1037278&r2=1037279&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/ParamSupport.java (original)
+++ tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/ParamSupport.java Sat Nov 20 17:57:45 2010
@@ -13,7 +13,7 @@
  * 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.taglibs.standard.tag.common.core;
 
@@ -33,8 +33,8 @@ import org.apache.taglibs.standard.resou
  * <p>Support for tag handlers for &lt;param&gt;, the URL parameter
  * subtag for &lt;import&gt; in JSTL 1.0.</p>
  *
- * @see ParamParent, ImportSupport, URLEncodeSupport
  * @author Shawn Bayern
+ * @see ParamParent, ImportSupport, URLEncodeSupport
  */
 
 public abstract class ParamSupport extends BodyTagSupport {
@@ -56,38 +56,42 @@ public abstract class ParamSupport exten
     // Constructor and initialization
 
     public ParamSupport() {
-	super();
-	init();
+        super();
+        init();
     }
 
     private void init() {
-	name = value = null;
+        name = value = null;
     }
 
     //*********************************************************************
     // Tag logic
 
     // simply send our name and value to our appropriate ancestor
+
     @Override
     public int doEndTag() throws JspException {
-	Tag t = findAncestorWithClass(this, ParamParent.class);
-	if (t == null)
-	    throw new JspTagException(
-		Resources.getMessage("PARAM_OUTSIDE_PARENT"));
-
-	// take no action for null or empty names
-	if (name == null || name.equals(""))
-	    return EVAL_PAGE;
-
-	// send the parameter to the appropriate ancestor
-	ParamParent parent = (ParamParent) t;
-	String value = this.value;
-	if (value == null) {
-	    if (bodyContent == null || bodyContent.getString() == null)
-		value = "";
-	    else
-		value = bodyContent.getString().trim();
-	}
+        Tag t = findAncestorWithClass(this, ParamParent.class);
+        if (t == null) {
+            throw new JspTagException(
+                    Resources.getMessage("PARAM_OUTSIDE_PARENT"));
+        }
+
+        // take no action for null or empty names
+        if (name == null || name.equals("")) {
+            return EVAL_PAGE;
+        }
+
+        // send the parameter to the appropriate ancestor
+        ParamParent parent = (ParamParent) t;
+        String value = this.value;
+        if (value == null) {
+            if (bodyContent == null || bodyContent.getString() == null) {
+                value = "";
+            } else {
+                value = bodyContent.getString().trim();
+            }
+        }
         if (encode) {
             String enc = pageContext.getResponse().getCharacterEncoding();
             try {
@@ -98,87 +102,94 @@ public abstract class ParamSupport exten
         } else {
             parent.addParameter(name, value);
         }
-	return EVAL_PAGE;
+        return EVAL_PAGE;
     }
 
     // Releases any resources we may have (or inherit)
+
     @Override
     public void release() {
-	init();
+        init();
     }
 
     //*********************************************************************
     // Support for parameter management
 
-    /** 
+    /**
      * Provides support for aggregating query parameters in URLs.
      * Specifically, accepts a series of parameters, ensuring that
-     *  - newer parameters will precede older ones in the output URL
-     *  - all supplied parameters precede those in the input URL
+     * - newer parameters will precede older ones in the output URL
+     * - all supplied parameters precede those in the input URL
      */
     public static class ParamManager {
 
         //*********************************
         // Private state
 
-	private List names = new LinkedList();
+        private List names = new LinkedList();
         private List values = new LinkedList();
-	private boolean done = false;
-        
-	//*********************************
+        private boolean done = false;
+
+        //*********************************
         // Public interface
 
-	/** Adds a new parameter to the list. */
+        /**
+         * Adds a new parameter to the list.
+         */
         public void addParameter(String name, String value) {
-	    if (done)
-		throw new IllegalStateException();
-	    if (name != null) {
-	        names.add(name);
-	        if (value != null)
-		    values.add(value);
-	        else
-		    values.add("");
-	    }
-	}
+            if (done) {
+                throw new IllegalStateException();
+            }
+            if (name != null) {
+                names.add(name);
+                if (value != null) {
+                    values.add(value);
+                } else {
+                    values.add("");
+                }
+            }
+        }
 
-	/**
+        /**
          * Produces a new URL with the stored parameters, in the appropriate
          * order.
          */
-	public String aggregateParams(String url) {
-	    /* 
-             * Since for efficiency we're destructive to the param lists,
-             * we don't want to run multiple times.
-             */
-	    if (done)
-		throw new IllegalStateException();
-	    done = true;
-
-	    //// reverse the order of our two lists
-	    // Collections.reverse(this.names);
-	    // Collections.reverse(this.values);
-
-	    // build a string from the parameter list 
-	    StringBuffer newParams = new StringBuffer();
-	    for (int i = 0; i < names.size(); i++) {
-		newParams.append(names.get(i) + "=" + values.get(i));
-		if (i < (names.size() - 1))
-		    newParams.append("&");
-	    }
-
-	    // insert these parameters into the URL as appropriate
-	    if (newParams.length() > 0) {
-	        int questionMark = url.indexOf('?');
-	        if (questionMark == -1) {
-		    return (url + "?" + newParams);
-	        } else {
-		    StringBuffer workingUrl = new StringBuffer(url);
-		    workingUrl.insert(questionMark + 1, (newParams + "&"));
-		    return workingUrl.toString();
-	        }
-	    } else {
-		return url;
-	    }
-	}
+        public String aggregateParams(String url) {
+            /*
+            * Since for efficiency we're destructive to the param lists,
+            * we don't want to run multiple times.
+            */
+            if (done) {
+                throw new IllegalStateException();
+            }
+            done = true;
+
+            //// reverse the order of our two lists
+            // Collections.reverse(this.names);
+            // Collections.reverse(this.values);
+
+            // build a string from the parameter list
+            StringBuffer newParams = new StringBuffer();
+            for (int i = 0; i < names.size(); i++) {
+                newParams.append(names.get(i) + "=" + values.get(i));
+                if (i < (names.size() - 1)) {
+                    newParams.append("&");
+                }
+            }
+
+            // insert these parameters into the URL as appropriate
+            if (newParams.length() > 0) {
+                int questionMark = url.indexOf('?');
+                if (questionMark == -1) {
+                    return (url + "?" + newParams);
+                } else {
+                    StringBuffer workingUrl = new StringBuffer(url);
+                    workingUrl.insert(questionMark + 1, (newParams + "&"));
+                    return workingUrl.toString();
+                }
+            } else {
+                return url;
+            }
+        }
     }
 }

Modified: tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/RedirectSupport.java
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/RedirectSupport.java?rev=1037279&r1=1037278&r2=1037279&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/RedirectSupport.java (original)
+++ tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/RedirectSupport.java Sat Nov 20 17:57:45 2010
@@ -13,7 +13,7 @@
  * 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.taglibs.standard.tag.common.core;
 
@@ -31,7 +31,7 @@ import javax.servlet.jsp.tagext.BodyTagS
  */
 
 public abstract class RedirectSupport extends BodyTagSupport
-    implements ParamParent {
+        implements ParamParent {
 
     //*********************************************************************
     // Protected state
@@ -43,25 +43,25 @@ public abstract class RedirectSupport ex
     // Private state
 
     private String var;                          // 'var' attribute
-    private int scope;				 // processed 'scope' attr
-    private ParamSupport.ParamManager params;	 // added parameters
+    private int scope;                 // processed 'scope' attr
+    private ParamSupport.ParamManager params;     // added parameters
 
     //*********************************************************************
     // Constructor and initialization
 
     public RedirectSupport() {
-	super();
-	init();
+        super();
+        init();
     }
 
     private void init() {
-	url = var = null;
-	params = null;
-	scope = PageContext.PAGE_SCOPE;
+        url = var = null;
+        params = null;
+        scope = PageContext.PAGE_SCOPE;
     }
 
 
-   //*********************************************************************
+    //*********************************************************************
     // Tag attributes known at translation time
 
     public void setVar(String var) {
@@ -69,7 +69,7 @@ public abstract class RedirectSupport ex
     }
 
     public void setScope(String scope) {
-	this.scope = Util.getScope(scope);
+        this.scope = Util.getScope(scope);
     }
 
 
@@ -77,8 +77,9 @@ public abstract class RedirectSupport ex
     // Collaboration with subtags
 
     // inherit Javadoc
+
     public void addParameter(String name, String value) {
-	params.addParameter(name, value);
+        params.addParameter(name, value);
     }
 
 
@@ -86,41 +87,45 @@ public abstract class RedirectSupport ex
     // Tag logic
 
     // resets any parameters that might be sent
+
     @Override
     public int doStartTag() throws JspException {
-	params = new ParamSupport.ParamManager();
-	return EVAL_BODY_BUFFERED;
+        params = new ParamSupport.ParamManager();
+        return EVAL_BODY_BUFFERED;
     }
 
 
     // gets the right value, encodes it, and prints or stores it
+
     @Override
     public int doEndTag() throws JspException {
-	String result;				// the eventual result
+        String result;                // the eventual result
 
-	// add (already encoded) parameters
+        // add (already encoded) parameters
         String baseUrl = UrlSupport.resolveUrl(url, context, pageContext);
         result = params.aggregateParams(baseUrl);
 
         // if the URL is relative, rewrite it with 'redirect' encoding rules
         HttpServletResponse response =
-            ((HttpServletResponse) pageContext.getResponse());
-        if (!ImportSupport.isAbsoluteUrl(result))
+                ((HttpServletResponse) pageContext.getResponse());
+        if (!ImportSupport.isAbsoluteUrl(result)) {
             result = response.encodeRedirectURL(result);
+        }
 
-	// redirect!
-	try {
-	    response.sendRedirect(result);
-	} catch (java.io.IOException ex) {
-	    throw new JspTagException(ex.toString(), ex);
-	}
+        // redirect!
+        try {
+            response.sendRedirect(result);
+        } catch (java.io.IOException ex) {
+            throw new JspTagException(ex.toString(), ex);
+        }
 
-	return SKIP_PAGE;
+        return SKIP_PAGE;
     }
 
     // Releases any resources we may have (or inherit)
+
     @Override
     public void release() {
-	init();
+        init();
     }
 }

Modified: tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/RemoveTag.java
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/RemoveTag.java?rev=1037279&r1=1037278&r2=1037279&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/RemoveTag.java (original)
+++ tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/RemoveTag.java Sat Nov 20 17:57:45 2010
@@ -13,7 +13,7 @@
  * 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.taglibs.standard.tag.common.core;
 
@@ -32,9 +32,9 @@ public class RemoveTag extends TagSuppor
     //*********************************************************************
     // Internal state
 
-    private int scope;					// tag attribute
-    private boolean scopeSpecified;			// ... by tag attribute
-    private String var;					// tag attribute
+    private int scope;                    // tag attribute
+    private boolean scopeSpecified;            // ... by tag attribute
+    private String var;                    // tag attribute
 
 
     //*********************************************************************
@@ -51,6 +51,7 @@ public class RemoveTag extends TagSuppor
     }
 
     // resets local state
+
     private void init() {
         var = null;
         scope = PageContext.PAGE_SCOPE;
@@ -58,6 +59,7 @@ public class RemoveTag extends TagSuppor
     }
 
     // Releases any resources we may have (or inherit)
+
     @Override
     public void release() {
         super.release();
@@ -69,13 +71,15 @@ public class RemoveTag extends TagSuppor
     // Tag logic
 
     // removes the variable (from a specific scope, if specified)
+
     @Override
     public int doEndTag() throws JspException {
-        if (!scopeSpecified)
+        if (!scopeSpecified) {
             pageContext.removeAttribute(var);
-        else
+        } else {
             pageContext.removeAttribute(var, scope);
-	return EVAL_PAGE;
+        }
+        return EVAL_PAGE;
     }
 
 
@@ -83,13 +87,15 @@ public class RemoveTag extends TagSuppor
     // Accessor methods
 
     // for tag attribute
+
     public void setVar(String var) {
-	this.var = var;
+        this.var = var;
     }
 
     // for tag attribute
+
     public void setScope(String scope) {
         this.scope = Util.getScope(scope);
-	scopeSpecified = true;
+        scopeSpecified = true;
     }
 }

Modified: tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/SetSupport.java
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/SetSupport.java?rev=1037279&r1=1037278&r2=1037279&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/SetSupport.java (original)
+++ tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/SetSupport.java Sat Nov 20 17:57:45 2010
@@ -13,31 +13,27 @@
  * 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.taglibs.standard.tag.common.core;
 
 import java.beans.IntrospectionException;
 import java.beans.Introspector;
 import java.beans.PropertyDescriptor;
-
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-
 import java.util.Map;
 
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ExpressionFactory;
+import javax.el.ValueExpression;
+import javax.el.VariableMapper;
 import javax.servlet.jsp.JspApplicationContext;
 import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.JspFactory;
 import javax.servlet.jsp.JspTagException;
 import javax.servlet.jsp.PageContext;
-
-import javax.el.ELException;
-import javax.el.ELContext;
-import javax.el.ValueExpression;
-import javax.el.VariableMapper;
-import javax.el.ExpressionFactory;
-
 import javax.servlet.jsp.tagext.BodyTagSupport;
 
 import org.apache.taglibs.standard.resources.Resources;
@@ -68,6 +64,7 @@ public abstract class SetSupport extends
     }
 
     // Releases any resources we may have (or inherit)
+
     @Override
     public void release() {
         var = null;
@@ -172,7 +169,7 @@ public abstract class SetSupport extends
                 if (scopeValue != PageContext.PAGE_SCOPE) {
                     throw new JspTagException(Resources.getMessage("SET_BAD_DEFERRED_SCOPE", scope));
                 }
-                vm.setVariable(var, (ValueExpression)result);
+                vm.setVariable(var, (ValueExpression) result);
             } else {
                 // make sure to remove it from the VariableMapper if we will be setting into page scope
                 if (scopeValue == PageContext.PAGE_SCOPE && vm.resolveVariable(var) != null) {
@@ -182,7 +179,7 @@ public abstract class SetSupport extends
             }
         } else {
             //make sure to remove it from the Var mapper
-            if (vm.resolveVariable(var)!=null) {
+            if (vm.resolveVariable(var) != null) {
                 vm.setVariable(var, null);
             }
             if (scope != null) {
@@ -196,9 +193,9 @@ public abstract class SetSupport extends
     /**
      * Export the result into a Map.
      *
-     * @param target the Map to export into
+     * @param target   the Map to export into
      * @param property the key to export into
-     * @param result the value to export
+     * @param result   the value to export
      */
     void exportToMapProperty(Object target, String property, Object result) {
         @SuppressWarnings("unchecked")
@@ -213,9 +210,9 @@ public abstract class SetSupport extends
     /**
      * Export the result into a bean property.
      *
-     * @param target the bean to export into
+     * @param target   the bean to export into
      * @param property the bean property to set
-     * @param result the value to export
+     * @param result   the value to export
      * @throws JspTagException if there was a problem exporting the result
      */
     void exportToBeanProperty(Object target, String property, Object result) throws JspTagException {
@@ -252,7 +249,7 @@ public abstract class SetSupport extends
      * rules of the Expression Language.
      *
      * @param value the value to convert
-     * @param m the setter method
+     * @param m     the setter method
      * @return value converted to an instance of the expected type; will be null if value was null
      * @throws javax.el.ELException if there was a problem coercing the value
      */

Modified: tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/UrlSupport.java
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/UrlSupport.java?rev=1037279&r1=1037278&r2=1037279&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/UrlSupport.java (original)
+++ tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/UrlSupport.java Sat Nov 20 17:57:45 2010
@@ -13,7 +13,7 @@
  * 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.taglibs.standard.tag.common.core;
 
@@ -34,38 +34,38 @@ import org.apache.taglibs.standard.resou
  */
 
 public abstract class UrlSupport extends BodyTagSupport
-    implements ParamParent {
+        implements ParamParent {
 
     //*********************************************************************
     // Protected state
 
     protected String value;                      // 'value' attribute
-    protected String context;			 // 'context' attribute
+    protected String context;             // 'context' attribute
 
     //*********************************************************************
     // Private state
 
     private String var;                          // 'var' attribute
-    private int scope;				 // processed 'scope' attr
-    private ParamSupport.ParamManager params;	 // added parameters
+    private int scope;                 // processed 'scope' attr
+    private ParamSupport.ParamManager params;     // added parameters
 
     //*********************************************************************
     // Constructor and initialization
 
     public UrlSupport() {
-	super();
-	init();
+        super();
+        init();
     }
 
     private void init() {
-	value = var = null;
-	params = null;
-	context = null;
-	scope = PageContext.PAGE_SCOPE;
+        value = var = null;
+        params = null;
+        context = null;
+        scope = PageContext.PAGE_SCOPE;
     }
 
 
-   //*********************************************************************
+    //*********************************************************************
     // Tag attributes known at translation time
 
     public void setVar(String var) {
@@ -73,7 +73,7 @@ public abstract class UrlSupport extends
     }
 
     public void setScope(String scope) {
-	this.scope = Util.getScope(scope);
+        this.scope = Util.getScope(scope);
     }
 
 
@@ -81,8 +81,9 @@ public abstract class UrlSupport extends
     // Collaboration with subtags
 
     // inherit Javadoc
+
     public void addParameter(String name, String value) {
-	params.addParameter(name, value);
+        params.addParameter(name, value);
     }
 
 
@@ -90,47 +91,50 @@ public abstract class UrlSupport extends
     // Tag logic
 
     // resets any parameters that might be sent
+
     @Override
     public int doStartTag() throws JspException {
-	params = new ParamSupport.ParamManager();
-	return EVAL_BODY_BUFFERED;
+        params = new ParamSupport.ParamManager();
+        return EVAL_BODY_BUFFERED;
     }
 
 
     // gets the right value, encodes it, and prints or stores it
+
     @Override
     public int doEndTag() throws JspException {
-	String result;				// the eventual result
+        String result;                // the eventual result
 
-	// add (already encoded) parameters
-	String baseUrl = resolveUrl(value, context, pageContext);
-	result = params.aggregateParams(baseUrl);
-
-	// if the URL is relative, rewrite it
-	if (!ImportSupport.isAbsoluteUrl(result)) {
-	    HttpServletResponse response =
-                ((HttpServletResponse) pageContext.getResponse());
+        // add (already encoded) parameters
+        String baseUrl = resolveUrl(value, context, pageContext);
+        result = params.aggregateParams(baseUrl);
+
+        // if the URL is relative, rewrite it
+        if (!ImportSupport.isAbsoluteUrl(result)) {
+            HttpServletResponse response =
+                    ((HttpServletResponse) pageContext.getResponse());
             result = response.encodeURL(result);
-	}
+        }
 
-	// store or print the output
-	if (var != null)
-	    pageContext.setAttribute(var, result, scope);
-	else {
-	    try {
-	        pageContext.getOut().print(result);
-	    } catch (java.io.IOException ex) {
-		throw new JspTagException(ex.toString(), ex);
-	    }
-	}
+        // store or print the output
+        if (var != null) {
+            pageContext.setAttribute(var, result, scope);
+        } else {
+            try {
+                pageContext.getOut().print(result);
+            } catch (java.io.IOException ex) {
+                throw new JspTagException(ex.toString(), ex);
+            }
+        }
 
-	return EVAL_PAGE;
+        return EVAL_PAGE;
     }
 
     // Releases any resources we may have (or inherit)
+
     @Override
     public void release() {
-	init();
+        init();
     }
 
     //*********************************************************************
@@ -138,23 +142,25 @@ public abstract class UrlSupport extends
 
     public static String resolveUrl(
             String url, String context, PageContext pageContext)
-	    throws JspException {
-	// don't touch absolute URLs
-	if (ImportSupport.isAbsoluteUrl(url))
-	    return url;
-
-	// normalize relative URLs against a context root
-	HttpServletRequest request =
-	    (HttpServletRequest) pageContext.getRequest();
-	if (context == null) {
-	    if (url.startsWith("/"))
-		return (request.getContextPath() + url);
-	    else
-		return url;
-	} else {
+            throws JspException {
+        // don't touch absolute URLs
+        if (ImportSupport.isAbsoluteUrl(url)) {
+            return url;
+        }
+
+        // normalize relative URLs against a context root
+        HttpServletRequest request =
+                (HttpServletRequest) pageContext.getRequest();
+        if (context == null) {
+            if (url.startsWith("/")) {
+                return (request.getContextPath() + url);
+            } else {
+                return url;
+            }
+        } else {
             if (!context.startsWith("/") || !url.startsWith("/")) {
                 throw new JspTagException(
-                    Resources.getMessage("IMPORT_BAD_RELATIVE"));
+                        Resources.getMessage("IMPORT_BAD_RELATIVE"));
             }
             if (context.endsWith("/") && url.startsWith("/")) {
                 // Don't produce string starting with '//', many

Modified: tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/Util.java
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/Util.java?rev=1037279&r1=1037278&r2=1037279&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/Util.java (original)
+++ tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/Util.java Sat Nov 20 17:57:45 2010
@@ -13,7 +13,7 @@
  * 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.taglibs.standard.tag.common.core;
 
@@ -34,9 +34,9 @@ import org.apache.taglibs.standard.resou
  */
 public class Util {
 
-    private static final String REQUEST = "request";   
-    private static final String SESSION = "session";   
-    private static final String APPLICATION = "application"; 
+    private static final String REQUEST = "request";
+    private static final String SESSION = "session";
+    private static final String APPLICATION = "application";
     private static final String DEFAULT = "default";
     private static final String SHORT = "short";
     private static final String MEDIUM = "medium";
@@ -54,17 +54,19 @@ public class Util {
      *
      * @return PageContext constant corresponding to given scope description
      */
+
     public static int getScope(String scope) {
-	int ret = PageContext.PAGE_SCOPE; // default
+        int ret = PageContext.PAGE_SCOPE; // default
 
-	if (REQUEST.equalsIgnoreCase(scope))
-	    ret = PageContext.REQUEST_SCOPE;
-	else if (SESSION.equalsIgnoreCase(scope))
-	    ret = PageContext.SESSION_SCOPE;
-	else if (APPLICATION.equalsIgnoreCase(scope))
-	    ret = PageContext.APPLICATION_SCOPE;
+        if (REQUEST.equalsIgnoreCase(scope)) {
+            ret = PageContext.REQUEST_SCOPE;
+        } else if (SESSION.equalsIgnoreCase(scope)) {
+            ret = PageContext.SESSION_SCOPE;
+        } else if (APPLICATION.equalsIgnoreCase(scope)) {
+            ret = PageContext.APPLICATION_SCOPE;
+        }
 
-	return ret;
+        return ret;
     }
 
     /*
@@ -78,27 +80,28 @@ public class Util {
      *
      * @throws JspException if the given style is invalid
      */
+
     public static int getStyle(String style, String errCode)
-	                throws JspException {
-	int ret = DateFormat.DEFAULT;
+            throws JspException {
+        int ret = DateFormat.DEFAULT;
 
-	if (style != null) {
-	    if (DEFAULT.equalsIgnoreCase(style)) {
-		ret = DateFormat.DEFAULT;
-	    } else if (SHORT.equalsIgnoreCase(style)) {
-		ret = DateFormat.SHORT;
-	    } else if (MEDIUM.equalsIgnoreCase(style)) {
-		ret = DateFormat.MEDIUM;
-	    } else if (LONG.equalsIgnoreCase(style)) {
-		ret = DateFormat.LONG;
-	    } else if (FULL.equalsIgnoreCase(style)) {
-		ret = DateFormat.FULL;
-	    } else {
-		throw new JspException(Resources.getMessage(errCode, style));
-	    }
-	}
+        if (style != null) {
+            if (DEFAULT.equalsIgnoreCase(style)) {
+                ret = DateFormat.DEFAULT;
+            } else if (SHORT.equalsIgnoreCase(style)) {
+                ret = DateFormat.SHORT;
+            } else if (MEDIUM.equalsIgnoreCase(style)) {
+                ret = DateFormat.MEDIUM;
+            } else if (LONG.equalsIgnoreCase(style)) {
+                ret = DateFormat.LONG;
+            } else if (FULL.equalsIgnoreCase(style)) {
+                ret = DateFormat.FULL;
+            } else {
+                throw new JspException(Resources.getMessage(errCode, style));
+            }
+        }
 
-	return ret;
+        return ret;
     }
 
 
@@ -107,48 +110,57 @@ public class Util {
      * Syntax defined in RFC 2045, section 5.1.
      */
     public static String getContentTypeAttribute(String input, String name) {
-	int begin;
-	int end;
+        int begin;
+        int end;
         int index = input.toUpperCase().indexOf(name.toUpperCase());
-        if (index == -1) return null;
+        if (index == -1) {
+            return null;
+        }
         index = index + name.length(); // positioned after the attribute name
         index = input.indexOf('=', index); // positioned at the '='
-        if (index == -1) return null;
+        if (index == -1) {
+            return null;
+        }
         index += 1; // positioned after the '='
         input = input.substring(index).trim();
-        
+
         if (input.charAt(0) == '"') {
             // attribute value is a quoted string
             begin = 1;
             end = input.indexOf('"', begin);
-            if (end == -1) return null;
+            if (end == -1) {
+                return null;
+            }
         } else {
             begin = 0;
             end = input.indexOf(';');
-            if (end == -1) end = input.indexOf(' ');
-            if (end == -1) end = input.length();
+            if (end == -1) {
+                end = input.indexOf(' ');
+            }
+            if (end == -1) {
+                end = input.length();
+            }
         }
         return input.substring(begin, end).trim();
     }
 
     /**
-     * HttpServletRequest.getLocales() returns the server's default locale 
+     * HttpServletRequest.getLocales() returns the server's default locale
      * if the request did not specify a preferred language.
      * We do not want this behavior, because it prevents us from using
-     * the fallback locale. 
-     * We therefore need to return an empty Enumeration if no preferred 
-     * locale has been specified. This way, the logic for the fallback 
+     * the fallback locale.
+     * We therefore need to return an empty Enumeration if no preferred
+     * locale has been specified. This way, the logic for the fallback
      * locale will be able to kick in.
      */
-    public static Enumeration getRequestLocales(HttpServletRequest request) {        
+    public static Enumeration getRequestLocales(HttpServletRequest request) {
         Enumeration values = request.getHeaders("accept-language");
         if (values == null) {
             // No header for "accept-language". Simply return
             // a new empty enumeration.
             // System.out.println("Null accept-language");
             return new Vector().elements();
-        } else
-        if (values.hasMoreElements()) {
+        } else if (values.hasMoreElements()) {
             // At least one "accept-language". Simply return
             // the enumeration returned by request.getLocales().
             // System.out.println("At least one accept-language");

Modified: tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/WhenTagSupport.java
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/WhenTagSupport.java?rev=1037279&r1=1037278&r2=1037279&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/WhenTagSupport.java (original)
+++ tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/core/WhenTagSupport.java Sat Nov 20 17:57:45 2010
@@ -13,7 +13,7 @@
  * 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.taglibs.standard.tag.common.core;
 
@@ -29,18 +29,17 @@ import org.apache.taglibs.standard.resou
  * implementation of &lt;when&gt;-style tags in both the rtexprvalue
  * and expression-evaluating libraries.  It also supports
  * &lt;otherwise&gt;.</p>
- *
+ * <p/>
  * <p>In particular, this base class does the following:</p>
- * 
+ * <p/>
  * <ul>
- *  <li> overrides ConditionalTagSupport.doStartTag() to implement the
- *       appropriate semantics of subtags of &lt;choose&gt; </li>
+ * <li> overrides ConditionalTagSupport.doStartTag() to implement the
+ * appropriate semantics of subtags of &lt;choose&gt; </li>
  * </ul>
  *
  * @author Shawn Bayern
  */
-public abstract class WhenTagSupport extends ConditionalTagSupport
-{
+public abstract class WhenTagSupport extends ConditionalTagSupport {
     //*********************************************************************
     // Implementation of exclusive-conditional behavior
 
@@ -49,25 +48,29 @@ public abstract class WhenTagSupport ext
      * ChooseTag wants it to do so.  The condition will not even be
      * evaluated if ChooseTag instructs us not to run.
      */
+
     @Override
     public int doStartTag() throws JspException {
 
         Tag parent;
 
         // make sure we're contained properly
-        if (!((parent = getParent()) instanceof ChooseTag))
+        if (!((parent = getParent()) instanceof ChooseTag)) {
             throw new JspTagException(
-		Resources.getMessage("WHEN_OUTSIDE_CHOOSE"));
+                    Resources.getMessage("WHEN_OUTSIDE_CHOOSE"));
+        }
 
         // make sure our parent wants us to continue
-        if (!((ChooseTag) parent).gainPermission())
-            return SKIP_BODY;                   // we've been reeled in
+        if (!((ChooseTag) parent).gainPermission()) {
+            return SKIP_BODY;
+        }                   // we've been reeled in
 
         // handle conditional behavior
         if (condition()) {
             ((ChooseTag) parent).subtagSucceeded();
             return EVAL_BODY_INCLUDE;
-        } else
+        } else {
             return SKIP_BODY;
+        }
     }
 }

Modified: tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/fmt/BundleSupport.java
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/fmt/BundleSupport.java?rev=1037279&r1=1037278&r2=1037279&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/fmt/BundleSupport.java (original)
+++ tomcat/taglibs/standard/trunk/impl/src/main/java/org/apache/taglibs/standard/tag/common/fmt/BundleSupport.java Sat Nov 20 17:57:45 2010
@@ -13,7 +13,7 @@
  * 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.taglibs.standard.tag.common.fmt;
 
@@ -41,7 +41,7 @@ import org.apache.taglibs.standard.tag.c
  */
 
 public abstract class BundleSupport extends BodyTagSupport {
-    
+
 
     //*********************************************************************
     // Private constants
@@ -67,25 +67,25 @@ public abstract class BundleSupport exte
     // Constructor and initialization
 
     public BundleSupport() {
-	super();
-	init();
+        super();
+        init();
     }
 
     private void init() {
-	basename = prefix = null;
-	locCtxt = null;
+        basename = prefix = null;
+        locCtxt = null;
     }
 
-    
+
     //*********************************************************************
     // Collaboration with subtags
 
     public LocalizationContext getLocalizationContext() {
-	return locCtxt;
+        return locCtxt;
     }
 
     public String getPrefix() {
-	return prefix;
+        return prefix;
     }
 
 
@@ -94,28 +94,29 @@ public abstract class BundleSupport exte
 
     @Override
     public int doStartTag() throws JspException {
-	locCtxt = getLocalizationContext(pageContext, basename);
-	return EVAL_BODY_BUFFERED;
+        locCtxt = getLocalizationContext(pageContext, basename);
+        return EVAL_BODY_BUFFERED;
     }
 
     @Override
     public int doEndTag() throws JspException {
-	if (bodyContent != null) {
-	    try {
-		pageContext.getOut().print(bodyContent.getString());
-	    } catch (IOException ioe) {
-		throw new JspTagException(ioe.toString(), ioe);
-	    }
-	}
+        if (bodyContent != null) {
+            try {
+                pageContext.getOut().print(bodyContent.getString());
+            } catch (IOException ioe) {
+                throw new JspTagException(ioe.toString(), ioe);
+            }
+        }
 
-	return EVAL_PAGE;
+        return EVAL_PAGE;
     }
 
     // Releases any resources we may have (or inherit)
+
     @Override
     public void release() {
         super.release();
-    	init();
+        init();
     }
 
 
@@ -126,142 +127,142 @@ public abstract class BundleSupport exte
      * Gets the default I18N localization context.
      *
      * @param pc Page in which to look up the default I18N localization context
-     */    
+     */
     public static LocalizationContext getLocalizationContext(PageContext pc) {
-	LocalizationContext locCtxt = null;
+        LocalizationContext locCtxt = null;
+
+        Object obj = Config.find(pc, Config.FMT_LOCALIZATION_CONTEXT);
+        if (obj == null) {
+            return null;
+        }
 
-	Object obj = Config.find(pc, Config.FMT_LOCALIZATION_CONTEXT);
-	if (obj == null) {
-	    return null;
-	}
-
-	if (obj instanceof LocalizationContext) {
-	    locCtxt = (LocalizationContext) obj;
-	} else {
-	    // localization context is a bundle basename
-	    locCtxt = getLocalizationContext(pc, (String) obj);
-	}
+        if (obj instanceof LocalizationContext) {
+            locCtxt = (LocalizationContext) obj;
+        } else {
+            // localization context is a bundle basename
+            locCtxt = getLocalizationContext(pc, (String) obj);
+        }
 
-	return locCtxt;
+        return locCtxt;
     }
 
     /**
      * Gets the resource bundle with the given base name, whose locale is
      * determined as follows:
-     *
+     * <p/>
      * Check if a match exists between the ordered set of preferred
      * locales and the available locales, for the given base name.
      * The set of preferred locales consists of a single locale
      * (if the <tt>javax.servlet.jsp.jstl.fmt.locale</tt> configuration
      * setting is present) or is equal to the client's preferred locales
      * determined from the client's browser settings.
-     *
+     * <p/>
      * <p> If no match was found in the previous step, check if a match
      * exists between the fallback locale (given by the
      * <tt>javax.servlet.jsp.jstl.fmt.fallbackLocale</tt> configuration
      * setting) and the available locales, for the given base name.
      *
-     * @param pc Page in which the resource bundle with the
-     * given base name is requested
+     * @param pc       Page in which the resource bundle with the
+     *                 given base name is requested
      * @param basename Resource bundle base name
-     *
      * @return Localization context containing the resource bundle with the
-     * given base name and the locale that led to the resource bundle match,
-     * or the empty localization context if no resource bundle match was found
+     *         given base name and the locale that led to the resource bundle match,
+     *         or the empty localization context if no resource bundle match was found
      */
     public static LocalizationContext getLocalizationContext(PageContext pc,
-							     String basename) {
-	LocalizationContext locCtxt = null;
-	ResourceBundle bundle = null;
-
-	if ((basename == null) || basename.equals("")) {
-	    return new LocalizationContext();
-	}
-
-	// Try preferred locales
-	Locale pref = SetLocaleSupport.getLocale(pc, Config.FMT_LOCALE);
-	if (pref != null) {
-	    // Preferred locale is application-based
-	    bundle = findMatch(basename, pref);
-	    if (bundle != null) {
-		locCtxt = new LocalizationContext(bundle, pref);
-	    }
-	} else {
-	    // Preferred locales are browser-based
-	    locCtxt = findMatch(pc, basename);
-	}
-	
-	if (locCtxt == null) {
-	    // No match found with preferred locales, try using fallback locale
-	    pref = SetLocaleSupport.getLocale(pc, Config.FMT_FALLBACK_LOCALE);
-	    if (pref != null) {
-		bundle = findMatch(basename, pref);
-		if (bundle != null) {
-		    locCtxt = new LocalizationContext(bundle, pref);
-		}
-	    }
-	}
-
-	if (locCtxt == null) {
-	    // try using the root resource bundle with the given basename
-	    try {
-	        ClassLoader cl = getClassLoaderCheckingPrivilege();
-            bundle = ResourceBundle.getBundle(basename, EMPTY_LOCALE, cl);
-		if (bundle != null) {
-		    locCtxt = new LocalizationContext(bundle, null);
-		}
-	    } catch (MissingResourceException mre) {
-		// do nothing
-	    }
-	}
-		 
-	if (locCtxt != null) {
-	    // set response locale
-	    if (locCtxt.getLocale() != null) {
-		SetLocaleSupport.setResponseLocale(pc, locCtxt.getLocale());
-	    }
-	} else {
-	    // create empty localization context
-	    locCtxt = new LocalizationContext();
-	}
+                                                             String basename) {
+        LocalizationContext locCtxt = null;
+        ResourceBundle bundle = null;
+
+        if ((basename == null) || basename.equals("")) {
+            return new LocalizationContext();
+        }
 
-	return locCtxt;
+        // Try preferred locales
+        Locale pref = SetLocaleSupport.getLocale(pc, Config.FMT_LOCALE);
+        if (pref != null) {
+            // Preferred locale is application-based
+            bundle = findMatch(basename, pref);
+            if (bundle != null) {
+                locCtxt = new LocalizationContext(bundle, pref);
+            }
+        } else {
+            // Preferred locales are browser-based
+            locCtxt = findMatch(pc, basename);
+        }
+
+        if (locCtxt == null) {
+            // No match found with preferred locales, try using fallback locale
+            pref = SetLocaleSupport.getLocale(pc, Config.FMT_FALLBACK_LOCALE);
+            if (pref != null) {
+                bundle = findMatch(basename, pref);
+                if (bundle != null) {
+                    locCtxt = new LocalizationContext(bundle, pref);
+                }
+            }
+        }
+
+        if (locCtxt == null) {
+            // try using the root resource bundle with the given basename
+            try {
+                ClassLoader cl = getClassLoaderCheckingPrivilege();
+                bundle = ResourceBundle.getBundle(basename, EMPTY_LOCALE, cl);
+                if (bundle != null) {
+                    locCtxt = new LocalizationContext(bundle, null);
+                }
+            } catch (MissingResourceException mre) {
+                // do nothing
+            }
+        }
+
+        if (locCtxt != null) {
+            // set response locale
+            if (locCtxt.getLocale() != null) {
+                SetLocaleSupport.setResponseLocale(pc, locCtxt.getLocale());
+            }
+        } else {
+            // create empty localization context
+            locCtxt = new LocalizationContext();
+        }
+
+        return locCtxt;
     }
 
 
     //*********************************************************************
     // Private utility methods
-    
+
     /*
-     * Determines the client's preferred locales from the request, and compares
-     * each of the locales (in order of preference) against the available
-     * locales in order to determine the best matching locale.
-     *
-     * @param pageContext the page in which the resource bundle with the
-     * given base name is requested
-     * @param basename the resource bundle's base name
-     *
-     * @return the localization context containing the resource bundle with
-     * the given base name and best matching locale, or <tt>null</tt> if no
-     * resource bundle match was found
-     */
+    * Determines the client's preferred locales from the request, and compares
+    * each of the locales (in order of preference) against the available
+    * locales in order to determine the best matching locale.
+    *
+    * @param pageContext the page in which the resource bundle with the
+    * given base name is requested
+    * @param basename the resource bundle's base name
+    *
+    * @return the localization context containing the resource bundle with
+    * the given base name and best matching locale, or <tt>null</tt> if no
+    * resource bundle match was found
+    */
+
     private static LocalizationContext findMatch(PageContext pageContext,
-						 String basename) {
-	LocalizationContext locCtxt = null;
-	
-	// Determine locale from client's browser settings.
-        
-	for (Enumeration enum_ = Util.getRequestLocales((HttpServletRequest)pageContext.getRequest());
-	     enum_.hasMoreElements(); ) {
-	    Locale pref = (Locale) enum_.nextElement();
-	    ResourceBundle match = findMatch(basename, pref);
-	    if (match != null) {
-		locCtxt = new LocalizationContext(match, pref);
-		break;
-	    }
-	}
-        	
-	return locCtxt;
+                                                 String basename) {
+        LocalizationContext locCtxt = null;
+
+        // Determine locale from client's browser settings.
+
+        for (Enumeration enum_ = Util.getRequestLocales((HttpServletRequest) pageContext.getRequest());
+             enum_.hasMoreElements();) {
+            Locale pref = (Locale) enum_.nextElement();
+            ResourceBundle match = findMatch(basename, pref);
+            if (match != null) {
+                locCtxt = new LocalizationContext(match, pref);
+                break;
+            }
+        }
+
+        return locCtxt;
     }
 
     /*
@@ -279,17 +280,18 @@ public abstract class BundleSupport exte
      * language-match between the preferred locale and the locale of
      * the bundle returned by java.util.ResourceBundle.getBundle().
      */
+
     private static ResourceBundle findMatch(String basename, Locale pref) {
-	ResourceBundle match = null;
+        ResourceBundle match = null;
 
-	try {
-	    ClassLoader cl = getClassLoaderCheckingPrivilege();
-        ResourceBundle bundle = ResourceBundle.getBundle(basename, pref, cl);
-	    Locale avail = bundle.getLocale();
-	    if (pref.equals(avail)) {
-		// Exact match
-		match = bundle;
-	    } else {
+        try {
+            ClassLoader cl = getClassLoaderCheckingPrivilege();
+            ResourceBundle bundle = ResourceBundle.getBundle(basename, pref, cl);
+            Locale avail = bundle.getLocale();
+            if (pref.equals(avail)) {
+                // Exact match
+                match = bundle;
+            } else {
                 /*
                  * We have to make sure that the match we got is for
                  * the specified locale. The way ResourceBundle.getBundle()
@@ -303,33 +305,33 @@ public abstract class BundleSupport exte
                  *     - avail locale must be equal to preferred locale
                  *     - avail country must be empty or equal to preferred country
                  *       (the equality match might have failed on the variant)
-		 */
+                 */
                 if (pref.getLanguage().equals(avail.getLanguage())
-		    && ("".equals(avail.getCountry()) || pref.getCountry().equals(avail.getCountry()))) {
-		    /*
-		     * Language match.
-		     * By making sure the available locale does not have a 
-		     * country and matches the preferred locale's language, we
-		     * rule out "matches" based on the container's default
-		     * locale. For example, if the preferred locale is 
-		     * "en-US", the container's default locale is "en-UK", and
-		     * there is a resource bundle (with the requested base
-		     * name) available for "en-UK", ResourceBundle.getBundle()
-		     * will return it, but even though its language matches
-		     * that of the preferred locale, we must ignore it,
-		     * because matches based on the container's default locale
-		     * are not portable across different containers with
-		     * different default locales.
-		     */
-		    match = bundle;
-		}
-	    }
-	} catch (MissingResourceException mre) {
-	}
+                        && ("".equals(avail.getCountry()) || pref.getCountry().equals(avail.getCountry()))) {
+                    /*
+                  * Language match.
+                  * By making sure the available locale does not have a
+                  * country and matches the preferred locale's language, we
+                  * rule out "matches" based on the container's default
+                  * locale. For example, if the preferred locale is
+                  * "en-US", the container's default locale is "en-UK", and
+                  * there is a resource bundle (with the requested base
+                  * name) available for "en-UK", ResourceBundle.getBundle()
+                  * will return it, but even though its language matches
+                  * that of the preferred locale, we must ignore it,
+                  * because matches based on the container's default locale
+                  * are not portable across different containers with
+                  * different default locales.
+                  */
+                    match = bundle;
+                }
+            }
+        } catch (MissingResourceException mre) {
+        }
 
-	return match;
+        return match;
     }
-    
+
     private static ClassLoader getClassLoaderCheckingPrivilege() {
         ClassLoader cl;
         SecurityManager sm = System.getSecurityManager();
@@ -337,8 +339,11 @@ public abstract class BundleSupport exte
             cl = Thread.currentThread().getContextClassLoader();
         } else {
             cl = java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedAction<ClassLoader>() 
-                {public ClassLoader run() {return Thread.currentThread().getContextClassLoader();}});
+                    new java.security.PrivilegedAction<ClassLoader>() {
+                        public ClassLoader run() {
+                            return Thread.currentThread().getContextClassLoader();
+                        }
+                    });
         }
         return cl;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message