• 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

90.57
/src/main/java/com/meterware/httpunit/dom/HTMLControl.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 com.meterware.httpunit.protocol.ParameterProcessor;
23

24
import java.io.IOException;
25
import java.util.Iterator;
26

27
import org.w3c.dom.Node;
28
import org.w3c.dom.html.HTMLCollection;
29
import org.w3c.dom.html.HTMLFormElement;
30

31
/**
32
 * The Class HTMLControl.
33
 */
34
public class HTMLControl extends HTMLElementImpl {
1✔
35

36
    /** The Constant serialVersionUID. */
37
    private static final long serialVersionUID = 1L;
38

39
    /**
40
     * Gets the disabled.
41
     *
42
     * @return the disabled
43
     */
44
    public boolean getDisabled() {
45
        return getBooleanAttribute("disabled");
1✔
46
    }
47

48
    /**
49
     * Gets the form.
50
     *
51
     * @return the form
52
     */
53
    public HTMLFormElement getForm() {
54
        Node parent = getParentNode();
1✔
55
        while (parent != null && !"form".equalsIgnoreCase(parent.getNodeName())) {
1✔
56
            parent = parent.getParentNode();
1✔
57
        }
58
        if (parent != null) {
1✔
59
            return (HTMLFormElement) parent;
1✔
60
        }
61

62
        for (Iterator here = preOrderIterator(); here.hasNext();) {
1✔
63
            Object o = here.next();
1✔
64
            if (o instanceof HTMLFormElement) {
1✔
65
                return getPreviousForm((HTMLFormElement) o);
1✔
66
            }
67
        }
1✔
68
        return getLastFormInDocument();
1✔
69
    }
70

71
    /**
72
     * Gets the previous form.
73
     *
74
     * @param nextForm
75
     *            the next form
76
     *
77
     * @return the previous form
78
     */
79
    private HTMLFormElement getPreviousForm(HTMLFormElement nextForm) {
80
        HTMLCollection forms = getHtmlDocument().getForms();
1✔
81
        for (int i = 0; i < forms.getLength(); i++) {
1!
82
            if (nextForm == forms.item(i)) {
1✔
83
                return i == 0 ? null : (HTMLFormElement) forms.item(i - 1);
1✔
84
            }
85
        }
86
        return null;
×
87
    }
88

89
    /**
90
     * Gets the last form in document.
91
     *
92
     * @return the last form in document
93
     */
94
    private HTMLFormElement getLastFormInDocument() {
95
        HTMLCollection forms = getHtmlDocument().getForms();
1✔
96
        return forms.getLength() == 0 ? null : (HTMLFormElement) forms.item(forms.getLength() - 1);
1!
97
    }
98

99
    /**
100
     * Gets the name.
101
     *
102
     * @return the name
103
     */
104
    public String getName() {
105
        return getAttributeWithNoDefault("name");
1✔
106
    }
107

108
    /**
109
     * Gets the read only.
110
     *
111
     * @return the read only
112
     */
113
    public boolean getReadOnly() {
114
        return getBooleanAttribute("readonly");
1✔
115
    }
116

117
    /**
118
     * Gets the tab index.
119
     *
120
     * @return the tab index
121
     */
122
    public int getTabIndex() {
123
        return getIntegerAttribute("tabindex");
1✔
124
    }
125

126
    /**
127
     * Gets the type.
128
     *
129
     * @return the type
130
     */
131
    public String getType() {
132
        return getAttributeWithDefault("type", "text");
1✔
133
    }
134

135
    /**
136
     * Sets the disabled.
137
     *
138
     * @param disabled
139
     *            the new disabled
140
     */
141
    public void setDisabled(boolean disabled) {
142
        setAttribute("disabled", disabled);
1✔
143
    }
1✔
144

145
    /**
146
     * Sets the name.
147
     *
148
     * @param name
149
     *            the new name
150
     */
151
    public void setName(String name) {
152
        setAttribute("name", name);
1✔
153
    }
1✔
154

155
    /**
156
     * Sets the read only.
157
     *
158
     * @param readOnly
159
     *            the new read only
160
     */
161
    public void setReadOnly(boolean readOnly) {
162
        setAttribute("readonly", readOnly);
1✔
163
    }
1✔
164

165
    /**
166
     * Sets the tab index.
167
     *
168
     * @param tabIndex
169
     *            the new tab index
170
     */
171
    public void setTabIndex(int tabIndex) {
172
        setAttribute("tabindex", tabIndex);
1✔
173
    }
1✔
174

175
    /**
176
     * Reset.
177
     */
178
    public void reset() {
179
    }
×
180

181
    /**
182
     * Adds the values.
183
     *
184
     * @param processor
185
     *            the processor
186
     * @param characterSet
187
     *            the character set
188
     *
189
     * @throws IOException
190
     *             Signals that an I/O exception has occurred.
191
     */
192
    void addValues(ParameterProcessor processor, String characterSet) throws IOException {
193
    }
×
194

195
    /**
196
     * Silence submit button.
197
     */
198
    public void silenceSubmitButton() {
199
    }
1✔
200
}
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