• 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

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

12
import java.io.IOException;
13
import java.util.Iterator;
14

15
import org.w3c.dom.Node;
16
import org.w3c.dom.html.HTMLCollection;
17
import org.w3c.dom.html.HTMLFormElement;
18

19
/**
20
 * The Class HTMLControl.
21
 */
22
public class HTMLControl extends HTMLElementImpl {
1✔
23

24
    /** The Constant serialVersionUID. */
25
    private static final long serialVersionUID = 1L;
26

27
    /**
28
     * Gets the disabled.
29
     *
30
     * @return the disabled
31
     */
32
    public boolean getDisabled() {
33
        return getBooleanAttribute("disabled");
1✔
34
    }
35

36
    /**
37
     * Gets the form.
38
     *
39
     * @return the form
40
     */
41
    public HTMLFormElement getForm() {
42
        Node parent = getParentNode();
1✔
43
        while (parent != null && !"form".equalsIgnoreCase(parent.getNodeName())) {
1✔
44
            parent = parent.getParentNode();
1✔
45
        }
46
        if (parent != null) {
1✔
47
            return (HTMLFormElement) parent;
1✔
48
        }
49

50
        for (Iterator here = preOrderIterator(); here.hasNext();) {
1✔
51
            Object o = here.next();
1✔
52
            if (o instanceof HTMLFormElement) {
1✔
53
                return getPreviousForm((HTMLFormElement) o);
1✔
54
            }
55
        }
1✔
56
        return getLastFormInDocument();
1✔
57
    }
58

59
    /**
60
     * Gets the previous form.
61
     *
62
     * @param nextForm
63
     *            the next form
64
     *
65
     * @return the previous form
66
     */
67
    private HTMLFormElement getPreviousForm(HTMLFormElement nextForm) {
68
        HTMLCollection forms = getHtmlDocument().getForms();
1✔
69
        for (int i = 0; i < forms.getLength(); i++) {
1!
70
            if (nextForm == forms.item(i)) {
1✔
71
                return i == 0 ? null : (HTMLFormElement) forms.item(i - 1);
1✔
72
            }
73
        }
74
        return null;
×
75
    }
76

77
    /**
78
     * Gets the last form in document.
79
     *
80
     * @return the last form in document
81
     */
82
    private HTMLFormElement getLastFormInDocument() {
83
        HTMLCollection forms = getHtmlDocument().getForms();
1✔
84
        return forms.getLength() == 0 ? null : (HTMLFormElement) forms.item(forms.getLength() - 1);
1!
85
    }
86

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

96
    /**
97
     * Gets the read only.
98
     *
99
     * @return the read only
100
     */
101
    public boolean getReadOnly() {
102
        return getBooleanAttribute("readonly");
1✔
103
    }
104

105
    /**
106
     * Gets the tab index.
107
     *
108
     * @return the tab index
109
     */
110
    public int getTabIndex() {
111
        return getIntegerAttribute("tabindex");
1✔
112
    }
113

114
    /**
115
     * Gets the type.
116
     *
117
     * @return the type
118
     */
119
    public String getType() {
120
        return getAttributeWithDefault("type", "text");
1✔
121
    }
122

123
    /**
124
     * Sets the disabled.
125
     *
126
     * @param disabled
127
     *            the new disabled
128
     */
129
    public void setDisabled(boolean disabled) {
130
        setAttribute("disabled", disabled);
1✔
131
    }
1✔
132

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

143
    /**
144
     * Sets the read only.
145
     *
146
     * @param readOnly
147
     *            the new read only
148
     */
149
    public void setReadOnly(boolean readOnly) {
150
        setAttribute("readonly", readOnly);
1✔
151
    }
1✔
152

153
    /**
154
     * Sets the tab index.
155
     *
156
     * @param tabIndex
157
     *            the new tab index
158
     */
159
    public void setTabIndex(int tabIndex) {
160
        setAttribute("tabindex", tabIndex);
1✔
161
    }
1✔
162

163
    /**
164
     * Reset.
165
     */
166
    public void reset() {
167
    }
×
168

169
    /**
170
     * Adds the values.
171
     *
172
     * @param processor
173
     *            the processor
174
     * @param characterSet
175
     *            the character set
176
     *
177
     * @throws IOException
178
     *             Signals that an I/O exception has occurred.
179
     */
180
    void addValues(ParameterProcessor processor, String characterSet) throws IOException {
181
    }
×
182

183
    /**
184
     * Silence submit button.
185
     */
186
    public void silenceSubmitButton() {
187
    }
1✔
188
}
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