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"><ol></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 * <h2 class='section'>Examples:</h2> 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 * 078 * <h2 class='section'>See Also:</h2><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 = "ol") 083public class Ol extends HtmlElementContainer<Ol> { 084 085 /** 086 * Creates an empty {@link Ol} element. 087 */ 088 public Ol() {} 089 090 /** 091 * Creates an {@link Ol} element with the specified child nodes. 092 * 093 * @param children The child nodes. Must not be <jk>null</jk>. 094 */ 095 public Ol(Object...children) { 096 children(children); 097 } 098 099 /** 100 * <a class="doclink" href="https://www.w3.org/TR/html5/grouping-content.html#attr-ol-reversed">reversed</a> 101 * attribute. 102 * 103 * <p> 104 * Number the list backwards.. 105 * 106 * <p> 107 * This attribute uses deminimized values: 108 * <ul> 109 * <li><jk>false</jk> - Attribute is not added</li> 110 * <li><jk>true</jk> - Attribute is added as <js>"reversed"</js></li> 111 * <li>Other values - Passed through as-is</li> 112 * </ul> 113 * 114 * @param value 115 * The new value for this attribute. 116 * Typically a {@link Boolean} or {@link String}. 117 * Can be <jk>null</jk> to unset the attribute. 118 * @return This object. 119 */ 120 public Ol reversed(Object value) { 121 attr("reversed", deminimize(value, "reversed")); 122 return this; 123 } 124 125 /** 126 * <a class="doclink" href="https://www.w3.org/TR/html5/grouping-content.html#attr-ol-start">start</a> attribute. 127 * 128 * <p> 129 * Ordinal value of the first item. 130 * 131 * @param value 132 * The new value for this attribute. 133 * Typically a {@link Number} or {@link String}. 134 * Can be <jk>null</jk> to unset the attribute. 135 * @return This object. 136 */ 137 public Ol start(Object value) { 138 attr("start", value); 139 return this; 140 } 141 142 /** 143 * <a class="doclink" href="https://www.w3.org/TR/html5/grouping-content.html#attr-ol-type">type</a> attribute. 144 * 145 * <p> 146 * Specifies the type of numbering to use for the ordered list items. 147 * 148 * <p> 149 * Possible values: 150 * <ul> 151 * <li><js>"1"</js> - Decimal numbers (1, 2, 3, ...) - default</li> 152 * <li><js>"a"</js> - Lowercase letters (a, b, c, ...)</li> 153 * <li><js>"A"</js> - Uppercase letters (A, B, C, ...)</li> 154 * <li><js>"i"</js> - Lowercase Roman numerals (i, ii, iii, ...)</li> 155 * <li><js>"I"</js> - Uppercase Roman numerals (I, II, III, ...)</li> 156 * </ul> 157 * 158 * @param value The type of numbering for the ordered list. Can be <jk>null</jk> to unset the attribute. 159 * @return This object. 160 */ 161 public Ol type(String value) { 162 attr("type", value); 163 return this; 164 } 165}