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-col-element">&lt;col&gt;</a>
023 * element.
024 *
025 * <p>
026 * The col element represents one or more columns in a column group represented by its parent colgroup
027 * element. It is used to define the structural columns of a table and can specify attributes that apply
028 * to all cells in those columns. The col element is a void element that does not contain any content
029 * and is typically used within a colgroup element to define column properties such as width, alignment,
030 * and styling.
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</jc>
037 *    Col <jv>simple</jv> = <jsm>col</jsm>();
038 *
039 *    <jc>// Column spanning multiple columns</jc>
040 *    Col <jv>spanning</jv> = <jsm>col</jsm>().span(3);
041 *
042 *    <jc>// Column with styling</jc>
043 *    Col <jv>styled</jv> = <jsm>col</jsm>()
044 *       .class_(<js>"highlight-column"</js>)
045 *       .style(<js>"background-color: #f0f0f0;"</js>);
046 *
047 *    <jc>// Column with width</jc>
048 *    Col <jv>withWidth</jv> = <jsm>col</jsm>()
049 *       .style(<js>"width: 200px;"</js>);
050 *
051 *    <jc>// Column with alignment</jc>
052 *    Col <jv>aligned</jv> = <jsm>col</jsm>()
053 *       .style(<js>"text-align: center;"</js>);
054 *
055 *    <jc>// Column with ID</jc>
056 *    Col <jv>withId</jv> = <jsm>col</jsm>()
057 *       .id(<js>"name-column"</js>)
058 *       .span(2);
059 *
060 *    <jc>// Column with multiple attributes</jc>
061 *    Col <jv>complex</jv> = <jsm>col</jsm>()
062 *       .span(2)
063 *       .class_(<js>"data-column"</js>)
064 *       .style(<js>"width: 150px; text-align: right;"</js>)
065 *       .title(<js>"Numeric data column"</js>);
066 * </p>
067 *
068 * <p>
069 * The following convenience methods are provided for constructing instances of this bean:
070 * <ul class='javatree'>
071 *    <li class='jc'>{@link HtmlBuilder}
072 *    <ul class='javatree'>
073 *       <li class='jm'>{@link HtmlBuilder#col() col()}
074 *    </ul>
075 * </ul>
076 * </p>
077 *
078 * <h5 class='section'>See Also:</h5><ul>
079 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a>
080 * </ul>
081 */
082@Marshalled(typeName = "col")
083public class Col extends HtmlElementVoid<Col> {
084
085   /**
086    * Creates an empty {@link Col} element.
087    */
088   public Col() {}
089
090   /**
091    * Creates a {@link Col} element with the specified {@link Col#span(Object)} attribute.
092    *
093    * @param span The {@link Col#span(Object)} attribute. Can be <jk>null</jk> to unset the attribute.
094    */
095   public Col(Number span) {
096      span(span);
097   }
098
099   /**
100    * <a class="doclink" href="https://www.w3.org/TR/html5/tabular-data.html#attr-col-span">span</a> attribute.
101    *
102    * <p>
103    * Number of columns spanned by the element.
104    *
105    * @param value
106    *    The new value for this attribute.
107    *    Typically a {@link Number} or {@link String}.
108    *    Can be <jk>null</jk> to unset the attribute.
109    * @return This object.
110    */
111   public Col span(Object value) {
112      attr("span", value);
113      return this;
114   }
115
116}