• 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

98.11
/src/main/java/com/meterware/httpunit/dom/HTMLElementImpl.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 org.w3c.dom.Attr;
11
import org.w3c.dom.NodeList;
12
import org.w3c.dom.html.HTMLElement;
13

14
/**
15
 * The Class HTMLElementImpl.
16
 */
17
public class HTMLElementImpl extends ElementImpl implements HTMLElement {
1✔
18

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

22
    /** The Constant UNSPECIFIED_ATTRIBUTE. */
23
    public static final String UNSPECIFIED_ATTRIBUTE = null;
1✔
24

25
    /**
26
     * Creates the.
27
     *
28
     * @return the element impl
29
     */
30
    ElementImpl create() {
31
        return new HTMLElementImpl();
1✔
32
    }
33

34
    /**
35
     * Click.
36
     */
37
    public void click() {
38
        doClickAction();
1✔
39
    }
1✔
40

41
    /**
42
     * Do click action.
43
     */
44
    public void doClickAction() {
45
    }
×
46

47
    /**
48
     * Gets the id.
49
     *
50
     * @return the id
51
     */
52
    @Override
53
    public String getId() {
54
        return getAttributeWithNoDefault("id");
1✔
55
    }
56

57
    /**
58
     * Sets the id.
59
     *
60
     * @param id
61
     *            the new id
62
     */
63
    @Override
64
    public void setId(String id) {
65
        setAttribute("id", id);
1✔
66
    }
1✔
67

68
    /**
69
     * Gets the title.
70
     *
71
     * @return the title
72
     */
73
    @Override
74
    public String getTitle() {
75
        return getAttributeWithNoDefault("title");
1✔
76
    }
77

78
    /**
79
     * Sets the title.
80
     *
81
     * @param title
82
     *            the new title
83
     */
84
    @Override
85
    public void setTitle(String title) {
86
        setAttribute("title", title);
1✔
87
    }
1✔
88

89
    /**
90
     * Gets the lang.
91
     *
92
     * @return the lang
93
     */
94
    @Override
95
    public String getLang() {
96
        return getAttributeWithNoDefault("lang");
1✔
97
    }
98

99
    /**
100
     * Sets the lang.
101
     *
102
     * @param lang
103
     *            the new lang
104
     */
105
    @Override
106
    public void setLang(String lang) {
107
        setAttribute("lang", lang);
1✔
108
    }
1✔
109

110
    /**
111
     * Gets the dir.
112
     *
113
     * @return the dir
114
     */
115
    @Override
116
    public String getDir() {
117
        return getAttributeWithNoDefault("dir");
1✔
118
    }
119

120
    /**
121
     * Sets the dir.
122
     *
123
     * @param dir
124
     *            the new dir
125
     */
126
    @Override
127
    public void setDir(String dir) {
128
        setAttribute("dir", dir);
1✔
129
    }
1✔
130

131
    @Override
132
    public String getClassName() {
133
        return getAttributeWithNoDefault("class");
1✔
134
    }
135

136
    /**
137
     * Sets the class name.
138
     *
139
     * @param className
140
     *            the new class name
141
     */
142
    @Override
143
    public void setClassName(String className) {
144
        setAttribute("class", className);
1✔
145
    }
1✔
146

147
    @Override
148
    public NodeList getElementsByTagName(String name) {
149
        return super.getElementsByTagName(((HTMLDocumentImpl) getOwnerDocument()).toNodeCase(name));
1✔
150
    }
151

152
    // ---------------------------------------------- protected methods
153
    // -----------------------------------------------------
154

155
    /**
156
     * Gets the attribute with default.
157
     *
158
     * @param attributeName
159
     *            the attribute name
160
     * @param defaultValue
161
     *            the default value
162
     *
163
     * @return the attribute with default
164
     */
165
    protected final String getAttributeWithDefault(String attributeName, String defaultValue) {
166
        if (hasAttribute(attributeName)) {
1✔
167
            return getAttribute(attributeName);
1✔
168
        }
169
        return defaultValue;
1✔
170
    }
171

172
    /**
173
     * Gets the attribute with no default.
174
     *
175
     * @param attributeName
176
     *            the attribute name
177
     *
178
     * @return the attribute with no default
179
     */
180
    protected final String getAttributeWithNoDefault(String attributeName) {
181
        if (hasAttribute(attributeName)) {
1✔
182
            return getAttribute(attributeName);
1✔
183
        }
184
        return UNSPECIFIED_ATTRIBUTE;
1✔
185
    }
186

187
    /**
188
     * Gets the boolean attribute.
189
     *
190
     * @param name
191
     *            the name
192
     *
193
     * @return the boolean attribute
194
     */
195
    protected boolean getBooleanAttribute(String name) {
196
        Attr attr = getAttributeNode(name);
1✔
197
        return attr != null && !attr.getValue().equalsIgnoreCase("false");
1✔
198
    }
199

200
    /**
201
     * Gets the integer attribute.
202
     *
203
     * @param name
204
     *            the name
205
     *
206
     * @return the integer attribute
207
     */
208
    protected int getIntegerAttribute(String name) {
209
        String value = getAttribute(name);
1✔
210
        return value.isEmpty() ? 0 : Integer.parseInt(value);
1✔
211
    }
212

213
    /**
214
     * Gets the integer attribute.
215
     *
216
     * @param name
217
     *            the name
218
     * @param defaultValue
219
     *            the default value
220
     *
221
     * @return the integer attribute
222
     */
223
    protected int getIntegerAttribute(String name, int defaultValue) {
224
        String value = getAttribute(name);
1✔
225
        return value.isEmpty() ? defaultValue : Integer.parseInt(value);
1✔
226
    }
227

228
    /**
229
     * Sets the attribute.
230
     *
231
     * @param name
232
     *            the name
233
     * @param disabled
234
     *            the disabled
235
     */
236
    protected void setAttribute(String name, boolean disabled) {
237
        setAttribute(name, disabled ? "true" : "false");
1✔
238
    }
1✔
239

240
    /**
241
     * Sets the attribute.
242
     *
243
     * @param name
244
     *            the name
245
     * @param value
246
     *            the value
247
     */
248
    protected void setAttribute(String name, int value) {
249
        setAttribute(name, Integer.toString(value));
1✔
250
    }
1✔
251

252
    /**
253
     * Gets the html document.
254
     *
255
     * @return the html document
256
     */
257
    HTMLDocumentImpl getHtmlDocument() {
258
        return (HTMLDocumentImpl) getOwnerDocument();
1✔
259
    }
260

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