Re: svn commit: r480849 -
technically, it would be an empty map not empty list, but even so, i'm not sure about this. if we can say for sure that no one (especially us) will ever want to tell the difference between an empty toolbox and no toolbox being set, then it would be marginally simpler to ensure that toolbox is never null. at this point, it's not a great burden to always test for the toolbox's presence and potentially provides more a more useful interface. in other words, i'll think about this... On 11/30/06, Henning P. Schmiedehausen [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] writes: +public Map getToolbox() +{ +if (this.toolbox != null) +{ +return Collections.unmodifiableMap(this.toolbox); +} Wouldn't it be better (and probably remove a lot of these tests) to make sure that the toolbox can never be null (but contains an empty List?). +return null; } I'd prefer Collections.EMPTY_LIST. Removes the necessity of always checking for null. Best regards Henning -- Henning P. Schmiedehausen -- [EMAIL PROTECTED] | J2EE, Linux, 91054 Buckenhof, Germany -- +49 9131 506540 | Apache person Open Source Consulting, Development, Design | Velocity - Turbine guy Save the cheerleader. Save the world. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r480849 - /jakarta/velocity/tools/trunk/src/java/org/apache/velocity/tools/view/context/ChainedContext.java
Author: nbubna Date: Wed Nov 29 22:19:04 2006 New Revision: 480849 URL: http://svn.apache.org/viewvc?view=revrev=480849 Log: add getToolbox() for read-only access to the context's tools Modified: jakarta/velocity/tools/trunk/src/java/org/apache/velocity/tools/view/context/ChainedContext.java Modified: jakarta/velocity/tools/trunk/src/java/org/apache/velocity/tools/view/context/ChainedContext.java URL: http://svn.apache.org/viewvc/jakarta/velocity/tools/trunk/src/java/org/apache/velocity/tools/view/context/ChainedContext.java?view=diffrev=480849r1=480848r2=480849 == --- jakarta/velocity/tools/trunk/src/java/org/apache/velocity/tools/view/context/ChainedContext.java (original) +++ jakarta/velocity/tools/trunk/src/java/org/apache/velocity/tools/view/context/ChainedContext.java Wed Nov 29 22:19:04 2006 @@ -19,6 +19,7 @@ * under the License. */ +import java.util.Collections; import java.util.Map; import javax.servlet.http.HttpServletRequest; @@ -130,6 +131,22 @@ * had to create a new session to hold session tools * let's make sure this context's session ref is current */ this.session = request.getSession(false); +} + +/** + * pReturns a read-only view of the toolbox [EMAIL PROTECTED] Map} + * for this context./p + * @since VelocityTools 1.3 + * @return an unmodifiable version of the toolbox for this request + * or [EMAIL PROTECTED] null} if there is none + */ +public Map getToolbox() +{ +if (this.toolbox != null) +{ +return Collections.unmodifiableMap(this.toolbox); +} +return null; } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]