• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hazendaz / sitemesh2 / 59

22 Mar 2026 02:30AM UTC coverage: 40.347%. Remained the same
59

push

github

hazendaz
[mvn] Update maven wrapper

698 of 1891 branches covered (36.91%)

Branch coverage included in aggregate %.

1555 of 3693 relevant lines covered (42.11%)

0.42 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com/opensymphony/module/sitemesh/mapper/PageDecoratorMapper.java
1
/*
2
 * SPDX-License-Identifier: Apache-2.0
3
 * Copyright 2011-2026 Hazendaz
4
 */
5
/*
6
 * Title:        PageDecoratorMapper
7
 * Description:
8
 *
9
 * This software is published under the terms of the OpenSymphony Software
10
 * License version 1.1, of which a copy has been included with this
11
 * distribution in the LICENSE.txt file.
12
 */
13

14
package com.opensymphony.module.sitemesh.mapper;
15

16
import com.opensymphony.module.sitemesh.Config;
17
import com.opensymphony.module.sitemesh.Decorator;
18
import com.opensymphony.module.sitemesh.DecoratorMapper;
19
import com.opensymphony.module.sitemesh.Page;
20

21
import jakarta.servlet.http.HttpServletRequest;
22

23
import java.util.ArrayList;
24
import java.util.List;
25
import java.util.Map.Entry;
26
import java.util.Properties;
27

28
/**
29
 * The PageDecoratorMapper allows the actual Page to determine the Decorator to be used.
30
 * <p>
31
 * The 'meta.decorator' and 'decorator' properties of the page are accessed and if any of them contain the name of a
32
 * valid Decorator, that Decorator shall be applied.
33
 * <p>
34
 * As an example, if HTML is being used, the Decorator could be chosen by using a
35
 * <code>&lt;html decorator="mydecorator"&gt;</code> root tag <i>or</i> by using a
36
 * <code>&lt;meta name="decorator" content="mydecorator"&gt;</code> tag in the header.
37
 * <p>
38
 * The actual properties to query are specified by passing properties to the mapper using the <code>property.?</code>
39
 * prefix. As the properties are stored in a Map, each key has to be unique. Example: property.1=decorator,
40
 * property.2=meta.decorator .
41
 *
42
 * @author <a href="mailto:joe@truemesh.com">Joe Walnes</a>
43
 *
44
 * @see com.opensymphony.module.sitemesh.DecoratorMapper
45
 */
46
public class PageDecoratorMapper extends AbstractDecoratorMapper {
×
47

48
    /** The page props. */
49
    private List<String> pageProps;
50

51
    @Override
52
    public void init(Config config, Properties properties, DecoratorMapper parent) throws InstantiationException {
53
        super.init(config, properties, parent);
×
54
        pageProps = new ArrayList<>();
×
55
        for (Entry<Object, Object> entry : properties.entrySet()) {
×
56
            String key = (String) entry.getKey();
×
57
            if (key.startsWith("property")) {
×
58
                pageProps.add((String) entry.getValue());
×
59
            }
60
        }
×
61
    }
×
62

63
    @Override
64
    public Decorator getDecorator(HttpServletRequest request, Page page) {
65
        Decorator result = null;
×
66
        for (String entry : pageProps) {
×
67
            String propName = entry;
×
68
            result = getByProperty(request, page, propName);
×
69
            if (result != null) {
×
70
                break;
×
71
            }
72
        }
×
73
        return result == null ? super.getDecorator(request, page) : result;
×
74
    }
75

76
    /**
77
     * Gets the by property.
78
     *
79
     * @param request
80
     *            the request
81
     * @param p
82
     *            the p
83
     * @param name
84
     *            the name
85
     *
86
     * @return the by property
87
     */
88
    private Decorator getByProperty(HttpServletRequest request, Page p, String name) {
89
        if (p.isPropertySet(name)) {
×
90
            return getNamedDecorator(request, p.getProperty(name));
×
91
        }
92
        return null;
×
93
    }
94
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc