http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlBuilder.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlBuilder.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlBuilder.java new file mode 100644 index 0000000..c2c31f2 --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlBuilder.java @@ -0,0 +1,1845 @@ +// *************************************************************************************************************************** +// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * +// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * +// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * +// * with the License. You may obtain a copy of the License at * +// * * +// * http://www.apache.org/licenses/LICENSE-2.0 * +// * * +// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * +// * specific language governing permissions and limitations under the License. * +// *************************************************************************************************************************** +package org.apache.juneau.dto.html5; + +/** + * Various useful static methods for creating HTML elements. + */ +public class HtmlBuilder { + + /** + * Creates an empty {@link A} element. + * @return The new element. + */ + public static final A a() { + return new A(); + } + + /** + * Creates an {@link A} element with the specified {@link A#href(String)} attribute and {@link A#children(Object[])} nodes. + * @param href The {@link A#href(String)} attribute. + * @param children The {@link A#children(Object[])} nodes. + * @return The new element. + */ + public static final A a(String href, Object...children) { + return a().href(href).children(children); + } + + /** + * Creates an empty {@link Abbr} element. + * @return The new element. + */ + public static final Abbr abbr() { + return new Abbr(); + } + + /** + * Creates an {@link Abbr} element with the specified {@link Abbr#title(String)} attribute and {@link Abbr#children(Object[])} nodes. + * @param title The {@link Abbr#title(String)} attribute. + * @param children The {@link Abbr#children(Object[])} nodes. + * @return The new element. + */ + public static final Abbr abbr(String title, Object...children) { + return abbr().title(title).children(children); + } + + /** + * Creates an empty {@link Address} element. + * @return The new element. + */ + public static final Address address() { + return new Address(); + } + + /** + * Creates an {@link Address} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Address address(Object...children) { + return address().children(children); + } + + /** + * Creates an empty {@link Area} element. + * @return The new element. + */ + public static final Area area() { + return new Area(); + } + + /** + * Creates an {@link Area} element with the specified {@link Area#shape(String)}, {@link Area#coords(String)}, and {@link Area#href(String)} attributes. + * @param shape The {@link Area#shape(String)} attribute. + * @param coords The {@link Area#coords(String)} attribute. + * @param href The {@link Area#href(String)} attribute. + * @return The new element. + */ + public static final Area area(String shape, String coords, String href) { + return area().shape(shape).coords(coords).href(href); + } + + /** + * Creates an empty {@link Article} element. + * @return The new element. + */ + public static final Article article() { + return new Article(); + } + + /** + * Creates an empty {@link Aside} element. + * @return The new element. + */ + public static final Aside aside() { + return new Aside(); + } + + /** + * Creates an {@link Aside} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Aside aside(Object...children) { + return aside().children(children); + } + + /** + * Creates an empty {@link Audio} element. + * @return The new element. + */ + public static final Audio audio() { + return new Audio(); + } + + /** + * Creates an {@link Audio} element with the specified {@link Audio#src(String)} attribute. + * @param src The {@link Audio#src(String)} attribute. + * @return The new element. + */ + public static final Audio audio(String src) { + return audio().src(src); + } + + /** + * Creates an empty {@link B} element. + * @return The new element. + */ + public static final B b() { + return new B(); + } + + /** + * Creates a {@link B} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final B b(Object...children) { + return b().children(children); + } + + /** + * Creates an empty {@link Base} element. + * @return The new element. + */ + public static final Base base() { + return new Base(); + } + + /** + * Creates a {@link Base} element with the specified {@link Base#href(String)} attribute. + * @param href The {@link Base#href(String)} attribute. + * @return The new element. + */ + public static final Base base(String href) { + return base().href(href); + } + + /** + * Creates an empty {@link Bdi} element. + * @return The new element. + */ + public static final Bdi bdi() { + return new Bdi(); + } + + /** + * Creates a {@link Bdi} element with the specified {@link Bdi#text(Object)} node. + * @param text The {@link Bdi#text(Object)} node. + * @return The new element. + */ + public static final Bdi bdi(Object text) { + return bdi().text(text); + } + + /** + * Creates an empty {@link Bdo} element. + * @return The new element. + */ + public static final Bdo bdo() { + return new Bdo(); + } + + /** + * Creates a {@link Bdo} element with the specified {@link Bdo#dir(String)} attribute and child nodes. + * @param dir The {@link Bdo#dir(String)} attribute. + * @param children The child nodes. + * @return The new element. + */ + public static final Bdo bdo(String dir, Object...children) { + return bdo().dir(dir).children(children); + } + + /** + * Creates an empty {@link Blockquote} element. + * @return The new element. + */ + public static final Blockquote blockquote() { + return new Blockquote(); + } + + /** + * Creates a {@link Blockquote} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Blockquote blockquote(Object...children) { + return blockquote().children(children); + } + + /** + * Creates an empty {@link Body} element. + * @return The new element. + */ + public static final Body body() { + return new Body(); + } + + /** + * Creates a {@link Body} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Body body(Object...children) { + return body().children(children); + } + + /** + * Creates an empty {@link Br} element. + * @return The new element. + */ + public static final Br br() { + return new Br(); + } + + /** + * Creates an empty {@link Button} element. + * @return The new element. + */ + public static final Button button() { + return new Button(); + } + + /** + * Creates a {@link Button} element with the specified {@link Button#type(String)} attribute. + * @param type The {@link Button#type(String)} attribute. + * @return The new element. + */ + public static final Button button(String type) { + return button().type(type); + } + + /** + * Creates a {@link Button} element with the specified {@link Button#type(String)} attribute and {@link Button#children(Object[])} nodes. + * @param type The {@link Button#type(String)} attribute. + * @param children The {@link Button#children(Object[])} nodes. + * @return The new element. + */ + public static final Button button(String type, Object...children) { + return button().type(type).child(children); + } + + /** + * Creates an empty {@link Canvas} element. + * @return The new element. + */ + public static final Canvas canvas() { + return new Canvas(); + } + + /** + * Creates a {@link Canvas} element with the specified {@link Canvas#width(long)} and {@link Canvas#height(long)} attributes. + * @param width The {@link Canvas#width(long)} attribute. + * @param height The {@link Canvas#height(long)} attribute. + * @return The new element. + */ + public static final Canvas canvas(long width, long height) { + return canvas().width(width).height(height); + } + + /** + * Creates an empty {@link Caption} element. + * @return The new element. + */ + public static final Caption caption() { + return new Caption(); + } + + /** + * Creates a {@link Caption} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Caption caption(Object...children) { + return caption().children(children); + } + + /** + * Creates an empty {@link Cite} element. + * @return The new element. + */ + public static final Cite cite() { + return new Cite(); + } + + /** + * Creates a {@link Cite} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Cite cite(Object...children) { + return cite().children(children); + } + + /** + * Creates an empty {@link Code} element. + * @return The new element. + */ + public static final Code code() { + return new Code(); + } + + /** + * Creates a {@link Code} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Code code(Object...children) { + return code().children(children); + } + + /** + * Creates an empty {@link Col} element. + * @return The new element. + */ + public static final Col col() { + return new Col(); + } + + /** + * Creates a {@link Col} element with the specified {@link Col#span(long)} attribute. + * @param span The {@link Col#span(long)} attribute. + * @return The new element. + */ + public static final Col col(long span) { + return col().span(span); + } + + /** + * Creates an empty {@link Colgroup} element. + * @return The new element. + */ + public static final Colgroup colgroup() { + return new Colgroup(); + } + + /** + * Creates a {@link Colgroup} element with the specified {@link Colgroup#span(long)} attribute. + * @param span The {@link Colgroup#span(long)} attribute. + * @return The new element. + */ + public static final Colgroup colgroup(long span) { + return colgroup().span(span); + } + + /** + * Creates a {@link Colgroup} element with the specified {@link Colgroup#span(long)} attribute and child nodes. + * @param span The {@link Colgroup#span(long)} attribute. + * @param children The child nodes. + * @return The new element. + */ + public static final Colgroup colgroup(long span, Object...children) { + return colgroup().span(span).children(children); + } + + /** + * Creates an empty {@link Data} element. + * @return The new element. + */ + public static final Data data() { + return new Data(); + } + + /** + * Creates a {@link Data} element with the specified {@link Data#value(String)} attribute. + * @param value The {@link Data#value(String)} attribute. + * @return The new element. + */ + public static final Data data(String value) { + return data().value(value); + } + + /** + * Creates an empty {@link Datalist} element. + * @return The new element. + */ + public static final Datalist datalist() { + return new Datalist(); + } + + /** + * Creates a {@link Datalist} element with the specified {@link Datalist#id(String)} attribute and child nodes. + * @param id The {@link Datalist#id(String)} attribute. + * @param children The child nodes. + * @return The new element. + */ + public static final Datalist datalist(String id, Option...children) { + return datalist().id(id).children((Object[])children); + } + + /** + * Creates an empty {@link Dd} element. + * @return The new element. + */ + public static final Dd dd() { + return new Dd(); + } + + /** + * Creates a {@link Dd} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Dd dd(Object...children) { + return dd().children(children); + } + + /** + * Creates an empty {@link Del} element. + * @return The new element. + */ + public static final Del del() { + return new Del(); + } + + /** + * Creates a {@link Del} element with the specified {@link Del#children(Object[])} node. + * @param children The {@link Del#children(Object[])} node. + * @return The new element. + */ + public static final Del del(Object...children) { + return del().children(children); + } + + /** + * Creates an empty {@link Dfn} element. + * @return The new element. + */ + public static final Dfn dfn() { + return new Dfn(); + } + + /** + * Creates a {@link Dfn} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Dfn dfn(Object...children) { + return dfn().children(children); + } + + /** + * Creates an empty {@link Div} element. + * @return The new element. + */ + public static final Div div() { + return new Div(); + } + + /** + * Creates a {@link Div} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Div div(Object...children) { + return div().children(children); + } + + /** + * Creates an empty {@link Dl} element. + * @return The new element. + */ + public static final Dl dl() { + return new Dl(); + } + + /** + * Creates a {@link Dl} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Dl dl(Dd...children) { + return dl().children((Object[])children); + } + + /** + * Creates an empty {@link Dt} element. + * @return The new element. + */ + public static final Dt dt() { + return new Dt(); + } + + /** + * Creates a {@link Dt} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Dt dt(Object...children) { + return dt().children(children); + } + + /** + * Creates an empty {@link Em} element. + * @return The new element. + */ + public static final Em em() { + return new Em(); + } + + /** + * Creates an {@link Em} element with the specified {@link Em#children(Object[])} nodes. + * @param children The {@link Em#children(Object[])} nodes. + * @return The new element. + */ + public static final Em em(Object...children) { + return em().children(children); + } + + /** + * Creates an empty {@link Embed} element. + * @return The new element. + */ + public static final Embed embed() { + return new Embed(); + } + + /** + * Creates an {@link Embed} element with the specified {@link Embed#src(String)} attribute. + * @param src The {@link Embed#src(String)} attribute. + * @return The new element. + */ + public static final Embed embed(String src) { + return embed().src(src); + } + + /** + * Creates an empty {@link Fieldset} element. + * @return The new element. + */ + public static final Fieldset fieldset() { + return new Fieldset(); + } + + /** + * Creates a {@link Fieldset} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Fieldset fieldset(Object...children) { + return fieldset().children(children); + } + + /** + * Creates an empty {@link Figcaption} element. + * @return The new element. + */ + public static final Figcaption figcaption() { + return new Figcaption(); + } + + /** + * Creates a {@link Figcaption} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Figcaption figcaption(Object...children) { + return figcaption().children(children); + } + + /** + * Creates an empty {@link Figure} element. + * @return The new element. + */ + public static final Figure figure() { + return new Figure(); + } + + /** + * Creates a {@link Figure} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Figure figure(Object...children) { + return figure().children(children); + } + + /** + * Creates an empty {@link Footer} element. + * @return The new element. + */ + public static final Footer footer() { + return new Footer(); + } + + /** + * Creates a {@link Footer} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Footer footer(Object...children) { + return footer().children(children); + } + + /** + * Creates an empty {@link Form} element. + * @return The new element. + */ + public static final Form form() { + return new Form(); + } + + /** + * Creates a {@link Form} element with the specified {@link Form#action(String)} attribute. + * @param action The {@link Form#action(String)} attribute. + * @return The new element. + */ + public static final Form form(String action) { + return form().action(action); + } + + /** + * Creates an {@link Form} element with the specified {@link Form#action(String)} attribute and child nodes. + * @param action The {@link Form#action(String)} attribute. + * @param children The child nodes. + * @return The new element. + */ + public static final Form form(String action, Object...children) { + return form().action(action).children(children); + } + + /** + * Creates an empty {@link H1} element. + * @return The new element. + */ + public static final H1 h1() { + return new H1(); + } + + /** + * Creates an {@link H1} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final H1 h1(Object...children) { + return h1().children(children); + } + + /** + * Creates an empty {@link H2} element. + * @return The new element. + */ + public static final H2 h2() { + return new H2(); + } + + /** + * Creates an {@link H2} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final H2 h2(Object...children) { + return h2().children(children); + } + + /** + * Creates an empty {@link H3} element. + * @return The new element. + */ + public static final H3 h3() { + return new H3(); + } + + /** + * Creates an {@link H3} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final H3 h3(Object...children) { + return h3().children(children); + } + + /** + * Creates an empty {@link H4} element. + * @return The new element. + */ + public static final H4 h4() { + return new H4(); + } + + /** + * Creates an {@link H4} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final H4 h4(Object...children) { + return h4().children(children); + } + + /** + * Creates an empty {@link H5} element. + * @return The new element. + */ + public static final H5 h5() { + return new H5(); + } + + /** + * Creates an {@link H5} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final H5 h5(Object...children) { + return h5().children(children); + } + + /** + * Creates an empty {@link H6} element. + * @return The new element. + */ + public static final H6 h6() { + return new H6(); + } + + /** + * Creates an {@link H6} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final H6 h6(Object...children) { + return h6().children(children); + } + + /** + * Creates an empty {@link Head} element. + * @return The new element. + */ + public static final Head head() { + return new Head(); + } + + /** + * Creates a {@link Head} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Head head(Object...children) { + return head().children(children); + } + + /** + * Creates an empty {@link Header} element. + * @return The new element. + */ + public static final Header header() { + return new Header(); + } + + /** + * Creates a {@link Header} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Header header(Object...children) { + return header().children(children); + } + + /** + * Creates an empty {@link Hr} element. + * @return The new element. + */ + public static final Hr hr() { + return new Hr(); + } + + /** + * Creates an empty {@link Html} element. + * @return The new element. + */ + public static final Html html() { + return new Html(); + } + + /** + * Creates an {@link Html} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Html html(Object...children) { + return html().children(children); + } + + /** + * Creates an empty {@link I} element. + * @return The new element. + */ + public static final I i() { + return new I(); + } + + /** + * Creates an {@link I} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final I i(Object...children) { + return i().children(children); + } + + /** + * Creates an empty {@link Iframe} element. + * @return The new element. + */ + public static final Iframe iframe() { + return new Iframe(); + } + + /** + * Creates an {@link Iframe} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Iframe iframe(Object...children) { + return iframe().children(children); + } + + /** + * Creates an empty {@link Img} element. + * @return The new element. + */ + public static final Img img() { + return new Img(); + } + + /** + * Creates an {@link Img} element with the specified {@link Img#src(String)} attribute. + * @param src The {@link Img#src(String)} attribute. + * @return The new element. + */ + public static final Img img(String src) { + return img().src(src); + } + + /** + * Creates an empty {@link Input} element. + * @return The new element. + */ + public static final Input input() { + return new Input(); + } + + /** + * Creates an {@link Input} element with the specified {@link Input#type(String)} attribute. + * @param type The {@link Input#type(String)} attribute. + * @return The new element. + */ + public static final Input input(String type) { + return input().type(type); + } + + /** + * Creates an empty {@link Ins} element. + * @return The new element. + */ + public static final Ins ins() { + return new Ins(); + } + + /** + * Creates an {@link Ins} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Ins ins(Object...children) { + return ins().children(children); + } + + /** + * Creates an empty {@link Kbd} element. + * @return The new element. + */ + public static final Kbd kbd() { + return new Kbd(); + } + + /** + * Creates a {@link Kbd} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Kbd kbd(Object...children) { + return kbd().children(children); + } + + /** + * Creates an empty {@link Keygen} element. + * @return The new element. + */ + public static final Keygen keygen() { + return new Keygen(); + } + + /** + * Creates an empty {@link Label} element. + * @return The new element. + */ + public static final Label label() { + return new Label(); + } + + /** + * Creates a {@link Label} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Label label(Object...children) { + return label().children(children); + } + + /** + * Creates an empty {@link Legend} element. + * @return The new element. + */ + public static final Legend legend() { + return new Legend(); + } + + /** + * Creates a {@link Legend} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Legend legend(Object...children) { + return legend().children(children); + } + + /** + * Creates an empty {@link Li} element. + * @return The new element. + */ + public static final Li li() { + return new Li(); + } + + /** + * Creates an {@link Li} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Li li(Object...children) { + return li().children(children); + } + + /** + * Creates an empty {@link Link} element. + * @return The new element. + */ + public static final Link link() { + return new Link(); + } + + /** + * Creates a {@link Link} element with the specified {@link Link#href(String)} attribute. + * @param href The {@link Link#href(String)} attribute. + * @return The new element. + */ + public static final Link link(String href) { + return link().href(href); + } + + /** + * Creates an empty {@link Main} element. + * @return The new element. + */ + public static final Main main() { + return new Main(); + } + + /** + * Creates a {@link Main} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Main main(Object...children) { + return main().children(children); + } + + /** + * Creates an empty {@link Map} element. + * @return The new element. + */ + public static final Map map() { + return new Map(); + } + + /** + * Creates a {@link Map} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Map map(Object...children) { + return map().children(children); + } + + /** + * Creates an empty {@link Mark} element. + * @return The new element. + */ + public static final Mark mark() { + return new Mark(); + } + + /** + * Creates a {@link Mark} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Mark mark(Object...children) { + return mark().children(children); + } + + /** + * Creates an empty {@link Meta} element. + * @return The new element. + */ + public static final Meta meta() { + return new Meta(); + } + + /** + * Creates an empty {@link Meter} element. + * @return The new element. + */ + public static final Meter meter() { + return new Meter(); + } + + /** + * Creates a {@link Meter} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Meter meter(Object...children) { + return meter().children(children); + } + + /** + * Creates an empty {@link Nav} element. + * @return The new element. + */ + public static final Nav nav() { + return new Nav(); + } + + /** + * Creates a {@link Nav} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Nav nav(Object...children) { + return nav().children(children); + } + + /** + * Creates an empty {@link Noscript} element. + * @return The new element. + */ + public static final Noscript noscript() { + return new Noscript(); + } + + /** + * Creates a {@link Noscript} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Noscript noscript(Object...children) { + return noscript().children(children); + } + + /** + * Creates an empty {@link Object2} element. + * @return The new element. + */ + public static final Object2 object() { + return new Object2(); + } + + /** + * Creates an {@link Object2} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Object2 object(Object...children) { + return object().children(children); + } + + /** + * Creates an empty {@link Ol} element. + * @return The new element. + */ + public static final Ol ol() { + return new Ol(); + } + + /** + * Creates an {@link Ol} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Ol ol(Object...children) { + return ol().children(children); + } + + /** + * Creates an empty {@link Optgroup} element. + * @return The new element. + */ + public static final Optgroup optgroup() { + return new Optgroup(); + } + + /** + * Creates an {@link Optgroup} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Optgroup optgroup(Object...children) { + return optgroup().children(children); + } + + /** + * Creates an empty {@link Option} element. + * @return The new element. + */ + public static final Option option() { + return new Option(); + } + + /** + * Creates an {@link Option} element with the specified {@link Option#value(String)} attribute and {@link Option#text(Object)} node. + * @param value The {@link Option#value(String)} attribute. + * @param text The {@link Option#text(Object)} node. + * @return The new element. + */ + public static final Option option(String value, String text) { + return option().value(value).text(text); + } + + /** + * Creates an empty {@link Output} element. + * @return The new element. + */ + public static final Output output() { + return new Output(); + } + + /** + * Creates an {@link Output} element with the specified {@link Output#name(String)} attribute. + * @param name The {@link Output#name(String)} attribute. + * @return The new element. + */ + public static final Output output(String name) { + return output().name(name); + } + + /** + * Creates an empty {@link P} element. + * @return The new element. + */ + public static final P p() { + return new P(); + } + + /** + * Creates a {@link P} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final P p(Object...children) { + return p().children(children); + } + + /** + * Creates an empty {@link Param} element. + * @return The new element. + */ + public static final Param param() { + return new Param(); + } + + /** + * Creates a {@link Param} element with the specified {@link Param#name(String)} and {@link Param#value(String)} attributes. + * @param name The {@link Param#name(String)} attribute. + * @param value The {@link Param#value(String)} attribute. + * @return The new element. + */ + public static final Param param(String name, String value) { + return param().name(name).value(value); + } + + /** + * Creates an empty {@link Pre} element. + * @return The new element. + */ + public static final Pre pre() { + return new Pre(); + } + + /** + * Creates a {@link Pre} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Pre pre(Object...children) { + return pre().children(children); + } + + /** + * Creates an empty {@link Progress} element. + * @return The new element. + */ + public static final Progress progress() { + return new Progress(); + } + + /** + * Creates a {@link Progress} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Progress progress(Object...children) { + return progress().children(children); + } + + /** + * Creates an empty {@link Q} element. + * @return The new element. + */ + public static final Q q() { + return new Q(); + } + + /** + * Creates a {@link Q} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Q q(Object...children) { + return q().children(children); + } + + /** + * Creates an empty {@link Rb} element. + * @return The new element. + */ + public static final Rb rb() { + return new Rb(); + } + + /** + * Creates a {@link Rb} element with the specified {@link Rb#children(Object[])} nodes. + * @param children The {@link Rb#children(Object[])} nodes. + * @return The new element. + */ + public static final Rb rb(Object...children) { + return rb().children(children); + } + + /** + * Creates an empty {@link Rp} element. + * @return The new element. + */ + public static final Rp rp() { + return new Rp(); + } + + /** + * Creates a {@link Rp} element with the specified {@link Rp#children(Object[])} nodes. + * @param children The {@link Rp#children(Object[])} nodes. + * @return The new element. + */ + public static final Rp rp(Object...children) { + return rp().children(children); + } + + /** + * Creates an empty {@link Rt} element. + * @return The new element. + */ + public static final Rt rt() { + return new Rt(); + } + + /** + * Creates a {@link Rt} element with the specified {@link Rt#children(Object[])} nodes. + * @param children The {@link Rt#children(Object[])} nodes. + * @return The new element. + */ + public static final Rt rt(Object...children) { + return rt().children(children); + } + + /** + * Creates an empty {@link Rtc} element. + * @return The new element. + */ + public static final Rtc rtc() { + return new Rtc(); + } + + /** + * Creates an {@link Rtc} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Rtc rtc(Object...children) { + return rtc().children(children); + } + + /** + * Creates an empty {@link Ruby} element. + * @return The new element. + */ + public static final Ruby ruby() { + return new Ruby(); + } + + /** + * Creates a {@link Ruby} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Ruby ruby(Object...children) { + return ruby().children(children); + } + + /** + * Creates an empty {@link S} element. + * @return The new element. + */ + public static final S s() { + return new S(); + } + + /** + * Creates an {@link S} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final S s(Object...children) { + return s().children(children); + } + + /** + * Creates an empty {@link Samp} element. + * @return The new element. + */ + public static final Samp samp() { + return new Samp(); + } + + /** + * Creates a {@link Samp} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Samp samp(Object...children) { + return samp().children(children); + } + + /** + * Creates an empty {@link Script} element. + * @return The new element. + */ + public static final Script script() { + return new Script(); + } + + /** + * Creates a {@link Script} element with the specified {@link Script#children(Object[])} nodes. + * @param children The {@link Script#children(Object[])} nodes. + * @return The new element. + */ + public static final Script script(Object...children) { + return script().children(children); + } + + /** + * Creates an empty {@link Section} element. + * @return The new element. + */ + public static final Section section() { + return new Section(); + } + + /** + * Creates a {@link Section} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Section section(Object...children) { + return section().children(children); + } + + /** + * Creates an empty {@link Select} element. + * @return The new element. + */ + public static final Select select() { + return new Select(); + } + + /** + * Creates a {@link Select} element with the specified {@link Select#name(String)} attribute and child nodes. + * @param name The {@link Select#name(String)} attribute. + * @param children The child nodes. + * @return The new element. + */ + public static final Select select(String name, Object...children) { + return select().name(name).children(children); + } + + /** + * Creates an empty {@link Small} element. + * @return The new element. + */ + public static final Small small() { + return new Small(); + } + + /** + * Creates a {@link Small} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Small small(Object...children) { + return small().children(children); + } + + /** + * Creates an empty {@link Source} element. + * @return The new element. + */ + public static final Source source() { + return new Source(); + } + + /** + * Creates a {@link Source} element with the specified {@link Source#src(String)} and {@link Source#type(String)} attributes. + * @param src The {@link Source#src(String)} attribute. + * @param type The {@link Source#type(String)} attribute. + * @return The new element. + */ + public static final Source source(String src, String type) { + return source().src(src).type(type); + } + + /** + * Creates an empty {@link Span} element. + * @return The new element. + */ + public static final Span span() { + return new Span(); + } + + /** + * Creates a {@link Span} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Span span(Object...children) { + return span().children(children); + } + + /** + * Creates an empty {@link Strong} element. + * @return The new element. + */ + public static final Strong strong() { + return new Strong(); + } + + /** + * Creates a {@link Strong} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Strong strong(Object...children) { + return strong().children(children); + } + + /** + * Creates an empty {@link Style} element. + * @return The new element. + */ + public static final Style style() { + return new Style(); + } + + /** + * Creates a {@link Style} element with the specified {@link Style#children(Object[])} nodes. + * @param children The {@link Style#children(Object[])} nodes. + * @return The new element. + */ + public static final Style style(Object...children) { + return style().children(children); + } + + /** + * Creates an empty {@link Sub} element. + * @return The new element. + */ + public static final Sub sub() { + return new Sub(); + } + + /** + * Creates a {@link Sub} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Sub sub(Object...children) { + return sub().children(children); + } + + /** + * Creates an empty {@link Sup} element. + * @return The new element. + */ + public static final Sup sup() { + return new Sup(); + } + + /** + * Creates a {@link Sup} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Sup sup(Object...children) { + return sup().children(children); + } + + /** + * Creates an empty {@link Table} element. + * @return The new element. + */ + public static final Table table() { + return new Table(); + } + + /** + * Creates a {@link Table} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Table table(Object...children) { + return table().children(children); + } + + /** + * Creates an empty {@link Tbody} element. + * @return The new element. + */ + public static final Tbody tbody() { + return new Tbody(); + } + + /** + * Creates a {@link Tbody} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Tbody tbody(Object...children) { + return tbody().children(children); + } + + /** + * Creates an empty {@link Td} element. + * @return The new element. + */ + public static final Td td() { + return new Td(); + } + + /** + * Creates a {@link Td} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Td td(Object...children) { + return td().children(children); + } + + /** + * Creates an empty {@link Template} element. + * @return The new element. + */ + public static final Template template() { + return new Template(); + } + + /** + * Creates a {@link Template} element with the specified {@link Template#id(String)} attribute and child nodes. + * @param id The {@link Template#id(String)} attribute. + * @param children The child nodes. + * @return The new element. + */ + public static final Template template(String id, Object...children) { + return template().id(id).children(children); + } + + /** + * Creates an empty {@link Textarea} element. + * @return The new element. + */ + public static final Textarea textarea() { + return new Textarea(); + } + + /** + * Creates a {@link Textarea} element with the specified {@link Textarea#name(String)} attribute and {@link Textarea#text(Object)} node. + * @param name The {@link Textarea#name(String)} attribute. + * @param text The {@link Textarea#text(Object)} node. + * @return The new element. + */ + public static final Textarea textarea(String name, String text) { + return textarea().name(name).text(text); + } + + /** + * Creates an empty {@link Tfoot} element. + * @return The new element. + */ + public static final Tfoot tfoot() { + return new Tfoot(); + } + + /** + * Creates a {@link Tfoot} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Tfoot tfoot(Object...children) { + return tfoot().children(children); + } + + /** + * Creates an empty {@link Th} element. + * @return The new element. + */ + public static final Th th() { + return new Th(); + } + + /** + * Creates a {@link Th} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Th th(Object...children) { + return th().children(children); + } + + /** + * Creates an empty {@link Thead} element. + * @return The new element. + */ + public static final Thead thead() { + return new Thead(); + } + + /** + * Creates a {@link Thead} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Thead thead(Object...children) { + return thead().children(children); + } + + /** + * Creates an empty {@link Time} element. + * @return The new element. + */ + public static final Time time() { + return new Time(); + } + + /** + * Creates a {@link Time} element with the specified {@link Time#children(Object[])} nodes. + * @param children The {@link Time#children(Object[])} nodes. + * @return The new element. + */ + public static final Time time(Object...children) { + return time().children(children); + } + + /** + * Creates an empty {@link Title} element. + * @return The new element. + */ + public static final Title title() { + return new Title(); + } + + /** + * Creates a {@link Title} element with the specified {@link Title#text(Object)} node. + * @param text The {@link Title#text(Object)} node. + * @return The new element. + */ + public static final Title title(String text) { + return title().text(text); + } + + /** + * Creates an empty {@link Tr} element. + * @return The new element. + */ + public static final Tr tr() { + return new Tr(); + } + + /** + * Creates a {@link Tr} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Tr tr(Object...children) { + return tr().children(children); + } + + /** + * Creates an empty {@link Track} element. + * @return The new element. + */ + public static final Track track() { + return new Track(); + } + + /** + * Creates a {@link Track} element with the specified {@link Track#src(String)} and {@link Track#kind(String)} attributes. + * @param src The {@link Track#src(String)} attribute. + * @param kind The {@link Track#kind(String)} attribute. + * @return The new element. + */ + public static final Track track(String src, String kind) { + return track().src(src).kind(kind); + } + + /** + * Creates an empty {@link U} element. + * @return The new element. + */ + public static final U u() { + return new U(); + } + + /** + * Creates a {@link U} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final U u(Object...children) { + return u().children(children); + } + + /** + * Creates an empty {@link Ul} element. + * @return The new element. + */ + public static final Ul ul() { + return new Ul(); + } + + /** + * Creates a {@link Ul} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Ul ul(Object...children) { + return ul().children(children); + } + + /** + * Creates an empty {@link Var} element. + * @return The new element. + */ + public static final Var var() { + return new Var(); + } + + /** + * Creates a {@link Var} element with the specified child nodes. + * @param children The child nodes. + * @return The new element. + */ + public static final Var var(Object...children) { + return var().children(children); + } + + /** + * Creates an empty {@link Video} element. + * @return The new element. + */ + public static final Video video() { + return new Video(); + } + + /** + * Creates a {@link Video} element with the specified {@link Video#src(String)} attribute. + * @param src The {@link Video#src(String)} attribute. + * @return The new element. + */ + public static final Video video(String src) { + return video().src(src); + } + + /** + * Creates an empty {@link Wbr} element. + * @return The new element. + */ + public static final Wbr wbr() { + return new Wbr(); + } +}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElement.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElement.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElement.java new file mode 100644 index 0000000..57e3e46 --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElement.java @@ -0,0 +1,673 @@ +// *************************************************************************************************************************** +// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * +// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * +// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * +// * with the License. You may obtain a copy of the License at * +// * * +// * http://www.apache.org/licenses/LICENSE-2.0 * +// * * +// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * +// * specific language governing permissions and limitations under the License. * +// *************************************************************************************************************************** +package org.apache.juneau.dto.html5; + +import static org.apache.juneau.xml.annotation.XmlFormat.*; + +import java.util.*; + +import org.apache.juneau.html.*; +import org.apache.juneau.xml.annotation.*; + +/** + * Superclass for all HTML elements. + * <p> + * These are beans that when serialized using {@link HtmlSerializer} generate valid HTML5 elements. + */ [email protected](asXml=true) +public abstract class HtmlElement { + + final LinkedHashMap<String,Object> attrs = new LinkedHashMap<String,Object>(); + + /** + * The attributes of this element. + * @return The attributes of this element. + */ + @Xml(format=ATTRS) + public LinkedHashMap<String,Object> getAttrs() { + return attrs; + } + + /** + * Adds an arbitrary attribute to this element. + * @param key The attribute name. + * @param val The attribute value. + * + * @return This object (for method chaining). + */ + public HtmlElement attr(String key, Object val) { + this.attrs.put(key, val); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/editing.html#the-accesskey-attribute'>accesskey</a> attribute. + * @param accesskey - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement accesskey(String accesskey) { + attrs.put("accesskey", accesskey); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/dom.html#classes'>class</a> attribute. + * @param _class - The new value for this attribute. + * @return This object (for method chaining). + */ + public HtmlElement _class(String _class) { + attrs.put("class", _class); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/editing.html#attr-contenteditable'>contenteditable</a> attribute. + * @param contenteditable - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement contenteditable(String contenteditable) { + attrs.put("contenteditable", contenteditable); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/dom.html#the-dir-attribute'>dir</a> attribute. + * @param dir - The new value for this attribute. + * @return This object (for method chaining). + */ + public HtmlElement dir(String dir) { + attrs.put("dir", dir); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/editing.html#the-hidden-attribute'>hidden</a> attribute. + * @param hidden - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement hidden(String hidden) { + attrs.put("hidden", hidden); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/dom.html#the-id-attribute'>id</a> attribute. + * @param id - The new value for this attribute. + * @return This object (for method chaining). + */ + public HtmlElement id(String id) { + attrs.put("id", id); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/dom.html#attr-lang'>lang</a> attribute. + * @param lang - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement lang(String lang) { + attrs.put("lang", lang); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onabort'>onabort</a> attribute. + * @param onabort - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onabort(String onabort) { + attrs.put("onabort", onabort); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onblur'>onblur</a> attribute. + * @param onblur - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onblur(String onblur) { + attrs.put("onblur", onblur); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-oncancel'>oncancel</a> attribute. + * @param oncancel - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement oncancel(String oncancel) { + attrs.put("oncancel", oncancel); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-oncanplay'>oncanplay</a> attribute. + * @param oncanplay - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement oncanplay(String oncanplay) { + attrs.put("oncanplay", oncanplay); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-oncanplaythrough'>oncanplaythrough</a> attribute. + * @param oncanplaythrough - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement oncanplaythrough(String oncanplaythrough) { + attrs.put("oncanplaythrough", oncanplaythrough); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onchange'>onchange</a> attribute. + * @param onchange - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onchange(String onchange) { + attrs.put("onchange", onchange); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onclick'>onclick</a> attribute. + * @param onclick - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onclick(String onclick) { + attrs.put("onclick", onclick); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-oncuechange'>oncuechange</a> attribute. + * @param oncuechange - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement oncuechange(String oncuechange) { + attrs.put("oncuechange", oncuechange); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-ondblclick'>ondblclick</a> attribute. + * @param ondblclick - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement ondblclick(String ondblclick) { + attrs.put("ondblclick", ondblclick); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-ondurationchange'>ondurationchange</a> attribute. + * @param ondurationchange - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement ondurationchange(String ondurationchange) { + attrs.put("ondurationchange", ondurationchange); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onemptied'>onemptied</a> attribute. + * @param onemptied - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onemptied(String onemptied) { + attrs.put("onemptied", onemptied); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onended'>onended</a> attribute. + * @param onended - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onended(String onended) { + attrs.put("onended", onended); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onerror'>onerror</a> attribute. + * @param onerror - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onerror(String onerror) { + attrs.put("onerror", onerror); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onfocus'>onfocus</a> attribute. + * @param onfocus - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onfocus(String onfocus) { + attrs.put("onfocus", onfocus); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-oninput'>oninput</a> attribute. + * @param oninput - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement oninput(String oninput) { + attrs.put("oninput", oninput); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-oninvalid'>oninvalid</a> attribute. + * @param oninvalid - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement oninvalid(String oninvalid) { + attrs.put("oninvalid", oninvalid); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onkeydown'>onkeydown</a> attribute. + * @param onkeydown - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onkeydown(String onkeydown) { + attrs.put("onkeydown", onkeydown); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onkeypress'>onkeypress</a> attribute. + * @param onkeypress - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onkeypress(String onkeypress) { + attrs.put("onkeypress", onkeypress); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onkeyup'>onkeyup</a> attribute. + * @param onkeyup - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onkeyup(String onkeyup) { + attrs.put("onkeyup", onkeyup); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onload'>onload</a> attribute. + * @param onload - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onload(String onload) { + attrs.put("onload", onload); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onloadeddata'>onloadeddata</a> attribute. + * @param onloadeddata - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onloadeddata(String onloadeddata) { + attrs.put("onloadeddata", onloadeddata); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onloadedmetadata'>onloadedmetadata</a> attribute. + * @param onloadedmetadata - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onloadedmetadata(String onloadedmetadata) { + attrs.put("onloadedmetadata", onloadedmetadata); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onloadstart'>onloadstart</a> attribute. + * @param onloadstart - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onloadstart(String onloadstart) { + attrs.put("onloadstart", onloadstart); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onmousedown'>onmousedown</a> attribute. + * @param onmousedown - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onmousedown(String onmousedown) { + attrs.put("onmousedown", onmousedown); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onmouseenter'>onmouseenter</a> attribute. + * @param onmouseenter - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onmouseenter(String onmouseenter) { + attrs.put("onmouseenter", onmouseenter); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onmouseleave'>onmouseleave</a> attribute. + * @param onmouseleave - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onmouseleave(String onmouseleave) { + attrs.put("onmouseleave", onmouseleave); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onmousemove'>onmousemove</a> attribute. + * @param onmousemove - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onmousemove(String onmousemove) { + attrs.put("onmousemove", onmousemove); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onmouseout'>onmouseout</a> attribute. + * @param onmouseout - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onmouseout(String onmouseout) { + attrs.put("onmouseout", onmouseout); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onmouseover'>onmouseover</a> attribute. + * @param onmouseover - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onmouseover(String onmouseover) { + attrs.put("onmouseover", onmouseover); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onmouseup'>onmouseup</a> attribute. + * @param onmouseup - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onmouseup(String onmouseup) { + attrs.put("onmouseup", onmouseup); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onmousewheel'>onmousewheel</a> attribute. + * @param onmousewheel - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onmousewheel(String onmousewheel) { + attrs.put("onmousewheel", onmousewheel); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onpause'>onpause</a> attribute. + * @param onpause - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onpause(String onpause) { + attrs.put("onpause", onpause); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onplay'>onplay</a> attribute. + * @param onplay - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onplay(String onplay) { + attrs.put("onplay", onplay); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onplaying'>onplaying</a> attribute. + * @param onplaying - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onplaying(String onplaying) { + attrs.put("onplaying", onplaying); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onprogress'>onprogress</a> attribute. + * @param onprogress - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onprogress(String onprogress) { + attrs.put("onprogress", onprogress); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onratechange'>onratechange</a> attribute. + * @param onratechange - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onratechange(String onratechange) { + attrs.put("onratechange", onratechange); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onreset'>onreset</a> attribute. + * @param onreset - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onreset(String onreset) { + attrs.put("onreset", onreset); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onresize'>onresize</a> attribute. + * @param onresize - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onresize(String onresize) { + attrs.put("onresize", onresize); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onscroll'>onscroll</a> attribute. + * @param onscroll - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onscroll(String onscroll) { + attrs.put("onscroll", onscroll); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onseeked'>onseeked</a> attribute. + * @param onseeked - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onseeked(String onseeked) { + attrs.put("onseeked", onseeked); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onseeking'>onseeking</a> attribute. + * @param onseeking - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onseeking(String onseeking) { + attrs.put("onseeking", onseeking); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onselect'>onselect</a> attribute. + * @param onselect - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onselect(String onselect) { + attrs.put("onselect", onselect); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onshow'>onshow</a> attribute. + * @param onshow - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onshow(String onshow) { + attrs.put("onshow", onshow); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onstalled'>onstalled</a> attribute. + * @param onstalled - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onstalled(String onstalled) { + attrs.put("onstalled", onstalled); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onsubmit'>onsubmit</a> attribute. + * @param onsubmit - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onsubmit(String onsubmit) { + attrs.put("onsubmit", onsubmit); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onsuspend'>onsuspend</a> attribute. + * @param onsuspend - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onsuspend(String onsuspend) { + attrs.put("onsuspend", onsuspend); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-ontimeupdate'>ontimeupdate</a> attribute. + * @param ontimeupdate - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement ontimeupdate(String ontimeupdate) { + attrs.put("ontimeupdate", ontimeupdate); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-ontoggle'>ontoggle</a> attribute. + * @param ontoggle - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement ontoggle(String ontoggle) { + attrs.put("ontoggle", ontoggle); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onvolumechange'>onvolumechange</a> attribute. + * @param onvolumechange - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onvolumechange(String onvolumechange) { + attrs.put("onvolumechange", onvolumechange); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/webappapis.html#handler-onwaiting'>onwaiting</a> attribute. + * @param onwaiting - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement onwaiting(String onwaiting) { + attrs.put("onwaiting", onwaiting); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/editing.html#attr-spellcheck'>spellcheck</a> attribute. + * @param spellcheck - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement spellcheck(String spellcheck) { + attrs.put("spellcheck", spellcheck); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/dom.html#the-style-attribute'>style</a> attribute. + * @param style - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement style(String style) { + attrs.put("style", style); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/editing.html#attr-tabindex'>tabindex</a> attribute. + * @param tabindex - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement tabindex(String tabindex) { + attrs.put("tabindex", tabindex); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/dom.html#attr-title'>title</a> attribute. + * @param title - The new value for this attribute. + * @return This object (for method chaining). + */ + public HtmlElement title(String title) { + attrs.put("title", title); + return this; + } + + /** + * <a class='doclink' href='https://www.w3.org/TR/html5/dom.html#attr-translate'>translate</a> attribute. + * @param translate - The new value for this attribute. + * @return This object (for method chaining). + */ + public final HtmlElement translate(String translate) { + attrs.put("translate", translate); + return this; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElementContainer.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElementContainer.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElementContainer.java new file mode 100644 index 0000000..6847303 --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElementContainer.java @@ -0,0 +1,59 @@ +// *************************************************************************************************************************** +// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * +// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * +// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * +// * with the License. You may obtain a copy of the License at * +// * * +// * http://www.apache.org/licenses/LICENSE-2.0 * +// * * +// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * +// * specific language governing permissions and limitations under the License. * +// *************************************************************************************************************************** +package org.apache.juneau.dto.html5; + +import static org.apache.juneau.xml.annotation.XmlFormat.*; + +import java.util.*; + +import org.apache.juneau.annotation.*; +import org.apache.juneau.xml.annotation.*; + +/** + * A subclass of HTML elements that contain only other elements, not text. + */ +public class HtmlElementContainer extends HtmlElement { + + final List<Object> children = new LinkedList<Object>(); + + /** + * The children of this element. + * @return The children of this element. + */ + @Xml(format=ELEMENTS) + @BeanProperty(beanDictionary=HtmlBeanDictionary.class) + public List<Object> getChildren() { + return children; + } + /** + * Adds one or more child elements to this element. + * @param children The children to add as child elements. + * @return This object (for method chaining). + */ + @SuppressWarnings("hiding") + public HtmlElement children(Object...children) { + for (Object c : children) + this.children.add(c); + return this; + } + + /** + * Adds a child element to this element. + * @param child The child to add as a child element. + * @return This object (for method chaining). + */ + public HtmlElement child(Object child) { + this.children.add(child); + return this; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElementEmpty.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElementEmpty.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElementEmpty.java new file mode 100644 index 0000000..267d43f --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElementEmpty.java @@ -0,0 +1,19 @@ +// *************************************************************************************************************************** +// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * +// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * +// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * +// * with the License. You may obtain a copy of the License at * +// * * +// * http://www.apache.org/licenses/LICENSE-2.0 * +// * * +// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * +// * specific language governing permissions and limitations under the License. * +// *************************************************************************************************************************** +package org.apache.juneau.dto.html5; + +/** + * A subclass of HTML elements that has no content. + */ +public class HtmlElementEmpty extends HtmlElement { +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElementMixed.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElementMixed.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElementMixed.java new file mode 100644 index 0000000..7673385 --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElementMixed.java @@ -0,0 +1,62 @@ +// *************************************************************************************************************************** +// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * +// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * +// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * +// * with the License. You may obtain a copy of the License at * +// * * +// * http://www.apache.org/licenses/LICENSE-2.0 * +// * * +// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * +// * specific language governing permissions and limitations under the License. * +// *************************************************************************************************************************** +package org.apache.juneau.dto.html5; + +import static org.apache.juneau.xml.annotation.XmlFormat.*; + +import java.util.*; + +import org.apache.juneau.annotation.*; +import org.apache.juneau.xml.annotation.*; + +/** + * A subclass of HTML elements that contain mixed content (elements and text). + */ +public class HtmlElementMixed extends HtmlElement { + + final List<Object> children = new LinkedList<Object>(); + + /** + * The children of this element. + * @return The children of this element. + */ + @Xml(format=MIXED) + @BeanProperty(beanDictionary=HtmlBeanDictionary.class) + public List<Object> getChildren() { + return children; + } + + /** + * Adds one or more child elements to this element. + * @param children The children to add as child elements. + * Can be a mixture of strings and {@link HtmlElement} objects. + * @return This object (for method chaining). + */ + @SuppressWarnings("hiding") + public HtmlElement children(Object...children) { + for (Object c : children) + this.children.add(c); + return this; + } + + /** + * Adds a child element to this element. + * @param child The child to add as a child element. + * Can be a string or {@link HtmlElement}. + * @return This object (for method chaining). + */ + public HtmlElement child(Object child) { + this.children.add(child); + return this; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElementText.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElementText.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElementText.java new file mode 100644 index 0000000..7c675c1 --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/HtmlElementText.java @@ -0,0 +1,45 @@ +// *************************************************************************************************************************** +// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * +// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * +// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * +// * with the License. You may obtain a copy of the License at * +// * * +// * http://www.apache.org/licenses/LICENSE-2.0 * +// * * +// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * +// * specific language governing permissions and limitations under the License. * +// *************************************************************************************************************************** +package org.apache.juneau.dto.html5; + +import org.apache.juneau.xml.annotation.*; + +/** + * A subclass of HTML elements that contain text only. + */ +@SuppressWarnings("hiding") +public class HtmlElementText extends HtmlElement { + + private Object text; + + /** + * Returns the inner text of this element. + * + * @return The inner text of this element, or <jk>null</jk> if no text is set. + */ + @Xml(format=XmlFormat.MIXED) + public Object getText() { + return text; + } + + /** + * Sets the text node on this element. + * + * @param text - The text node to add to this element. + * @return This object (for method chaining). + */ + public HtmlElement text(Object text) { + this.text = text; + return this; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/dto/html5/I.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/I.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/I.java new file mode 100644 index 0000000..9641447 --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/I.java @@ -0,0 +1,52 @@ +// *************************************************************************************************************************** +// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * +// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * +// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * +// * with the License. You may obtain a copy of the License at * +// * * +// * http://www.apache.org/licenses/LICENSE-2.0 * +// * * +// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * +// * specific language governing permissions and limitations under the License. * +// *************************************************************************************************************************** +package org.apache.juneau.dto.html5; + +import org.apache.juneau.annotation.*; + +/** + * DTO for an HTML <a href='https://www.w3.org/TR/html5/text-level-semantics.html#the-i-element'><i></a> element. + * <p> + */ +@Bean(typeName="i") +@SuppressWarnings("hiding") +public class I extends HtmlElementMixed { + + //-------------------------------------------------------------------------------- + // Overridden methods + //-------------------------------------------------------------------------------- + + @Override /* HtmlElement */ + public final I _class(String _class) { + super._class(_class); + return this; + } + + @Override /* HtmlElement */ + public final I id(String id) { + super.id(id); + return this; + } + + @Override /* HtmlElementMixed */ + public I children(Object...children) { + super.children(children); + return this; + } + + @Override /* HtmlElementMixed */ + public I child(Object child) { + this.children.add(child); + return this; + } +}
