1 /*
2 * Copyright (c) 2002-2026 Gargoyle Software Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 * https://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 package org.htmlunit.html;
16
17 import java.util.Map;
18
19 import org.htmlunit.SgmlPage;
20 import org.htmlunit.util.StringUtils;
21
22 /**
23 * Wrapper for the HTML element "fieldset".
24 *
25 * @author Mike Bowler
26 * @author David K. Taylor
27 * @author Christian Sell
28 * @author Ahmed Ashour
29 * @author Frank Danek
30 * @author Ronald Brill
31 * @author Lai Quang Duong
32 */
33 public class HtmlFieldSet extends HtmlElement implements DisabledElement, ValidatableHtmlElement {
34
35 /** The HTML tag represented by this element. */
36 public static final String TAG_NAME = "fieldset";
37
38 private String customValidity_;
39
40 /**
41 * Creates an instance of HtmlFieldSet.
42 *
43 * @param qualifiedName the qualified name of the element type to instantiate
44 * @param page the HtmlPage that contains this element
45 * @param attributes the initial attributes
46 */
47 HtmlFieldSet(final String qualifiedName, final SgmlPage page,
48 final Map<String, DomAttr> attributes) {
49 super(qualifiedName, page, attributes);
50 }
51
52 /**
53 * {@inheritDoc}
54 */
55 @Override
56 public boolean willValidate() {
57 return false;
58 }
59
60 /**
61 * {@inheritDoc}
62 */
63 @Override
64 public String getCustomValidity() {
65 return customValidity_;
66 }
67
68 /**
69 * {@inheritDoc}
70 */
71 @Override
72 public void setCustomValidity(final String message) {
73 customValidity_ = message;
74 }
75
76 /**
77 * {@inheritDoc}
78 */
79 @Override
80 public boolean isCustomErrorValidityState() {
81 return !StringUtils.isEmptyOrNull(customValidity_);
82 }
83
84 /**
85 * {@inheritDoc}
86 */
87 @Override
88 public boolean isValid() {
89 return true;
90 }
91
92 @Override
93 public boolean isValidValidityState() {
94 return !isCustomErrorValidityState();
95 }
96
97 /**
98 * {@inheritDoc}
99 */
100 @Override
101 public final String getDisabledAttribute() {
102 return getAttributeDirect(ATTRIBUTE_DISABLED);
103 }
104 }