Continuation of HTML5 support. Project: http://git-wip-us.apache.org/repos/asf/incubator-juneau/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-juneau/commit/21c0e1ea Tree: http://git-wip-us.apache.org/repos/asf/incubator-juneau/tree/21c0e1ea Diff: http://git-wip-us.apache.org/repos/asf/incubator-juneau/diff/21c0e1ea
Branch: refs/heads/master Commit: 21c0e1ea7481f20cdb7e6168dc2c69f40ba3c0df Parents: d1e00a0 Author: JamesBognar <[email protected]> Authored: Sun Jan 29 20:51:52 2017 -0500 Committer: JamesBognar <[email protected]> Committed: Sun Jan 29 20:56:31 2017 -0500 ---------------------------------------------------------------------- .../juneau/jena/RdfSerializerSession.java | 4 +- .../juneau/dto/html/BasicHtmlSchemaTest.java | 156 ---- .../juneau/dto/html5/BasicHtmlSchemaTest.java | 876 +++++++++++++++++++ .../org/apache/juneau/html/BasicHtmlTest.java | 210 ++++- .../org/apache/juneau/xml/BasicXmlTest.java | 216 ++++- .../main/java/org/apache/juneau/Swappable.java | 42 + .../org/apache/juneau/dto/atom/package.html | 3 +- .../java/org/apache/juneau/dto/html5/A.java | 23 +- .../java/org/apache/juneau/dto/html5/Abbr.java | 3 +- .../org/apache/juneau/dto/html5/Address.java | 3 +- .../java/org/apache/juneau/dto/html5/Area.java | 28 +- .../org/apache/juneau/dto/html5/Article.java | 3 +- .../java/org/apache/juneau/dto/html5/Aside.java | 3 +- .../java/org/apache/juneau/dto/html5/Audio.java | 49 +- .../java/org/apache/juneau/dto/html5/B.java | 3 +- .../java/org/apache/juneau/dto/html5/Base.java | 9 +- .../java/org/apache/juneau/dto/html5/Bdo.java | 3 +- .../org/apache/juneau/dto/html5/Blockquote.java | 5 +- .../java/org/apache/juneau/dto/html5/Body.java | 15 +- .../org/apache/juneau/dto/html5/Button.java | 36 +- .../org/apache/juneau/dto/html5/Canvas.java | 22 +- .../org/apache/juneau/dto/html5/Caption.java | 3 +- .../java/org/apache/juneau/dto/html5/Cite.java | 3 +- .../java/org/apache/juneau/dto/html5/Code.java | 3 +- .../java/org/apache/juneau/dto/html5/Col.java | 5 +- .../org/apache/juneau/dto/html5/Colgroup.java | 24 +- .../java/org/apache/juneau/dto/html5/Data.java | 8 +- .../org/apache/juneau/dto/html5/Datalist.java | 19 +- .../java/org/apache/juneau/dto/html5/Dd.java | 3 +- .../java/org/apache/juneau/dto/html5/Del.java | 7 +- .../java/org/apache/juneau/dto/html5/Dfn.java | 3 +- .../java/org/apache/juneau/dto/html5/Div.java | 3 +- .../java/org/apache/juneau/dto/html5/Dl.java | 19 +- .../java/org/apache/juneau/dto/html5/Dt.java | 3 +- .../java/org/apache/juneau/dto/html5/Em.java | 3 +- .../java/org/apache/juneau/dto/html5/Embed.java | 19 +- .../org/apache/juneau/dto/html5/Fieldset.java | 12 +- .../org/apache/juneau/dto/html5/Figcaption.java | 3 +- .../org/apache/juneau/dto/html5/Figure.java | 19 +- .../org/apache/juneau/dto/html5/Footer.java | 3 +- .../java/org/apache/juneau/dto/html5/Form.java | 22 +- .../java/org/apache/juneau/dto/html5/H1.java | 3 +- .../java/org/apache/juneau/dto/html5/H2.java | 3 +- .../java/org/apache/juneau/dto/html5/H3.java | 3 +- .../java/org/apache/juneau/dto/html5/H4.java | 3 +- .../java/org/apache/juneau/dto/html5/H5.java | 3 +- .../java/org/apache/juneau/dto/html5/H6.java | 3 +- .../java/org/apache/juneau/dto/html5/Head.java | 19 +- .../org/apache/juneau/dto/html5/Header.java | 3 +- .../java/org/apache/juneau/dto/html5/Html.java | 21 +- .../apache/juneau/dto/html5/HtmlBuilder.java | 150 ++-- .../apache/juneau/dto/html5/HtmlElement.java | 155 ++-- .../juneau/dto/html5/HtmlElementContainer.java | 25 +- .../juneau/dto/html5/HtmlElementMixed.java | 25 +- .../juneau/dto/html5/HtmlElementText.java | 13 +- .../java/org/apache/juneau/dto/html5/I.java | 3 +- .../org/apache/juneau/dto/html5/Iframe.java | 26 +- .../java/org/apache/juneau/dto/html5/Img.java | 28 +- .../java/org/apache/juneau/dto/html5/Input.java | 108 ++- .../java/org/apache/juneau/dto/html5/Ins.java | 7 +- .../java/org/apache/juneau/dto/html5/Kbd.java | 3 +- .../org/apache/juneau/dto/html5/Keygen.java | 18 +- .../java/org/apache/juneau/dto/html5/Label.java | 7 +- .../org/apache/juneau/dto/html5/Legend.java | 3 +- .../java/org/apache/juneau/dto/html5/Li.java | 3 +- .../java/org/apache/juneau/dto/html5/Link.java | 19 +- .../java/org/apache/juneau/dto/html5/Main.java | 19 +- .../java/org/apache/juneau/dto/html5/Map.java | 21 +- .../java/org/apache/juneau/dto/html5/Mark.java | 3 +- .../java/org/apache/juneau/dto/html5/Meta.java | 8 +- .../java/org/apache/juneau/dto/html5/Meter.java | 33 +- .../java/org/apache/juneau/dto/html5/Nav.java | 3 +- .../org/apache/juneau/dto/html5/Noscript.java | 3 +- .../org/apache/juneau/dto/html5/Object2.java | 28 +- .../java/org/apache/juneau/dto/html5/Ol.java | 31 +- .../org/apache/juneau/dto/html5/Optgroup.java | 26 +- .../org/apache/juneau/dto/html5/Option.java | 17 +- .../org/apache/juneau/dto/html5/Output.java | 9 +- .../java/org/apache/juneau/dto/html5/P.java | 3 +- .../java/org/apache/juneau/dto/html5/Param.java | 7 +- .../java/org/apache/juneau/dto/html5/Pre.java | 15 +- .../org/apache/juneau/dto/html5/Progress.java | 13 +- .../java/org/apache/juneau/dto/html5/Q.java | 5 +- .../java/org/apache/juneau/dto/html5/Rb.java | 3 +- .../java/org/apache/juneau/dto/html5/Rp.java | 3 +- .../java/org/apache/juneau/dto/html5/Rt.java | 3 +- .../java/org/apache/juneau/dto/html5/Rtc.java | 3 +- .../java/org/apache/juneau/dto/html5/Ruby.java | 3 +- .../java/org/apache/juneau/dto/html5/S.java | 3 +- .../java/org/apache/juneau/dto/html5/Samp.java | 3 +- .../org/apache/juneau/dto/html5/Script.java | 45 +- .../org/apache/juneau/dto/html5/Section.java | 3 +- .../org/apache/juneau/dto/html5/Select.java | 48 +- .../java/org/apache/juneau/dto/html5/Small.java | 3 +- .../org/apache/juneau/dto/html5/Source.java | 9 +- .../java/org/apache/juneau/dto/html5/Span.java | 9 +- .../org/apache/juneau/dto/html5/Strong.java | 3 +- .../java/org/apache/juneau/dto/html5/Style.java | 26 +- .../java/org/apache/juneau/dto/html5/Sub.java | 3 +- .../java/org/apache/juneau/dto/html5/Sup.java | 3 +- .../java/org/apache/juneau/dto/html5/Table.java | 24 +- .../java/org/apache/juneau/dto/html5/Tbody.java | 19 +- .../java/org/apache/juneau/dto/html5/Td.java | 15 +- .../org/apache/juneau/dto/html5/Template.java | 3 +- .../org/apache/juneau/dto/html5/Textarea.java | 54 +- .../java/org/apache/juneau/dto/html5/Tfoot.java | 19 +- .../java/org/apache/juneau/dto/html5/Th.java | 21 +- .../java/org/apache/juneau/dto/html5/Thead.java | 19 +- .../java/org/apache/juneau/dto/html5/Time.java | 5 +- .../java/org/apache/juneau/dto/html5/Tr.java | 19 +- .../java/org/apache/juneau/dto/html5/Track.java | 15 +- .../java/org/apache/juneau/dto/html5/U.java | 3 +- .../java/org/apache/juneau/dto/html5/Ul.java | 13 +- .../java/org/apache/juneau/dto/html5/Var.java | 3 +- .../java/org/apache/juneau/dto/html5/Video.java | 59 +- .../org/apache/juneau/dto/html5/package.html | 156 +++- .../apache/juneau/html/HtmlDocSerializer.java | 4 +- .../java/org/apache/juneau/html/HtmlParser.java | 322 ++----- .../apache/juneau/html/HtmlParserSession.java | 147 ++++ .../org/apache/juneau/html/HtmlSerializer.java | 10 +- .../java/org/apache/juneau/html/HtmlTag.java | 140 +++ .../java/org/apache/juneau/html/HtmlWriter.java | 28 +- .../org/apache/juneau/internal/StringUtils.java | 45 + .../juneau/serializer/SerializerWriter.java | 15 +- .../juneau/serializer/WriterSerializer.java | 11 + .../java/org/apache/juneau/xml/XmlBeanMeta.java | 8 +- .../java/org/apache/juneau/xml/XmlParser.java | 133 +-- .../org/apache/juneau/xml/XmlParserContext.java | 24 - .../org/apache/juneau/xml/XmlParserSession.java | 166 +++- .../apache/juneau/xml/XmlSchemaSerializer.java | 2 +- .../org/apache/juneau/xml/XmlSerializer.java | 36 +- .../java/org/apache/juneau/xml/XmlUtils.java | 335 +++---- .../java/org/apache/juneau/xml/XmlWriter.java | 52 +- .../apache/juneau/xml/annotation/XmlFormat.java | 12 + .../java/org/apache/juneau/xml/package.html | 300 ++++++- juneau-core/src/main/javadoc/overview.html | 317 ++++++- juneau-rest-test/pom.xml | 5 - 137 files changed, 3902 insertions(+), 1624 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java ---------------------------------------------------------------------- diff --git a/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java b/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java index d30f934..a204ab8 100644 --- a/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java +++ b/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java @@ -246,7 +246,7 @@ public final class RdfSerializerSession extends SerializerSession { } /** - * XML-encodes the specified string using the {@link XmlUtils#encodeTextInvalidChars(Object)} method. + * XML-encodes the specified string using the {@link XmlUtils#encodeInvalidCharsForText(Object)} method. * * @param o The string being encoded. * @return The encoded string, or <jk>null</jk> if the input was <jk>null</jk>. @@ -255,7 +255,7 @@ public final class RdfSerializerSession extends SerializerSession { if (o == null) return null; String s = toString(o); - return XmlUtils.encodeTextInvalidChars(s); + return XmlUtils.encodeInvalidCharsForText(s); } /** http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core-test/src/test/java/org/apache/juneau/dto/html/BasicHtmlSchemaTest.java ---------------------------------------------------------------------- diff --git a/juneau-core-test/src/test/java/org/apache/juneau/dto/html/BasicHtmlSchemaTest.java b/juneau-core-test/src/test/java/org/apache/juneau/dto/html/BasicHtmlSchemaTest.java deleted file mode 100755 index b3ba825..0000000 --- a/juneau-core-test/src/test/java/org/apache/juneau/dto/html/BasicHtmlSchemaTest.java +++ /dev/null @@ -1,156 +0,0 @@ -// *************************************************************************************************************************** -// * 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.html; - -import static org.junit.Assert.*; - -import java.util.*; - -import org.apache.juneau.dto.html5.*; -import org.apache.juneau.html.*; -import org.apache.juneau.parser.*; -import org.apache.juneau.serializer.*; -import org.apache.juneau.xml.*; -import org.junit.*; -import org.junit.runner.*; -import org.junit.runners.*; - -@RunWith(Parameterized.class) -@SuppressWarnings({"javadoc"}) -public class BasicHtmlSchemaTest { - - private static final WriterSerializer - sXmlSq = XmlSerializer.DEFAULT_SQ, - sXmlSqReadable = XmlSerializer.DEFAULT_SQ_READABLE, - sXmlNsSq = XmlSerializer.DEFAULT_NS_SQ, - sHtmlSq = HtmlSerializer.DEFAULT_SQ, - sHtmlSqReadable = HtmlSerializer.DEFAULT_SQ_READABLE; - - private static final ReaderParser - pXml = XmlParser.DEFAULT, - pHtml = HtmlParser.DEFAULT; - - private static final B btag = HtmlBuilder.b("bbb"); - - @Parameterized.Parameters - public static Collection<Object[]> getParameters() { - return Arrays.asList(new Object[][] { - { - "A-1", - HtmlBuilder.a("http://foo", "bar"), - "<a href='http://foo'>bar</a>", - "<a href='http://foo'>bar</a>\n", - "<a href='http://foo'>bar</a>", - "<a href='http://foo'>bar</a>", - "<a href='http://foo'>bar</a>\n", - }, - { - "A-2", - HtmlBuilder.a("http://foo", "bar", btag, "baz"), - "<a href='http://foo'>bar<b>bbb</b>baz</a>", - "<a href='http://foo'>bar<b>bbb</b>baz</a>\n", - "<a href='http://foo'>bar<b>bbb</b>baz</a>", - "<a href='http://foo'>bar<b>bbb</b>baz</a>", - "<a href='http://foo'>bar<b>bbb</b>baz</a>\n", - }, - }); - } - - - private String label, e1, e2, e3, e4, e5; - private Object in; - - public BasicHtmlSchemaTest(String label, Object in, String e1, String e2, String e3, String e4, String e5) throws Exception { - this.label = label; - this.in = in; - this.e1 = e1; - this.e2 = e2; - this.e3 = e3; - this.e4 = e4; - this.e5 = e5; - } - - private void testSerialize(WriterSerializer s, String expected) throws Exception { - try { - String r = s.serialize(in); - assertEquals(label + " serialize-normal failed", expected, r); - } catch (AssertionError e) { - throw e; - } catch (Exception e) { - throw new AssertionError(label + " test failed", e); - } - } - - private void testParse(WriterSerializer s, ReaderParser p, String expected) throws Exception { - try { - String r = s.serialize(in); - Object o = p.parse(r, in == null ? Object.class : in.getClass()); - r = s.serialize(o); - assertEquals(label + " parse-normal failed", expected, r); - } catch (AssertionError e) { - throw e; - } catch (Exception e) { - throw new AssertionError(label + " test failed", e); - } - } - - @Test - public void serializeXmlDefaultSq() throws Exception { - testSerialize(sXmlSq, e1); - } - - @Test - public void parseXmlDefaultSq() throws Exception { - testParse(sXmlSq, pXml, e1); - } - - @Test - public void serializeXmlDefaultSqReadable() throws Exception { - testSerialize(sXmlSqReadable, e2); - } - - @Test - public void parseXmlDefaultSqReadable() throws Exception { - testParse(sXmlSqReadable, pXml, e2); - } - - @Test - public void serializeXmlDefaultNsSq() throws Exception { - testSerialize(sXmlNsSq, e3); - } - - @Test - public void parseXmlDefaultNsSq() throws Exception { - testParse(sXmlNsSq, pXml, e3); - } - - @Test - public void serializeHtmlDefaultSq() throws Exception { - testSerialize(sHtmlSq, e4); - } - - @Test - public void parseHtmlDefaultSq() throws Exception { - testParse(sHtmlSq, pHtml, e4); - } - - @Test - public void serializeHtmlDefaultSqReadable() throws Exception { - testSerialize(sHtmlSqReadable, e5); - } - - @Test - public void parseHtmlDefaultSqReadable() throws Exception { - testParse(sHtmlSqReadable, pHtml, e5); - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core-test/src/test/java/org/apache/juneau/dto/html5/BasicHtmlSchemaTest.java ---------------------------------------------------------------------- diff --git a/juneau-core-test/src/test/java/org/apache/juneau/dto/html5/BasicHtmlSchemaTest.java b/juneau-core-test/src/test/java/org/apache/juneau/dto/html5/BasicHtmlSchemaTest.java new file mode 100755 index 0000000..9291052 --- /dev/null +++ b/juneau-core-test/src/test/java/org/apache/juneau/dto/html5/BasicHtmlSchemaTest.java @@ -0,0 +1,876 @@ +// *************************************************************************************************************************** +// * 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.junit.Assert.*; +import static org.apache.juneau.dto.html5.HtmlBuilder.*; + +import java.util.*; + +import org.apache.juneau.html.*; +import org.apache.juneau.parser.*; +import org.apache.juneau.serializer.*; +import org.apache.juneau.xml.*; +import org.junit.*; +import org.junit.runner.*; +import org.junit.runners.*; + + +@RunWith(Parameterized.class) +@SuppressWarnings({"javadoc"}) +public class BasicHtmlSchemaTest { + + private static final WriterSerializer + sXmlSq = XmlSerializer.DEFAULT_SQ, + sXmlNsSq = XmlSerializer.DEFAULT_NS_SQ, + sXmlSqReadable = XmlSerializer.DEFAULT_SQ_READABLE, + sHtmlSq = HtmlSerializer.DEFAULT_SQ, + sHtmlSqReadable = HtmlSerializer.DEFAULT_SQ_READABLE; + + private static final ReaderParser + pXml = XmlParser.DEFAULT, + pHtml = HtmlParser.DEFAULT; + + private static final B btag = b("bbb"); + + @Parameterized.Parameters + public static Collection<Object[]> getParameters() { + return Arrays.asList(new Object[][] { + { + "A-1", + a("http://foo", "bar"), + "<a href='http://foo'>bar</a>", + "<a href='http://foo'>bar</a>\n", + "<a href='http://foo'>bar</a>", + "<a href='http://foo'>bar</a>\n", + }, + { + "A-2", + a("http://foo", "bar", btag, "baz"), + "<a href='http://foo'>bar<b>bbb</b>baz</a>", + "<a href='http://foo'>bar<b>bbb</b>baz</a>\n", + "<a href='http://foo'>bar<b>bbb</b>baz</a>", + "<a href='http://foo'>bar<b>bbb</b>baz</a>\n", + }, + { + "A-3", + a("http://foo", ""), + "<a href='http://foo'>_xE000_</a>", + "<a href='http://foo'>_xE000_</a>\n", + "<a href='http://foo'><sp/></a>", + "<a href='http://foo'><sp/></a>\n", + }, + { + "A-4", + a("http://foo", " "), + "<a href='http://foo'>_x0020_</a>", + "<a href='http://foo'>_x0020_</a>\n", + "<a href='http://foo'><sp> </sp></a>", + "<a href='http://foo'><sp> </sp></a>\n", + }, + { + "A-5", + a("http://foo"), + "<a href='http://foo'/>", + "<a href='http://foo'/>\n", + "<a href='http://foo'/>", + "<a href='http://foo'/>\n", + }, + { + "Abbr-1", + abbr().children("foo"), + "<abbr>foo</abbr>", + "<abbr>foo</abbr>\n", + "<abbr>foo</abbr>", + "<abbr>foo</abbr>\n", + }, + { + "Abbr-2", + abbr("foo", "bar", btag, "baz"), + "<abbr title='foo'>bar<b>bbb</b>baz</abbr>", + "<abbr title='foo'>bar<b>bbb</b>baz</abbr>\n", + "<abbr title='foo'>bar<b>bbb</b>baz</abbr>", + "<abbr title='foo'>bar<b>bbb</b>baz</abbr>\n", + }, + { + "Address-1", + address(), + "<address/>", + "<address/>\n", + "<address/>", + "<address/>\n", + }, + { + "Address-2", + address(""), + "<address>_xE000_</address>", + "<address>_xE000_</address>\n", + "<address><sp/></address>", + "<address><sp/></address>\n", + }, + { + "Address-3", + address("foo", a("bar", "baz"), a("qux", "quux")), + "<address>foo<a href='bar'>baz</a><a href='qux'>quux</a></address>", + "<address>foo<a href='bar'>baz</a><a href='qux'>quux</a></address>\n", + "<address>foo<a href='bar'>baz</a><a href='qux'>quux</a></address>", + "<address>foo<a href='bar'>baz</a><a href='qux'>quux</a></address>\n", + }, + { + "Aside-1", + aside( + h1("header1"),p("foo") + ), + "<aside><h1>header1</h1><p>foo</p></aside>", + "<aside><h1>header1</h1><p>foo</p></aside>\n", + "<aside><h1>header1</h1><p>foo</p></aside>", + "<aside><h1>header1</h1><p>foo</p></aside>\n", + }, + { + "Audio/Source-1", + audio().controls(true).children( + source("foo.ogg", "audio/ogg"), + source("foo.mp3", "audio/mpeg") + ), + "<audio controls='true'><source src='foo.ogg' type='audio/ogg'/><source src='foo.mp3' type='audio/mpeg'/></audio>", + "<audio controls='true'>\n\t<source src='foo.ogg' type='audio/ogg'/>\n\t<source src='foo.mp3' type='audio/mpeg'/>\n</audio>\n", + "<audio controls='true'><source src='foo.ogg' type='audio/ogg'/><source src='foo.mp3' type='audio/mpeg'/></audio>", + "<audio controls='true'>\n\t<source src='foo.ogg' type='audio/ogg'/>\n\t<source src='foo.mp3' type='audio/mpeg'/>\n</audio>\n", + }, + { + "Bdi-1", + p("foo", bdi("Ø¥ÙØ§Ù"), "bar"), + "<p>foo<bdi>Ø¥ÙØ§Ù</bdi>bar</p>", + "<p>foo<bdi>Ø¥ÙØ§Ù</bdi>bar</p>\n", + "<p>foo<bdi>Ø¥ÙØ§Ù</bdi>bar</p>", + "<p>foo<bdi>Ø¥ÙØ§Ù</bdi>bar</p>\n", + }, + { + "Bdo-1", + p("foo", bdo("rtl", "baz"), "bar"), + "<p>foo<bdo dir='rtl'>baz</bdo>bar</p>", + "<p>foo<bdo dir='rtl'>baz</bdo>bar</p>\n", + "<p>foo<bdo dir='rtl'>baz</bdo>bar</p>", + "<p>foo<bdo dir='rtl'>baz</bdo>bar</p>\n", + }, + { + "Blockquote-1", + blockquote("foo"), + "<blockquote>foo</blockquote>", + "<blockquote>foo</blockquote>\n", + "<blockquote>foo</blockquote>", + "<blockquote>foo</blockquote>\n", + }, + { + "Br-1", + br(), + "<br/>", + "<br/>\n", + "<br/>", + "<br/>\n", + }, + { + "Br-2", + p(br()), + "<p><br/></p>", + "<p><br/></p>\n", + "<p><br/></p>", + "<p><br/></p>\n", + }, + { + "Button-1", + button("button", "foo"), + "<button type='button'>foo</button>", + "<button type='button'>foo</button>\n", + "<button type='button'>foo</button>", + "<button type='button'>foo</button>\n", + }, + { + "Canvas-1", + canvas(100, 200), + "<canvas width='100' height='200'/>", + "<canvas width='100' height='200'/>\n", + "<canvas width='100' height='200'/>", + "<canvas width='100' height='200'/>\n", + }, + { + "Cite-1", + p(cite("foo")), + "<p><cite>foo</cite></p>", + "<p><cite>foo</cite></p>\n", + "<p><cite>foo</cite></p>", + "<p><cite>foo</cite></p>\n", + }, + { + "Cite-1", + p(cite("foo")), + "<p><cite>foo</cite></p>", + "<p><cite>foo</cite></p>\n", + "<p><cite>foo</cite></p>", + "<p><cite>foo</cite></p>\n", + }, + { + "Code-1", + code("foo\n\tbar"), + "<code>foo
	bar</code>", + "<code>foo
	bar</code>\n", + "<code>foo<br/><sp> </sp>bar</code>", + "<code>foo<br/><sp> </sp>bar</code>\n", + }, + { + "Datalist-1", + datalist("foo", + option("One"), + option("Two") + ), + "<datalist id='foo'><option value='One'/><option value='Two'/></datalist>", + "<datalist id='foo'>\n\t<option value='One'/>\n\t<option value='Two'/>\n</datalist>\n", + "<datalist id='foo'><option value='One'/><option value='Two'/></datalist>", + "<datalist id='foo'>\n\t<option value='One'/>\n\t<option value='Two'/>\n</datalist>\n", + }, + { + "Dl/Dt/Dd", + dl( + dt("foo"), + dd("bar") + ), + "<dl><dt>foo</dt><dd>bar</dd></dl>", + "<dl>\n\t<dt>foo</dt>\n\t<dd>bar</dd>\n</dl>\n", + "<dl><dt>foo</dt><dd>bar</dd></dl>", + "<dl>\n\t<dt>foo</dt>\n\t<dd>bar</dd>\n</dl>\n", + }, + { + "Del/Ins", + p(del("foo",btag,"bar"),ins("baz")), + "<p><del>foo<b>bbb</b>bar</del><ins>baz</ins></p>", + "<p><del>foo<b>bbb</b>bar</del><ins>baz</ins></p>\n", + "<p><del>foo<b>bbb</b>bar</del><ins>baz</ins></p>", + "<p><del>foo<b>bbb</b>bar</del><ins>baz</ins></p>\n", + }, + { + "Dfn", + p(dfn("foo")), + "<p><dfn>foo</dfn></p>", + "<p><dfn>foo</dfn></p>\n", + "<p><dfn>foo</dfn></p>", + "<p><dfn>foo</dfn></p>\n", + }, + { + "Div", + div("foo",btag,"bar"), + "<div>foo<b>bbb</b>bar</div>", + "<div>foo<b>bbb</b>bar</div>\n", + "<div>foo<b>bbb</b>bar</div>", + "<div>foo<b>bbb</b>bar</div>\n", + }, + { + "Em", + p("foo",em("bar"),"baz"), + "<p>foo<em>bar</em>baz</p>", + "<p>foo<em>bar</em>baz</p>\n", + "<p>foo<em>bar</em>baz</p>", + "<p>foo<em>bar</em>baz</p>\n", + }, + { + "Embed", + embed("foo.swf"), + "<embed src='foo.swf'/>", + "<embed src='foo.swf'/>\n", + "<embed src='foo.swf'/>", + "<embed src='foo.swf'/>\n", + }, + { + "Form/Fieldset/Legend/Input/Keygen/Label", + form("bar", + fieldset( + legend("foo:"), + "Name:", input("text"), br(), + "Email:", input("text"), br(), + "X:", keygen().name("X"), + label("label")._for("Name") + ) + ), + "<form action='bar'><fieldset><legend>foo:</legend>Name:<input type='text'/><br/>Email:<input type='text'/><br/>X:<keygen name='X'/><label for='Name'>label</label></fieldset></form>", + "<form action='bar'><fieldset><legend>foo:</legend>Name:<input type='text'/><br/>Email:<input type='text'/><br/>X:<keygen name='X'/><label for='Name'>label</label></fieldset></form>\n", + "<form action='bar'><fieldset><legend>foo:</legend>Name:<input type='text'/><br/>Email:<input type='text'/><br/>X:<keygen name='X'/><label for='Name'>label</label></fieldset></form>", + "<form action='bar'><fieldset><legend>foo:</legend>Name:<input type='text'/><br/>Email:<input type='text'/><br/>X:<keygen name='X'/><label for='Name'>label</label></fieldset></form>\n", + }, + { + "Figure/Figcaption/Img", + figure( + img("foo.png").alt("foo").width(100).height(200), + figcaption("The caption") + ), + "<figure><img src='foo.png' alt='foo' width='100' height='200'/><figcaption>The caption</figcaption></figure>", + "<figure>\n\t<img src='foo.png' alt='foo' width='100' height='200'/>\n\t<figcaption>The caption</figcaption>\n</figure>\n", + "<figure><img src='foo.png' alt='foo' width='100' height='200'/><figcaption>The caption</figcaption></figure>", + "<figure>\n\t<img src='foo.png' alt='foo' width='100' height='200'/>\n\t<figcaption>The caption</figcaption>\n</figure>\n", + }, + { + "H1/H2/H3/H4/H5/H6", + div( + h1("One"),h2("Two"),h3("Three"),h4("Four"),h5("Five"),h6("Six") + ), + "<div><h1>One</h1><h2>Two</h2><h3>Three</h3><h4>Four</h4><h5>Five</h5><h6>Six</h6></div>", + "<div><h1>One</h1><h2>Two</h2><h3>Three</h3><h4>Four</h4><h5>Five</h5><h6>Six</h6></div>\n", + "<div><h1>One</h1><h2>Two</h2><h3>Three</h3><h4>Four</h4><h5>Five</h5><h6>Six</h6></div>", + "<div><h1>One</h1><h2>Two</h2><h3>Three</h3><h4>Four</h4><h5>Five</h5><h6>Six</h6></div>\n", + }, + { + "Hr", + p(hr()), + "<p><hr/></p>", + "<p><hr/></p>\n", + "<p><hr/></p>", + "<p><hr/></p>\n", + }, + { + "Html/Head/Body/Title/Base/Link/Meta", + html( + head( + title("title"), + base("foo").target("_blank"), + link().rel("stylesheet").type("text/css").href("theme.css"), + meta().charset("UTF-8") + ), + body( + "bar" + ) + ), + "<html><head><title>title</title><base href='foo' target='_blank'/><link rel='stylesheet' type='text/css' href='theme.css'/><meta charset='UTF-8'/></head><body>bar</body></html>", + "<html>\n" + +" <head>\n" + +" <title>title</title>\n" + +" <base href='foo' target='_blank'/>\n" + +" <link rel='stylesheet' type='text/css' href='theme.css'/>\n" + +" <meta charset='UTF-8'/>\n" + +" </head>\n" + +" <body>bar</body>\n" + +"</html>\n", + "<html><head><title>title</title><base href='foo' target='_blank'/><link rel='stylesheet' type='text/css' href='theme.css'/><meta charset='UTF-8'/></head><body>bar</body></html>", + "<html>\n" + +" <head>\n" + +" <title>title</title>\n" + +" <base href='foo' target='_blank'/>\n" + +" <link rel='stylesheet' type='text/css' href='theme.css'/>\n" + +" <meta charset='UTF-8'/>\n" + +" </head>\n" + +" <body>bar</body>\n" + +"</html>\n", + }, + { + "I", + p(i("foo")), + "<p><i>foo</i></p>", + "<p><i>foo</i></p>\n", + "<p><i>foo</i></p>", + "<p><i>foo</i></p>\n", + }, + { + "Iframe", + iframe("foo"), + "<iframe>foo</iframe>", + "<iframe>foo</iframe>\n", + "<iframe>foo</iframe>", + "<iframe>foo</iframe>\n", + }, + { + "Kbd", + p(kbd("foo")), + "<p><kbd>foo</kbd></p>", + "<p><kbd>foo</kbd></p>\n", + "<p><kbd>foo</kbd></p>", + "<p><kbd>foo</kbd></p>\n", + }, + { + "Main/Article/Header/Footer-1", + main( + article( + header(h1("header1"),p("header2")), + p("content"), + footer(h2("footer1"),p("footer2")) + ) + ), + "<main><article><header><h1>header1</h1><p>header2</p></header><p>content</p><footer><h2>footer1</h2><p>footer2</p></footer></article></main>", + "<main>\n\t<article><header><h1>header1</h1><p>header2</p></header><p>content</p><footer><h2>footer1</h2><p>footer2</p></footer></article>\n</main>\n", + "<main><article><header><h1>header1</h1><p>header2</p></header><p>content</p><footer><h2>footer1</h2><p>footer2</p></footer></article></main>", + "<main>\n\t<article><header><h1>header1</h1><p>header2</p></header><p>content</p><footer><h2>footer1</h2><p>footer2</p></footer></article>\n</main>\n", + }, + { + "Map/Area-1", + map(area("rect", "0,1,2,3", "foo").alt("bar")).name("baz"), + "<map name='baz'><area shape='rect' coords='0,1,2,3' href='foo' alt='bar'/></map>", + "<map name='baz'>\n\t<area shape='rect' coords='0,1,2,3' href='foo' alt='bar'/>\n</map>\n", + "<map name='baz'><area shape='rect' coords='0,1,2,3' href='foo' alt='bar'/></map>", + "<map name='baz'>\n\t<area shape='rect' coords='0,1,2,3' href='foo' alt='bar'/>\n</map>\n", + }, + { + "Mark", + p(mark("foo")), + "<p><mark>foo</mark></p>", + "<p><mark>foo</mark></p>\n", + "<p><mark>foo</mark></p>", + "<p><mark>foo</mark></p>\n", + }, + { + "Meter", + meter("foo").value(1).min(0).max(2), + "<meter value='1' min='0' max='2'>foo</meter>", + "<meter value='1' min='0' max='2'>foo</meter>\n", + "<meter value='1' min='0' max='2'>foo</meter>", + "<meter value='1' min='0' max='2'>foo</meter>\n", + }, + { + "Nav", + nav(a("foo","bar")), + "<nav><a href='foo'>bar</a></nav>", + "<nav><a href='foo'>bar</a></nav>\n", + "<nav><a href='foo'>bar</a></nav>", + "<nav><a href='foo'>bar</a></nav>\n", + }, + { + "Noscript", + noscript("No script!"), + "<noscript>No script!</noscript>", + "<noscript>No script!</noscript>\n", + "<noscript>No script!</noscript>", + "<noscript>No script!</noscript>\n", + }, + { + "Object/Param", + object().width(1).height(2).data("foo.swf").child(param("autoplay",true)), + "<object width='1' height='2' data='foo.swf'><param name='autoplay' value='true'/></object>", + "<object width='1' height='2' data='foo.swf'><param name='autoplay' value='true'/></object>\n", + "<object width='1' height='2' data='foo.swf'><param name='autoplay' value='true'/></object>", + "<object width='1' height='2' data='foo.swf'><param name='autoplay' value='true'/></object>\n", + }, + { + "Ol/Li", + ol(li("foo")), + "<ol><li>foo</li></ol>", + "<ol>\n\t<li>foo</li>\n</ol>\n", + "<ol><li>foo</li></ol>", + "<ol>\n\t<li>foo</li>\n</ol>\n", + }, + { + "Output", + form("testform", + 0,input("range").id("a").value(50), + "+",input("number").id("b").value(50), + "=",output().name("x")._for("a b") + ).oninput("x.value=parseInt(a.value)+parseInt(b.value)"), + "<form action='testform' oninput='x.value=parseInt(a.value)+parseInt(b.value)'>0<input type='range' id='a' value='50'/>+<input type='number' id='b' value='50'/>=<output name='x' for='a b'/></form>", + "<form action='testform' oninput='x.value=parseInt(a.value)+parseInt(b.value)'>0<input type='range' id='a' value='50'/>+<input type='number' id='b' value='50'/>=<output name='x' for='a b'/></form>\n", + "<form action='testform' oninput='x.value=parseInt(a.value)+parseInt(b.value)'>0<input type='range' id='a' value='50'/>+<input type='number' id='b' value='50'/>=<output name='x' for='a b'/></form>", + "<form action='testform' oninput='x.value=parseInt(a.value)+parseInt(b.value)'>0<input type='range' id='a' value='50'/>+<input type='number' id='b' value='50'/>=<output name='x' for='a b'/></form>\n", + }, + { + "p", + p("foo"), + "<p>foo</p>", + "<p>foo</p>\n", + "<p>foo</p>", + "<p>foo</p>\n", + }, + { + "Pre", + pre("foo \n bar"), + "<pre>foo 
 bar</pre>", + "<pre>foo 
 bar</pre>\n", + "<pre>foo \n bar</pre>", + "<pre>foo \n bar</pre>\n", + }, + { + "Progress", + progress().value(1), + "<progress value='1'/>", + "<progress value='1'/>\n", + "<progress value='1'/>", + "<progress value='1'/>\n", + }, + { + "Q", + p("foo",q("bar"),"baz"), + "<p>foo<q>bar</q>baz</p>", + "<p>foo<q>bar</q>baz</p>\n", + "<p>foo<q>bar</q>baz</p>", + "<p>foo<q>bar</q>baz</p>\n", + }, + { + "Ruby/Rb/Rtc/Rp/Rt", + ruby( + "æ³",rb("è¯"),"çµ",rtc("ã",rp("ã"),"ã") + ), + "<ruby>æ³<rb>è¯</rb>çµ<rtc>ã<rp>ã</rp>ã</rtc></ruby>", + "<ruby>æ³<rb>è¯</rb>çµ<rtc>ã<rp>ã</rp>ã</rtc></ruby>\n", + "<ruby>æ³<rb>è¯</rb>çµ<rtc>ã<rp>ã</rp>ã</rtc></ruby>", + "<ruby>æ³<rb>è¯</rb>çµ<rtc>ã<rp>ã</rp>ã</rtc></ruby>\n", + }, + { + "S", + p("foo",s("bar"),"baz"), + "<p>foo<s>bar</s>baz</p>", + "<p>foo<s>bar</s>baz</p>\n", + "<p>foo<s>bar</s>baz</p>", + "<p>foo<s>bar</s>baz</p>\n", + }, + { + "Samp", + samp("foo"), + "<samp>foo</samp>", + "<samp>foo</samp>\n", + "<samp>foo</samp>", + "<samp>foo</samp>\n", + }, + { + "Script", + script("text/javascript", "\n\talert('hello world!');\n"), + "<script type='text/javascript'>
	alert('hello world!');
</script>", + "<script type='text/javascript'>
	alert('hello world!');
</script>\n", + "<script type='text/javascript'>\n\talert('hello world!');\n</script>", + "<script type='text/javascript'>\n\talert('hello world!');\n</script>\n", + }, + { + "Section", + section(h1("foo"),p("bar")), + "<section><h1>foo</h1><p>bar</p></section>", + "<section><h1>foo</h1><p>bar</p></section>\n", + "<section><h1>foo</h1><p>bar</p></section>", + "<section><h1>foo</h1><p>bar</p></section>\n", + }, + { + "Select/Optgroup/Option", + select("foo", optgroup(option("o1","v1")).label("bar")), + "<select name='foo'><optgroup label='bar'><option value='o1'>v1</option></optgroup></select>", + "<select name='foo'>\n\t<optgroup label='bar'>\n\t\t<option value='o1'>v1</option>\n\t</optgroup>\n</select>\n", + "<select name='foo'><optgroup label='bar'><option value='o1'>v1</option></optgroup></select>", + "<select name='foo'>\n\t<optgroup label='bar'>\n\t\t<option value='o1'>v1</option>\n\t</optgroup>\n</select>\n", + }, + { + "Small", + p(small("foo")), + "<p><small>foo</small></p>", + "<p><small>foo</small></p>\n", + "<p><small>foo</small></p>", + "<p><small>foo</small></p>\n", + }, + { + "Span", + p("My mother has ",span().style("color:blue").child("blue"), " eyes."), + "<p>My mother has_x0020_<span style='color:blue'>blue</span>_x0020_eyes.</p>", + "<p>My mother has_x0020_<span style='color:blue'>blue</span>_x0020_eyes.</p>\n", + "<p>My mother has<sp> </sp><span style='color:blue'>blue</span><sp> </sp>eyes.</p>", + "<p>My mother has<sp> </sp><span style='color:blue'>blue</span><sp> </sp>eyes.</p>\n", + }, + { + "Strong", + p(strong("foo")), + "<p><strong>foo</strong></p>", + "<p><strong>foo</strong></p>\n", + "<p><strong>foo</strong></p>", + "<p><strong>foo</strong></p>\n", + }, + { + "Style", + head(style("\n\th1 {color:red;}\n\tp: {color:blue;}\n")), + "<head><style>
	h1 {color:red;}
	p: {color:blue;}
</style></head>", + "<head>\n\t<style>
	h1 {color:red;}
	p: {color:blue;}
</style>\n</head>\n", + "<head><style>\n\th1 {color:red;}\n\tp: {color:blue;}\n</style></head>", + "<head>\n\t<style>\n\th1 {color:red;}\n\tp: {color:blue;}\n</style>\n</head>\n", + }, + { + "Sub", + p(sub("foo")), + "<p><sub>foo</sub></p>", + "<p><sub>foo</sub></p>\n", + "<p><sub>foo</sub></p>", + "<p><sub>foo</sub></p>\n", + }, + { + "Sup", + p(sup("foo")), + "<p><sup>foo</sup></p>", + "<p><sup>foo</sup></p>\n", + "<p><sup>foo</sup></p>", + "<p><sup>foo</sup></p>\n", + }, + { + "Table/Colgroup/Col/Caption/THead/TBody/TFoot/Tr/Th/Td-1", + table( + caption("caption1"), + colgroup( + col()._class("foo"), + col()._class("bar") + ), + thead(tr(th("c1"),th("c2"))), + tbody(tr(td("v1"),td("v2"))), + tfoot(tr(td("f1"),td("f2"))) + ), + "<table>" + +"<caption>caption1</caption>" + +"<colgroup>" + +"<col class='foo'/>" + +"<col class='bar'/>" + +"</colgroup>" + +"<thead>" + +"<tr>" + +"<th>c1</th>" + +"<th>c2</th>" + +"</tr>" + +"</thead>" + +"<tbody>" + +"<tr>" + +"<td>v1</td>" + +"<td>v2</td>" + +"</tr>" + +"</tbody>" + +"<tfoot>" + +"<tr>" + +"<td>f1</td>" + +"<td>f2</td>" + +"</tr>" + +"</tfoot>" + +"</table>", + "<table>\n" + +"\t<caption>caption1</caption>\n" + +"\t<colgroup>\n" + +"\t\t<col class='foo'/>\n" + +"\t\t<col class='bar'/>\n" + +"\t</colgroup>\n" + +"\t<thead>\n" + +"\t\t<tr>\n" + +"\t\t\t<th>c1</th>\n" + +"\t\t\t<th>c2</th>\n" + +"\t\t</tr>\n" + +"\t</thead>\n" + +"\t<tbody>\n" + +"\t\t<tr>\n" + +"\t\t\t<td>v1</td>\n" + +"\t\t\t<td>v2</td>\n" + +"\t\t</tr>\n" + +"\t</tbody>\n" + +"\t<tfoot>\n" + +"\t\t<tr>\n" + +"\t\t\t<td>f1</td>\n" + +"\t\t\t<td>f2</td>\n" + +"\t\t</tr>\n" + +"\t</tfoot>\n" + +"</table>\n", + "<table>" + +"<caption>caption1</caption>" + +"<colgroup>" + +"<col class='foo'/>" + +"<col class='bar'/>" + +"</colgroup>" + +"<thead>" + +"<tr>" + +"<th>c1</th>" + +"<th>c2</th>" + +"</tr>" + +"</thead>" + +"<tbody>" + +"<tr>" + +"<td>v1</td>" + +"<td>v2</td>" + +"</tr>" + +"</tbody>" + +"<tfoot>" + +"<tr>" + +"<td>f1</td>" + +"<td>f2</td>" + +"</tr>" + +"</tfoot>" + +"</table>", + "<table>\n" + +"\t<caption>caption1</caption>\n" + +"\t<colgroup>\n" + +"\t\t<col class='foo'/>\n" + +"\t\t<col class='bar'/>\n" + +"\t</colgroup>\n" + +"\t<thead>\n" + +"\t\t<tr>\n" + +"\t\t\t<th>c1</th>\n" + +"\t\t\t<th>c2</th>\n" + +"\t\t</tr>\n" + +"\t</thead>\n" + +"\t<tbody>\n" + +"\t\t<tr>\n" + +"\t\t\t<td>v1</td>\n" + +"\t\t\t<td>v2</td>\n" + +"\t\t</tr>\n" + +"\t</tbody>\n" + +"\t<tfoot>\n" + +"\t\t<tr>\n" + +"\t\t\t<td>f1</td>\n" + +"\t\t\t<td>f2</td>\n" + +"\t\t</tr>\n" + +"\t</tfoot>\n" + +"</table>\n", + }, + { + "Template", + template("foo",div("bar")), + "<template id='foo'><div>bar</div></template>", + "<template id='foo'><div>bar</div></template>\n", + "<template id='foo'><div>bar</div></template>", + "<template id='foo'><div>bar</div></template>\n", + }, + { + "Textarea", + textarea("foo", "bar"), + "<textarea name='foo'>bar</textarea>", + "<textarea name='foo'>bar</textarea>\n", + "<textarea name='foo'>bar</textarea>", + "<textarea name='foo'>bar</textarea>\n", + }, + { + "Time", + p("I have a date on ",time("Valentines day").datetime("2016-02-14 18:00"), "."), + "<p>I have a date on_x0020_<time datetime='2016-02-14 18:00'>Valentines day</time>.</p>", + "<p>I have a date on_x0020_<time datetime='2016-02-14 18:00'>Valentines day</time>.</p>\n", + "<p>I have a date on<sp> </sp><time datetime='2016-02-14 18:00'>Valentines day</time>.</p>", + "<p>I have a date on<sp> </sp><time datetime='2016-02-14 18:00'>Valentines day</time>.</p>\n", + }, + { + "U", + p(u("foo")), + "<p><u>foo</u></p>", + "<p><u>foo</u></p>\n", + "<p><u>foo</u></p>", + "<p><u>foo</u></p>\n", + }, + { + "Ul/Li", + ul(li("foo")), + "<ul><li>foo</li></ul>", + "<ul>\n\t<li>foo</li>\n</ul>\n", + "<ul><li>foo</li></ul>", + "<ul>\n\t<li>foo</li>\n</ul>\n", + }, + { + "Var", + p(var("foo")), + "<p><var>foo</var></p>", + "<p><var>foo</var></p>\n", + "<p><var>foo</var></p>", + "<p><var>foo</var></p>\n", + }, + { + "Video/Source/Track", + video().width(100).height(200).controls(true).children( + source("foo.mp4", "video/mp4"), + track("subtitles_en.vtt", "subtitles").srclang("en") + ), + "<video width='100' height='200' controls='true'><source src='foo.mp4' type='video/mp4'/><track src='subtitles_en.vtt' kind='subtitles' srclang='en'/></video>", + "<video width='100' height='200' controls='true'>\n\t<source src='foo.mp4' type='video/mp4'/>\n\t<track src='subtitles_en.vtt' kind='subtitles' srclang='en'/>\n</video>\n", + "<video width='100' height='200' controls='true'><source src='foo.mp4' type='video/mp4'/><track src='subtitles_en.vtt' kind='subtitles' srclang='en'/></video>", + "<video width='100' height='200' controls='true'>\n\t<source src='foo.mp4' type='video/mp4'/>\n\t<track src='subtitles_en.vtt' kind='subtitles' srclang='en'/>\n</video>\n", + }, + { + "Wbr", + p("foo",wbr(),"bar"), + "<p>foo<wbr/>bar</p>", + "<p>foo<wbr/>bar</p>\n", + "<p>foo<wbr/>bar</p>", + "<p>foo<wbr/>bar</p>\n", + }, + }); + } + + + private String label, xml, xmlr, html, htmlr; + private Object in; + + public BasicHtmlSchemaTest(String label, Object in, String xml, String xmlr, String html, String htmlr) throws Exception { + this.label = label; + this.in = in; + this.xml = xml; + this.xmlr = xmlr; + this.html = html; + this.htmlr = htmlr; + } + + private void testSerialize(WriterSerializer s, String expected) throws Exception { + try { + String r = s.serialize(in); + assertEquals(label + " serialize-normal failed", expected, r); + } catch (AssertionError e) { + throw e; + } catch (Exception e) { + throw new AssertionError(label + " test failed", e); + } + } + + private void testParse(WriterSerializer s, ReaderParser p, String expected) throws Exception { + try { + String r = s.serialize(in); + Object o = p.parse(r, in == null ? Object.class : in.getClass()); + r = s.serialize(o); + assertEquals(label + " parse-normal failed", expected, r); + } catch (AssertionError e) { + throw e; + } catch (Exception e) { + throw new AssertionError(label + " test failed", e); + } + } + + @Test + public void serializeXmlDefaultSq() throws Exception { + testSerialize(sXmlSq, xml); + } + + @Test + public void parseXmlDefaultSq() throws Exception { + testParse(sXmlSq, pXml, xml); + } + + @Test + public void serializeXmlDefaultNsSq() throws Exception { + testSerialize(sXmlNsSq, xml); + } + + @Test + public void parseXmlDefaultNsSq() throws Exception { + testParse(sXmlNsSq, pXml, xml); + } + + @Test + public void serializeHtmlDefaultSq() throws Exception { + testSerialize(sHtmlSq, html); + } + + @Test + public void parseHtmlDefaultSq() throws Exception { + testParse(sHtmlSq, pHtml, html); + } + + @Test + public void serializeXmlDefaultSqReadable() throws Exception { + testSerialize(sXmlSqReadable, xmlr); + } + + @Test + public void parseXmlDefaultSqReadable() throws Exception { + testParse(sXmlSqReadable, pXml, xmlr); + } + + @Test + public void serializeHtmlDefaultSqReadable() throws Exception { + testSerialize(sHtmlSqReadable, htmlr); + } + + @Test + public void parseHtmlDefaultSqReadable() throws Exception { + testParse(sHtmlSqReadable, pHtml, htmlr); + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core-test/src/test/java/org/apache/juneau/html/BasicHtmlTest.java ---------------------------------------------------------------------- diff --git a/juneau-core-test/src/test/java/org/apache/juneau/html/BasicHtmlTest.java b/juneau-core-test/src/test/java/org/apache/juneau/html/BasicHtmlTest.java index b7a86dd..b251eea 100644 --- a/juneau-core-test/src/test/java/org/apache/juneau/html/BasicHtmlTest.java +++ b/juneau-core-test/src/test/java/org/apache/juneau/html/BasicHtmlTest.java @@ -17,6 +17,9 @@ import static org.junit.Assert.*; import java.util.*; import org.apache.juneau.annotation.*; +import org.apache.juneau.html.annotation.Html; +import org.apache.juneau.xml.annotation.Xml; +import org.apache.juneau.xml.annotation.XmlFormat; import org.junit.*; import org.junit.runner.*; import org.junit.runners.*; @@ -841,8 +844,19 @@ public class BasicHtmlTest { { "BeanWithSpecialCharacters", new BeanWithSpecialCharacters().init(), - "<table><tr><td>a</td><td><br/><bs/><ff/><tb> </tb></td></tr></table>", - "<table>\n\t<tr>\n\t\t<td>a</td>\n\t\t<td><br/><bs/><ff/><tb> </tb></td>\n\t</tr>\n</table>\n" + "<table><tr><td>a</td><td><sp> </sp> <bs/><ff/><br/><sp> </sp> <sp> </sp></td></tr></table>", + "<table>\n\t<tr>\n\t\t<td>a</td>\n\t\t<td><sp> </sp> <bs/><ff/><br/><sp> </sp> <sp> </sp></td>\n\t</tr>\n</table>\n" + }, + { + "BeanWithSpecialCharacters2", + new BeanWithSpecialCharacters().init(), + "<table><tr><td>a</td><td><sp> </sp> <bs/><ff/><br/><sp> </sp> <sp> </sp></td></tr></table>", + "<table>\n" + +" <tr>\n" + +" <td>a</td>\n" + +" <td><sp> </sp> <bs/><ff/><br/><sp> </sp> <sp> </sp></td>\n" + +" </tr>\n" + +"</table>\n" }, { "BeanWithNullProperties", @@ -1251,7 +1265,139 @@ public class BasicHtmlTest { +"\t\t</td>\n" +"\t</tr>\n" +"</table>\n" - } + }, + { + "BeanWithWhitespaceTextFields-1", + new BeanWithWhitespaceTextFields().init(null), + "<object/>", + "<object/>\n", + }, + { + "BeanWithWhitespaceTextFields-2", + new BeanWithWhitespaceTextFields().init(""), + "<object><sp/></object>", + "<object><sp/></object>\n", + }, + { + "BeanWithWhitespaceTextFields-3", + new BeanWithWhitespaceTextFields().init(" "), + "<object><sp> </sp></object>", + "<object><sp> </sp></object>\n", + }, + { + "BeanWithWhitespaceTextFields-4", + new BeanWithWhitespaceTextFields().init(" "), + "<object><sp> </sp><sp> </sp></object>", + "<object><sp> </sp><sp> </sp></object>\n", + }, + { + "BeanWithWhitespaceTextFields-5", + new BeanWithWhitespaceTextFields().init(" foobar "), + "<object><sp> </sp> foobar <sp> </sp></object>", + "<object><sp> </sp> foobar <sp> </sp></object>\n", + }, + { + "BeanWithWhitespaceTextPwsFields-1", + new BeanWithWhitespaceTextPwsFields().init(null), + "<object/>", + "<object/>\n", + }, + { + "BeanWithWhitespaceTextPwsFields-2", + new BeanWithWhitespaceTextPwsFields().init(""), + "<object><sp/></object>", + "<object><sp/></object>\n", + }, + { + "BeanWithWhitespaceTextPwsFields-3", + new BeanWithWhitespaceTextPwsFields().init(" "), + "<object> </object>", + "<object> </object>\n", + }, + { + "BeanWithWhitespaceTextPwsFields-4", + new BeanWithWhitespaceTextPwsFields().init(" "), + "<object> </object>", + "<object> </object>\n", + }, + { + "BeanWithWhitespaceTextPwsFields-5", + new BeanWithWhitespaceTextPwsFields().init(" foobar "), + "<object> foobar </object>", + "<object> foobar </object>\n", + }, + { + "BeanWithWhitespaceMixedFields-1", + new BeanWithWhitespaceMixedFields().init(null), + "<object/>", + "<object/>\n", + }, + { + "BeanWithWhitespaceMixedFields-2", + new BeanWithWhitespaceMixedFields().init(new String[0]), + "<object/>", + "<object/>\n", + }, + { + "BeanWithWhitespaceMixedFields-3", + new BeanWithWhitespaceMixedFields().init(new String[]{""}), + "<object><sp/></object>", + "<object><sp/></object>\n", + }, + { + "BeanWithWhitespaceMixedFields-4", + new BeanWithWhitespaceMixedFields().init(new String[]{" "}), + "<object><sp> </sp></object>", + "<object><sp> </sp></object>\n", + }, + { + "BeanWithWhitespaceMixedFields-5", + new BeanWithWhitespaceMixedFields().init(new String[]{" "}), + "<object><sp> </sp><sp> </sp></object>", + "<object><sp> </sp><sp> </sp></object>\n", + }, + { + "BeanWithWhitespaceMixedFields-6", + new BeanWithWhitespaceMixedFields().init(new String[]{" foobar "}), + "<object><sp> </sp> foobar <sp> </sp></object>", + "<object><sp> </sp> foobar <sp> </sp></object>\n", + }, + { + "BeanWithWhitespaceMixedPwsFields-1", + new BeanWithWhitespaceMixedPwsFields().init(null), + "<object/>", + "<object/>\n", + }, + { + "BeanWithWhitespaceMixedPwsFields-2", + new BeanWithWhitespaceMixedPwsFields().init(new String[0]), + "<object/>", + "<object/>\n", + }, + { + "BeanWithWhitespaceMixedPwsFields-3", + new BeanWithWhitespaceMixedPwsFields().init(new String[]{""}), + "<object><sp/></object>", + "<object><sp/></object>\n", + }, + { + "BeanWithWhitespaceMixedPwsFields-4", + new BeanWithWhitespaceMixedPwsFields().init(new String[]{" "}), + "<object> </object>", + "<object> </object>\n", + }, + { + "BeanWithWhitespaceMixedPwsFields-5", + new BeanWithWhitespaceMixedPwsFields().init(new String[]{" "}), + "<object> </object>", + "<object> </object>\n", + }, + { + "BeanWithWhitespaceMixedPwsFields-6", + new BeanWithWhitespaceMixedPwsFields().init(new String[]{" foobar "}), + "<object> foobar </object>", + "<object> foobar </object>\n", + }, }); } @@ -1525,11 +1671,23 @@ public class BasicHtmlTest { public String a; BeanWithSpecialCharacters init() { - a = "\n\b\f\t"; + a = " \b\f\n\t\r "; return this; } } + @Bean(typeName=" \b\f\n\t\r ") + public static class BeanWithSpecialCharacters2 { + + @BeanProperty(name=" \b\f\n\t\r ") + public String a; + + BeanWithSpecialCharacters2 init() { + a = " \b\f\n\t\r "; + return this; + } + } + public static class BeanWithNullProperties { public String a; public String[] b; @@ -1613,4 +1771,48 @@ public class BasicHtmlTest { return this; } } + + @Html(asXml=true) + public static class BeanWithWhitespaceTextFields { + @Xml(format=XmlFormat.TEXT) + public String a; + + public BeanWithWhitespaceTextFields init(String s) { + a = s; + return this; + } + } + + @Html(asXml=true) + public static class BeanWithWhitespaceTextPwsFields { + @Xml(format=XmlFormat.TEXT_PWS) + public String a; + + public BeanWithWhitespaceTextPwsFields init(String s) { + a = s; + return this; + } + } + + @Html(asXml=true) + public static class BeanWithWhitespaceMixedFields { + @Xml(format=XmlFormat.MIXED) + public String[] a; + + public BeanWithWhitespaceMixedFields init(String[] s) { + a = s; + return this; + } + } + + @Html(asXml=true) + public static class BeanWithWhitespaceMixedPwsFields { + @Xml(format=XmlFormat.MIXED_PWS) + public String[] a; + + public BeanWithWhitespaceMixedPwsFields init(String[] s) { + a = s; + return this; + } + } } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core-test/src/test/java/org/apache/juneau/xml/BasicXmlTest.java ---------------------------------------------------------------------- diff --git a/juneau-core-test/src/test/java/org/apache/juneau/xml/BasicXmlTest.java b/juneau-core-test/src/test/java/org/apache/juneau/xml/BasicXmlTest.java index c3b9abb..fab246d 100644 --- a/juneau-core-test/src/test/java/org/apache/juneau/xml/BasicXmlTest.java +++ b/juneau-core-test/src/test/java/org/apache/juneau/xml/BasicXmlTest.java @@ -564,16 +564,16 @@ public class BasicXmlTest { { "BeanWithSpecialCharacters", new BeanWithSpecialCharacters().init(), - "<object><a>_x000A__x0008__x000C__x0009_</a></object>", - "<object>\n\t<a>_x000A__x0008__x000C__x0009_</a>\n</object>\n", - "<object><a>_x000A__x0008__x000C__x0009_</a></object>" + "<object><a>_x0020_ _x0008__x000C_
	
 _x0020_</a></object>", + "<object>\n\t<a>_x0020_ _x0008__x000C_
	
 _x0020_</a>\n</object>\n", + "<object><a>_x0020_ _x0008__x000C_
	
 _x0020_</a></object>" }, { "BeanWithSpecialCharacters2", new BeanWithSpecialCharacters2().init(), - "<_x0024__x0023__x0021_><_x002A__x0028__x0029_>_x000A__x0008__x000C__x0009_</_x002A__x0028__x0029_></_x0024__x0023__x0021_>", - "<_x0024__x0023__x0021_>\n\t<_x002A__x0028__x0029_>_x000A__x0008__x000C__x0009_</_x002A__x0028__x0029_>\n</_x0024__x0023__x0021_>\n", - "<_x0024__x0023__x0021_><_x002A__x0028__x0029_>_x000A__x0008__x000C__x0009_</_x002A__x0028__x0029_></_x0024__x0023__x0021_>" + "<_x0020__x0020__x0008__x000C__x000A__x0009__x000D__x0020__x0020_><_x0020__x0020__x0008__x000C__x000A__x0009__x000D__x0020__x0020_>_x0020_ _x0008__x000C_
	
 _x0020_</_x0020__x0020__x0008__x000C__x000A__x0009__x000D__x0020__x0020_></_x0020__x0020__x0008__x000C__x000A__x0009__x000D__x0020__x0020_>", + "<_x0020__x0020__x0008__x000C__x000A__x0009__x000D__x0020__x0020_>\n\t<_x0020__x0020__x0008__x000C__x000A__x0009__x000D__x0020__x0020_>_x0020_ _x0008__x000C_
	
 _x0020_</_x0020__x0020__x0008__x000C__x000A__x0009__x000D__x0020__x0020_>\n</_x0020__x0020__x0008__x000C__x000A__x0009__x000D__x0020__x0020_>\n", + "<_x0020__x0020__x0008__x000C__x000A__x0009__x000D__x0020__x0020_><_x0020__x0020__x0008__x000C__x000A__x0009__x000D__x0020__x0020_>_x0020_ _x0008__x000C_
	
 _x0020_</_x0020__x0020__x0008__x000C__x000A__x0009__x000D__x0020__x0020_></_x0020__x0020__x0008__x000C__x000A__x0009__x000D__x0020__x0020_>" }, { "BeanWithNullProperties", @@ -936,7 +936,161 @@ public class BasicXmlTest { +"</o2>" +"</o>" +"</object>", - } + }, + { + "BeanWithWhitespaceTextFields-1", + new BeanWithWhitespaceTextFields().init(null), + "<object/>", + "<object/>\n", + "<object/>", + }, + { + "BeanWithWhitespaceTextFields-2", + new BeanWithWhitespaceTextFields().init(""), + "<object>_xE000_</object>", + "<object>_xE000_</object>\n", + "<object>_xE000_</object>", + }, + { + "BeanWithWhitespaceTextFields-3", + new BeanWithWhitespaceTextFields().init(" "), + "<object>_x0020_</object>", + "<object>_x0020_</object>\n", + "<object>_x0020_</object>", + }, + { + "BeanWithWhitespaceTextFields-4", + new BeanWithWhitespaceTextFields().init(" "), + "<object>_x0020__x0020_</object>", + "<object>_x0020__x0020_</object>\n", + "<object>_x0020__x0020_</object>", + }, + { + "BeanWithWhitespaceTextFields-5", + new BeanWithWhitespaceTextFields().init(" foo\n\tbar "), + "<object>_x0020_foo
	bar_x0020_</object>", + "<object>_x0020_foo
	bar_x0020_</object>\n", + "<object>_x0020_foo
	bar_x0020_</object>", + }, + { + "BeanWithWhitespaceTextPwsFields-1", + new BeanWithWhitespaceTextPwsFields().init(null), + "<object/>", + "<object/>\n", + "<object/>", + }, + { + "BeanWithWhitespaceTextPwsFields-2", + new BeanWithWhitespaceTextPwsFields().init(""), + "<object>_xE000_</object>", + "<object>_xE000_</object>\n", + "<object>_xE000_</object>", + }, + { + "BeanWithWhitespaceTextPwsFields-3", + new BeanWithWhitespaceTextPwsFields().init(" "), + "<object> </object>", + "<object> </object>\n", + "<object> </object>", + }, + { + "BeanWithWhitespaceTextPwsFields-4", + new BeanWithWhitespaceTextPwsFields().init(" "), + "<object> </object>", + "<object> </object>\n", + "<object> </object>", + }, + { + "BeanWithWhitespaceTextPwsFields-5", + new BeanWithWhitespaceTextPwsFields().init(" foobar "), + "<object> foobar </object>", + "<object> foobar </object>\n", + "<object> foobar </object>", + }, + { + "BeanWithWhitespaceMixedFields-1", + new BeanWithWhitespaceMixedFields().init(null), + "<object/>", + "<object/>\n", + "<object/>", + }, + { + "BeanWithWhitespaceMixedFields-2", + new BeanWithWhitespaceMixedFields().init(new String[0]), + "<object/>", + "<object/>\n", + "<object/>", + }, + { + "BeanWithWhitespaceMixedFields-3", + new BeanWithWhitespaceMixedFields().init(new String[]{""}), + "<object>_xE000_</object>", + "<object>_xE000_</object>\n", + "<object>_xE000_</object>", + }, + { + "BeanWithWhitespaceMixedFields-4", + new BeanWithWhitespaceMixedFields().init(new String[]{" "}), + "<object>_x0020_</object>", + "<object>_x0020_</object>\n", + "<object>_x0020_</object>", + }, + { + "BeanWithWhitespaceMixedFields-5", + new BeanWithWhitespaceMixedFields().init(new String[]{" "}), + "<object>_x0020__x0020_</object>", + "<object>_x0020__x0020_</object>\n", + "<object>_x0020__x0020_</object>", + }, + { + "BeanWithWhitespaceMixedFields-6", + new BeanWithWhitespaceMixedFields().init(new String[]{" foobar "}), + "<object>_x0020_ foobar _x0020_</object>", + "<object>_x0020_ foobar _x0020_</object>\n", + "<object>_x0020_ foobar _x0020_</object>", + }, + { + "BeanWithWhitespaceMixedPwsFields-1", + new BeanWithWhitespaceMixedPwsFields().init(null), + "<object/>", + "<object/>\n", + "<object/>", + }, + { + "BeanWithWhitespaceMixedPwsFields-2", + new BeanWithWhitespaceMixedPwsFields().init(new String[0]), + "<object/>", + "<object/>\n", + "<object/>", + }, + { + "BeanWithWhitespaceMixedPwsFields-3", + new BeanWithWhitespaceMixedPwsFields().init(new String[]{""}), + "<object>_xE000_</object>", + "<object>_xE000_</object>\n", + "<object>_xE000_</object>", + }, + { + "BeanWithWhitespaceMixedPwsFields-4", + new BeanWithWhitespaceMixedPwsFields().init(new String[]{" "}), + "<object> </object>", + "<object> </object>\n", + "<object> </object>", + }, + { + "BeanWithWhitespaceMixedPwsFields-5", + new BeanWithWhitespaceMixedPwsFields().init(new String[]{" "}), + "<object> </object>", + "<object> </object>\n", + "<object> </object>", + }, + { + "BeanWithWhitespaceMixedPwsFields-6", + new BeanWithWhitespaceMixedPwsFields().init(new String[]{" foobar "}), + "<object> foobar </object>", + "<object> foobar </object>\n", + "<object> foobar </object>", + }, }); } @@ -1382,19 +1536,19 @@ public class BasicXmlTest { public String a; BeanWithSpecialCharacters init() { - a = "\n\b\f\t"; + a = " \b\f\n\t\r "; return this; } } - @Bean(typeName="$#!") + @Bean(typeName=" \b\f\n\t\r ") public static class BeanWithSpecialCharacters2 { - @BeanProperty(name="*()") + @BeanProperty(name=" \b\f\n\t\r ") public String a; BeanWithSpecialCharacters2 init() { - a = "\n\b\f\t"; + a = " \b\f\n\t\r "; return this; } } @@ -1505,4 +1659,44 @@ public class BasicXmlTest { return this; } } + + public static class BeanWithWhitespaceTextFields { + @Xml(format=XmlFormat.TEXT) + public String a; + + public BeanWithWhitespaceTextFields init(String s) { + a = s; + return this; + } + } + + public static class BeanWithWhitespaceTextPwsFields { + @Xml(format=XmlFormat.TEXT_PWS) + public String a; + + public BeanWithWhitespaceTextPwsFields init(String s) { + a = s; + return this; + } + } + + public static class BeanWithWhitespaceMixedFields { + @Xml(format=XmlFormat.MIXED) + public String[] a; + + public BeanWithWhitespaceMixedFields init(String[] s) { + a = s; + return this; + } + } + + public static class BeanWithWhitespaceMixedPwsFields { + @Xml(format=XmlFormat.MIXED_PWS) + public String[] a; + + public BeanWithWhitespaceMixedPwsFields init(String[] s) { + a = s; + return this; + } + } } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/Swappable.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/Swappable.java b/juneau-core/src/main/java/org/apache/juneau/Swappable.java new file mode 100644 index 0000000..f9da08e --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/Swappable.java @@ -0,0 +1,42 @@ +// *************************************************************************************************************************** +// * 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; + +/** + * Identifies a class that gets swapped out for another class during serialization. + * <p> + * *** This feature has not yet been implemented *** + * <p> + * Allows fine-tuned controlling of serialization of classes by allowing you to create a surrogate + * form of the class that then gets serialized instead of the original class. + * <p> + * During serialization, the {@link #swap(String)} method is used to convert this object into a serialized + * form. + * <p> + * Serialized form can be any object that can be serialized by this framework. + * <p> + * Parsing back into the original object can be accomplished by specifying a public constructor that takes in + * a single parameter of type T. + * + * @param <T> The class of the serialized form of this class. + */ +public interface Swappable<T> { + + /** + * Method to implement that converts this object to a surrogate serialized form. + * + * @param mediaType The media type string being serialized to (e.g. <js>"application/json"</js>). + * @return The surrogate object. + */ + public T swap(String mediaType); +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/atom/package.html ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/package.html b/juneau-core/src/main/java/org/apache/juneau/dto/atom/package.html index 65bd484..c68e8da 100644 --- a/juneau-core/src/main/java/org/apache/juneau/dto/atom/package.html +++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/package.html @@ -88,12 +88,11 @@ <div class='topic'> <p> The Juneau ATOM feed DTOs are simply beans with fluent-style setters.<br> - The following code shows a feed being created programmatically using + The following code shows a feed being created programmatically using the {@link org.apache.juneau.dto.atom.AtomBuilder} class. </p> <p class='bcode'> <jk>import static</jk> org.apache.juneau.dto.atom.AtomBuilder.*; - <jk>import</jk> org.apache.juneau.dto.html.HtmlBuilder; Feed feed = feed(<js>"tag:juneau.apache.org"</js>, <js>"Juneau ATOM specification"</js>, <js>"2016-01-02T03:04:05Z"</js>) http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/A.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/A.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/A.java index 021e7fe..c7eb9c6 100644 --- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/A.java +++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/A.java @@ -13,23 +13,25 @@ package org.apache.juneau.dto.html5; +import java.net.*; + import org.apache.juneau.annotation.*; /** * DTO for an HTML <a href='https://www.w3.org/TR/html5/text-level-semantics.html#the-a-element'><a></a> element. */ @Bean(typeName="a") -@SuppressWarnings("hiding") public class A extends HtmlElementMixed { /** * <a class='doclink' href='https://www.w3.org/TR/html5/links.html#attr-hyperlink-download'>download</a> attribute. * Whether to download the resource instead of navigating to it, and its file name if so. * @param download - The new value for this attribute. + * Typically a {@link Boolean} or {@link String}. * @return This object (for method chaining). */ - public final A download(String download) { - attrs.put("download", download); + public final A download(Object download) { + attr("download", download); return this; } @@ -37,10 +39,11 @@ public class A extends HtmlElementMixed { * <a class='doclink' href='https://www.w3.org/TR/html5/links.html#attr-hyperlink-href'>href</a> attribute. * Address of the hyperlink. * @param href - The new value for this attribute. + * Typically a {@link URL} or {@link String}. * @return This object (for method chaining). */ - public final A href(String href) { - attrs.put("href", href); + public final A href(Object href) { + attr("href", href); return this; } @@ -51,7 +54,7 @@ public class A extends HtmlElementMixed { * @return This object (for method chaining). */ public final A hreflang(String hreflang) { - attrs.put("hreflang", hreflang); + attr("hreflang", hreflang); return this; } @@ -62,7 +65,7 @@ public class A extends HtmlElementMixed { * @return This object (for method chaining). */ public final A rel(String rel) { - attrs.put("rel", rel); + attr("rel", rel); return this; } @@ -73,7 +76,7 @@ public class A extends HtmlElementMixed { * @return This object (for method chaining). */ public final A target(String target) { - attrs.put("target", target); + attr("target", target); return this; } @@ -84,7 +87,7 @@ public class A extends HtmlElementMixed { * @return This object (for method chaining). */ public final A type(String type) { - attrs.put("type", type); + attr("type", type); return this; } @@ -112,7 +115,7 @@ public class A extends HtmlElementMixed { @Override /* HtmlElementMixed */ public A child(Object child) { - this.children.add(child); + super.child(child); return this; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/Abbr.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Abbr.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Abbr.java index 287feba..d5d4123 100644 --- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Abbr.java +++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Abbr.java @@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*; * <p> */ @Bean(typeName="abbr") -@SuppressWarnings("hiding") public class Abbr extends HtmlElementMixed { //-------------------------------------------------------------------------------- @@ -52,7 +51,7 @@ public class Abbr extends HtmlElementMixed { @Override /* HtmlElementMixed */ public Abbr child(Object child) { - this.children.add(child); + super.child(child); return this; } } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/Address.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Address.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Address.java index cb320f4..198a0dc 100644 --- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Address.java +++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Address.java @@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*; * <p> */ @Bean(typeName="address") -@SuppressWarnings("hiding") public class Address extends HtmlElementMixed { //-------------------------------------------------------------------------------- @@ -46,7 +45,7 @@ public class Address extends HtmlElementMixed { @Override /* HtmlElementMixed */ public Address child(Object child) { - this.children.add(child); + super.child(child); return this; } } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/Area.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Area.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Area.java index 4fd994b..e41f2af 100644 --- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Area.java +++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Area.java @@ -12,6 +12,8 @@ // *************************************************************************************************************************** package org.apache.juneau.dto.html5; +import java.net.*; + import org.apache.juneau.annotation.*; /** @@ -19,7 +21,7 @@ import org.apache.juneau.annotation.*; * <p> */ @Bean(typeName="area") -public class Area extends HtmlElement { +public class Area extends HtmlElementEmpty { /** * <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-area-alt'>alt</a> attribute. @@ -28,7 +30,7 @@ public class Area extends HtmlElement { * @return This object (for method chaining). */ public final Area alt(String alt) { - attrs.put("alt", alt); + attr("alt", alt); return this; } @@ -39,7 +41,7 @@ public class Area extends HtmlElement { * @return This object (for method chaining). */ public final Area coords(String coords) { - attrs.put("coords", coords); + attr("coords", coords); return this; } @@ -47,10 +49,11 @@ public class Area extends HtmlElement { * <a class='doclink' href='https://www.w3.org/TR/html5/links.html#attr-hyperlink-download'>download</a> attribute. * Whether to download the resource instead of navigating to it, and its file name if so. * @param download - The new value for this attribute. + * Typically a {@link Boolean} or {@link String}. * @return This object (for method chaining). */ - public final Area download(String download) { - attrs.put("download", download); + public final Area download(Object download) { + attr("download", download); return this; } @@ -58,10 +61,11 @@ public class Area extends HtmlElement { * <a class='doclink' href='https://www.w3.org/TR/html5/links.html#attr-hyperlink-href'>href</a> attribute. * Address of the hyperlink. * @param href - The new value for this attribute. + * Typically a {@link URL} or {@link String}. * @return This object (for method chaining). */ - public final Area href(String href) { - attrs.put("href", href); + public final Area href(Object href) { + attr("href", href); return this; } @@ -72,7 +76,7 @@ public class Area extends HtmlElement { * @return This object (for method chaining). */ public final Area hreflang(String hreflang) { - attrs.put("hreflang", hreflang); + attr("hreflang", hreflang); return this; } @@ -83,7 +87,7 @@ public class Area extends HtmlElement { * @return This object (for method chaining). */ public final Area rel(String rel) { - attrs.put("rel", rel); + attr("rel", rel); return this; } @@ -94,7 +98,7 @@ public class Area extends HtmlElement { * @return This object (for method chaining). */ public final Area shape(String shape) { - attrs.put("shape", shape); + attr("shape", shape); return this; } @@ -105,7 +109,7 @@ public class Area extends HtmlElement { * @return This object (for method chaining). */ public final Area target(String target) { - attrs.put("target", target); + attr("target", target); return this; } @@ -116,7 +120,7 @@ public class Area extends HtmlElement { * @return This object (for method chaining). */ public final Area type(String type) { - attrs.put("type", type); + attr("type", type); return this; } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/Article.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Article.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Article.java index 9089197..69e3cc4 100644 --- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Article.java +++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Article.java @@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*; * <p> */ @Bean(typeName="article") -@SuppressWarnings("hiding") public class Article extends HtmlElementMixed { /** @@ -90,7 +89,7 @@ public class Article extends HtmlElementMixed { @Override /* HtmlElementMixed */ public Article child(Object child) { - this.children.add(child); + super.child(child); return this; } } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/Aside.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Aside.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Aside.java index 9203593..c088385 100644 --- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Aside.java +++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Aside.java @@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*; * <p> */ @Bean(typeName="aside") -@SuppressWarnings("hiding") public class Aside extends HtmlElementMixed { //-------------------------------------------------------------------------------- @@ -46,7 +45,7 @@ public class Aside extends HtmlElementMixed { @Override /* HtmlElementMixed */ public Aside child(Object child) { - this.children.add(child); + super.child(child); return this; } } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/Audio.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Audio.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Audio.java index 5f244ee..65ee816 100644 --- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Audio.java +++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Audio.java @@ -12,6 +12,8 @@ // *************************************************************************************************************************** package org.apache.juneau.dto.html5; +import java.net.*; + import org.apache.juneau.annotation.*; /** @@ -19,16 +21,17 @@ import org.apache.juneau.annotation.*; * <p> */ @Bean(typeName="audio") -public class Audio extends HtmlElementEmpty { +public class Audio extends HtmlElementContainer { /** * <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-autoplay'>autoplay</a> attribute. * Hint that the media resource can be started automatically when the page is loaded. * @param autoplay - The new value for this attribute. + * Typically a {@link Boolean} or {@link String}. * @return This object (for method chaining). */ - public final Audio autoplay(String autoplay) { - attrs.put("autoplay", autoplay); + public final Audio autoplay(Object autoplay) { + attr("autoplay", autoplay); return this; } @@ -36,10 +39,11 @@ public class Audio extends HtmlElementEmpty { * <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-controls'>controls</a> attribute. * Show user agent controls. * @param controls - The new value for this attribute. + * Typically a {@link Boolean} or {@link String}. * @return This object (for method chaining). */ - public final Audio controls(String controls) { - attrs.put("controls", controls); + public final Audio controls(Object controls) { + attr("controls", controls); return this; } @@ -50,7 +54,7 @@ public class Audio extends HtmlElementEmpty { * @return This object (for method chaining). */ public final Audio crossorigin(String crossorigin) { - attrs.put("crossorigin", crossorigin); + attr("crossorigin", crossorigin); return this; } @@ -58,10 +62,11 @@ public class Audio extends HtmlElementEmpty { * <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-loop'>loop</a> attribute. * Whether to loop the media resource. * @param loop - The new value for this attribute. + * Typically a {@link Boolean} or {@link String}. * @return This object (for method chaining). */ - public final Audio loop(String loop) { - attrs.put("loop", loop); + public final Audio loop(Object loop) { + attr("loop", loop); return this; } @@ -72,7 +77,7 @@ public class Audio extends HtmlElementEmpty { * @return This object (for method chaining). */ public final Audio mediagroup(String mediagroup) { - attrs.put("mediagroup", mediagroup); + attr("mediagroup", mediagroup); return this; } @@ -80,10 +85,11 @@ public class Audio extends HtmlElementEmpty { * <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-muted'>muted</a> attribute. * Whether to mute the media resource by default. * @param muted - The new value for this attribute. + * Typically a {@link Boolean} or {@link String}. * @return This object (for method chaining). */ - public final Audio muted(String muted) { - attrs.put("muted", muted); + public final Audio muted(Object muted) { + attr("muted", muted); return this; } @@ -93,8 +99,8 @@ public class Audio extends HtmlElementEmpty { * @param preload - The new value for this attribute. * @return This object (for method chaining). */ - public final Audio preload(String preload) { - attrs.put("preload", preload); + public final Audio preload(Object preload) { + attr("preload", preload); return this; } @@ -102,10 +108,11 @@ public class Audio extends HtmlElementEmpty { * <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-src'>src</a> attribute. * Address of the resource. * @param src - The new value for this attribute. + * Typically a {@link URL} or {@link String}. * @return This object (for method chaining). */ - public final Audio src(String src) { - attrs.put("src", src); + public final Audio src(Object src) { + attr("src", src); return this; } @@ -124,4 +131,16 @@ public class Audio extends HtmlElementEmpty { super.id(id); return this; } + + @Override /* HtmlElementContainer */ + public final Audio children(Object...children) { + super.children(children); + return this; + } + + @Override /* HtmlElementContainer */ + public final Audio child(Object child) { + super.child(child); + return this; + } } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/B.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/B.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/B.java index 03bf02b..e473d59 100644 --- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/B.java +++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/B.java @@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*; * <p> */ @Bean(typeName="b") -@SuppressWarnings("hiding") public class B extends HtmlElementMixed { //-------------------------------------------------------------------------------- @@ -46,7 +45,7 @@ public class B extends HtmlElementMixed { @Override /* HtmlElementMixed */ public B child(Object child) { - this.children.add(child); + super.child(child); return this; } } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/Base.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Base.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Base.java index c85c2c0..2d7e95d 100644 --- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Base.java +++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Base.java @@ -12,6 +12,8 @@ // *************************************************************************************************************************** package org.apache.juneau.dto.html5; +import java.net.*; + import org.apache.juneau.annotation.*; /** @@ -25,10 +27,11 @@ public class Base extends HtmlElementEmpty { * <a class='doclink' href='https://www.w3.org/TR/html5/document-metadata.html#attr-base-href'>href</a> attribute. * Document base URL. * @param href - The new value for this attribute. + * Typically a {@link URL} or {@link String}. * @return This object (for method chaining). */ - public final Base href(String href) { - attrs.put("href", href); + public final Base href(Object href) { + attr("href", href); return this; } @@ -39,7 +42,7 @@ public class Base extends HtmlElementEmpty { * @return This object (for method chaining). */ public final Base target(String target) { - attrs.put("target", target); + attr("target", target); return this; } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/Bdo.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Bdo.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Bdo.java index b462628..53877cc 100644 --- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Bdo.java +++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Bdo.java @@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*; * <p> */ @Bean(typeName="bdo") -@SuppressWarnings("hiding") public class Bdo extends HtmlElementMixed { //-------------------------------------------------------------------------------- @@ -52,7 +51,7 @@ public class Bdo extends HtmlElementMixed { @Override /* HtmlElementMixed */ public Bdo child(Object child) { - this.children.add(child); + super.child(child); return this; } } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/Blockquote.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Blockquote.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Blockquote.java index baa02c9..8fce5a0 100644 --- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Blockquote.java +++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Blockquote.java @@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*; * <p> */ @Bean(typeName="blockquote") -@SuppressWarnings("hiding") public class Blockquote extends HtmlElementMixed { /** @@ -29,7 +28,7 @@ public class Blockquote extends HtmlElementMixed { * @return This object (for method chaining). */ public final Blockquote cite(String cite) { - attrs.put("cite", cite); + attr("cite", cite); return this; } @@ -57,7 +56,7 @@ public class Blockquote extends HtmlElementMixed { @Override /* HtmlElementMixed */ public Blockquote child(Object child) { - this.children.add(child); + super.child(child); return this; } }
