• 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

41.94
/displaytag/src/main/java/org/displaytag/util/Anchor.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
/**
10
 * Anchor object used to output an html link (an <a> tag).
11
 */
12
public class Anchor {
13

14
    /**
15
     * Href object to be written in the "href" html attribute.
16
     */
17
    private Href href;
18

19
    /**
20
     * link body text.
21
     */
22
    private String linkText;
23

24
    /**
25
     * HashMap containing all the html attributes.
26
     */
27
    private final HtmlAttributeMap attributeMap = new HtmlAttributeMap();
1✔
28

29
    /**
30
     * Creates a new Anchor whit the supplied Href and body text.
31
     *
32
     * @param linkHref
33
     *            baseHref
34
     * @param linkBody
35
     *            String link body
36
     */
37
    public Anchor(final Href linkHref, final String linkBody) {
1✔
38
        this.href = linkHref;
1✔
39
        this.linkText = linkBody;
1✔
40
    }
1✔
41

42
    /**
43
     * setter the anchor Href.
44
     *
45
     * @param linkHref
46
     *            Href
47
     */
48
    public void setHref(final Href linkHref) {
49
        this.href = linkHref;
×
50
    }
×
51

52
    /**
53
     * setter for the link body text.
54
     *
55
     * @param linkBody
56
     *            String
57
     */
58
    public void setText(final String linkBody) {
59
        this.linkText = linkBody;
×
60
    }
×
61

62
    /**
63
     * add a "class" attribute to the html link.
64
     *
65
     * @param cssClass
66
     *            String
67
     */
68
    public void setClass(final String cssClass) {
69
        this.attributeMap.put(TagConstants.ATTRIBUTE_CLASS, cssClass);
×
70
    }
×
71

72
    /**
73
     * add a "style" attribute to the html link.
74
     *
75
     * @param style
76
     *            String
77
     */
78
    public void setStyle(final String style) {
79
        this.attributeMap.put(TagConstants.ATTRIBUTE_STYLE, style);
×
80
    }
×
81

82
    /**
83
     * add a "title" attribute to the html link.
84
     *
85
     * @param title
86
     *            String
87
     */
88
    public void setTitle(final String title) {
89
        this.attributeMap.put(TagConstants.ATTRIBUTE_TITLE, title);
×
90
    }
×
91

92
    /**
93
     * returns the href attribute, surrounded by quotes and prefixed with " href=".
94
     *
95
     * @return String <code> href ="<em>href value</em>"</code> or an emty String if Href is null
96
     */
97
    private String getHrefString() {
98
        if (this.href == null) {
1!
99
            return TagConstants.EMPTY_STRING;
×
100
        }
101
        return " href=\"" + this.href.toString() + "\""; //$NON-NLS-1$ //$NON-NLS-2$
1✔
102
    }
103

104
    /**
105
     * Returns the &lt;a&gt; tag, with rendered href and any html attribute.
106
     *
107
     * @return String
108
     */
109
    public String getOpenTag() {
110

111
        // shortcut for links with no attributes
112
        if (this.attributeMap.size() == 0) {
1!
113
            return TagConstants.TAG_OPEN + TagConstants.TAGNAME_ANCHOR + this.getHrefString() + TagConstants.TAG_CLOSE;
1✔
114
        }
115

116
        // append all attributes
117
        final StringBuilder buffer = new StringBuilder();
×
118

119
        buffer.append(TagConstants.TAG_OPEN).append(TagConstants.TAGNAME_ANCHOR).append(this.getHrefString());
×
120

121
        buffer.append(this.attributeMap);
×
122

123
        buffer.append(TagConstants.TAG_CLOSE);
×
124

125
        return buffer.toString();
×
126
    }
127

128
    /**
129
     * returns the &lt;/a&gt; tag.
130
     *
131
     * @return String
132
     */
133
    public String getCloseTag() {
134
        return TagConstants.TAG_OPENCLOSING + TagConstants.TAGNAME_ANCHOR + TagConstants.TAG_CLOSE;
1✔
135
    }
136

137
    /**
138
     * returns the full &lt;a href=""&gt;body&lt;/a&gt;.
139
     *
140
     * @return String html link
141
     */
142
    @Override
143
    public String toString() {
144
        return this.getOpenTag() + this.linkText + this.getCloseTag();
1✔
145
    }
146

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