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/grouping-content.html#the-ol-element">&lt;ol&gt;</a>
023 * element.
024 *
025 * <p>
026 * The ol element represents an ordered list of items. It contains li elements that represent
027 * individual list items. The list items are typically numbered automatically by the browser,
028 * and the numbering can be customized using the type and start attributes.
029 *
030 * <h5 class='section'>Examples:</h5>
031 * <p class='bcode w800'>
032 *    <jk>import static</jk> org.apache.juneau.bean.html5.HtmlBuilder.*;
033 *
034 *    <jc>// Simple ordered list</jc>
035 *    Ol <jv>ol1</jv> = <jsm>ol</jsm>(
036 *       <jsm>li</jsm>(<js>"First item"</js>),
037 *       <jsm>li</jsm>(<js>"Second item"</js>),
038 *       <jsm>li</jsm>(<js>"Third item"</js>)
039 *    );
040 *
041 *    <jc>// Ordered list with custom numbering</jc>
042 *    Ol <jv>ol2</jv> = <jsm>ol</jsm>(
043 *       <jsm>li</jsm>(<js>"Item A"</js>),
044 *       <jsm>li</jsm>(<js>"Item B"</js>),
045 *       <jsm>li</jsm>(<js>"Item C"</js>)
046 *    ).type(<js>"A"</js>).start(1);
047 *
048 *    <jc>// Reversed ordered list</jc>
049 *    Ol <jv>ol3</jv> = <jsm>ol</jsm>(
050 *       <jsm>li</jsm>(<js>"Last item"</js>),
051 *       <jsm>li</jsm>(<js>"Middle item"</js>),
052 *       <jsm>li</jsm>(<js>"First item"</js>)
053 *    ).reversed(<jk>true</jk>);
054 *
055 *    <jc>// Nested ordered list</jc>
056 *    Ol <jv>ol4</jv> = <jsm>ol</jsm>(
057 *       <jsm>li</jsm>(<js>"Main item 1"</js>),
058 *       <jsm>li</jsm>(
059 *          <jsm>ol</jsm>(
060 *             <jsm>li</jsm>(<js>"Sub item 1.1"</js>),
061 *             <jsm>li</jsm>(<js>"Sub item 1.2"</js>)
062 *          )
063 *       ),
064 *       <jsm>li</jsm>(<js>"Main item 2"</js>)
065 *    );
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#ol() ol()}
074 *       <li class='jm'>{@link HtmlBuilder#ol(Object...) ol(Object...)}
075 *    </ul>
076 * </ul>
077 * </p>
078 *
079 * <h5 class='section'>See Also:</h5><ul>
080 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a>
081 * </ul>
082 */
083@Marshalled(typeName = "ol")
084public class Ol extends HtmlElementContainer<Ol> {
085
086   /**
087    * Creates an empty {@link Ol} element.
088    */
089   public Ol() {}
090
091   /**
092    * Creates an {@link Ol} element with the specified child nodes.
093    *
094    * @param children The child nodes. Must not be <jk>null</jk>.
095    */
096   public Ol(Object...children) {
097      children(children);
098   }
099
100   /**
101    * <a class="doclink" href="https://www.w3.org/TR/html5/grouping-content.html#attr-ol-reversed">reversed</a>
102    * attribute.
103    *
104    * <p>
105    * Number the list backwards..
106    *
107    * <p>
108    * This attribute uses deminimized values:
109    * <ul>
110    *    <li><jk>false</jk> - Attribute is not added</li>
111    *    <li><jk>true</jk> - Attribute is added as <js>"reversed"</js></li>
112    *    <li>Other values - Passed through as-is</li>
113    * </ul>
114    *
115    * @param value
116    *    The new value for this attribute.
117    *    Typically a {@link Boolean} or {@link String}.
118    *    Can be <jk>null</jk> to unset the attribute.
119    * @return This object.
120    */
121   public Ol reversed(Object value) {
122      attr("reversed", deminimize(value, "reversed"));
123      return this;
124   }
125
126   /**
127    * <a class="doclink" href="https://www.w3.org/TR/html5/grouping-content.html#attr-ol-start">start</a> attribute.
128    *
129    * <p>
130    * Ordinal value of the first item.
131    *
132    * @param value
133    *    The new value for this attribute.
134    *    Typically a {@link Number} or {@link String}.
135    *    Can be <jk>null</jk> to unset the attribute.
136    * @return This object.
137    */
138   public Ol start(Object value) {
139      attr("start", value);
140      return this;
141   }
142
143   /**
144    * <a class="doclink" href="https://www.w3.org/TR/html5/grouping-content.html#attr-ol-type">type</a> attribute.
145    *
146    * <p>
147    * Specifies the type of numbering to use for the ordered list items.
148    *
149    * <p>
150    * Possible values:
151    * <ul>
152    *    <li><js>"1"</js> - Decimal numbers (1, 2, 3, ...) - default</li>
153    *    <li><js>"a"</js> - Lowercase letters (a, b, c, ...)</li>
154    *    <li><js>"A"</js> - Uppercase letters (A, B, C, ...)</li>
155    *    <li><js>"i"</js> - Lowercase Roman numerals (i, ii, iii, ...)</li>
156    *    <li><js>"I"</js> - Uppercase Roman numerals (I, II, III, ...)</li>
157    * </ul>
158    *
159    * @param value The type of numbering for the ordered list. Can be <jk>null</jk> to unset the attribute.
160    * @return This object.
161    */
162   public Ol type(String value) {
163      attr("type", value);
164      return this;
165   }
166}