001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.bean.html5;
018
019import org.apache.juneau.marshall.*;
020
021/**
022 * DTO for an HTML <a class="doclink" href="https://www.w3.org/TR/html5/tabular-data.html#the-colgroup-element">&lt;colgroup&gt;</a>
023 * element.
024 *
025 * <p>
026 * The colgroup element represents a group of one or more columns in a table. It is used to define
027 * structural columns and can specify attributes that apply to all cells in those columns. The colgroup
028 * element can contain col elements to define individual columns, or it can use the span attribute to
029 * define a group of columns without explicitly listing each one. This element is typically placed
030 * immediately after the opening table tag and before any thead, tbody, or tr elements.
031 *
032 * <h5 class='section'>Examples:</h5>
033 * <p class='bcode w800'>
034 *    <jk>import static</jk> org.apache.juneau.bean.html5.HtmlBuilder.*;
035 *
036 *    <jc>// Simple column group</jc>
037 *    Colgroup <jv>simple</jv> = <jsm>colgroup</jsm>();
038 *
039 *    <jc>// Column group with span</jc>
040 *    Colgroup <jv>withSpan</jv> = <jsm>colgroup</jsm>().span(3);
041 *
042 *    <jc>// Column group with individual columns</jc>
043 *    Colgroup <jv>withColumns</jv> = <jsm>colgroup</jsm>(
044 *       <jsm>col</jsm>().span(2),
045 *       <jsm>col</jsm>().span(1)
046 *    );
047 *
048 *    <jc>// Column group with styling</jc>
049 *    Colgroup <jv>styled</jv> = <jsm>colgroup</jsm>()
050 *       .class_(<js>"header-columns"</js>)
051 *       .style(<js>"background-color: #f0f0f0;"</js>);
052 *
053 *    <jc>// Column group with multiple columns</jc>
054 *    Colgroup <jv>multiple</jv> = <jsm>colgroup</jsm>(
055 *       <jsm>col</jsm>().class_(<js>"name-column"</js>).style(<js>"width: 200px;"</js>),
056 *       <jsm>col</jsm>().class_(<js>"age-column"</js>).style(<js>"width: 100px;"</js>),
057 *       <jsm>col</jsm>().class_(<js>"city-column"</js>).style(<js>"width: 150px;"</js>)
058 *    );
059 *
060 *    <jc>// Column group with alignment</jc>
061 *    Colgroup <jv>aligned</jv> = <jsm>colgroup</jsm>(
062 *       <jsm>col</jsm>().style(<js>"text-align: left;"</js>),
063 *       <jsm>col</jsm>().style(<js>"text-align: center;"</js>),
064 *       <jsm>col</jsm>().style(<js>"text-align: right;"</js>)
065 *    );
066 *
067 *    <jc>// Column group with ID</jc>
068 *    Colgroup <jv>withId</jv> = <jsm>colgroup</jsm>()
069 *       .id(<js>"data-columns"</js>)
070 *       .span(4);
071 * </p>
072 *
073 * <p>
074 * The following convenience methods are provided for constructing instances of this bean:
075 * <ul class='javatree'>
076 *    <li class='jc'>{@link HtmlBuilder}
077 *    <ul class='javatree'>
078 *       <li class='jm'>{@link HtmlBuilder#colgroup() colgroup()}
079 *       <li class='jm'>{@link HtmlBuilder#colgroup(Object...) colgroup(Object...)}
080 *    </ul>
081 * </ul>
082 * </p>
083 *
084 * <h5 class='section'>See Also:</h5><ul>
085 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a>
086 * </ul>
087 */
088@Marshalled(typeName = "colgroup")
089public class Colgroup extends HtmlElementContainer<Colgroup> {
090
091   /**
092    * Creates an empty {@link Colgroup} element.
093    */
094   public Colgroup() {}
095
096   /**
097    * Creates a {@link Colgroup} element with the specified child nodes.
098    *
099    * @param children The child nodes. Must not be <jk>null</jk>.
100    */
101   public Colgroup(Object...children) {
102      children(children);
103   }
104
105   /**
106    * <a class="doclink" href="https://www.w3.org/TR/html5/tabular-data.html#attr-colgroup-span">span</a> attribute.
107    *
108    * <p>
109    * Number of columns spanned by the element.
110    *
111    * @param value
112    *    The new value for this attribute.
113    *    Typically a {@link Number} or {@link String}.
114    *    Can be <jk>null</jk> to unset the attribute.
115    * @return This object.
116    */
117   public Colgroup span(Object value) {
118      attr("span", value);
119      return this;
120   }
121
122}