• 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

75.0
/displaytag/src/main/java/org/displaytag/util/MultipleHtmlAttribute.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.util;
8

9
import java.util.Iterator;
10
import java.util.LinkedHashSet;
11
import java.util.Set;
12

13
import org.apache.commons.lang3.StringUtils;
14

15
/**
16
 * Object used to contain html multiple attribute value (for the "class" attribute).
17
 */
18
public class MultipleHtmlAttribute implements Cloneable {
19

20
    /**
21
     * Sets containing splitted attribute values.
22
     */
23
    private final Set<String> attributeSet;
24

25
    /**
26
     * Constructor for MultipleHtmlAttribute.
27
     *
28
     * @param attributeValue
29
     *            String
30
     */
31
    public MultipleHtmlAttribute(final String attributeValue) {
1✔
32
        this.attributeSet = new LinkedHashSet<>();
1✔
33
        this.addAllAttributesFromArray(StringUtils.split(attributeValue));
1✔
34
    }
1✔
35

36
    /**
37
     * Adds attributes from an array.
38
     *
39
     * @param attributes
40
     *            Object[] Array containing attributes
41
     */
42
    private void addAllAttributesFromArray(final String[] attributes) {
43
        if (attributes == null) {
1!
44
            return;
×
45
        }
46

47
        // number of attributes to add
48
        final int length = attributes.length;
1✔
49

50
        // add all the splitted attributes
51
        for (int j = 0; j < length; j++) {
1✔
52

53
            // don't add if empty
54
            if (!StringUtils.isEmpty(attributes[j])) {
1!
55
                this.attributeSet.add(attributes[j]);
1✔
56
            }
57

58
        }
59
    }
1✔
60

61
    /**
62
     * Returns the list of attributes separated by a space.
63
     *
64
     * @return String
65
     */
66
    @Override
67
    public String toString() {
68
        final StringBuilder buffer = new StringBuilder();
1✔
69

70
        final Iterator<String> iterator = this.attributeSet.iterator();
1✔
71

72
        while (iterator.hasNext()) {
1✔
73
            // apend next value
74
            buffer.append(iterator.next());
1✔
75
            if (iterator.hasNext()) {
1✔
76
                // append a space if there are more
77
                buffer.append(' ');
1✔
78
            }
79
        }
80

81
        return buffer.toString();
1✔
82
    }
83

84
    /**
85
     * Adds a value to the attribute.
86
     *
87
     * @param attributeValue
88
     *            value to add to the attribute
89
     */
90
    public void addAttributeValue(final String attributeValue) {
91
        // don't add if empty
92
        if (!StringUtils.isEmpty(attributeValue)) {
1!
93
            this.attributeSet.add(attributeValue);
1✔
94
        }
95

96
    }
1✔
97

98
    /**
99
     * Return true if this MultipleHtmlValue doesn't store any value.
100
     *
101
     * @return <code>true</code> if this MultipleHtmlValue doesn't store any value
102
     */
103
    public boolean isEmpty() {
104
        return this.attributeSet.isEmpty();
1✔
105
    }
106

107
    /**
108
     * Clone.
109
     *
110
     * @return the object
111
     *
112
     * @see java.lang.Object#clone()
113
     */
114
    @Override
115
    protected Object clone() {
116
        MultipleHtmlAttribute clone;
117

118
        try {
119
            clone = (MultipleHtmlAttribute) super.clone();
×
120
        } catch (final CloneNotSupportedException e) {
×
121
            // should never happen
122
            throw new RuntimeException(e);
×
123
        }
×
124

125
        // copy attributes
126
        clone.addAllAttributesFromArray(this.attributeSet.toArray(new String[this.attributeSet.size()]));
×
127

128
        return clone;
×
129
    }
130

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