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

hazendaz / httpunit / 656

06 Dec 2025 09:11PM UTC coverage: 80.452% (+0.02%) from 80.435%
656

push

github

hazendaz
[maven-release-plugin] prepare for next development iteration

3213 of 4105 branches covered (78.27%)

Branch coverage included in aggregate %.

8245 of 10137 relevant lines covered (81.34%)

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
 * MIT License
3
 *
4
 * Copyright 2011-2025 Russell Gold
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
7
 * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
8
 * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
9
 * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
 *
11
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions
12
 * of the Software.
13
 *
14
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
15
 * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
17
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18
 * DEALINGS IN THE SOFTWARE.
19
 */
20
package com.meterware.httpunit.dom;
21

22
import org.w3c.dom.Attr;
23
import org.w3c.dom.NodeList;
24
import org.w3c.dom.html.HTMLElement;
25

26
/**
27
 * The Class HTMLElementImpl.
28
 */
29
public class HTMLElementImpl extends ElementImpl implements HTMLElement {
1✔
30

31
    /** The Constant serialVersionUID. */
32
    private static final long serialVersionUID = 1L;
33

34
    /** The Constant UNSPECIFIED_ATTRIBUTE. */
35
    public static final String UNSPECIFIED_ATTRIBUTE = null;
1✔
36

37
    /**
38
     * Creates the.
39
     *
40
     * @return the element impl
41
     */
42
    ElementImpl create() {
43
        return new HTMLElementImpl();
1✔
44
    }
45

46
    /**
47
     * Click.
48
     */
49
    public void click() {
50
        doClickAction();
1✔
51
    }
1✔
52

53
    /**
54
     * Do click action.
55
     */
56
    public void doClickAction() {
57
    }
×
58

59
    /**
60
     * Gets the id.
61
     *
62
     * @return the id
63
     */
64
    @Override
65
    public String getId() {
66
        return getAttributeWithNoDefault("id");
1✔
67
    }
68

69
    /**
70
     * Sets the id.
71
     *
72
     * @param id
73
     *            the new id
74
     */
75
    @Override
76
    public void setId(String id) {
77
        setAttribute("id", id);
1✔
78
    }
1✔
79

80
    /**
81
     * Gets the title.
82
     *
83
     * @return the title
84
     */
85
    @Override
86
    public String getTitle() {
87
        return getAttributeWithNoDefault("title");
1✔
88
    }
89

90
    /**
91
     * Sets the title.
92
     *
93
     * @param title
94
     *            the new title
95
     */
96
    @Override
97
    public void setTitle(String title) {
98
        setAttribute("title", title);
1✔
99
    }
1✔
100

101
    /**
102
     * Gets the lang.
103
     *
104
     * @return the lang
105
     */
106
    @Override
107
    public String getLang() {
108
        return getAttributeWithNoDefault("lang");
1✔
109
    }
110

111
    /**
112
     * Sets the lang.
113
     *
114
     * @param lang
115
     *            the new lang
116
     */
117
    @Override
118
    public void setLang(String lang) {
119
        setAttribute("lang", lang);
1✔
120
    }
1✔
121

122
    /**
123
     * Gets the dir.
124
     *
125
     * @return the dir
126
     */
127
    @Override
128
    public String getDir() {
129
        return getAttributeWithNoDefault("dir");
1✔
130
    }
131

132
    /**
133
     * Sets the dir.
134
     *
135
     * @param dir
136
     *            the new dir
137
     */
138
    @Override
139
    public void setDir(String dir) {
140
        setAttribute("dir", dir);
1✔
141
    }
1✔
142

143
    @Override
144
    public String getClassName() {
145
        return getAttributeWithNoDefault("class");
1✔
146
    }
147

148
    /**
149
     * Sets the class name.
150
     *
151
     * @param className
152
     *            the new class name
153
     */
154
    @Override
155
    public void setClassName(String className) {
156
        setAttribute("class", className);
1✔
157
    }
1✔
158

159
    @Override
160
    public NodeList getElementsByTagName(String name) {
161
        return super.getElementsByTagName(((HTMLDocumentImpl) getOwnerDocument()).toNodeCase(name));
1✔
162
    }
163

164
    // ---------------------------------------------- protected methods
165
    // -----------------------------------------------------
166

167
    /**
168
     * Gets the attribute with default.
169
     *
170
     * @param attributeName
171
     *            the attribute name
172
     * @param defaultValue
173
     *            the default value
174
     *
175
     * @return the attribute with default
176
     */
177
    protected final String getAttributeWithDefault(String attributeName, String defaultValue) {
178
        if (hasAttribute(attributeName)) {
1✔
179
            return getAttribute(attributeName);
1✔
180
        }
181
        return defaultValue;
1✔
182
    }
183

184
    /**
185
     * Gets the attribute with no default.
186
     *
187
     * @param attributeName
188
     *            the attribute name
189
     *
190
     * @return the attribute with no default
191
     */
192
    protected final String getAttributeWithNoDefault(String attributeName) {
193
        if (hasAttribute(attributeName)) {
1✔
194
            return getAttribute(attributeName);
1✔
195
        }
196
        return UNSPECIFIED_ATTRIBUTE;
1✔
197
    }
198

199
    /**
200
     * Gets the boolean attribute.
201
     *
202
     * @param name
203
     *            the name
204
     *
205
     * @return the boolean attribute
206
     */
207
    protected boolean getBooleanAttribute(String name) {
208
        Attr attr = getAttributeNode(name);
1✔
209
        return attr != null && !attr.getValue().equalsIgnoreCase("false");
1✔
210
    }
211

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

225
    /**
226
     * Gets the integer attribute.
227
     *
228
     * @param name
229
     *            the name
230
     * @param defaultValue
231
     *            the default value
232
     *
233
     * @return the integer attribute
234
     */
235
    protected int getIntegerAttribute(String name, int defaultValue) {
236
        String value = getAttribute(name);
1✔
237
        return value.isEmpty() ? defaultValue : Integer.parseInt(value);
1✔
238
    }
239

240
    /**
241
     * Sets the attribute.
242
     *
243
     * @param name
244
     *            the name
245
     * @param disabled
246
     *            the disabled
247
     */
248
    protected void setAttribute(String name, boolean disabled) {
249
        setAttribute(name, disabled ? "true" : "false");
1✔
250
    }
1✔
251

252
    /**
253
     * Sets the attribute.
254
     *
255
     * @param name
256
     *            the name
257
     * @param value
258
     *            the value
259
     */
260
    protected void setAttribute(String name, int value) {
261
        setAttribute(name, Integer.toString(value));
1✔
262
    }
1✔
263

264
    /**
265
     * Gets the html document.
266
     *
267
     * @return the html document
268
     */
269
    HTMLDocumentImpl getHtmlDocument() {
270
        return (HTMLDocumentImpl) getOwnerDocument();
1✔
271
    }
272

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