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-td-element">&lt;td&gt;</a>
023 * element.
024 *
025 * <p>
026 * The td element represents a data cell in a table. It is used to contain the actual data content
027 * of a table row, as opposed to header cells (th) which contain column or row headers. The td
028 * element can contain any flow content and supports attributes for spanning multiple columns or
029 * rows, as well as associating with header cells for accessibility.
030 *
031 * <h5 class='section'>Examples:</h5>
032 * <p class='bcode w800'>
033 *    <jk>import static</jk> org.apache.juneau.bean.html5.HtmlBuilder.*;
034 *
035 *    <jc>// Simple data cell</jc>
036 *    Td <jv>simple</jv> = <jsm>td</jsm>(<js>"John Doe"</js>);
037 *
038 *    <jc>// Data cell with styling</jc>
039 *    Td <jv>styled</jv> = <jsm>td</jsm>(<js>"Important Data"</js>)
040 *       .class_(<js>"highlight"</js>);
041 *
042 *    <jc>// Data cell spanning multiple columns</jc>
043 *    Td <jv>colspan</jv> = <jsm>td</jsm>(<js>"Spans 2 columns"</js>)
044 *       .colspan(2);
045 *
046 *    <jc>// Data cell spanning multiple rows</jc>
047 *    Td <jv>rowspan</jv> = <jsm>td</jsm>(<js>"Spans 3 rows"</js>)
048 *       .rowspan(3);
049 *
050 *    <jc>// Data cell with headers association</jc>
051 *    Td <jv>headers</jv> = <jsm>td</jsm>(<js>"25"</js>)
052 *       .headers(<js>"name-header age-header"</js>);
053 *
054 *    <jc>// Data cell with complex content</jc>
055 *    Td <jv>complex</jv> = <jsm>td</jsm>(
056 *       <jsm>strong</jsm>(<js>"Bold text"</js>),
057 *       <js>" and "</js>,
058 *       <jsm>em</jsm>(<js>"italic text"</js>)
059 *    );
060 * </p>
061 *
062 * <h5 class='section'>See Also:</h5><ul>
063 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a>
064 * </ul>
065 */
066@Marshalled(typeName = "td")
067public class Td extends HtmlElementMixed<Td> {
068
069   /**
070    * Creates an empty {@link Td} element.
071    */
072   public Td() {}
073
074   /**
075    * Creates a {@link Td} element with the specified child nodes.
076    *
077    * @param children The child nodes. Must not be <jk>null</jk>.
078    */
079   public Td(Object...children) {
080      children(children);
081   }
082
083   /**
084    * <a class="doclink" href="https://www.w3.org/TR/html5/tabular-data.html#attr-tdth-colspan">colspan</a> attribute.
085    *
086    * <p>
087    * Number of columns that the cell is to span.
088    *
089    * @param value
090    *    The new value for this attribute.
091    *    Typically a {@link Number} or {@link String}.
092    *    Can be <jk>null</jk> to unset the attribute.
093    * @return This object.
094    */
095   public Td colspan(Object value) {
096      attr("colspan", value);
097      return this;
098   }
099
100   /**
101    * <a class="doclink" href="https://www.w3.org/TR/html5/tabular-data.html#attr-tdth-headers">headers</a> attribute.
102    *
103    * <p>
104    * Specifies the IDs of header cells that apply to this table cell. This creates a programmatic
105    * relationship between the cell and its headers for accessibility purposes.
106    *
107    * <p>
108    * Multiple IDs can be specified as a space-separated list.
109    *
110    * @param value The IDs of header cells that apply to this cell. Can be <jk>null</jk> to unset the attribute.
111    * @return This object.
112    */
113   public Td headers(String value) {
114      attr("headers", value);
115      return this;
116   }
117
118   /**
119    * <a class="doclink" href="https://www.w3.org/TR/html5/tabular-data.html#attr-tdth-rowspan">rowspan</a> attribute.
120    *
121    * <p>
122    * Number of rows that the cell is to span.
123    *
124    * @param value
125    *    The new value for this attribute.
126    *    Typically a {@link Number} or {@link String}.
127    *    Can be <jk>null</jk> to unset the attribute.
128    * @return This object.
129    */
130   public Td rowspan(Object value) {
131      attr("rowspan", value);
132      return this;
133   }
134}