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

hazendaz / httpunit / 755

14 Feb 2026 07:14PM UTC coverage: 80.526%. Remained the same
755

push

github

hazendaz
[ci] Fix badge

3213 of 4105 branches covered (78.27%)

Branch coverage included in aggregate %.

8245 of 10124 relevant lines covered (81.44%)

0.81 hits per line

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

79.03
/src/main/java/com/meterware/httpunit/dom/HTMLAnchorElementImpl.java
1
/*
2
 * SPDX-License-Identifier: MIT
3
 * See LICENSE file for details.
4
 *
5
 * Copyright 2000-2026 Russell Gold
6
 * Copyright 2021-2000 hazendaz
7
 */
8
package com.meterware.httpunit.dom;
9

10
import java.net.MalformedURLException;
11
import java.net.URL;
12

13
import org.w3c.dom.html.HTMLAnchorElement;
14

15
/**
16
 * The Class HTMLAnchorElementImpl.
17
 */
18
public class HTMLAnchorElementImpl extends HTMLElementImpl implements HTMLAnchorElement {
1✔
19

20
    /** The Constant serialVersionUID. */
21
    private static final long serialVersionUID = 1L;
22

23
    @Override
24
    ElementImpl create() {
25
        return new HTMLAnchorElementImpl();
1✔
26
    }
27

28
    /**
29
     * Gets the charset.
30
     *
31
     * @return the charset
32
     */
33
    @Override
34
    public String getCharset() {
35
        return getAttributeWithNoDefault("charset");
1✔
36
    }
37

38
    /**
39
     * Gets the href.
40
     *
41
     * @return the href
42
     */
43
    @Override
44
    public String getHref() {
45
        String relativeLocation = getAttributeWithNoDefault("href");
1✔
46
        if (relativeLocation.indexOf(':') > 0 || relativeLocation.equals("#")) {
1✔
47
            return relativeLocation;
1✔
48
        }
49
        try {
50
            return new URL(((HTMLDocumentImpl) getOwnerDocument()).getBaseUrl(), relativeLocation).toExternalForm();
1✔
51
        } catch (MalformedURLException e) {
×
52
            return e.toString();
×
53
        }
54
    }
55

56
    /**
57
     * Gets the hreflang.
58
     *
59
     * @return the hreflang
60
     */
61
    @Override
62
    public String getHreflang() {
63
        return getAttributeWithNoDefault("hreflang");
1✔
64
    }
65

66
    /**
67
     * Gets the rel.
68
     *
69
     * @return the rel
70
     */
71
    @Override
72
    public String getRel() {
73
        return getAttributeWithNoDefault("rel");
1✔
74
    }
75

76
    /**
77
     * Gets the rev.
78
     *
79
     * @return the rev
80
     */
81
    @Override
82
    public String getRev() {
83
        return getAttributeWithNoDefault("rev");
1✔
84
    }
85

86
    /**
87
     * Gets the target.
88
     *
89
     * @return the target
90
     */
91
    @Override
92
    public String getTarget() {
93
        return getAttributeWithNoDefault("target");
1✔
94
    }
95

96
    /**
97
     * Gets the type.
98
     *
99
     * @return the type
100
     */
101
    @Override
102
    public String getType() {
103
        return getAttributeWithNoDefault("type");
1✔
104
    }
105

106
    /**
107
     * Sets the charset.
108
     *
109
     * @param charset
110
     *            the new charset
111
     */
112
    @Override
113
    public void setCharset(String charset) {
114
        setAttribute("charset", charset);
1✔
115
    }
1✔
116

117
    /**
118
     * Sets the href.
119
     *
120
     * @param href
121
     *            the new href
122
     */
123
    @Override
124
    public void setHref(String href) {
125
        setAttribute("href", href);
1✔
126
    }
1✔
127

128
    /**
129
     * Sets the hreflang.
130
     *
131
     * @param hreflang
132
     *            the new hreflang
133
     */
134
    @Override
135
    public void setHreflang(String hreflang) {
136
        setAttribute("hreflang", hreflang);
1✔
137
    }
1✔
138

139
    /**
140
     * Sets the rel.
141
     *
142
     * @param rel
143
     *            the new rel
144
     */
145
    @Override
146
    public void setRel(String rel) {
147
        setAttribute("rel", rel);
1✔
148
    }
1✔
149

150
    /**
151
     * Sets the rev.
152
     *
153
     * @param rev
154
     *            the new rev
155
     */
156
    @Override
157
    public void setRev(String rev) {
158
        setAttribute("rev", rev);
1✔
159
    }
1✔
160

161
    /**
162
     * Sets the target.
163
     *
164
     * @param target
165
     *            the new target
166
     */
167
    @Override
168
    public void setTarget(String target) {
169
        setAttribute("target", target);
1✔
170
    }
1✔
171

172
    /**
173
     * Sets the type.
174
     *
175
     * @param type
176
     *            the new type
177
     */
178
    @Override
179
    public void setType(String type) {
180
        setAttribute("type", type);
1✔
181
    }
1✔
182

183
    /**
184
     * simulate blur.
185
     */
186
    @Override
187
    public void blur() {
188
        handleEvent("onblur");
×
189
    }
×
190

191
    /**
192
     * simulate focus;.
193
     */
194
    @Override
195
    public void focus() {
196
        handleEvent("onfocus");
×
197
    }
×
198

199
    /**
200
     * Gets the access key.
201
     *
202
     * @return the access key
203
     */
204
    @Override
205
    public String getAccessKey() {
206
        return getAttributeWithNoDefault("accesskey");
1✔
207
    }
208

209
    /**
210
     * Gets the coords.
211
     *
212
     * @return the coords
213
     */
214
    @Override
215
    public String getCoords() {
216
        return getAttributeWithNoDefault("coords");
×
217
    }
218

219
    /**
220
     * Gets the name.
221
     *
222
     * @return the name
223
     */
224
    @Override
225
    public String getName() {
226
        return getAttributeWithNoDefault("name");
1✔
227
    }
228

229
    /**
230
     * Gets the shape.
231
     *
232
     * @return the shape
233
     */
234
    @Override
235
    public String getShape() {
236
        return getAttributeWithNoDefault("shape");
×
237
    }
238

239
    /**
240
     * Gets the tab index.
241
     *
242
     * @return the tab index
243
     */
244
    @Override
245
    public int getTabIndex() {
246
        return getIntegerAttribute("tabindex");
1✔
247
    }
248

249
    /**
250
     * Sets the access key.
251
     *
252
     * @param accessKey
253
     *            the new access key
254
     */
255
    @Override
256
    public void setAccessKey(String accessKey) {
257
        setAttribute("accesskey", accessKey);
1✔
258
    }
1✔
259

260
    /**
261
     * Sets the coords.
262
     *
263
     * @param coords
264
     *            the new coords
265
     */
266
    @Override
267
    public void setCoords(String coords) {
268
        setAttribute("coords", coords);
×
269
    }
×
270

271
    /**
272
     * Sets the name.
273
     *
274
     * @param name
275
     *            the new name
276
     */
277
    @Override
278
    public void setName(String name) {
279
        setAttribute("name", name);
1✔
280
    }
1✔
281

282
    /**
283
     * Sets the shape.
284
     *
285
     * @param shape
286
     *            the new shape
287
     */
288
    @Override
289
    public void setShape(String shape) {
290
        setAttribute("shape", shape);
×
291
    }
×
292

293
    /**
294
     * Sets the tab index.
295
     *
296
     * @param tabIndex
297
     *            the new tab index
298
     */
299
    @Override
300
    public void setTabIndex(int tabIndex) {
301
        setAttribute("tabindex", tabIndex);
1✔
302
    }
1✔
303

304
    @Override
305
    public void doClickAction() {
306
        if (null == getHref() || getHref().startsWith("#")) {
1!
307
            return;
1✔
308
        }
309
        try {
310
            ((HTMLDocumentImpl) getOwnerDocument()).getWindow().submitRequest(this, "GET", getHref(), getTarget(),
1✔
311
                    new byte[0]);
312
        } catch (Exception e) {
1✔
313
            throw new RuntimeException("Error clicking link: " + e);
1✔
314
        }
1✔
315
    }
1✔
316
}
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