1 /*
2 * Copyright (c) 2002-2025 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.ArrayList;
18 import java.util.List;
19 import java.util.Map;
20
21 import org.htmlunit.SgmlPage;
22
23 /**
24 * Superclass for the wrappers for the HTML elements "thead", "tbody" and "tfoot".
25 *
26 * @author Mike Bowler
27 * @author David K. Taylor
28 * @author Christian Sell
29 * @author Ahmed Ashour
30 * @author Daniel Gredler
31 * @author Ronald Brill
32 * @author Frank Danek
33 */
34 public abstract class TableRowGroup extends HtmlElement {
35
36 /**
37 * Creates an instance of TableRowGroup.
38 *
39 * @param qualifiedName the qualified name of the element type to instantiate
40 * @param page the HtmlPage that contains this element
41 * @param attributes the initial attributes
42 */
43 protected TableRowGroup(final String qualifiedName, final SgmlPage page,
44 final Map<String, DomAttr> attributes) {
45 super(qualifiedName, page, attributes);
46 }
47
48 /**
49 * Returns a list of table rows contained in this element.
50 *
51 * @return a list of table rows
52 */
53 public final List<HtmlTableRow> getRows() {
54 final List<HtmlTableRow> resultList = new ArrayList<>();
55
56 for (final DomElement element : getChildElements()) {
57 if (element instanceof HtmlTableRow) {
58 resultList.add((HtmlTableRow) element);
59 }
60 }
61
62 return resultList;
63 }
64
65 /**
66 * Returns the value of the attribute {@code align}. Refer to the
67 * <a href="http://www.w3.org/TR/html401/">HTML 4.01</a>
68 * documentation for details on the use of this attribute.
69 *
70 * @return the value of the attribute {@code align}
71 * or an empty string if that attribute isn't defined.
72 */
73 public final String getAlignAttribute() {
74 return getAttributeDirect("align");
75 }
76
77 /**
78 * Returns the value of the attribute {@code char}. Refer to the
79 * <a href="http://www.w3.org/TR/html401/">HTML 4.01</a>
80 * documentation for details on the use of this attribute.
81 *
82 * @return the value of the attribute {@code char}
83 * or an empty string if that attribute isn't defined.
84 */
85 public final String getCharAttribute() {
86 return getAttributeDirect("char");
87 }
88
89 /**
90 * Returns the value of the attribute {@code charoff}. Refer to the
91 * <a href="http://www.w3.org/TR/html401/">HTML 4.01</a>
92 * documentation for details on the use of this attribute.
93 *
94 * @return the value of the attribute {@code charoff}
95 * or an empty string if that attribute isn't defined.
96 */
97 public final String getCharoffAttribute() {
98 return getAttributeDirect("charoff");
99 }
100
101 /**
102 * Returns the value of the attribute {@code valign}. Refer to the
103 * <a href="http://www.w3.org/TR/html401/">HTML 4.01</a>
104 * documentation for details on the use of this attribute.
105 *
106 * @return the value of the attribute {@code valign}
107 * or an empty string if that attribute isn't defined.
108 */
109 public final String getValignAttribute() {
110 return getAttributeDirect("valign");
111 }
112 }