1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
/* * Title: DefaultDecorator * Description: * * This software is published under the terms of the OpenSymphony Software * License version 1.1, of which a copy has been included with this * distribution in the LICENSE.txt file. */ package com.opensymphony.module.sitemesh.mapper; import com.opensymphony.module.sitemesh.Decorator; import java.util.Map; import java.util.Iterator; import java.util.Collections; /** * Default implementation of Decorator. All properties are set by the * constructor. * * @author <a href="mailto:joe@truemesh.com">Joe Walnes</a> * @version $Revision: 1.1 $ * * @see com.opensymphony.module.sitemesh.Decorator */ public class DefaultDecorator implements Decorator { /** @see #getPage() */ protected String page = null; /** @see #getName() */ protected String name = null; /** @see #getURIPath() */ protected String uriPath = null; /** @see #getRole() */ protected String role = null; /** @see #getInitParameter(java.lang.String) */ protected Map parameters = null; /** Constructor to set name, page and parameters. */ public DefaultDecorator(String name, String page, Map parameters) { this(name, page, null, null, parameters); } /** Constructor to set all properties. */ public DefaultDecorator(String name, String page, String uriPath, Map parameters) { this(name, page, uriPath, null, parameters); } /** Constructor to set all properties. */ public DefaultDecorator(String name, String page, String uriPath, String role, Map parameters) { this.name = name; this.page = page; this.uriPath = uriPath; this.role = role; this.parameters = parameters; } /** * URI of the Servlet/JSP to dispatch the request to (relative to the * web-app context). */ public String getPage() { return page; } /** Name of Decorator. For information purposes only. */ public String getName() { return name; } /** URI path of the Decorator. Enables support for decorators defined in seperate web-apps. */ public String getURIPath() { return uriPath; } /** Role the user has to be in to get this decorator applied. */ public String getRole() { return role; } /** * Returns a String containing the value of the named initialization parameter, * or null if the parameter does not exist. * * @param paramName Key of parameter. * @return Value of parameter or null if not found. */ public String getInitParameter(String paramName) { if (parameters == null || !parameters.containsKey(paramName)) { return null; } return (String) parameters.get(paramName); } /** * Returns the names of the Decorator's initialization parameters as an Iterator * of String objects, or an empty Iterator if the Decorator has no initialization parameters. */ public Iterator getInitParameterNames() { if (parameters == null) { // make sure we always return an empty iterator return Collections.EMPTY_MAP.keySet().iterator(); } return parameters.keySet().iterator(); } }