Source code: com/sitemesh/mapper/DefaultDecorator.java
1 package com.sitemesh.mapper;
2
3 import java.util.Map;
4 import com.sitemesh.Decorator;
5
6 /**
7 * Default implementation of Decorator. All properties are set by the
8 * constructor.
9 *
10 * @author <a href="mailto:joe@truemesh.com">Joe Walnes</a>
11 * @version $Revision: 1.5 $
12 *
13 * @see com.sitemesh.Decorator
14 * @see com.sitemesh.mapper.DefaultDecoratorMapper
15 */
16 public class DefaultDecorator implements Decorator {
17
18 /**
19 * @see #getPage()
20 */
21 protected String page;
22
23 /**
24 * @see #getName()
25 */
26 protected String name;
27
28 /**
29 * @see #getInitParam(java.lang.String)
30 */
31 protected Map parameters;
32
33 /**
34 * Constructor to set all properties.
35 */
36 public DefaultDecorator( String name, String page, Map parameters ) {
37 this.name = name;
38 this.page = page;
39 this.parameters = parameters;
40 }
41
42 /**
43 * URI of Servlet/JSP to dispatch request to (relative to
44 * web-app context).
45 */
46 public String getPage() {
47 return page;
48 }
49
50 /**
51 * Name of Decorator. For information purposes only.
52 */
53 public String getName() {
54 return name;
55 }
56
57 /**
58 * Return init parameter of Decorator.
59 *
60 * @param paramName Key of parameter.
61 * @return Value of parameter or null if not found.
62 */
63 public String getInitParam( String paramName ) {
64 if ( parameters == null ) return null;
65 if ( !parameters.containsKey( name ) ) return null;
66 return ( String )parameters.get( name );
67 }
68
69 }