001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.dto.html5; 014 015import static org.apache.juneau.xml.annotation.XmlFormat.*; 016 017import java.util.*; 018 019import org.apache.juneau.*; 020import org.apache.juneau.annotation.*; 021import org.apache.juneau.internal.*; 022import org.apache.juneau.xml.annotation.*; 023 024/** 025 * A subclass of HTML elements that contain mixed content (elements and text). 026 * 027 * <h5 class='section'>See Also:</h5><ul> 028 * <li class='link'><a class="doclink" href="../../../../../index.html#jd.Html5">Overview > juneau-dto > HTML5</a> 029 * </ul> 030 */ 031@FluentSetters 032public class HtmlElementMixed extends HtmlElement { 033 034 private LinkedList<Object> children; 035 036 /** 037 * The children of this element. 038 * 039 * @return The children of this element. 040 */ 041 @Xml(format=MIXED) 042 @Beanp(dictionary=HtmlBeanDictionary.class, name="c") 043 public LinkedList<Object> getChildren() { 044 return children; 045 } 046 047 /** 048 * Sets the children of this element. 049 * 050 * @param children The new children of this element. 051 * @return This object. 052 */ 053 @Beanp("c") 054 public HtmlElement setChildren(LinkedList<Object> children) { 055 this.children = children; 056 return this; 057 } 058 059 /** 060 * Returns the child node at the specified index. 061 * 062 * @param index The index of the node in the list of children. 063 * @return The child node, or <jk>null</jk> if it doesn't exist. 064 */ 065 public Object getChild(int index) { 066 return (children == null || children.size() <= index || index < 0 ? null : children.get(index)); 067 } 068 069 /** 070 * Returns the child node at the specified address. 071 * 072 * <p> 073 * Indexes are zero-indexed. 074 * 075 * <p> 076 * For example, calling <c>getChild(1,2,3);</c> will return the 4th child of the 3rd child of the 2nd child. 077 * 078 * @param index The child indexes. 079 * @return The child node, or <jk>null</jk> if it doesn't point to a valid child. 080 */ 081 public Object getChild(int...index) { 082 if (index.length == 0) 083 return null; 084 if (index.length == 1) 085 return getChild(index[0]); 086 Object c = this; 087 for (int element : index) { 088 if (c instanceof HtmlElementMixed) 089 c = ((HtmlElementMixed)c).getChild(element); 090 else if (c instanceof HtmlElementContainer) 091 c = ((HtmlElementContainer)c).getChild(element); 092 else 093 return null; 094 } 095 return c; 096 } 097 098 /** 099 * Returns the child node at the specified index. 100 * 101 * @param <T> he class type of the node. 102 * @param type The class type of the node. 103 * @param index The index of the node in the list of children. 104 * @return The child node, or <jk>null</jk> if it doesn't exist. 105 * @throws InvalidDataConversionException If node is not the expected type. 106 */ 107 public <T> T getChild(Class<T> type, int index) { 108 return ( 109 children == null || children.size() <= index || index < 0 110 ? null 111 : ConverterUtils.toType(children.get(index), type) 112 ); 113 } 114 115 /** 116 * Adds one or more child elements to this element. 117 * 118 * @param children 119 * The children to add as child elements. 120 * Can be a mixture of strings and {@link HtmlElement} objects. 121 * Can also be containers of strings and elements. 122 * @return This object. 123 */ 124 @FluentSetter 125 public HtmlElement children(Object...children) { 126 if (children.length != 0) 127 for (Object c : children) 128 child(c); 129 return this; 130 } 131 132 /** 133 * Adds a child element to this element. 134 * 135 * @param child 136 * The child to add as a child element. 137 * Can be a string or {@link HtmlElement}. 138 * Can also be a container of strings and elements. 139 * @return This object. 140 */ 141 @FluentSetter 142 public HtmlElement child(Object child) { 143 if (this.children == null) 144 this.children = new LinkedList<>(); 145 if (child instanceof Collection) 146 this.children.addAll((Collection<?>)child); 147 else 148 this.children.add(child); 149 return this; 150 } 151 152 // <FluentSetters> 153 154 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 155 public HtmlElementMixed _class(String _class) { 156 super._class(_class); 157 return this; 158 } 159 160 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 161 public HtmlElementMixed accesskey(String accesskey) { 162 super.accesskey(accesskey); 163 return this; 164 } 165 166 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 167 public HtmlElementMixed contenteditable(Object contenteditable) { 168 super.contenteditable(contenteditable); 169 return this; 170 } 171 172 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 173 public HtmlElementMixed dir(String dir) { 174 super.dir(dir); 175 return this; 176 } 177 178 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 179 public HtmlElementMixed hidden(Object hidden) { 180 super.hidden(hidden); 181 return this; 182 } 183 184 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 185 public HtmlElementMixed id(String id) { 186 super.id(id); 187 return this; 188 } 189 190 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 191 public HtmlElementMixed lang(String lang) { 192 super.lang(lang); 193 return this; 194 } 195 196 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 197 public HtmlElementMixed onabort(String onabort) { 198 super.onabort(onabort); 199 return this; 200 } 201 202 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 203 public HtmlElementMixed onblur(String onblur) { 204 super.onblur(onblur); 205 return this; 206 } 207 208 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 209 public HtmlElementMixed oncancel(String oncancel) { 210 super.oncancel(oncancel); 211 return this; 212 } 213 214 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 215 public HtmlElementMixed oncanplay(String oncanplay) { 216 super.oncanplay(oncanplay); 217 return this; 218 } 219 220 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 221 public HtmlElementMixed oncanplaythrough(String oncanplaythrough) { 222 super.oncanplaythrough(oncanplaythrough); 223 return this; 224 } 225 226 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 227 public HtmlElementMixed onchange(String onchange) { 228 super.onchange(onchange); 229 return this; 230 } 231 232 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 233 public HtmlElementMixed onclick(String onclick) { 234 super.onclick(onclick); 235 return this; 236 } 237 238 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 239 public HtmlElementMixed oncuechange(String oncuechange) { 240 super.oncuechange(oncuechange); 241 return this; 242 } 243 244 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 245 public HtmlElementMixed ondblclick(String ondblclick) { 246 super.ondblclick(ondblclick); 247 return this; 248 } 249 250 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 251 public HtmlElementMixed ondurationchange(String ondurationchange) { 252 super.ondurationchange(ondurationchange); 253 return this; 254 } 255 256 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 257 public HtmlElementMixed onemptied(String onemptied) { 258 super.onemptied(onemptied); 259 return this; 260 } 261 262 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 263 public HtmlElementMixed onended(String onended) { 264 super.onended(onended); 265 return this; 266 } 267 268 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 269 public HtmlElementMixed onerror(String onerror) { 270 super.onerror(onerror); 271 return this; 272 } 273 274 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 275 public HtmlElementMixed onfocus(String onfocus) { 276 super.onfocus(onfocus); 277 return this; 278 } 279 280 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 281 public HtmlElementMixed oninput(String oninput) { 282 super.oninput(oninput); 283 return this; 284 } 285 286 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 287 public HtmlElementMixed oninvalid(String oninvalid) { 288 super.oninvalid(oninvalid); 289 return this; 290 } 291 292 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 293 public HtmlElementMixed onkeydown(String onkeydown) { 294 super.onkeydown(onkeydown); 295 return this; 296 } 297 298 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 299 public HtmlElementMixed onkeypress(String onkeypress) { 300 super.onkeypress(onkeypress); 301 return this; 302 } 303 304 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 305 public HtmlElementMixed onkeyup(String onkeyup) { 306 super.onkeyup(onkeyup); 307 return this; 308 } 309 310 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 311 public HtmlElementMixed onload(String onload) { 312 super.onload(onload); 313 return this; 314 } 315 316 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 317 public HtmlElementMixed onloadeddata(String onloadeddata) { 318 super.onloadeddata(onloadeddata); 319 return this; 320 } 321 322 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 323 public HtmlElementMixed onloadedmetadata(String onloadedmetadata) { 324 super.onloadedmetadata(onloadedmetadata); 325 return this; 326 } 327 328 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 329 public HtmlElementMixed onloadstart(String onloadstart) { 330 super.onloadstart(onloadstart); 331 return this; 332 } 333 334 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 335 public HtmlElementMixed onmousedown(String onmousedown) { 336 super.onmousedown(onmousedown); 337 return this; 338 } 339 340 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 341 public HtmlElementMixed onmouseenter(String onmouseenter) { 342 super.onmouseenter(onmouseenter); 343 return this; 344 } 345 346 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 347 public HtmlElementMixed onmouseleave(String onmouseleave) { 348 super.onmouseleave(onmouseleave); 349 return this; 350 } 351 352 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 353 public HtmlElementMixed onmousemove(String onmousemove) { 354 super.onmousemove(onmousemove); 355 return this; 356 } 357 358 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 359 public HtmlElementMixed onmouseout(String onmouseout) { 360 super.onmouseout(onmouseout); 361 return this; 362 } 363 364 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 365 public HtmlElementMixed onmouseover(String onmouseover) { 366 super.onmouseover(onmouseover); 367 return this; 368 } 369 370 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 371 public HtmlElementMixed onmouseup(String onmouseup) { 372 super.onmouseup(onmouseup); 373 return this; 374 } 375 376 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 377 public HtmlElementMixed onmousewheel(String onmousewheel) { 378 super.onmousewheel(onmousewheel); 379 return this; 380 } 381 382 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 383 public HtmlElementMixed onpause(String onpause) { 384 super.onpause(onpause); 385 return this; 386 } 387 388 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 389 public HtmlElementMixed onplay(String onplay) { 390 super.onplay(onplay); 391 return this; 392 } 393 394 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 395 public HtmlElementMixed onplaying(String onplaying) { 396 super.onplaying(onplaying); 397 return this; 398 } 399 400 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 401 public HtmlElementMixed onprogress(String onprogress) { 402 super.onprogress(onprogress); 403 return this; 404 } 405 406 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 407 public HtmlElementMixed onratechange(String onratechange) { 408 super.onratechange(onratechange); 409 return this; 410 } 411 412 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 413 public HtmlElementMixed onreset(String onreset) { 414 super.onreset(onreset); 415 return this; 416 } 417 418 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 419 public HtmlElementMixed onresize(String onresize) { 420 super.onresize(onresize); 421 return this; 422 } 423 424 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 425 public HtmlElementMixed onscroll(String onscroll) { 426 super.onscroll(onscroll); 427 return this; 428 } 429 430 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 431 public HtmlElementMixed onseeked(String onseeked) { 432 super.onseeked(onseeked); 433 return this; 434 } 435 436 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 437 public HtmlElementMixed onseeking(String onseeking) { 438 super.onseeking(onseeking); 439 return this; 440 } 441 442 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 443 public HtmlElementMixed onselect(String onselect) { 444 super.onselect(onselect); 445 return this; 446 } 447 448 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 449 public HtmlElementMixed onshow(String onshow) { 450 super.onshow(onshow); 451 return this; 452 } 453 454 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 455 public HtmlElementMixed onstalled(String onstalled) { 456 super.onstalled(onstalled); 457 return this; 458 } 459 460 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 461 public HtmlElementMixed onsubmit(String onsubmit) { 462 super.onsubmit(onsubmit); 463 return this; 464 } 465 466 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 467 public HtmlElementMixed onsuspend(String onsuspend) { 468 super.onsuspend(onsuspend); 469 return this; 470 } 471 472 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 473 public HtmlElementMixed ontimeupdate(String ontimeupdate) { 474 super.ontimeupdate(ontimeupdate); 475 return this; 476 } 477 478 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 479 public HtmlElementMixed ontoggle(String ontoggle) { 480 super.ontoggle(ontoggle); 481 return this; 482 } 483 484 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 485 public HtmlElementMixed onvolumechange(String onvolumechange) { 486 super.onvolumechange(onvolumechange); 487 return this; 488 } 489 490 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 491 public HtmlElementMixed onwaiting(String onwaiting) { 492 super.onwaiting(onwaiting); 493 return this; 494 } 495 496 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 497 public HtmlElementMixed spellcheck(Object spellcheck) { 498 super.spellcheck(spellcheck); 499 return this; 500 } 501 502 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 503 public HtmlElementMixed style(String style) { 504 super.style(style); 505 return this; 506 } 507 508 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 509 public HtmlElementMixed tabindex(Object tabindex) { 510 super.tabindex(tabindex); 511 return this; 512 } 513 514 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 515 public HtmlElementMixed title(String title) { 516 super.title(title); 517 return this; 518 } 519 520 @Override /* GENERATED - org.apache.juneau.dto.html5.HtmlElement */ 521 public HtmlElementMixed translate(Object translate) { 522 super.translate(translate); 523 return this; 524 } 525 526 // </FluentSetters> 527}