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

hazendaz / displaytag / 1753

12 Feb 2026 03:17AM UTC coverage: 77.321% (-0.01%) from 77.334%
1753

push

github

web-flow
Merge pull request #1102 from hazendaz/renovate/javax-support-logback-monorepo

Update dependency ch.qos.logback:logback-classic to v1.5.29 (javax-support)

1438 of 2003 branches covered (71.79%)

Branch coverage included in aggregate %.

4034 of 5074 relevant lines covered (79.5%)

0.8 hits per line

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

85.71
/displaytag/src/main/java/org/displaytag/decorator/MessageFormatColumnDecorator.java
1
/*
2
 * SPDX-License-Identifier: MIT
3
 * See LICENSE file for details.
4
 *
5
 * Copyright 2002-2026 Fabrizio Giustina, the Displaytag team
6
 */
7
package org.displaytag.decorator;
8

9
import java.text.MessageFormat;
10
import java.util.Locale;
11

12
import javax.servlet.jsp.PageContext;
13

14
import org.displaytag.Messages;
15
import org.displaytag.properties.MediaTypeEnum;
16
import org.slf4j.Logger;
17
import org.slf4j.LoggerFactory;
18

19
/**
20
 * A decorator that simply formats input Objects using a <code>java.text.messageFormat</code>. By design, this
21
 * implementations handle MessageFormat errors by returning the unformatted value and logging the exception.
22
 */
23
public class MessageFormatColumnDecorator implements DisplaytagColumnDecorator {
24

25
    /**
26
     * Logger.
27
     */
28
    private static Logger log = LoggerFactory.getLogger(MessageFormatColumnDecorator.class);
1✔
29

30
    /**
31
     * Pre-compiled messageFormat.
32
     */
33
    private final MessageFormat format;
34

35
    /**
36
     * Pattern is held for alternative (eg excel) formatters.
37
     */
38
    private final String pattern;
39

40
    /**
41
     * Instantiates a new MessageFormatColumnDecorator with a given pattern and locale.
42
     *
43
     * @param pattern
44
     *            see <code>java.text.messageFormat</code>
45
     * @param locale
46
     *            current locale
47
     *
48
     * @see java.text.MessageFormat
49
     */
50
    public MessageFormatColumnDecorator(final String pattern, final Locale locale) {
1✔
51
        this.pattern = pattern;
1✔
52
        this.format = new MessageFormat(pattern, locale);
1✔
53
    }
1✔
54

55
    /**
56
     * Decorate.
57
     *
58
     * @param columnValue
59
     *            the column value
60
     * @param pageContext
61
     *            the page context
62
     * @param media
63
     *            the media
64
     *
65
     * @return the object
66
     *
67
     * @see org.displaytag.decorator.DisplaytagColumnDecorator#decorate(Object, PageContext, MediaTypeEnum)
68
     */
69
    @Override
70
    public Object decorate(final Object columnValue, final PageContext pageContext, final MediaTypeEnum media) {
71
        try {
72
            return this.format.format(new Object[] { columnValue });
1✔
73
        } catch (final IllegalArgumentException e) {
1✔
74
            MessageFormatColumnDecorator.log.error(Messages.getString("MessageFormatColumnDecorator.invalidArgument", //$NON-NLS-1$
1✔
75
                    new Object[] { this.format.toPattern(),
1✔
76
                            columnValue != null ? columnValue.getClass().getName() : "null" })); //$NON-NLS-1$
1!
77

78
            return columnValue;
1✔
79
        }
80
    }
81

82
    /**
83
     * get the format.
84
     *
85
     * @return the format
86
     */
87
    public String getPattern() {
88
        return this.pattern;
×
89
    }
90

91
}
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