dgraham 2003/07/13 17:02:29 Modified: src/share/org/apache/struts/taglib/bean ResourceTag.java Log: Fixed formatting. Revision Changes Path 1.12 +39 -50 jakarta-struts/src/share/org/apache/struts/taglib/bean/ResourceTag.java Index: ResourceTag.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/ResourceTag.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- ResourceTag.java 22 Sep 2002 06:32:46 -0000 1.11 +++ ResourceTag.java 14 Jul 2003 00:02:29 -0000 1.12 @@ -7,7 +7,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999-2001 The Apache Software Foundation. All rights + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -59,20 +59,18 @@ * */ - package org.apache.struts.taglib.bean; - import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; + import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.TagSupport; + import org.apache.struts.util.MessageResources; import org.apache.struts.util.RequestUtils; - - /** * Define a scripting variable based on the contents of the specified * web application resource. @@ -80,19 +78,15 @@ * @author Craig R. McClanahan * @version $Revision$ $Date$ */ - public class ResourceTag extends TagSupport { - // ------------------------------------------------------------- Properties - /** * Buffer size to use when reading the input stream. */ protected static final int BUFFER_SIZE = 256; - /** * The name of the scripting variable that will be exposed as a page * scope attribute. @@ -107,7 +101,6 @@ this.id = id; } - /** * Return an InputStream to the specified resource if this is non-null. */ @@ -121,14 +114,12 @@ this.input = input; } - /** * The message resources for this package. */ protected static MessageResources messages = - MessageResources.getMessageResources - ("org.apache.struts.taglib.bean.LocalStrings"); - + MessageResources.getMessageResources( + "org.apache.struts.taglib.bean.LocalStrings"); /** * The module-relative URI of the resource whose contents are to @@ -144,10 +135,8 @@ this.name = name; } - // --------------------------------------------------------- Public Methods - /** * Retrieve the required property and expose it as a scripting variable. * @@ -157,45 +146,46 @@ // Acquire an input stream to the specified resource InputStream stream = - pageContext.getServletContext().getResourceAsStream(name); - if (stream == null) { - JspException e = new JspException - (messages.getMessage("resource.get", name)); + pageContext.getServletContext().getResourceAsStream(name); + + if (stream == null) { + JspException e = + new JspException(messages.getMessage("resource.get", name)); RequestUtils.saveException(pageContext, e); throw e; } - // If we are returning an InputStream, do so and return - if (input != null) { - pageContext.setAttribute(id, stream); - return (SKIP_BODY); - } - - // Accumulate the contents of this resource into a StringBuffer - try { - StringBuffer sb = new StringBuffer(); - InputStreamReader reader = - new InputStreamReader(stream); - char buffer[] = new char[BUFFER_SIZE]; - int n = 0; - while (true) { - n = reader.read(buffer); - if (n < 1) - break; - sb.append(buffer, 0, n); + // If we are returning an InputStream, do so and return + if (input != null) { + pageContext.setAttribute(id, stream); + return (SKIP_BODY); } - reader.close(); - pageContext.setAttribute(id, sb.toString()); - } catch (IOException e) { + + // Accumulate the contents of this resource into a StringBuffer + try { + StringBuffer sb = new StringBuffer(); + InputStreamReader reader = new InputStreamReader(stream); + char buffer[] = new char[BUFFER_SIZE]; + int n = 0; + while (true) { + n = reader.read(buffer); + if (n < 1) { + break; + } + sb.append(buffer, 0, n); + } + reader.close(); + pageContext.setAttribute(id, sb.toString()); + + } catch (IOException e) { RequestUtils.saveException(pageContext, e); - throw new JspException - (messages.getMessage("resource.get", name)); - } + throw new JspException(messages.getMessage("resource.get", name)); + } + return (SKIP_BODY); } - /** * Release all allocated resources. */ @@ -207,6 +197,5 @@ name = null; } - }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]