You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2017/01/30 01:57:54 UTC
[1/6] incubator-juneau git commit: Continuation of HTML5 support.
Repository: incubator-juneau
Updated Branches:
refs/heads/master d1e00a01a -> 21c0e1ea7
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/javadoc/overview.html
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/javadoc/overview.html b/juneau-core/src/main/javadoc/overview.html
index 06c445c..8dabebb 100644
--- a/juneau-core/src/main/javadoc/overview.html
+++ b/juneau-core/src/main/javadoc/overview.html
@@ -88,6 +88,13 @@
<li><p><a class='doclink' href='#Core.ConfigFile'>Configuration Files</a></p>
<li><p><a class='doclink' href='#Core.SupportedLanguages'>Supported Languages</a></p>
</ol>
+ <li><p><a class='doclink' href='#DTOs'>Juneau Data Transfer Objects (org.apache.juneau.dto)</a></p>
+ <ol>
+ <li><p><a class='doclink' href='#DTOs.HTML5'>HTML5</a></p>
+ <li><p><a class='doclink' href='#DTOs.Atom'>Atom</a></p>
+ <li><p><a class='doclink' href='#DTOs.Swagger'>Swagger</a></p>
+ <li><p><a class='doclink' href='#DTOs.JsonSchema'>JSON-Schema</a></p>
+ </ol>
<li><p><a class='doclink' href='#Server'>Juneau Server (org.apache.juneau.rest)</a></p>
<li><p><a class='doclink' href='#Client'>Juneau Client (org.apache.juneau.rest.client)</a></p>
<li><p><a class='doclink' href='#Remoteable'>Remoteable services (org.apache.juneau.rest.remoteable)</a></p>
@@ -194,10 +201,11 @@
<li>
<p>Data Transfer Objects:</p>
<ul>
+ <li>HTML5
<li>ATOM
+ <li>Swagger
<li>Cognos
<li>JSON-Schema
- <li>HTML 5 (in progress)
</ul>
<p>DTOs can be used with any serializers and parsers (e.g. ATOM as JSON).
<li>
@@ -1376,10 +1384,225 @@
</ul>
</div>
</div>
+
+<!-- ======================================================================================================== -->
+<a id="DTOs"></a>
+<h2 class='topic' onclick='toggle(this)'>3 - Juneau Data Transfer Objects (org.apache.juneau.dto)</h2>
+<div class='topic'>
+ <p>
+ The Juneau Core library contains several predefined POJOs for generating commonly-used document types.
+ This section describes support for these POJOs.
+ </p>
+
+ <!-- ======================================================================================================== -->
+ <a id="DTOs.HTML5"></a>
+ <h3 class='topic' onclick='toggle(this)'>3.1 - HTML5</h3>
+ <div class='topic'>
+ <p>
+ The Juneau HTML5 DTOs are simply beans with fluent-style setters that allow you to quickly construct HTML
+ fragments as Java objects. These object can then be serialized to HTML using one of the existing HTML serializers,
+ or to other languages such as JSON using the JSON serializers.
+ </p>
+ <p>
+ The {@link org.apache.juneau.dto.html5.HtmlBuilder} class is a utility class with predefined static methods
+ that allow you to easily construct DTO instances in a minimal amount of code.
+ </p>
+ <p>
+ The following examples show how to create HTML tables.
+ </p>
+ <table class='styled' style='width:auto'>
+ <tr>
+ <th>Java code</th>
+ <th>HTML</th>
+ </tr>
+ <tr>
+ <td class='code'>
+ <jk>import static</jk> org.apache.juneau.dto.html5.HtmlBuilder.*;
+
+ Object mytable =
+ table(
+ tr(th(<js>"c1"</js>),th(<js>"c2"</js>)),
+ tr(td(<js>"v1"</js>),td(<js>"v2"</js>))
+ );
+
+ String html = HtmlSerializer.<jsf>DEFAULT</jsf>.serialize(mytable);
+ </td>
+ <td class='code'><xt>
+ <table>
+ <tr>
+ <th><xv>c1</xv></th>
+ <th><xv>c2</xv></th>
+ </tr>
+ <tr>
+ <td><xv>v1</xv></td>
+ <td><xv>v2</xv></td>
+ </tr>
+ </table>
+ </xt></td>
+ </tr>
+ </table>
+ <p>
+ Using the HTML5 DTOs, you should be able to construct any valid HTML5 from full document bodies
+ to any possible fragements.
+ </p>
+ <p>
+ The {@link org.apache.juneau.html.HtmlParser} class can be used convert these HTML documents back
+ into POJOs.
+ </p>
+ <p>
+ Other serializers and parsers (e.g. {@link org.apache.juneau.json.JsonSerializer}) can be used to
+ represent these POJOs in languages other than HTML.
+ </p>
+
+ <h6 class='topic'>Additional Information</h6>
+ <ul class='javahierarchy'>
+ <li class='p'><a class='doclink' href='org/apache/juneau/dto/html5/package-summary.html#TOC'>org.apache.juneau.dto.html5</a> - HTML DTOs.
+ </ul>
+ </div>
+
+ <!-- ======================================================================================================== -->
+ <a id="DTOs.Atom"></a>
+ <h3 class='topic' onclick='toggle(this)'>3.2 - Atom</h3>
+ <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 {@link org.apache.juneau.dto.atom.AtomBuilder} class.
+ </p>
+ <p class='bcode'>
+
+ <jk>import static</jk> org.apache.juneau.dto.atom.AtomBuilder.*;
+
+ Feed feed =
+ feed(<js>"tag:juneau.apache.org"</js>, <js>"Juneau ATOM specification"</js>, <js>"2016-01-02T03:04:05Z"</js>)
+ .subtitle(text(<js>"html"</js>).children(<js>"Describes <em>stuff</em> about Juneau"</js>))
+ .links(
+ link(<js>"alternate"</js>, <js>"text/html"</js>, <js>"http://www.sample.com/"</js>).hreflang(<js>"en"</js>),
+ link(<js>"self"</js>, <js>"application/atom+xml"</js>, <js>"http://www.sample.com/feed.atom"</js>)
+ )
+ .rights(<js>"Copyright (c) 2016, Apache Foundation"</js>)
+ .generator(
+ generator(<js>"Juneau"</js>).uri(<js>"http://juneau.apache.org/"</js>).version(<js>"1.0"</js>)
+ )
+ .entries(
+ entry(<js>"tag:juneau.sample.com,2013:1.2345"</js>, <js>"Juneau ATOM specification snapshot"</js>, <js>"2016-01-02T03:04:05Z"</js>)
+ .links(
+ link<js>"alternate"</js>, <js>"text/html"</js>, <js>"http://www.sample.com/2012/05/08/juneau.atom"</js>),
+ link(<js>"enclosure"</js>, <js>"audio/mpeg"</js>, <js>"http://www.sample.com/audio/juneau_podcast.mp3"</js>).length(1337)
+ )
+ .published(<js>"2016-01-02T03:04:05Z"</js>)
+ .authors(
+ person(<js>"James Bognar"</js>).uri(<js>"http://www.sample.com/"</js>).email(<js>"jamesbognar@apache.org"</js>)
+ )
+ .contributors(
+ person(<js>"Barry M. Caceres"</js>)
+ )
+ .content(
+ content(<js>"xhtml"</js>)
+ .lang(<js>"en"</js>)
+ .base(<js>"http://www.apache.org/"</js>)
+ .children(
+ HtmlBuilder.div().child(
+ HtmlBuilder.p(
+ HtmlBuilder.i(<js>"[Update: Juneau supports ATOM.]"</js>)
+ )
+ )
+ )
+ )
+ );
+ </p>
+ <p>
+ To serialize this to ATOM, use the {@link org.apache.juneau.xml.XmlSerializer} class:
+ </p>
+
+ <h6 class='figure'>Example with no namespaces</h6>
+ <p class='bcode'>
+ <jc>// Create a serializer with readable output, no namespaces yet.</jc>
+ XmlSerializer s = <jk>new</jk> XmlSerializer.SqReadable();
+
+ <jc>// Serialize to ATOM/XML</jc>
+ String atomXml = s.serialize(feed);
+ </p>
+
+ <h6 class='figure'>Results</h6>
+ <p class='bcode'>
+ <xt><feed></xt>
+ <xt><id></xt>
+ tag:juneau.apache.org
+ <xt></id></xt>
+ <xt><link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/'</xs> <xa>rel</xa>=<xs>'alternate'</xs> <xa>type</xa>=<xs>'text/html'</xs> <xa>hreflang</xa>=<xs>'en'</xs>/<xt>></xt>
+ <xt><link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/feed.atom'</xs> <xa>rel</xa>=<xs>'self'</xs> <xa>type</xa>=<xs>'application/atom+xml'</xs>/<xt>></xt>
+ <xt><rights></xt>
+ Copyright (c) 2016, Apache Foundation
+ <xt></rights></xt>
+ <xt><title</xt> <xa>type</xa>=<xs>'text'</xs>></xt>
+ Juneau ATOM specification
+ <xt></title></xt>
+ <xt><updated></xt>2016-01-02T03:04:05Z<xt></updated></xt>
+ <xt><generator</xt> <xa>uri</xa>=<xs>'http://juneau.apache.org/'</xs> <xa>version</xa>=<xs>'1.0'</xs><xt>></xt>
+ Juneau
+ <xt></generator></xt>
+ <xt><subtitle</xt> <xa>type</xa>=<xs>'html'</xs><xt>></xt>
+ Describes <em>stuff</em> about Juneau
+ <xt></subtitle></xt>
+ <xt><entry></xt>
+ <xt><author></xt>
+ <xt><name></xt>James Bognar<xt></name></xt>
+ <xt><uri></xt>http://juneau.apache.org/<xt></uri></xt>
+ <xt><email></xt>jamesbognar@apache.org<xt></email></xt>
+ <xt></author></xt>
+ <xt><contributor></xt>
+ <xt><name></xt>Barry M. Caceres<xt></name></xt>
+ <xt></contributor></xt>
+ <xt><id></xt>
+ tag:juneau.apache.org
+ <xt></id></xt>
+ <xt><link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/juneau.atom'</xs> <xa>rel</xa>=<xs>'alternate'</xs> <xa>type</xa>=<xs>'text/html'</xs>/<xt>></xt>
+ <xt><link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/audio/juneau_podcast.mp3'</xs> <xa>rel</xa>=<xs>'enclosure'</xs> <xa>type</xa>=<xs>'audio/mpeg'</xs> <xa>length</xa>=<xs>'12345'</xs>/<xt>></xt>
+ <xt><title></xt>
+ Juneau ATOM specification snapshot
+ <xt></title></xt>
+ <xt><updated></xt>2016-01-02T03:04:05Z<xt></updated></xt>
+ <xt><content</xt> <xa>base</xa>=<xs>'http://www.apache.org/'</xs> <xa>lang</xa>=<xs>'en'</xs> <xa>type</xa>=<xs>'xhtml'</xs><xt>></xt>
+ <xt><div</xt> <xa>xmlns</xa>=<xs>"http://www.w3.org/1999/xhtml"</xs><xt>><p><i></xt>[Update: Juneau supports ATOM.]<xt></i></p></div></xt>
+ <xt></content></xt>
+ <xt><published></xt>2016-01-02T03:04:05Z<xt></published></xt>
+ <xt></entry></xt>
+ <xt></feed></xt>
+ </p>
+ <p>
+ The {@link org.apache.juneau.html.XmlParser} class can be used convert these Atom documents back
+ into POJOs.
+ </p>
+ <p>
+ Other serializers and parsers (e.g. {@link org.apache.juneau.json.JsonSerializer}) can be used to
+ represent these POJOs in languages other than XML.
+ </p>
+
+ <h6 class='topic'>Additional Information</h6>
+ <ul class='javahierarchy'>
+ <li class='p'><a class='doclink' href='org/apache/juneau/dto/html5/package-summary.html#TOC'>org.apache.juneau.dto.atom</a> - Atom DTOs.
+ </ul>
+ </div>
+
+ <!-- ======================================================================================================== -->
+ <a id="DTOs.Swagger"></a>
+ <h3 class='topic' onclick='toggle(this)'>3.3 - Swagger</h3>
+ <div class='topic'>
+ TODO
+ </div>
+
+ <!-- ======================================================================================================== -->
+ <a id="DTOs.JsonSchema"></a>
+ <h3 class='topic' onclick='toggle(this)'>3.4 - JSON-Schema</h3>
+ <div class='topic'>
+ TODO
+ </div>
+
+</div>
<!-- ======================================================================================================== -->
<a id="Server"></a>
-<h2 class='topic' onclick='toggle(this)'>3 - Juneau Server (org.apache.juneau.rest)</h2>
+<h2 class='topic' onclick='toggle(this)'>4 - Juneau Server (org.apache.juneau.rest)</h2>
<div class='topic'>
<p>
The Juneau REST Server API provides servlet-based REST resources on top of existing POJOs.
@@ -1641,7 +1864,7 @@
<!-- ======================================================================================================== -->
<a id="Client"></a>
-<h2 class='topic' onclick='toggle(this)'>4 - Juneau Client (org.apache.juneau.rest.client)</h2>
+<h2 class='topic' onclick='toggle(this)'>5 - Juneau Client (org.apache.juneau.rest.client)</h2>
<div class='topic'>
<p>
The REST client API provides the ability to access remote REST interfaces and transparently convert the input and output to and from POJOs using any
@@ -1684,7 +1907,7 @@
<!-- ======================================================================================================== -->
<a id="Remoteable"></a>
-<h2 class='topic' onclick='toggle(this)'>5 - Remoteable Services (org.apache.juneau.rest.remoteable)</h2>
+<h2 class='topic' onclick='toggle(this)'>6 - Remoteable Services (org.apache.juneau.rest.remoteable)</h2>
<div class='topic'>
<p>
Juneau provides the capability of calling methods on POJOs on a server through client-side proxy interfaces.
@@ -1749,7 +1972,7 @@
<!-- ======================================================================================================== -->
<a id="Microservices"></a>
-<h2 class='topic' onclick='toggle(this)'>6 - Juneau Microservices (org.apache.juneau.microservice)</h2>
+<h2 class='topic' onclick='toggle(this)'>7 - Juneau Microservices (org.apache.juneau.microservice)</h2>
<div class='topic'>
<p>
<b>WARNING - The microservice API is still in beta. It may be replaced with an OSGi-based architecture.</b>
@@ -1778,7 +2001,7 @@
<!-- ======================================================================================================== -->
<a id="Samples"></a>
-<h2 class='topic' onclick='toggle(this)'>7 - Samples</h2>
+<h2 class='topic' onclick='toggle(this)'>8 - Samples</h2>
<div class='topic'>
<p>
The <l>microservice-samples-project.zip</l> file is a zipped eclipse project that includes everything you
@@ -1791,7 +2014,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.Installing"></a>
- <h3 class='topic' onclick='toggle(this)'>7.1 - Installing in Eclipse</h3>
+ <h3 class='topic' onclick='toggle(this)'>8.1 - Installing in Eclipse</h3>
<div class='topic'>
<p>
Follow these instructions to create the Samples project in Eclipse:
@@ -1867,7 +2090,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.Running"></a>
- <h3 class='topic' onclick='toggle(this)'>7.2 - Running in Eclipse</h3>
+ <h3 class='topic' onclick='toggle(this)'>8.2 - Running in Eclipse</h3>
<div class='topic'>
<p>
The <l>microservice-samples-project.launch</l> file is already provided to allow you to quickly start
@@ -1893,7 +2116,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.Building"></a>
- <h3 class='topic' onclick='toggle(this)'>7.3 - Building and Running from Command-Line</h3>
+ <h3 class='topic' onclick='toggle(this)'>8.3 - Building and Running from Command-Line</h3>
<div class='topic'>
<p>
The <l>build.xml</l> file is a very basic ANT script for building the Samples microservice
@@ -1916,7 +2139,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.RestResource"></a>
- <h3 class='topic' onclick='toggle(this)'>7.4 - MANIFEST.MF</h3>
+ <h3 class='topic' onclick='toggle(this)'>8.4 - MANIFEST.MF</h3>
<div class='topic'>
<p>
The <l>META-INF/MANIFEST.MF</l> file is used to describe the microservice.
@@ -1967,7 +2190,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.RootResources"></a>
- <h3 class='topic' onclick='toggle(this)'>7.5 - RootResources</h3>
+ <h3 class='topic' onclick='toggle(this)'>8.5 - RootResources</h3>
<div class='topic'>
<p>
The <l>RootResources</l> class is the main page for the REST microservice.
@@ -2106,7 +2329,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.HelloWorldResource"></a>
- <h3 class='topic' onclick='toggle(this)'>7.6 - HelloWorldResource</h3>
+ <h3 class='topic' onclick='toggle(this)'>8.6 - HelloWorldResource</h3>
<div class='topic'>
<p>
The <l>HelloWorldResource</l> class is a simple resource that prints a "Hello world!" message.
@@ -2173,7 +2396,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.MethodExampleResource"></a>
- <h3 class='topic' onclick='toggle(this)'>7.7 - MethodExampleResource</h3>
+ <h3 class='topic' onclick='toggle(this)'>8.7 - MethodExampleResource</h3>
<div class='topic'>
<p>
The <l>MethodExampleResource</l> class provides examples of the following:
@@ -2395,7 +2618,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.UrlEncodedFormResource"></a>
- <h3 class='topic' onclick='toggle(this)'>7.8 - UrlEncodedFormResource</h3>
+ <h3 class='topic' onclick='toggle(this)'>8.8 - UrlEncodedFormResource</h3>
<div class='topic'>
<p>
The <l>UrlEncodedFormResource</l> class provides examples of the following:
@@ -2531,7 +2754,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.RequestEchoResource"></a>
- <h3 class='topic' onclick='toggle(this)'>7.9 - RequestEchoResource</h3>
+ <h3 class='topic' onclick='toggle(this)'>8.9 - RequestEchoResource</h3>
<div class='topic'>
<p>
The <l>RequestEchoResource</l> class shows how existing complex POJOs can be serialized to a variety of content types.
@@ -2643,7 +2866,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.AddressBookResource"></a>
- <h3 class='topic' onclick='toggle(this)'>7.10 - AddressBookResource</h3>
+ <h3 class='topic' onclick='toggle(this)'>8.10 - AddressBookResource</h3>
<div class='topic'>
<p>
The <l>AddressBookResource</l> class is a proof-of-concept class that shows a true RESTful API using the Juneau REST toolkit.
@@ -2677,7 +2900,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.AddressBookResource.Classes"></a>
- <h4 class='topic' onclick='toggle(this)'>7.10.1 - Classes</h4>
+ <h4 class='topic' onclick='toggle(this)'>8.10.1 - Classes</h4>
<div class='topic'>
<p>
The code is straightforward, consisting of the following classes:
@@ -3398,7 +3621,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.AddressBookResource.Demo"></a>
- <h4 class='topic' onclick='toggle(this)'>7.10.2 - Demo</h4>
+ <h4 class='topic' onclick='toggle(this)'>8.10.2 - Demo</h4>
<div class='topic'>
<p>
Pointing a browser to the resource shows the results of running the <l>getRoot()</l> method:
@@ -3465,7 +3688,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.AddressBookResource.Traversable"></a>
- <h4 class='topic' onclick='toggle(this)'>7.10.3 - Traversable</h4>
+ <h4 class='topic' onclick='toggle(this)'>8.10.3 - Traversable</h4>
<div class='topic'>
<p>
Because you added the <l>Traversable</l> converter to the <l>getPerson</l> method, you can also address child nodes in the POJO model
@@ -3478,7 +3701,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.AddressBookResource.Queryable"></a>
- <h4 class='topic' onclick='toggle(this)'>7.10.4 - Queryable</h4>
+ <h4 class='topic' onclick='toggle(this)'>8.10.4 - Queryable</h4>
<div class='topic'>
<p>
The <l>Queryable</l> converter on the <l>getAllPeople()</l> method allows us to perform search/view/sort functions against the data
@@ -3494,7 +3717,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.AddressBookResource.Introspectable"></a>
- <h4 class='topic' onclick='toggle(this)'>7.10.5 - Introspectable</h4>
+ <h4 class='topic' onclick='toggle(this)'>8.10.5 - Introspectable</h4>
<div class='topic'>
<p>
The <l>Introspectable</l> converter on the <l>getPerson</l> method allows us to invoke public methods on the addressed POJO (in this case, public methods on the <l>String</l> class):
@@ -3504,7 +3727,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.AddressBookResource.RestClient"></a>
- <h4 class='topic' onclick='toggle(this)'>7.10.6 - ClientTest</h4>
+ <h4 class='topic' onclick='toggle(this)'>8.10.6 - ClientTest</h4>
<div class='topic'>
<p>
The <l>ClientTest</l> class is provided to demonstrate how POJOs can be serialized and parsed
@@ -3617,7 +3840,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.AddressBookResource.Browser"></a>
- <h4 class='topic' onclick='toggle(this)'>7.10.7 - Browser Tips</h4>
+ <h4 class='topic' onclick='toggle(this)'>8.10.7 - Browser Tips</h4>
<div class='topic'>
<p>
The Juneau architecture is designed to make it easy to debug REST resources using nothing more than a browser.
@@ -3648,7 +3871,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.SampleRemoteableServlet"></a>
- <h3 class='topic' onclick='toggle(this)'>7.11 - SampleRemoteableServlet</h3>
+ <h3 class='topic' onclick='toggle(this)'>8.11 - SampleRemoteableServlet</h3>
<div class='topic'>
<p>
The <l>SampleRemoteableServlet</l> class shows examples of the following:
@@ -3747,7 +3970,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.TempDirResource"></a>
- <h3 class='topic' onclick='toggle(this)'>7.12 - TempDirResource</h3>
+ <h3 class='topic' onclick='toggle(this)'>8.12 - TempDirResource</h3>
<div class='topic'>
<p>
The <l>TempDirResource</l> class shows examples of the following:
@@ -3864,7 +4087,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.AtomFeedResource"></a>
- <h3 class='topic' onclick='toggle(this)'>7.13 - AtomFeedResource</h3>
+ <h3 class='topic' onclick='toggle(this)'>8.13 - AtomFeedResource</h3>
<div class='topic'>
<p>
The <l>AtomFeedResource</l> class shows examples of the following:
@@ -3974,7 +4197,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.DockerRegistryResource"></a>
- <h3 class='topic' onclick='toggle(this)'>7.14 - DockerRegistryResource</h3>
+ <h3 class='topic' onclick='toggle(this)'>8.14 - DockerRegistryResource</h3>
<div class='topic'>
<p>
The <l>DockerRegistryResource</l> class shows examples of the following:
@@ -4061,7 +4284,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.TumblrParserResource"></a>
- <h3 class='topic' onclick='toggle(this)'>7.15 - TumblrParserResource</h3>
+ <h3 class='topic' onclick='toggle(this)'>8.15 - TumblrParserResource</h3>
<div class='topic'>
<p>
The <l>TumblrParserResource</l> class shows examples of the following:
@@ -4140,7 +4363,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.PhotosResource"></a>
- <h3 class='topic' onclick='toggle(this)'>7.16 - PhotosResource</h3>
+ <h3 class='topic' onclick='toggle(this)'>8.16 - PhotosResource</h3>
<div class='topic'>
<p>
The <l>PhotosResource</l> class shows examples of the following:
@@ -4282,7 +4505,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.JsonSchemaResource"></a>
- <h3 class='topic' onclick='toggle(this)'>7.17 - JsonSchemaResource</h3>
+ <h3 class='topic' onclick='toggle(this)'>8.17 - JsonSchemaResource</h3>
<div class='topic'>
<p>
The <l>JsonSchemaResource</l> class shows examples of the following:
@@ -4360,7 +4583,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.SqlQueryResource"></a>
- <h3 class='topic' onclick='toggle(this)'>7.18 - SqlQueryResource</h3>
+ <h3 class='topic' onclick='toggle(this)'>8.18 - SqlQueryResource</h3>
<div class='topic'>
<p>
The <l>SqlQueryResource</l> class shows examples of the following:
@@ -4552,7 +4775,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.ConfigResource"></a>
- <h3 class='topic' onclick='toggle(this)'>7.19 - ConfigResource</h3>
+ <h3 class='topic' onclick='toggle(this)'>8.19 - ConfigResource</h3>
<div class='topic'>
<p>
The {@link org.apache.juneau.microservice.resources.ConfigResource} class is a reusable resource
@@ -4763,7 +4986,7 @@
<!-- ======================================================================================================== -->
<a id="Samples.LogsResource"></a>
- <h3 class='topic' onclick='toggle(this)'>7.20 - LogsResource</h3>
+ <h3 class='topic' onclick='toggle(this)'>8.20 - LogsResource</h3>
<div class='topic'>
<p>
The {@link org.apache.juneau.microservice.resources.LogsResource} class is a reusable resource
@@ -4787,12 +5010,12 @@
<!-- ======================================================================================================== -->
<a id="Cookbook"></a>
-<h2 class='topic' onclick='toggle(this)'>8 - Cookbook Examples</h2>
+<h2 class='topic' onclick='toggle(this)'>9 - Cookbook Examples</h2>
<div class='topic'>
<!-- ======================================================================================================== -->
<a id="Cookbook.Core"></a>
- <h3 class='topic' onclick='toggle(this)'>8.1 - Core API</h3>
+ <h3 class='topic' onclick='toggle(this)'>9.1 - Core API</h3>
<div class='topic'>
<h6 class='topic'>TODO topics</h6>
<ol>
@@ -4803,11 +5026,11 @@
<!-- ======================================================================================================== -->
<a id="Cookbook.Server"></a>
- <h3 class='topic' onclick='toggle(this)'>8.2 - Server API</h3>
+ <h3 class='topic' onclick='toggle(this)'>9.2 - Server API</h3>
<div class='topic'>
<!-- ======================================================================================================== -->
<a id="Cookbook.Server.applyDoubleTransform"></a>
- <h3 class='topic' onclick='toggle(this)'>8.2.1 - Apply a transform that changes the format of doubles</h3>
+ <h3 class='topic' onclick='toggle(this)'>9.2.1 - Apply a transform that changes the format of doubles</h3>
<div class='topic'>
<p>
The {@link org.apache.juneau.rest.annotation.RestResource#pojoSwaps()} annotation can be used to add
@@ -4838,7 +5061,7 @@
<!-- ======================================================================================================== -->
<a id="Cookbook.Server.applyTransformsSubset"></a>
- <h3 class='topic' onclick='toggle(this)'>8.2.2 - Apply transforms to a subset of serializers or parsers</h3>
+ <h3 class='topic' onclick='toggle(this)'>9.2.2 - Apply transforms to a subset of serializers or parsers</h3>
<div class='topic'>
<p>
The {@link org.apache.juneau.rest.RestServlet#createSerializers(ObjectMap,Class[],Class[])} and {@link org.apache.juneau.rest.RestServlet#createParsers(ObjectMap,Class[],Class[])}
@@ -4919,20 +5142,20 @@
<!-- ======================================================================================================== -->
<a id="Cookbook.Client"></a>
- <h3 class='topic' onclick='toggle(this)'>8.3 - Client API</h3>
+ <h3 class='topic' onclick='toggle(this)'>9.3 - Client API</h3>
<div class='topic'>
</div>
<!-- ======================================================================================================== -->
<a id="Cookbook.Microservice"></a>
- <h3 class='topic' onclick='toggle(this)'>8.4 - Microservice API</h3>
+ <h3 class='topic' onclick='toggle(this)'>9.4 - Microservice API</h3>
<div class='topic'>
</div>
</div>
<!-- ======================================================================================================== -->
<a id="BestPractices"></a>
-<h2 class='topic' onclick='toggle(this)'>9 - Best Practices</h2>
+<h2 class='topic' onclick='toggle(this)'>10 - Best Practices</h2>
<div class='topic'>
<ol>
<li>Reuse instances of serializers and parsers whenever possible.<br>
@@ -4952,7 +5175,7 @@
<!-- ======================================================================================================== -->
<a id="ImportantLinks"></a>
-<h2 class='topic' onclick='toggle(this)'>10 - Important Document Links</h2>
+<h2 class='topic' onclick='toggle(this)'>11 - Important Document Links</h2>
<div class='topic'>
<p>
All up-to-date Juneau documentation is stored in Javadocs, especially package-level Javadocs.
@@ -4980,7 +5203,7 @@
<!-- ======================================================================================================== -->
<a id="ReleaseNotes"></a>
-<h2 class='topic' onclick='toggle(this)'>11 - Release Notes</h2>
+<h2 class='topic' onclick='toggle(this)'>12 - Release Notes</h2>
<div class='topic'>
<h5 class='toc'>What's new in each release</h5>
@@ -5078,7 +5301,9 @@
setting above on specific bean properties.
<li>New {@link org.apache.juneau.xml.annotation.XmlFormat#ELEMENTS} format can be applied to a bean property of type array/Collection to represent the child elements.
<li>New {@link org.apache.juneau.xml.annotation.XmlFormat#MIXED} format can be applied to a bean property of type array/Collection to represent mixed content (text + child elements).
+ <li>New {@link org.apache.juneau.xml.annotation.XmlFormat#MIXED_PWS} format. Identical to <jsf>MIXED</jsf> except preserves whitespace.
<li>New {@link org.apache.juneau.xml.annotation.XmlFormat#TEXT} format can be applied to a bean property of a single object to represent a text node as a child.
+ <li>New {@link org.apache.juneau.xml.annotation.XmlFormat#TEXT_PWS} format. Identical to <jsf>TEXT</jsf> except preserves whitespace.
<li>New {@link org.apache.juneau.xml.annotation.XmlFormat#XMLTEXT} format that's identical to {@link org.apache.juneau.xml.annotation.XmlFormat#TEXT} except
XML content is not escaped and serialized directly as the child content. The parser will reconvert this to the original XML text during parsing.
</ul>
@@ -5091,12 +5316,12 @@
<li>Eliminated the <code>addJsonTypeAttrs</code> and <code>addJsonStringTypeAttrs</code> settings.
<li>Namespace support is now disabled by default.
</ul>
- <li>Improvements to HTML serialization support.
+ <li>Significant modifications and improvements to HTML serialization support.
<ul>
<li>Parser converted from <code>XMLEventReader</code>-based to <code>XMLStreamReader</code>.
<li>Eliminated many unnecessary type tags and <xt><string></xt> elements and improved the readable layout.
The new format is much leaner.
- <li>New support methodology section added to {@link org.apache.juneau.html} documentation.
+ <li>New exhaustive support methodology section added to {@link org.apache.juneau.html} documentation.
</ul>
<li>New HTML5 DTO support: {@link org.apache.juneau.dto.html5}.
<li>{@link org.apache.juneau.BeanContext} class split into separate {@link org.apache.juneau.BeanContext} and {@link org.apache.juneau.BeanSession} classes.
@@ -5157,6 +5382,8 @@
<li>Updated {@link org.apache.juneau.dto.atom} documentation.
</ul>
<li>New {@link org.apache.juneau.transform.MapSwap} and {@link org.apache.juneau.transform.StringSwap} classes.
+ <li>New {@link org.apache.juneau.serializer.WriterSerializer#println(Object)} method. Useful for debugging purposes.
+ <li>New section added to this document: <a class='doclink' href='#DTOs'>Juneau Data Transfer Objects (org.apache.juneau.dto)</a>
</ul>
<h6 class='topic'>org.apache.juneau.rest</h6>
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-rest-test/pom.xml
----------------------------------------------------------------------
diff --git a/juneau-rest-test/pom.xml b/juneau-rest-test/pom.xml
index 2d7c070..e2f3d6d 100644
--- a/juneau-rest-test/pom.xml
+++ b/juneau-rest-test/pom.xml
@@ -35,11 +35,6 @@
<dependencies>
<dependency>
<groupId>org.apache.juneau</groupId>
- <artifactId>juneau-examples-rest</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.juneau</groupId>
<artifactId>juneau-rest-jaxrs</artifactId>
<version>${project.version}</version>
</dependency>
[4/6] incubator-juneau git commit: Continuation of HTML5 support.
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/Iframe.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Iframe.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Iframe.java
index 5afcaee..da3f860 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Iframe.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Iframe.java
@@ -12,6 +12,8 @@
// ***************************************************************************************************************************
package org.apache.juneau.dto.html5;
+import java.net.*;
+
import org.apache.juneau.annotation.*;
/**
@@ -19,17 +21,17 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="iframe")
-@SuppressWarnings("hiding")
public class Iframe extends HtmlElementMixed {
/**
* <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-height'>height</a> attribute.
* Vertical dimension.
* @param height - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Iframe height(String height) {
- attrs.put("height", height);
+ public final Iframe height(Object height) {
+ attr("height", height);
return this;
}
@@ -40,7 +42,7 @@ public class Iframe extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Iframe name(String name) {
- attrs.put("name", name);
+ attr("name", name);
return this;
}
@@ -51,7 +53,7 @@ public class Iframe extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Iframe sandbox(String sandbox) {
- attrs.put("sandbox", sandbox);
+ attr("sandbox", sandbox);
return this;
}
@@ -59,10 +61,11 @@ public class Iframe extends HtmlElementMixed {
* <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-iframe-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 Iframe src(String src) {
- attrs.put("src", src);
+ public final Iframe src(Object src) {
+ attr("src", src);
return this;
}
@@ -73,7 +76,7 @@ public class Iframe extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Iframe srcdoc(String srcdoc) {
- attrs.put("srcdoc", srcdoc);
+ attr("srcdoc", srcdoc);
return this;
}
@@ -81,10 +84,11 @@ public class Iframe extends HtmlElementMixed {
* <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-width'>width</a> attribute.
* Horizontal dimension.
* @param width - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Iframe width(String width) {
- attrs.put("width", width);
+ public final Iframe width(Object width) {
+ attr("width", width);
return this;
}
@@ -112,7 +116,7 @@ public class Iframe extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Iframe 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/Img.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Img.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Img.java
index a0e05a4..28be530 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Img.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Img.java
@@ -12,6 +12,8 @@
// ***************************************************************************************************************************
package org.apache.juneau.dto.html5;
+import java.net.*;
+
import org.apache.juneau.annotation.*;
/**
@@ -27,7 +29,7 @@ public class Img extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Img alt(String alt) {
- attrs.put("alt", alt);
+ attr("alt", alt);
return this;
}
@@ -38,7 +40,7 @@ public class Img extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Img crossorigin(String crossorigin) {
- attrs.put("crossorigin", crossorigin);
+ attr("crossorigin", crossorigin);
return this;
}
@@ -46,10 +48,11 @@ public class Img extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-height'>height</a> attribute.
* Vertical dimension.
* @param height - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Img height(String height) {
- attrs.put("height", height);
+ public final Img height(Object height) {
+ attr("height", height);
return this;
}
@@ -57,10 +60,11 @@ public class Img extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-img-ismap'>ismap</a> attribute.
* Whether the image is a server-side image map.
* @param ismap - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Img ismap(String ismap) {
- attrs.put("ismap", ismap);
+ public final Img ismap(Object ismap) {
+ attr("ismap", ismap);
return this;
}
@@ -68,10 +72,11 @@ public class Img extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-img-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 Img src(String src) {
- attrs.put("src", src);
+ public final Img src(Object src) {
+ attr("src", src);
return this;
}
@@ -82,7 +87,7 @@ public class Img extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Img usemap(String usemap) {
- attrs.put("usemap", usemap);
+ attr("usemap", usemap);
return this;
}
@@ -90,10 +95,11 @@ public class Img extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-width'>width</a> attribute.
* Horizontal dimension.
* @param width - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Img width(String width) {
- attrs.put("width", width);
+ public final Img width(Object width) {
+ attr("width", width);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/Input.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Input.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Input.java
index 3f8831d..fce1b01 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Input.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Input.java
@@ -12,6 +12,8 @@
// ***************************************************************************************************************************
package org.apache.juneau.dto.html5;
+import java.net.*;
+
import org.apache.juneau.annotation.*;
/**
@@ -28,7 +30,7 @@ public class Input extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Input accept(String accept) {
- attrs.put("accept", accept);
+ attr("accept", accept);
return this;
}
@@ -39,7 +41,7 @@ public class Input extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Input alt(String alt) {
- attrs.put("alt", alt);
+ attr("alt", alt);
return this;
}
@@ -50,7 +52,7 @@ public class Input extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Input autocomplete(String autocomplete) {
- attrs.put("autocomplete", autocomplete);
+ attr("autocomplete", autocomplete);
return this;
}
@@ -61,7 +63,7 @@ public class Input extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Input autofocus(String autofocus) {
- attrs.put("autofocus", autofocus);
+ attr("autofocus", autofocus);
return this;
}
@@ -69,10 +71,11 @@ public class Input extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-input-checked'>checked</a> attribute.
* Whether the command or control is checked.
* @param checked - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Input checked(String checked) {
- attrs.put("checked", checked);
+ public final Input checked(Object checked) {
+ attr("checked", checked);
return this;
}
@@ -83,7 +86,7 @@ public class Input extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Input dirname(String dirname) {
- attrs.put("dirname", dirname);
+ attr("dirname", dirname);
return this;
}
@@ -91,10 +94,11 @@ public class Input extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-fe-disabled'>disabled</a> attribute.
* Whether the form control is disabled.
* @param disabled - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Input disabled(String disabled) {
- attrs.put("disabled", disabled);
+ public final Input disabled(Object disabled) {
+ attr("disabled", disabled);
return this;
}
@@ -105,7 +109,7 @@ public class Input extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Input form(String form) {
- attrs.put("form", form);
+ attr("form", form);
return this;
}
@@ -116,7 +120,7 @@ public class Input extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Input formaction(String formaction) {
- attrs.put("formaction", formaction);
+ attr("formaction", formaction);
return this;
}
@@ -127,7 +131,7 @@ public class Input extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Input formenctype(String formenctype) {
- attrs.put("formenctype", formenctype);
+ attr("formenctype", formenctype);
return this;
}
@@ -138,7 +142,7 @@ public class Input extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Input formmethod(String formmethod) {
- attrs.put("formmethod", formmethod);
+ attr("formmethod", formmethod);
return this;
}
@@ -149,7 +153,7 @@ public class Input extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Input formnovalidate(String formnovalidate) {
- attrs.put("formnovalidate", formnovalidate);
+ attr("formnovalidate", formnovalidate);
return this;
}
@@ -160,7 +164,7 @@ public class Input extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Input formtarget(String formtarget) {
- attrs.put("formtarget", formtarget);
+ attr("formtarget", formtarget);
return this;
}
@@ -168,10 +172,11 @@ public class Input extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-height'>height</a> attribute.
* Vertical dimension.
* @param height - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Input height(String height) {
- attrs.put("height", height);
+ public final Input height(Object height) {
+ attr("height", height);
return this;
}
@@ -182,7 +187,7 @@ public class Input extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Input inputmode(String inputmode) {
- attrs.put("inputmode", inputmode);
+ attr("inputmode", inputmode);
return this;
}
@@ -193,7 +198,7 @@ public class Input extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Input list(String list) {
- attrs.put("list", list);
+ attr("list", list);
return this;
}
@@ -201,10 +206,11 @@ public class Input extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-input-max'>max</a> attribute.
* Maximum value.
* @param max - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Input max(String max) {
- attrs.put("max", max);
+ public final Input max(Object max) {
+ attr("max", max);
return this;
}
@@ -212,10 +218,11 @@ public class Input extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-input-maxlength'>maxlength</a> attribute.
* Maximum length of value.
* @param maxlength - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Input maxlength(String maxlength) {
- attrs.put("maxlength", maxlength);
+ public final Input maxlength(Object maxlength) {
+ attr("maxlength", maxlength);
return this;
}
@@ -223,10 +230,11 @@ public class Input extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-input-min'>min</a> attribute.
* Minimum value.
* @param min - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Input min(String min) {
- attrs.put("min", min);
+ public final Input min(Object min) {
+ attr("min", min);
return this;
}
@@ -234,10 +242,11 @@ public class Input extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-input-minlength'>minlength</a> attribute.
* Minimum length of value.
* @param minlength - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Input minlength(String minlength) {
- attrs.put("minlength", minlength);
+ public final Input minlength(Object minlength) {
+ attr("minlength", minlength);
return this;
}
@@ -245,10 +254,11 @@ public class Input extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-input-multiple'>multiple</a> attribute.
* Whether to allow multiple values.
* @param multiple - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Input multiple(String multiple) {
- attrs.put("multiple", multiple);
+ public final Input multiple(Object multiple) {
+ attr("multiple", multiple);
return this;
}
@@ -259,7 +269,7 @@ public class Input extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Input name(String name) {
- attrs.put("name", name);
+ attr("name", name);
return this;
}
@@ -270,7 +280,7 @@ public class Input extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Input pattern(String pattern) {
- attrs.put("pattern", pattern);
+ attr("pattern", pattern);
return this;
}
@@ -281,7 +291,7 @@ public class Input extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Input placeholder(String placeholder) {
- attrs.put("placeholder", placeholder);
+ attr("placeholder", placeholder);
return this;
}
@@ -289,10 +299,11 @@ public class Input extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-input-readonly'>readonly</a> attribute.
* Whether to allow the value to be edited by the user.
* @param readonly - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Input readonly(String readonly) {
- attrs.put("readonly", readonly);
+ public final Input readonly(Object readonly) {
+ attr("readonly", readonly);
return this;
}
@@ -300,10 +311,11 @@ public class Input extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-input-readonly'>required</a> attribute.
* Whether the control is required for form submission.
* @param required - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Input required(String required) {
- attrs.put("required", required);
+ public final Input required(Object required) {
+ attr("required", required);
return this;
}
@@ -311,10 +323,11 @@ public class Input extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-input-size'>size</a> attribute.
* Size of the control.
* @param size - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Input size(String size) {
- attrs.put("size", size);
+ public final Input size(Object size) {
+ attr("size", size);
return this;
}
@@ -322,10 +335,11 @@ public class Input extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-input-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 Input src(String src) {
- attrs.put("src", src);
+ public final Input src(Object src) {
+ attr("src", src);
return this;
}
@@ -336,7 +350,7 @@ public class Input extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Input step(String step) {
- attrs.put("step", step);
+ attr("step", step);
return this;
}
@@ -347,7 +361,7 @@ public class Input extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Input type(String type) {
- attrs.put("type", type);
+ attr("type", type);
return this;
}
@@ -355,10 +369,11 @@ public class Input extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-input-value'>value</a> attribute.
* Value of the form control.
* @param value - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Input value(String value) {
- attrs.put("value", value);
+ public final Input value(Object value) {
+ attr("value", value);
return this;
}
@@ -366,10 +381,11 @@ public class Input extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-width'>width</a> attribute.
* Horizontal dimension.
* @param width - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Input width(String width) {
- attrs.put("width", width);
+ public final Input width(Object width) {
+ attr("width", width);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/Ins.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Ins.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Ins.java
index a2bc4a3..e948e26 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Ins.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Ins.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="ins")
-@SuppressWarnings("hiding")
public class Ins extends HtmlElementMixed {
/**
@@ -29,7 +28,7 @@ public class Ins extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Ins cite(String cite) {
- attrs.put("cite", cite);
+ attr("cite", cite);
return this;
}
@@ -40,7 +39,7 @@ public class Ins extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Ins datetime(String datetime) {
- attrs.put("datetime", datetime);
+ attr("datetime", datetime);
return this;
}
@@ -68,7 +67,7 @@ public class Ins extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Ins 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/Kbd.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Kbd.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Kbd.java
index 07f34b1..c6a61de 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Kbd.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Kbd.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="kbd")
-@SuppressWarnings("hiding")
public class Kbd extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Kbd extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Kbd 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/Keygen.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Keygen.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Keygen.java
index 57e0129..dbcc4f4 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Keygen.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Keygen.java
@@ -25,10 +25,11 @@ public class Keygen extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-fe-autofocus'>autofocus</a> attribute.
* Automatically focus the form control when the page is loaded.
* @param autofocus - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Keygen autofocus(String autofocus) {
- attrs.put("autofocus", autofocus);
+ public final Keygen autofocus(Object autofocus) {
+ attr("autofocus", autofocus);
return this;
}
@@ -39,7 +40,7 @@ public class Keygen extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Keygen challenge(String challenge) {
- attrs.put("challenge", challenge);
+ attr("challenge", challenge);
return this;
}
@@ -47,10 +48,11 @@ public class Keygen extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-fe-disabled'>disabled</a> attribute.
* Whether the form control is disabled.
* @param disabled - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Keygen disabled(String disabled) {
- attrs.put("disabled", disabled);
+ public final Keygen disabled(Object disabled) {
+ attr("disabled", disabled);
return this;
}
@@ -61,7 +63,7 @@ public class Keygen extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Keygen form(String form) {
- attrs.put("form", form);
+ attr("form", form);
return this;
}
@@ -72,7 +74,7 @@ public class Keygen extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Keygen keytype(String keytype) {
- attrs.put("keytype", keytype);
+ attr("keytype", keytype);
return this;
}
@@ -83,7 +85,7 @@ public class Keygen extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Keygen name(String name) {
- attrs.put("name", name);
+ attr("name", name);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/Label.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Label.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Label.java
index 16d0bc6..ea13dac 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Label.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Label.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="label")
-@SuppressWarnings("hiding")
public class Label extends HtmlElementMixed {
/**
@@ -29,7 +28,7 @@ public class Label extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Label _for(String _for) {
- attrs.put("for", _for);
+ attr("for", _for);
return this;
}
@@ -40,7 +39,7 @@ public class Label extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Label form(String form) {
- attrs.put("form", form);
+ attr("form", form);
return this;
}
@@ -68,7 +67,7 @@ public class Label extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Label 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/Legend.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Legend.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Legend.java
index 92b29d4..16756a0 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Legend.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Legend.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="legend")
-@SuppressWarnings("hiding")
public class Legend extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Legend extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Legend 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/Li.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Li.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Li.java
index 8a5b387..94bae01 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Li.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Li.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="li")
-@SuppressWarnings("hiding")
public class Li extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Li extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Li 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/Link.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Link.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Link.java
index d28f40b..9513e1c 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Link.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Link.java
@@ -12,6 +12,8 @@
// ***************************************************************************************************************************
package org.apache.juneau.dto.html5;
+import java.net.*;
+
import org.apache.juneau.annotation.*;
/**
@@ -28,7 +30,7 @@ public class Link extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Link crossorigin(String crossorigin) {
- attrs.put("crossorigin", crossorigin);
+ attr("crossorigin", crossorigin);
return this;
}
@@ -36,10 +38,11 @@ public class Link extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/document-metadata.html#attr-link-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 Link href(String href) {
- attrs.put("href", href);
+ public final Link href(Object href) {
+ attr("href", href);
return this;
}
@@ -50,7 +53,7 @@ public class Link extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Link hreflang(String hreflang) {
- attrs.put("hreflang", hreflang);
+ attr("hreflang", hreflang);
return this;
}
@@ -61,7 +64,7 @@ public class Link extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Link media(String media) {
- attrs.put("media", media);
+ attr("media", media);
return this;
}
@@ -72,7 +75,7 @@ public class Link extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Link rel(String rel) {
- attrs.put("rel", rel);
+ attr("rel", rel);
return this;
}
@@ -83,7 +86,7 @@ public class Link extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Link sizes(String sizes) {
- attrs.put("sizes", sizes);
+ attr("sizes", sizes);
return this;
}
@@ -94,7 +97,7 @@ public class Link extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Link 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/Main.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Main.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Main.java
index 7605126..94b410d 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Main.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Main.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="main")
-@SuppressWarnings("hiding")
public class Main extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@@ -27,12 +26,6 @@ public class Main extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@Override /* HtmlElement */
- public Main children(Object...children) {
- super.children(children);
- return this;
- }
-
- @Override /* HtmlElement */
public final Main _class(String _class) {
super._class(_class);
return this;
@@ -43,4 +36,16 @@ public class Main extends HtmlElementContainer {
super.id(id);
return this;
}
+
+ @Override /* HtmlElementContainer */
+ public final Main children(Object...children) {
+ super.children(children);
+ return this;
+ }
+
+ @Override /* HtmlElementContainer */
+ public final Main 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/Map.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Map.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Map.java
index 10e4261..281f272 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Map.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Map.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="map")
-@SuppressWarnings("hiding")
public class Map extends HtmlElementContainer {
/**
@@ -29,7 +28,7 @@ public class Map extends HtmlElementContainer {
* @return This object (for method chaining).
*/
public final Map name(String name) {
- attrs.put("name", name);
+ attr("name", name);
return this;
}
@@ -38,12 +37,6 @@ public class Map extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@Override /* HtmlElement */
- public Map children(Object...children) {
- super.children(children);
- return this;
- }
-
- @Override /* HtmlElement */
public final Map _class(String _class) {
super._class(_class);
return this;
@@ -54,4 +47,16 @@ public class Map extends HtmlElementContainer {
super.id(id);
return this;
}
+
+ @Override /* HtmlElementContainer */
+ public final Map children(Object...children) {
+ super.children(children);
+ return this;
+ }
+
+ @Override /* HtmlElementContainer */
+ public final Map 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/Mark.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Mark.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Mark.java
index 5d6407e..3c37c51 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Mark.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Mark.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="mark")
-@SuppressWarnings("hiding")
public class Mark extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Mark extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Mark 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/Meta.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Meta.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Meta.java
index 0f4975a..7611dca 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Meta.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Meta.java
@@ -28,7 +28,7 @@ public class Meta extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Meta charset(String charset) {
- attrs.put("charset", charset);
+ attr("charset", charset);
return this;
}
@@ -39,7 +39,7 @@ public class Meta extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Meta content(String content) {
- attrs.put("content", content);
+ attr("content", content);
return this;
}
@@ -50,7 +50,7 @@ public class Meta extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Meta httpequiv(String httpequiv) {
- attrs.put("http-equiv", httpequiv);
+ attr("http-equiv", httpequiv);
return this;
}
@@ -61,7 +61,7 @@ public class Meta extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Meta name(String name) {
- attrs.put("name", name);
+ attr("name", name);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/Meter.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Meter.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Meter.java
index d42186c..3674019 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Meter.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Meter.java
@@ -19,17 +19,17 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="meter")
-@SuppressWarnings("hiding")
public class Meter extends HtmlElementMixed {
/**
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-meter-high'>high</a> attribute.
* Low limit of high range.
* @param high - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Meter high(String high) {
- attrs.put("high", high);
+ public final Meter high(Object high) {
+ attr("high", high);
return this;
}
@@ -37,10 +37,11 @@ public class Meter extends HtmlElementMixed {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-meter-low'>low</a> attribute.
* High limit of low range.
* @param low - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Meter low(String low) {
- attrs.put("low", low);
+ public final Meter low(Object low) {
+ attr("low", low);
return this;
}
@@ -48,10 +49,11 @@ public class Meter extends HtmlElementMixed {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-meter-max'>max</a> attribute.
* Upper bound of range.
* @param max - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Meter max(String max) {
- attrs.put("max", max);
+ public final Meter max(Object max) {
+ attr("max", max);
return this;
}
@@ -59,10 +61,11 @@ public class Meter extends HtmlElementMixed {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-meter-min'>min</a> attribute.
* Lower bound of range.
* @param min - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Meter min(String min) {
- attrs.put("min", min);
+ public final Meter min(Object min) {
+ attr("min", min);
return this;
}
@@ -70,10 +73,11 @@ public class Meter extends HtmlElementMixed {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-meter-optimum'>optimum</a> attribute.
* Optimum value in gauge.
* @param optimum - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Meter optimum(String optimum) {
- attrs.put("optimum", optimum);
+ public final Meter optimum(Object optimum) {
+ attr("optimum", optimum);
return this;
}
@@ -81,10 +85,11 @@ public class Meter extends HtmlElementMixed {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-meter-value'>value</a> attribute.
* Current value of the element.
* @param value - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Meter value(String value) {
- attrs.put("value", value);
+ public final Meter value(Object value) {
+ attr("value", value);
return this;
}
@@ -112,7 +117,7 @@ public class Meter extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Meter 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/Nav.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Nav.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Nav.java
index dffebd1..16586bb 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Nav.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Nav.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="nav")
-@SuppressWarnings("hiding")
public class Nav extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Nav extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Nav 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/Noscript.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Noscript.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Noscript.java
index 3d83738..526800d 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Noscript.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Noscript.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="noscript")
-@SuppressWarnings("hiding")
public class Noscript extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -47,7 +46,7 @@ public class Noscript extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Noscript 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/Object2.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Object2.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Object2.java
index b4c2094..fd43cb1 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Object2.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Object2.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="object")
-@SuppressWarnings("hiding")
public class Object2 extends HtmlElementMixed {
/**
@@ -29,7 +28,7 @@ public class Object2 extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Object2 data(String data) {
- attrs.put("data", data);
+ attr("data", data);
return this;
}
@@ -40,7 +39,7 @@ public class Object2 extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Object2 form(String form) {
- attrs.put("form", form);
+ attr("form", form);
return this;
}
@@ -48,10 +47,11 @@ public class Object2 extends HtmlElementMixed {
* <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-height'>height</a> attribute.
* Vertical dimension.
* @param height - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Object2 height(String height) {
- attrs.put("height", height);
+ public final Object2 height(Object height) {
+ attr("height", height);
return this;
}
@@ -62,7 +62,7 @@ public class Object2 extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Object2 name(String name) {
- attrs.put("name", name);
+ attr("name", name);
return this;
}
@@ -73,7 +73,7 @@ public class Object2 extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Object2 type(String type) {
- attrs.put("type", type);
+ attr("type", type);
return this;
}
@@ -81,10 +81,11 @@ public class Object2 extends HtmlElementMixed {
* <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-object-typemustmatch'>typemustmatch</a> attribute.
* Whether the type attribute and the Content-Type value need to match for the resource to be used.
* @param typemustmatch - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Object2 typemustmatch(String typemustmatch) {
- attrs.put("typemustmatch", typemustmatch);
+ public final Object2 typemustmatch(Object typemustmatch) {
+ attr("typemustmatch", typemustmatch);
return this;
}
@@ -95,7 +96,7 @@ public class Object2 extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Object2 usemap(String usemap) {
- attrs.put("usemap", usemap);
+ attr("usemap", usemap);
return this;
}
@@ -103,10 +104,11 @@ public class Object2 extends HtmlElementMixed {
* <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-width'>width</a> attribute.
* Horizontal dimension.
* @param width - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Object2 width(String width) {
- attrs.put("width", width);
+ public final Object2 width(Object width) {
+ attr("width", width);
return this;
}
@@ -134,7 +136,7 @@ public class Object2 extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Object2 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/Ol.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Ol.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Ol.java
index 626e3a9..1ad64e3 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Ol.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Ol.java
@@ -19,17 +19,17 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="ol")
-@SuppressWarnings("hiding")
public class Ol extends HtmlElementContainer {
/**
* <a class='doclink' href='https://www.w3.org/TR/html5/grouping-content.html#attr-ol-reversed'>reversed</a> attribute.
* Number the list backwards..
* @param reversed - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Ol reversed(String reversed) {
- attrs.put("reversed", reversed);
+ public final Ol reversed(Object reversed) {
+ attr("reversed", reversed);
return this;
}
@@ -37,10 +37,11 @@ public class Ol extends HtmlElementContainer {
* <a class='doclink' href='https://www.w3.org/TR/html5/grouping-content.html#attr-ol-start'>start</a> attribute.
* Ordinal value of the first item.
* @param start - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Ol start(String start) {
- attrs.put("start", start);
+ public final Ol start(Object start) {
+ attr("start", start);
return this;
}
@@ -51,7 +52,7 @@ public class Ol extends HtmlElementContainer {
* @return This object (for method chaining).
*/
public final Ol type(String type) {
- attrs.put("type", type);
+ attr("type", type);
return this;
}
@@ -60,12 +61,6 @@ public class Ol extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@Override /* HtmlElement */
- public Ol children(Object...children) {
- super.children(children);
- return this;
- }
-
- @Override /* HtmlElement */
public final Ol _class(String _class) {
super._class(_class);
return this;
@@ -76,4 +71,16 @@ public class Ol extends HtmlElementContainer {
super.id(id);
return this;
}
+
+ @Override /* HtmlElementContainer */
+ public final Ol children(Object...children) {
+ super.children(children);
+ return this;
+ }
+
+ @Override /* HtmlElementContainer */
+ public final Ol 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/Optgroup.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Optgroup.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Optgroup.java
index e8a8680..59bad44 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Optgroup.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Optgroup.java
@@ -19,17 +19,17 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="optgroup")
-@SuppressWarnings("hiding")
public class Optgroup extends HtmlElementContainer {
/**
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-optgroup-disabled'>disabled</a> attribute.
* Whether the form control is disabled.
* @param disabled - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Optgroup disabled(String disabled) {
- attrs.put("disabled", disabled);
+ public final Optgroup disabled(Object disabled) {
+ attr("disabled", disabled);
return this;
}
@@ -40,7 +40,7 @@ public class Optgroup extends HtmlElementContainer {
* @return This object (for method chaining).
*/
public final Optgroup label(String label) {
- attrs.put("label", label);
+ attr("label", label);
return this;
}
@@ -49,12 +49,6 @@ public class Optgroup extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@Override /* HtmlElement */
- public Optgroup children(Object...children) {
- super.children(children);
- return this;
- }
-
- @Override /* HtmlElement */
public final Optgroup _class(String _class) {
super._class(_class);
return this;
@@ -65,4 +59,16 @@ public class Optgroup extends HtmlElementContainer {
super.id(id);
return this;
}
+
+ @Override /* HtmlElementContainer */
+ public final Optgroup children(Object...children) {
+ super.children(children);
+ return this;
+ }
+
+ @Override /* HtmlElementContainer */
+ public final Optgroup 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/Option.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Option.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Option.java
index b946c72..ee9069e 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Option.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Option.java
@@ -25,10 +25,11 @@ public class Option extends HtmlElementText {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-option-disabled'>disabled</a> attribute.
* Whether the form control is disabled.
* @param disabled - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Option disabled(String disabled) {
- attrs.put("disabled", disabled);
+ public final Option disabled(Object disabled) {
+ attr("disabled", disabled);
return this;
}
@@ -39,7 +40,7 @@ public class Option extends HtmlElementText {
* @return This object (for method chaining).
*/
public final Option label(String label) {
- attrs.put("label", label);
+ attr("label", label);
return this;
}
@@ -47,10 +48,11 @@ public class Option extends HtmlElementText {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-option-selected'>selected</a> attribute.
* Whether the option is selected by default.
* @param selected - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Option selected(String selected) {
- attrs.put("selected", selected);
+ public final Option selected(Object selected) {
+ attr("selected", selected);
return this;
}
@@ -58,10 +60,11 @@ public class Option extends HtmlElementText {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-option-value'>value</a> attribute.
* Value to be used for form submission.
* @param value - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Option value(String value) {
- attrs.put("value", value);
+ public final Option value(Object value) {
+ attr("value", value);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/Output.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Output.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Output.java
index 5eb61ab..8510f38 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Output.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Output.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="output")
-@SuppressWarnings("hiding")
public class Output extends HtmlElementMixed {
/**
@@ -29,7 +28,7 @@ public class Output extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Output _for(String _for) {
- attrs.put("for", _for);
+ attr("for", _for);
return this;
}
@@ -40,7 +39,7 @@ public class Output extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Output form(String form) {
- attrs.put("form", form);
+ attr("form", form);
return this;
}
@@ -51,7 +50,7 @@ public class Output extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Output name(String name) {
- attrs.put("name", name);
+ attr("name", name);
return this;
}
@@ -79,7 +78,7 @@ public class Output extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Output 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/P.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/P.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/P.java
index 7ee4ecb..d017450 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/P.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/P.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="p")
-@SuppressWarnings("hiding")
public class P extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class P extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public P 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/Param.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Param.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Param.java
index bac2a05..a7699ce 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Param.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Param.java
@@ -28,7 +28,7 @@ public class Param extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Param name(String name) {
- attrs.put("name", name);
+ attr("name", name);
return this;
}
@@ -36,10 +36,11 @@ public class Param extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-param-value'>value</a> attribute.
* Value of parameter.
* @param value - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Param value(String value) {
- attrs.put("value", value);
+ public final Param value(Object value) {
+ attr("value", value);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/Pre.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Pre.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Pre.java
index 5bc28b4..51f72a3 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Pre.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Pre.java
@@ -12,20 +12,31 @@
// ***************************************************************************************************************************
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.*;
/**
* DTO for an HTML <a href='https://www.w3.org/TR/html5/grouping-content.html#the-pre-element'><pre></a> element.
* <p>
*/
@Bean(typeName="pre")
-@SuppressWarnings("hiding")
public class Pre extends HtmlElementMixed {
//--------------------------------------------------------------------------------
// Overridden methods
//--------------------------------------------------------------------------------
+ @Xml(format=MIXED_PWS)
+ @BeanProperty(beanDictionary=HtmlBeanDictionary.class)
+ @Override
+ public LinkedList<Object> getChildren() {
+ return super.getChildren();
+ }
+
@Override /* HtmlElement */
public final Pre _class(String _class) {
super._class(_class);
@@ -46,7 +57,7 @@ public class Pre extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Pre 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/Progress.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Progress.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Progress.java
index dd30811..847c328 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Progress.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Progress.java
@@ -19,17 +19,17 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="progress")
-@SuppressWarnings("hiding")
public class Progress extends HtmlElementMixed {
/**
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-progress-max'>max</a> attribute.
* Upper bound of range.
* @param max - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Progress max(String max) {
- attrs.put("max", max);
+ public final Progress max(Object max) {
+ attr("max", max);
return this;
}
@@ -37,10 +37,11 @@ public class Progress extends HtmlElementMixed {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-progress-value'>value</a> attribute.
* Current value of the element.
* @param value - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Progress value(String value) {
- attrs.put("value", value);
+ public final Progress value(Object value) {
+ attr("value", value);
return this;
}
@@ -68,7 +69,7 @@ public class Progress extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Progress 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/Q.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Q.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Q.java
index b61aa6e..29ec5d3 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Q.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Q.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="q")
-@SuppressWarnings("hiding")
public class Q extends HtmlElementMixed {
/**
@@ -29,7 +28,7 @@ public class Q extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Q cite(String cite) {
- attrs.put("cite", cite);
+ attr("cite", cite);
return this;
}
@@ -57,7 +56,7 @@ public class Q extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Q 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/Rb.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Rb.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Rb.java
index 6b9a571..f8314b3 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Rb.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Rb.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="rb")
-@SuppressWarnings("hiding")
public class Rb extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Rb extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Rb 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/Rp.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Rp.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Rp.java
index e02d50f..fb6b41e 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Rp.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Rp.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="rp")
-@SuppressWarnings("hiding")
public class Rp extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Rp extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Rp 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/Rt.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Rt.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Rt.java
index 9eb0852..cc1a3d0 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Rt.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Rt.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="rt")
-@SuppressWarnings("hiding")
public class Rt extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Rt extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Rt 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/Rtc.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Rtc.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Rtc.java
index 6eee0aa..fd39c4f 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Rtc.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Rtc.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="rtc")
-@SuppressWarnings("hiding")
public class Rtc extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Rtc extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Rtc 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/Ruby.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Ruby.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Ruby.java
index 9f122df..19a18f9 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Ruby.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Ruby.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="ruby")
-@SuppressWarnings("hiding")
public class Ruby extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Ruby extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Ruby 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/S.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/S.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/S.java
index 4d84780..e285970 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/S.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/S.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="s")
-@SuppressWarnings("hiding")
public class S extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class S extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public S 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/Samp.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Samp.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Samp.java
index e643498..d419bda 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Samp.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Samp.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="samp")
-@SuppressWarnings("hiding")
public class Samp extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Samp extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Samp 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/Script.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Script.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Script.java
index 743d371..3d6c1ae 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Script.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Script.java
@@ -12,24 +12,27 @@
// ***************************************************************************************************************************
package org.apache.juneau.dto.html5;
+import java.net.*;
+
import org.apache.juneau.annotation.*;
+import org.apache.juneau.xml.annotation.*;
/**
* DTO for an HTML <a href='https://www.w3.org/TR/html5/scripting-1.html#the-script-element'><script></a> element.
* <p>
*/
@Bean(typeName="script")
-@SuppressWarnings("hiding")
-public class Script extends HtmlElementMixed {
+public class Script extends HtmlElementText {
/**
* <a class='doclink' href='https://www.w3.org/TR/html5/scripting-1.html#attr-script-async'>async</a> attribute.
* Execute script asynchronously.
* @param async - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Script async(String async) {
- attrs.put("async", async);
+ public final Script async(Object async) {
+ attr("async", async);
return this;
}
@@ -40,7 +43,7 @@ public class Script extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Script charset(String charset) {
- attrs.put("charset", charset);
+ attr("charset", charset);
return this;
}
@@ -51,7 +54,7 @@ public class Script extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Script crossorigin(String crossorigin) {
- attrs.put("crossorigin", crossorigin);
+ attr("crossorigin", crossorigin);
return this;
}
@@ -59,10 +62,11 @@ public class Script extends HtmlElementMixed {
* <a class='doclink' href='https://www.w3.org/TR/html5/scripting-1.html#attr-script-defer'>defer</a> attribute.
* Defer script execution.
* @param defer - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Script defer(String defer) {
- attrs.put("defer", defer);
+ public final Script defer(Object defer) {
+ attr("defer", defer);
return this;
}
@@ -70,10 +74,11 @@ public class Script extends HtmlElementMixed {
* <a class='doclink' href='https://www.w3.org/TR/html5/scripting-1.html#attr-script-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 Script src(String src) {
- attrs.put("src", src);
+ public final Script src(Object src) {
+ attr("src", src);
return this;
}
@@ -84,7 +89,7 @@ public class Script extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Script type(String type) {
- attrs.put("type", type);
+ attr("type", type);
return this;
}
@@ -92,6 +97,12 @@ public class Script extends HtmlElementMixed {
// Overridden methods
//--------------------------------------------------------------------------------
+ @Xml(format=XmlFormat.TEXT_PWS)
+ @Override
+ public Object getText() {
+ return super.getText();
+ }
+
@Override /* HtmlElement */
public final Script _class(String _class) {
super._class(_class);
@@ -104,15 +115,9 @@ public class Script extends HtmlElementMixed {
return this;
}
- @Override /* HtmlElementMixed */
- public Script children(Object...children) {
- super.children(children);
- return this;
- }
-
- @Override /* HtmlElementMixed */
- public Script child(Object child) {
- this.children.add(child);
+ @Override /* HtmlElementText */
+ public Script text(Object text) {
+ super.text(text);
return this;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/Section.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Section.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Section.java
index b545eee..1ea0688 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Section.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Section.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="section")
-@SuppressWarnings("hiding")
public class Section extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Section extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Section 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/Select.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Select.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Select.java
index 63641d0..bf7965f 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Select.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Select.java
@@ -19,17 +19,17 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="select")
-@SuppressWarnings("hiding")
public class Select extends HtmlElementContainer {
/**
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-fe-autofocus'>autofocus</a> attribute.
* Automatically focus the form control when the page is loaded.
* @param autofocus - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Select autofocus(String autofocus) {
- attrs.put("autofocus", autofocus);
+ public final Select autofocus(Object autofocus) {
+ attr("autofocus", autofocus);
return this;
}
@@ -37,10 +37,11 @@ public class Select extends HtmlElementContainer {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-fe-disabled'>disabled</a> attribute.
* Whether the form control is disabled.
* @param disabled - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Select disabled(String disabled) {
- attrs.put("disabled", disabled);
+ public final Select disabled(Object disabled) {
+ attr("disabled", disabled);
return this;
}
@@ -51,7 +52,7 @@ public class Select extends HtmlElementContainer {
* @return This object (for method chaining).
*/
public final Select form(String form) {
- attrs.put("form", form);
+ attr("form", form);
return this;
}
@@ -59,10 +60,11 @@ public class Select extends HtmlElementContainer {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-select-multiple'>multiple</a> attribute.
* Whether to allow multiple values.
* @param multiple - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Select multiple(String multiple) {
- attrs.put("multiple", multiple);
+ public final Select multiple(Object multiple) {
+ attr("multiple", multiple);
return this;
}
@@ -73,7 +75,7 @@ public class Select extends HtmlElementContainer {
* @return This object (for method chaining).
*/
public final Select name(String name) {
- attrs.put("name", name);
+ attr("name", name);
return this;
}
@@ -81,10 +83,11 @@ public class Select extends HtmlElementContainer {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-select-required'>required</a> attribute.
* Whether the control is required for form submission.
* @param required - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Select required(String required) {
- attrs.put("required", required);
+ public final Select required(Object required) {
+ attr("required", required);
return this;
}
@@ -92,10 +95,11 @@ public class Select extends HtmlElementContainer {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-select-size'>size</a> attribute.
* Size of the control.
* @param size - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Select size(String size) {
- attrs.put("size", size);
+ public final Select size(Object size) {
+ attr("size", size);
return this;
}
@@ -104,12 +108,6 @@ public class Select extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@Override /* HtmlElement */
- public Select children(Object...children) {
- super.children(children);
- return this;
- }
-
- @Override /* HtmlElement */
public final Select _class(String _class) {
super._class(_class);
return this;
@@ -120,4 +118,16 @@ public class Select extends HtmlElementContainer {
super.id(id);
return this;
}
+
+ @Override /* HtmlElementContainer */
+ public final Select children(Object...children) {
+ super.children(children);
+ return this;
+ }
+
+ @Override /* HtmlElementContainer */
+ public final Select 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/Small.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Small.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Small.java
index b0be6fc..560fb0c 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Small.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Small.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="small")
-@SuppressWarnings("hiding")
public class Small extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Small extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Small 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/Source.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Source.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Source.java
index f9bf26c..2eb98a9 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Source.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Source.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 Source extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-source-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 Source src(String src) {
- attrs.put("src", src);
+ public final Source src(Object src) {
+ attr("src", src);
return this;
}
@@ -39,7 +42,7 @@ public class Source extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Source 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/Span.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Span.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Span.java
index 51fac15..246e3b6 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Span.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Span.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="span")
-@SuppressWarnings("hiding")
public class Span extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -38,6 +37,12 @@ public class Span extends HtmlElementMixed {
return this;
}
+ @Override /* HtmlElement */
+ public final Span style(String style) {
+ attr("style", style);
+ return this;
+ }
+
@Override /* HtmlElementMixed */
public Span children(Object...children) {
super.children(children);
@@ -46,7 +51,7 @@ public class Span extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Span 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/Strong.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Strong.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Strong.java
index c6ca3e7..224dff4 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Strong.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Strong.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="strong")
-@SuppressWarnings("hiding")
public class Strong extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Strong extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Strong 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/Style.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Style.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Style.java
index 3f3e1d3..e9948a8 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Style.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Style.java
@@ -13,14 +13,14 @@
package org.apache.juneau.dto.html5;
import org.apache.juneau.annotation.*;
+import org.apache.juneau.xml.annotation.*;
/**
* DTO for an HTML <a href='https://www.w3.org/TR/html5/document-metadata.html#the-style-element'><style></a> element.
* <p>
*/
@Bean(typeName="style")
-@SuppressWarnings("hiding")
-public class Style extends HtmlElementMixed {
+public class Style extends HtmlElementText {
/**
* <a class='doclink' href='https://www.w3.org/TR/html5/document-metadata.html#attr-style-media'>media</a> attribute.
@@ -29,7 +29,7 @@ public class Style extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Style media(String media) {
- attrs.put("media", media);
+ attr("media", media);
return this;
}
@@ -40,7 +40,7 @@ public class Style extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Style type(String type) {
- attrs.put("type", type);
+ attr("type", type);
return this;
}
@@ -48,6 +48,12 @@ public class Style extends HtmlElementMixed {
// Overridden methods
//--------------------------------------------------------------------------------
+ @Xml(format=XmlFormat.TEXT_PWS)
+ @Override /* HtmlElementText */
+ public Object getText() {
+ return super.getText();
+ }
+
@Override /* HtmlElement */
public final Style _class(String _class) {
super._class(_class);
@@ -60,15 +66,9 @@ public class Style extends HtmlElementMixed {
return this;
}
- @Override /* HtmlElementMixed */
- public Style children(Object...children) {
- super.children(children);
- return this;
- }
-
- @Override /* HtmlElementMixed */
- public Style child(Object child) {
- this.children.add(child);
+ @Override /* HtmlElementText */
+ public final Style text(Object text) {
+ super.text(text);
return this;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/Sub.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Sub.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Sub.java
index cabe28a..f32b893 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Sub.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Sub.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="sub")
-@SuppressWarnings("hiding")
public class Sub extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Sub extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Sub 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/Sup.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Sup.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Sup.java
index 96eb6dc..60934a1 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Sup.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Sup.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="sup")
-@SuppressWarnings("hiding")
public class Sup extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Sup extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Sup child(Object child) {
- this.children.add(child);
+ super.child(child);
return this;
}
}
[5/6] incubator-juneau git commit: Continuation of HTML5 support.
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/Body.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Body.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Body.java
index 2eaad5a..b23b6f9 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Body.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Body.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="body")
-@SuppressWarnings("hiding")
public class Body extends HtmlElementMixed {
/**
@@ -29,7 +28,7 @@ public class Body extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Body onafterprint(String onafterprint) {
- attrs.put("onafterprint", onafterprint);
+ attr("onafterprint", onafterprint);
return this;
}
@@ -40,7 +39,7 @@ public class Body extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Body onbeforeunload(String onbeforeunload) {
- attrs.put("onbeforeunload", onbeforeunload);
+ attr("onbeforeunload", onbeforeunload);
return this;
}
@@ -51,7 +50,7 @@ public class Body extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Body onmessage(String onmessage) {
- attrs.put("onmessage", onmessage);
+ attr("onmessage", onmessage);
return this;
}
@@ -62,7 +61,7 @@ public class Body extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Body ononline(String ononline) {
- attrs.put("ononline", ononline);
+ attr("ononline", ononline);
return this;
}
@@ -73,7 +72,7 @@ public class Body extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Body onpageshow(String onpageshow) {
- attrs.put("onpageshow", onpageshow);
+ attr("onpageshow", onpageshow);
return this;
}
@@ -84,7 +83,7 @@ public class Body extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Body onstorage(String onstorage) {
- attrs.put("onstorage", onstorage);
+ attr("onstorage", onstorage);
return this;
}
@@ -112,7 +111,7 @@ public class Body extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Body 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/Button.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Button.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Button.java
index 8974a85..6ed6937 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Button.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Button.java
@@ -19,17 +19,17 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="button")
-@SuppressWarnings("hiding")
public class Button extends HtmlElementMixed {
/**
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-fe-autofocus'>autofocus</a> attribute.
* Automatically focus the form control when the page is loaded.
* @param autofocus - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Button autofocus(String autofocus) {
- attrs.put("autofocus", autofocus);
+ public final Button autofocus(Object autofocus) {
+ attr("autofocus", autofocus);
return this;
}
@@ -37,10 +37,11 @@ public class Button extends HtmlElementMixed {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-fe-disabled'>disabled</a> attribute.
* Whether the form control is disabled.
* @param disabled - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Button disabled(String disabled) {
- attrs.put("disabled", disabled);
+ public final Button disabled(Object disabled) {
+ attr("disabled", disabled);
return this;
}
@@ -51,7 +52,7 @@ public class Button extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Button form(String form) {
- attrs.put("form", form);
+ attr("form", form);
return this;
}
@@ -62,7 +63,7 @@ public class Button extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Button formaction(String formaction) {
- attrs.put("formaction", formaction);
+ attr("formaction", formaction);
return this;
}
@@ -73,7 +74,7 @@ public class Button extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Button formenctype(String formenctype) {
- attrs.put("formenctype", formenctype);
+ attr("formenctype", formenctype);
return this;
}
@@ -84,7 +85,7 @@ public class Button extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Button formmethod(String formmethod) {
- attrs.put("formmethod", formmethod);
+ attr("formmethod", formmethod);
return this;
}
@@ -95,7 +96,7 @@ public class Button extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Button formnovalidate(String formnovalidate) {
- attrs.put("formnovalidate", formnovalidate);
+ attr("formnovalidate", formnovalidate);
return this;
}
@@ -106,7 +107,7 @@ public class Button extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Button formtarget(String formtarget) {
- attrs.put("formtarget", formtarget);
+ attr("formtarget", formtarget);
return this;
}
@@ -117,7 +118,7 @@ public class Button extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Button menu(String menu) {
- attrs.put("menu", menu);
+ attr("menu", menu);
return this;
}
@@ -128,7 +129,7 @@ public class Button extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Button name(String name) {
- attrs.put("name", name);
+ attr("name", name);
return this;
}
@@ -139,7 +140,7 @@ public class Button extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Button type(String type) {
- attrs.put("type", type);
+ attr("type", type);
return this;
}
@@ -147,10 +148,11 @@ public class Button extends HtmlElementMixed {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-button-value'>value</a> attribute.
* Value to be used for form submission.
* @param value - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Button value(String value) {
- attrs.put("value", value);
+ public final Button value(Object value) {
+ attr("value", value);
return this;
}
@@ -178,7 +180,7 @@ public class Button extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Button 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/Canvas.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Canvas.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Canvas.java
index 21db9dd..51289e1 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Canvas.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Canvas.java
@@ -25,10 +25,11 @@ public class Canvas extends HtmlElementContainer {
* <a class='doclink' href='https://www.w3.org/TR/html5/scripting-1.html#attr-canvas-height'>height</a> attribute.
* Vertical dimension.
* @param height - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Canvas height(long height) {
- attrs.put("height", height);
+ public final Canvas height(Object height) {
+ attr("height", height);
return this;
}
@@ -36,10 +37,11 @@ public class Canvas extends HtmlElementContainer {
* <a class='doclink' href='https://www.w3.org/TR/html5/scripting-1.html#attr-canvas-width'>width</a> attribute.
* Horizontal dimension.
* @param width - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Canvas width(long width) {
- attrs.put("width", width);
+ public final Canvas width(Object width) {
+ attr("width", width);
return this;
}
@@ -58,4 +60,16 @@ public class Canvas extends HtmlElementContainer {
super.id(id);
return this;
}
+
+ @Override /* HtmlElementContainer */
+ public final Canvas children(Object...children) {
+ super.children(children);
+ return this;
+ }
+
+ @Override /* HtmlElementContainer */
+ public final Canvas 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/Caption.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Caption.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Caption.java
index 1b7b9d8..5a035a3 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Caption.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Caption.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="caption")
-@SuppressWarnings("hiding")
public class Caption extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Caption extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Caption 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/Cite.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Cite.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Cite.java
index 00245eb..e7693de 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Cite.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Cite.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="cite")
-@SuppressWarnings("hiding")
public class Cite extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Cite extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Cite 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/Code.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Code.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Code.java
index af5cc19..9215ccc 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Code.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Code.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="code")
-@SuppressWarnings("hiding")
public class Code extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Code extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Code 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/Col.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Col.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Col.java
index 94502c2..9ace341 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Col.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Col.java
@@ -25,10 +25,11 @@ public class Col extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/tabular-data.html#attr-col-span'>span</a> attribute.
* Number of columns spanned by the element.
* @param span - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Col span(long span) {
- attrs.put("span", span);
+ public final Col span(Object span) {
+ attr("span", span);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/Colgroup.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Colgroup.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Colgroup.java
index b404ca4..62cf30c 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Colgroup.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Colgroup.java
@@ -19,17 +19,17 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="colgroup")
-@SuppressWarnings("hiding")
public class Colgroup extends HtmlElementContainer {
/**
* <a class='doclink' href='https://www.w3.org/TR/html5/tabular-data.html#attr-colgroup-span'>span</a> attribute.
* Number of columns spanned by the element.
* @param span - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Colgroup span(long span) {
- attrs.put("span", span);
+ public final Colgroup span(Object span) {
+ attr("span", span);
return this;
}
@@ -38,12 +38,6 @@ public class Colgroup extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@Override /* HtmlElement */
- public Colgroup children(Object...children) {
- super.children(children);
- return this;
- }
-
- @Override /* HtmlElement */
public final Colgroup _class(String _class) {
super._class(_class);
return this;
@@ -54,4 +48,16 @@ public class Colgroup extends HtmlElementContainer {
super.id(id);
return this;
}
+
+ @Override /* HtmlElementContainer */
+ public final Colgroup children(Object...children) {
+ super.children(children);
+ return this;
+ }
+
+ @Override /* HtmlElementContainer */
+ public final Colgroup 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/Data.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Data.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Data.java
index 5f7de70..07e7338 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Data.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Data.java
@@ -19,17 +19,17 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="data")
-@SuppressWarnings("hiding")
public class Data extends HtmlElementMixed {
/**
* <a class='doclink' href='https://www.w3.org/TR/html5/text-level-semantics.html#attr-data-value'>value</a> attribute.
* Machine-readable value.
* @param value - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Data value(String value) {
- attrs.put("value", value);
+ public final Data value(Object value) {
+ attr("value", value);
return this;
}
@@ -57,7 +57,7 @@ public class Data extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Data 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/Datalist.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Datalist.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Datalist.java
index 1034344..13f030b 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Datalist.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Datalist.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="datalist")
-@SuppressWarnings("hiding")
public class Datalist extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@@ -27,12 +26,6 @@ public class Datalist extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@Override /* HtmlElement */
- public Datalist children(Object...children) {
- super.children(children);
- return this;
- }
-
- @Override /* HtmlElement */
public final Datalist _class(String _class) {
super._class(_class);
return this;
@@ -43,4 +36,16 @@ public class Datalist extends HtmlElementContainer {
super.id(id);
return this;
}
+
+ @Override /* HtmlElementContainer */
+ public final Datalist children(Object...children) {
+ super.children(children);
+ return this;
+ }
+
+ @Override /* HtmlElementContainer */
+ public final Datalist 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/Dd.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Dd.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Dd.java
index a86567e..3ee021f 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Dd.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Dd.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="dd")
-@SuppressWarnings("hiding")
public class Dd extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Dd extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Dd 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/Del.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Del.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Del.java
index 4037fff..a1b95b5 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Del.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Del.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="del")
-@SuppressWarnings("hiding")
public class Del extends HtmlElementMixed {
/**
@@ -29,7 +28,7 @@ public class Del extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Del cite(String cite) {
- attrs.put("cite", cite);
+ attr("cite", cite);
return this;
}
@@ -40,7 +39,7 @@ public class Del extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Del datetime(String datetime) {
- attrs.put("datetime", datetime);
+ attr("datetime", datetime);
return this;
}
@@ -68,7 +67,7 @@ public class Del extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Del 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/Dfn.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Dfn.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Dfn.java
index baa4b97..c39d68e 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Dfn.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Dfn.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="dfn")
-@SuppressWarnings("hiding")
public class Dfn extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Dfn extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Dfn 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/Div.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Div.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Div.java
index 7c58a77..a530ef7 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Div.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Div.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="div")
-@SuppressWarnings("hiding")
public class Div extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Div extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Div 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/Dl.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Dl.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Dl.java
index 607d1bc..568fe37 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Dl.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Dl.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="dl")
-@SuppressWarnings("hiding")
public class Dl extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@@ -27,12 +26,6 @@ public class Dl extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@Override /* HtmlElement */
- public final Dl children(Object...children) {
- super.children(children);
- return this;
- }
-
- @Override /* HtmlElement */
public final Dl _class(String _class) {
super._class(_class);
return this;
@@ -43,4 +36,16 @@ public class Dl extends HtmlElementContainer {
super.id(id);
return this;
}
+
+ @Override /* HtmlElementContainer */
+ public final Dl children(Object...children) {
+ super.children(children);
+ return this;
+ }
+
+ @Override /* HtmlElementContainer */
+ public final Dl 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/Dt.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Dt.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Dt.java
index 1ef264e..ee3603c 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Dt.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Dt.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="dt")
-@SuppressWarnings("hiding")
public class Dt extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Dt extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Dt 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/Em.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Em.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Em.java
index 07934ef..a71f59c 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Em.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Em.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="em")
-@SuppressWarnings("hiding")
public class Em extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Em extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Em 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/Embed.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Embed.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Embed.java
index f37975b..6b39259 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Embed.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Embed.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 Embed extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-height'>height</a> attribute.
* Vertical dimension.
* @param height - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Embed height(String height) {
- attrs.put("height", height);
+ public final Embed height(Object height) {
+ attr("height", height);
return this;
}
@@ -36,10 +39,11 @@ public class Embed extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-embed-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 Embed src(String src) {
- attrs.put("src", src);
+ public final Embed src(Object src) {
+ attr("src", src);
return this;
}
@@ -50,7 +54,7 @@ public class Embed extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Embed type(String type) {
- attrs.put("type", type);
+ attr("type", type);
return this;
}
@@ -58,10 +62,11 @@ public class Embed extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-width'>width</a> attribute.
* Horizontal dimension.
* @param width - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Embed width(String width) {
- attrs.put("width", width);
+ public final Embed width(Object width) {
+ attr("width", width);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/Fieldset.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Fieldset.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Fieldset.java
index 4a9bfad..46bebec 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Fieldset.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Fieldset.java
@@ -19,17 +19,17 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="fieldset")
-@SuppressWarnings("hiding")
public class Fieldset extends HtmlElementMixed {
/**
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-fieldset-disabled'>disabled</a> attribute.
* Whether the form control is disabled.
* @param disabled - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Fieldset disabled(String disabled) {
- attrs.put("disabled", disabled);
+ public final Fieldset disabled(Boolean disabled) {
+ attr("disabled", disabled);
return this;
}
@@ -40,7 +40,7 @@ public class Fieldset extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Fieldset form(String form) {
- attrs.put("form", form);
+ attr("form", form);
return this;
}
@@ -51,7 +51,7 @@ public class Fieldset extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Fieldset name(String name) {
- attrs.put("name", name);
+ attr("name", name);
return this;
}
@@ -79,7 +79,7 @@ public class Fieldset extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Fieldset 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/Figcaption.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Figcaption.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Figcaption.java
index 9dafbaa..5540173 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Figcaption.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Figcaption.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="figcaption")
-@SuppressWarnings("hiding")
public class Figcaption extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Figcaption extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Figcaption 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/Figure.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Figure.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Figure.java
index 102b0d1..e4547a6 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Figure.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Figure.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="figure")
-@SuppressWarnings("hiding")
public class Figure extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@@ -27,12 +26,6 @@ public class Figure extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@Override /* HtmlElement */
- public final Figure children(Object...children) {
- super.children(children);
- return this;
- }
-
- @Override /* HtmlElement */
public final Figure _class(String _class) {
super._class(_class);
return this;
@@ -43,4 +36,16 @@ public class Figure extends HtmlElementContainer {
super.id(id);
return this;
}
+
+ @Override /* HtmlElementContainer */
+ public final Figure children(Object...children) {
+ super.children(children);
+ return this;
+ }
+
+ @Override /* HtmlElementContainer */
+ public final Figure 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/Footer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Footer.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Footer.java
index b2844c0..036d0df 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Footer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Footer.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="footer")
-@SuppressWarnings("hiding")
public class Footer extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Footer extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Footer 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/Form.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Form.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Form.java
index 6e04499..c7b0e57 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Form.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Form.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="form")
-@SuppressWarnings("hiding")
public class Form extends HtmlElementMixed {
/**
@@ -29,7 +28,7 @@ public class Form extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Form acceptcharset(String acceptcharset) {
- attrs.put("accept-charset", acceptcharset);
+ attr("accept-charset", acceptcharset);
return this;
}
@@ -40,7 +39,7 @@ public class Form extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Form action(String action) {
- attrs.put("action", action);
+ attr("action", action);
return this;
}
@@ -51,7 +50,7 @@ public class Form extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Form autocomplete(String autocomplete) {
- attrs.put("autocomplete", autocomplete);
+ attr("autocomplete", autocomplete);
return this;
}
@@ -62,7 +61,7 @@ public class Form extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Form enctype(String enctype) {
- attrs.put("enctype", enctype);
+ attr("enctype", enctype);
return this;
}
@@ -73,7 +72,7 @@ public class Form extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Form method(String method) {
- attrs.put("method", method);
+ attr("method", method);
return this;
}
@@ -84,7 +83,7 @@ public class Form extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Form name(String name) {
- attrs.put("name", name);
+ attr("name", name);
return this;
}
@@ -92,10 +91,11 @@ public class Form extends HtmlElementMixed {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-fs-novalidate'>novalidate</a> attribute.
* Bypass form control validation for form submission.
* @param novalidate - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Form novalidate(String novalidate) {
- attrs.put("novalidate", novalidate);
+ public final Form novalidate(Boolean novalidate) {
+ attr("novalidate", novalidate);
return this;
}
@@ -106,7 +106,7 @@ public class Form extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Form target(String target) {
- attrs.put("target", target);
+ attr("target", target);
return this;
}
@@ -135,7 +135,7 @@ public class Form extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Form 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/H1.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/H1.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/H1.java
index d2bf51f..b7ec1f5 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/H1.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/H1.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="h1")
-@SuppressWarnings("hiding")
public class H1 extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class H1 extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public H1 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/H2.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/H2.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/H2.java
index 9d9222d..50389a4 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/H2.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/H2.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="h2")
-@SuppressWarnings("hiding")
public class H2 extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class H2 extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public H2 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/H3.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/H3.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/H3.java
index dda0bfb..9515961 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/H3.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/H3.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="h3")
-@SuppressWarnings("hiding")
public class H3 extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class H3 extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public H3 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/H4.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/H4.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/H4.java
index 4e064f3..3e69395 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/H4.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/H4.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="h4")
-@SuppressWarnings("hiding")
public class H4 extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class H4 extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public H4 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/H5.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/H5.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/H5.java
index 9a48c27..efeeb00 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/H5.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/H5.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="h5")
-@SuppressWarnings("hiding")
public class H5 extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class H5 extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public H5 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/H6.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/H6.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/H6.java
index d86be21..d995264 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/H6.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/H6.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="h6")
-@SuppressWarnings("hiding")
public class H6 extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class H6 extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public H6 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/Head.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Head.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Head.java
index 4fbc1a6..8e21342 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Head.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Head.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="head")
-@SuppressWarnings("hiding")
public class Head extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@@ -27,12 +26,6 @@ public class Head extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@Override /* HtmlElement */
- public Head children(Object...children) {
- super.children(children);
- return this;
- }
-
- @Override /* HtmlElement */
public final Head _class(String _class) {
super._class(_class);
return this;
@@ -43,4 +36,16 @@ public class Head extends HtmlElementContainer {
super.id(id);
return this;
}
+
+ @Override /* HtmlElementContainer */
+ public final Head children(Object...children) {
+ super.children(children);
+ return this;
+ }
+
+ @Override /* HtmlElementContainer */
+ public final Head 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/Header.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Header.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Header.java
index 72c2bdd..7258cbc 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Header.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Header.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="header")
-@SuppressWarnings("hiding")
public class Header extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Header extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Header 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/Html.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Html.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Html.java
index bdcc860..56c6c23 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Html.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Html.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="html")
-@SuppressWarnings("hiding")
public class Html extends HtmlElementContainer {
/**
@@ -29,7 +28,7 @@ public class Html extends HtmlElementContainer {
* @return This object (for method chaining).
*/
public final Html manifest(String manifest) {
- attrs.put("manifest", manifest);
+ attr("manifest", manifest);
return this;
}
@@ -38,12 +37,6 @@ public class Html extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@Override /* HtmlElement */
- public Html children(Object...children) {
- super.children(children);
- return this;
- }
-
- @Override /* HtmlElement */
public final Html _class(String _class) {
super._class(_class);
return this;
@@ -54,4 +47,16 @@ public class Html extends HtmlElementContainer {
super.id(id);
return this;
}
+
+ @Override /* HtmlElementContainer */
+ public final Html children(Object...children) {
+ super.children(children);
+ return this;
+ }
+
+ @Override /* HtmlElementContainer */
+ public final Html 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/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
index c2c31f2..306f5e1 100644
--- 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
@@ -26,12 +26,12 @@ public class HtmlBuilder {
}
/**
- * 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.
+ * Creates an {@link A} element with the specified {@link A#href(Object)} attribute and {@link A#children(Object[])} nodes.
+ * @param href The {@link A#href(Object)} attribute.
* @param children The {@link A#children(Object[])} nodes.
* @return The new element.
*/
- public static final A a(String href, Object...children) {
+ public static final A a(Object href, Object...children) {
return a().href(href).children(children);
}
@@ -79,13 +79,13 @@ public class HtmlBuilder {
}
/**
- * Creates an {@link Area} element with the specified {@link Area#shape(String)}, {@link Area#coords(String)}, and {@link Area#href(String)} attributes.
+ * Creates an {@link Area} element with the specified {@link Area#shape(String)}, {@link Area#coords(String)}, and {@link Area#href(Object)} 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.
+ * @param href The {@link Area#href(Object)} attribute.
* @return The new element.
*/
- public static final Area area(String shape, String coords, String href) {
+ public static final Area area(String shape, String coords, Object href) {
return area().shape(shape).coords(coords).href(href);
}
@@ -98,6 +98,15 @@ public class HtmlBuilder {
}
/**
+ * Creates an {@link Article} element with the specified child nodes.
+ * @param children The child nodes.
+ * @return The new element.
+ */
+ public static final Article article(Object...children) {
+ return article().children(children);
+ }
+
+ /**
* Creates an empty {@link Aside} element.
* @return The new element.
*/
@@ -123,8 +132,8 @@ public class HtmlBuilder {
}
/**
- * Creates an {@link Audio} element with the specified {@link Audio#src(String)} attribute.
- * @param src The {@link Audio#src(String)} attribute.
+ * Creates an {@link Audio} element with the specified {@link Audio#src(Object)} attribute.
+ * @param src The {@link Audio#src(Object)} attribute.
* @return The new element.
*/
public static final Audio audio(String src) {
@@ -157,11 +166,11 @@ public class HtmlBuilder {
}
/**
- * Creates a {@link Base} element with the specified {@link Base#href(String)} attribute.
- * @param href The {@link Base#href(String)} attribute.
+ * Creates a {@link Base} element with the specified {@link Base#href(Object)} attribute.
+ * @param href The {@link Base#href(Object)} attribute.
* @return The new element.
*/
- public static final Base base(String href) {
+ public static final Base base(Object href) {
return base().href(href);
}
@@ -266,7 +275,7 @@ public class HtmlBuilder {
* @return The new element.
*/
public static final Button button(String type, Object...children) {
- return button().type(type).child(children);
+ return button().type(type).children(children);
}
/**
@@ -278,12 +287,12 @@ public class HtmlBuilder {
}
/**
- * 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.
+ * Creates a {@link Canvas} element with the specified {@link Canvas#width(Object)} and {@link Canvas#height(Object)} attributes.
+ * @param width The {@link Canvas#width(Object)} attribute.
+ * @param height The {@link Canvas#height(Object)} attribute.
* @return The new element.
*/
- public static final Canvas canvas(long width, long height) {
+ public static final Canvas canvas(Number width, Number height) {
return canvas().width(width).height(height);
}
@@ -347,11 +356,11 @@ public class HtmlBuilder {
}
/**
- * Creates a {@link Col} element with the specified {@link Col#span(long)} attribute.
- * @param span The {@link Col#span(long)} attribute.
+ * Creates a {@link Col} element with the specified {@link Col#span(Object)} attribute.
+ * @param span The {@link Col#span(Object)} attribute.
* @return The new element.
*/
- public static final Col col(long span) {
+ public static final Col col(Number span) {
return col().span(span);
}
@@ -364,22 +373,12 @@ public class HtmlBuilder {
}
/**
- * 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.
+ * Creates a {@link Colgroup} element with the specified child nodes.
* @param children The child nodes.
* @return The new element.
*/
- public static final Colgroup colgroup(long span, Object...children) {
- return colgroup().span(span).children(children);
+ public static final Colgroup colgroup(Object...children) {
+ return colgroup().children(children);
}
/**
@@ -391,12 +390,13 @@ public class HtmlBuilder {
}
/**
- * Creates a {@link Data} element with the specified {@link Data#value(String)} attribute.
- * @param value The {@link Data#value(String)} attribute.
+ * Creates a {@link Data} element with the specified {@link Data#value(Object)} attribute and child node.
+ * @param value The {@link Data#value(Object)} attribute.
+ * @param child The child node.
* @return The new element.
*/
- public static final Data data(String value) {
- return data().value(value);
+ public static final Data data(String value, Object child) {
+ return data().value(value).child(child);
}
/**
@@ -498,8 +498,8 @@ public class HtmlBuilder {
* @param children The child nodes.
* @return The new element.
*/
- public static final Dl dl(Dd...children) {
- return dl().children((Object[])children);
+ public static final Dl dl(Object...children) {
+ return dl().children(children);
}
/**
@@ -545,11 +545,11 @@ public class HtmlBuilder {
}
/**
- * Creates an {@link Embed} element with the specified {@link Embed#src(String)} attribute.
- * @param src The {@link Embed#src(String)} attribute.
+ * Creates an {@link Embed} element with the specified {@link Embed#src(Object)} attribute.
+ * @param src The {@link Embed#src(Object)} attribute.
* @return The new element.
*/
- public static final Embed embed(String src) {
+ public static final Embed embed(Object src) {
return embed().src(src);
}
@@ -852,11 +852,11 @@ public class HtmlBuilder {
}
/**
- * Creates an {@link Img} element with the specified {@link Img#src(String)} attribute.
- * @param src The {@link Img#src(String)} attribute.
+ * Creates an {@link Img} element with the specified {@link Img#src(Object)} attribute.
+ * @param src The {@link Img#src(Object)} attribute.
* @return The new element.
*/
- public static final Img img(String src) {
+ public static final Img img(Object src) {
return img().src(src);
}
@@ -979,11 +979,11 @@ public class HtmlBuilder {
}
/**
- * Creates a {@link Link} element with the specified {@link Link#href(String)} attribute.
- * @param href The {@link Link#href(String)} attribute.
+ * Creates a {@link Link} element with the specified {@link Link#href(Object)} attribute.
+ * @param href The {@link Link#href(Object)} attribute.
* @return The new element.
*/
- public static final Link link(String href) {
+ public static final Link link(Object href) {
return link().href(href);
}
@@ -1157,12 +1157,21 @@ public class HtmlBuilder {
}
/**
- * 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.
+ * Creates an {@link Option} element with the specified {@link Option#value(Object)} attribute.
+ * @param value The {@link Option#value(Object)} attribute.
+ * @return The new element.
+ */
+ public static final Option option(Object value) {
+ return option().value(value);
+ }
+
+ /**
+ * Creates an {@link Option} element with the specified {@link Option#value(Object)} attribute and {@link Option#text(Object)} node.
+ * @param value The {@link Option#value(Object)} attribute.
* @param text The {@link Option#text(Object)} node.
* @return The new element.
*/
- public static final Option option(String value, String text) {
+ public static final Option option(Object value, Object text) {
return option().value(value).text(text);
}
@@ -1209,12 +1218,12 @@ public class HtmlBuilder {
}
/**
- * Creates a {@link Param} element with the specified {@link Param#name(String)} and {@link Param#value(String)} attributes.
+ * Creates a {@link Param} element with the specified {@link Param#name(String)} and {@link Param#value(Object)} attributes.
* @param name The {@link Param#name(String)} attribute.
- * @param value The {@link Param#value(String)} attribute.
+ * @param value The {@link Param#value(Object)} attribute.
* @return The new element.
*/
- public static final Param param(String name, String value) {
+ public static final Param param(String name, Object value) {
return param().name(name).value(value);
}
@@ -1397,12 +1406,13 @@ public class HtmlBuilder {
}
/**
- * Creates a {@link Script} element with the specified {@link Script#children(Object[])} nodes.
- * @param children The {@link Script#children(Object[])} nodes.
+ * Creates a {@link Script} element with the specified {@link Script#type(String)} attribute and {@link Script#text(Object)} node.
+ * @param type The {@link Script#type(String)} attribute.
+ * @param text The child text node.
* @return The new element.
*/
- public static final Script script(Object...children) {
- return script().children(children);
+ public static final Script script(String type, String text) {
+ return script().type(type).text(text);
}
/**
@@ -1466,12 +1476,12 @@ public class HtmlBuilder {
}
/**
- * 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.
+ * Creates a {@link Source} element with the specified {@link Source#src(Object)} and {@link Source#type(String)} attributes.
+ * @param src The {@link Source#src(Object)} attribute.
* @param type The {@link Source#type(String)} attribute.
* @return The new element.
*/
- public static final Source source(String src, String type) {
+ public static final Source source(Object src, String type) {
return source().src(src).type(type);
}
@@ -1518,12 +1528,12 @@ public class HtmlBuilder {
}
/**
- * Creates a {@link Style} element with the specified {@link Style#children(Object[])} nodes.
- * @param children The {@link Style#children(Object[])} nodes.
+ * Creates a {@link Style} element with the specified {@link Style#text(Object)} node.
+ * @param text The {@link Style#text(Object)} node.
* @return The new element.
*/
- public static final Style style(Object...children) {
- return style().children(children);
+ public static final Style style(Object text) {
+ return style().text(text);
}
/**
@@ -1758,12 +1768,12 @@ public class HtmlBuilder {
}
/**
- * 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.
+ * Creates a {@link Track} element with the specified {@link Track#src(Object)} and {@link Track#kind(String)} attributes.
+ * @param src The {@link Track#src(Object)} attribute.
* @param kind The {@link Track#kind(String)} attribute.
* @return The new element.
*/
- public static final Track track(String src, String kind) {
+ public static final Track track(Object src, String kind) {
return track().src(src).kind(kind);
}
@@ -1827,11 +1837,11 @@ public class HtmlBuilder {
}
/**
- * Creates a {@link Video} element with the specified {@link Video#src(String)} attribute.
- * @param src The {@link Video#src(String)} attribute.
+ * Creates a {@link Video} element with the specified {@link Video#src(Object)} attribute.
+ * @param src The {@link Video#src(Object)} attribute.
* @return The new element.
*/
- public static final Video video(String src) {
+ public static final Video video(Object src) {
return video().src(src);
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/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
index 57e3e46..cdbdfed 100644
--- 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
@@ -27,7 +27,7 @@ import org.apache.juneau.xml.annotation.*;
@org.apache.juneau.html.annotation.Html(asXml=true)
public abstract class HtmlElement {
- final LinkedHashMap<String,Object> attrs = new LinkedHashMap<String,Object>();
+ private LinkedHashMap<String,Object> attrs;
/**
* The attributes of this element.
@@ -39,6 +39,16 @@ public abstract class HtmlElement {
}
/**
+ * Sets the attributes for this element.
+ * @param attrs The new attributes for this element.
+ * @return This object (for method chaining).
+ */
+ public HtmlElement setAttrs(LinkedHashMap<String,Object> attrs) {
+ this.attrs = attrs;
+ return this;
+ }
+
+ /**
* Adds an arbitrary attribute to this element.
* @param key The attribute name.
* @param val The attribute value.
@@ -46,6 +56,8 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public HtmlElement attr(String key, Object val) {
+ if (this.attrs == null)
+ this.attrs = new LinkedHashMap<String,Object>();
this.attrs.put(key, val);
return this;
}
@@ -56,7 +68,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement accesskey(String accesskey) {
- attrs.put("accesskey", accesskey);
+ attr("accesskey", accesskey);
return this;
}
@@ -66,17 +78,18 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public HtmlElement _class(String _class) {
- attrs.put("class", _class);
+ attr("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.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final HtmlElement contenteditable(String contenteditable) {
- attrs.put("contenteditable", contenteditable);
+ public final HtmlElement contenteditable(Object contenteditable) {
+ attr("contenteditable", contenteditable);
return this;
}
@@ -86,17 +99,18 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public HtmlElement dir(String dir) {
- attrs.put("dir", dir);
+ attr("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.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final HtmlElement hidden(String hidden) {
- attrs.put("hidden", hidden);
+ public final HtmlElement hidden(Object hidden) {
+ attr("hidden", hidden);
return this;
}
@@ -106,7 +120,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public HtmlElement id(String id) {
- attrs.put("id", id);
+ attr("id", id);
return this;
}
@@ -116,7 +130,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement lang(String lang) {
- attrs.put("lang", lang);
+ attr("lang", lang);
return this;
}
@@ -126,7 +140,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onabort(String onabort) {
- attrs.put("onabort", onabort);
+ attr("onabort", onabort);
return this;
}
@@ -136,7 +150,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onblur(String onblur) {
- attrs.put("onblur", onblur);
+ attr("onblur", onblur);
return this;
}
@@ -146,7 +160,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement oncancel(String oncancel) {
- attrs.put("oncancel", oncancel);
+ attr("oncancel", oncancel);
return this;
}
@@ -156,7 +170,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement oncanplay(String oncanplay) {
- attrs.put("oncanplay", oncanplay);
+ attr("oncanplay", oncanplay);
return this;
}
@@ -166,7 +180,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement oncanplaythrough(String oncanplaythrough) {
- attrs.put("oncanplaythrough", oncanplaythrough);
+ attr("oncanplaythrough", oncanplaythrough);
return this;
}
@@ -176,7 +190,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onchange(String onchange) {
- attrs.put("onchange", onchange);
+ attr("onchange", onchange);
return this;
}
@@ -186,7 +200,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onclick(String onclick) {
- attrs.put("onclick", onclick);
+ attr("onclick", onclick);
return this;
}
@@ -196,7 +210,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement oncuechange(String oncuechange) {
- attrs.put("oncuechange", oncuechange);
+ attr("oncuechange", oncuechange);
return this;
}
@@ -206,7 +220,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement ondblclick(String ondblclick) {
- attrs.put("ondblclick", ondblclick);
+ attr("ondblclick", ondblclick);
return this;
}
@@ -216,7 +230,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement ondurationchange(String ondurationchange) {
- attrs.put("ondurationchange", ondurationchange);
+ attr("ondurationchange", ondurationchange);
return this;
}
@@ -226,7 +240,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onemptied(String onemptied) {
- attrs.put("onemptied", onemptied);
+ attr("onemptied", onemptied);
return this;
}
@@ -236,7 +250,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onended(String onended) {
- attrs.put("onended", onended);
+ attr("onended", onended);
return this;
}
@@ -246,7 +260,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onerror(String onerror) {
- attrs.put("onerror", onerror);
+ attr("onerror", onerror);
return this;
}
@@ -256,7 +270,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onfocus(String onfocus) {
- attrs.put("onfocus", onfocus);
+ attr("onfocus", onfocus);
return this;
}
@@ -266,7 +280,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement oninput(String oninput) {
- attrs.put("oninput", oninput);
+ attr("oninput", oninput);
return this;
}
@@ -276,7 +290,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement oninvalid(String oninvalid) {
- attrs.put("oninvalid", oninvalid);
+ attr("oninvalid", oninvalid);
return this;
}
@@ -286,7 +300,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onkeydown(String onkeydown) {
- attrs.put("onkeydown", onkeydown);
+ attr("onkeydown", onkeydown);
return this;
}
@@ -296,7 +310,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onkeypress(String onkeypress) {
- attrs.put("onkeypress", onkeypress);
+ attr("onkeypress", onkeypress);
return this;
}
@@ -306,7 +320,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onkeyup(String onkeyup) {
- attrs.put("onkeyup", onkeyup);
+ attr("onkeyup", onkeyup);
return this;
}
@@ -316,7 +330,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onload(String onload) {
- attrs.put("onload", onload);
+ attr("onload", onload);
return this;
}
@@ -326,7 +340,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onloadeddata(String onloadeddata) {
- attrs.put("onloadeddata", onloadeddata);
+ attr("onloadeddata", onloadeddata);
return this;
}
@@ -336,7 +350,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onloadedmetadata(String onloadedmetadata) {
- attrs.put("onloadedmetadata", onloadedmetadata);
+ attr("onloadedmetadata", onloadedmetadata);
return this;
}
@@ -346,7 +360,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onloadstart(String onloadstart) {
- attrs.put("onloadstart", onloadstart);
+ attr("onloadstart", onloadstart);
return this;
}
@@ -356,7 +370,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onmousedown(String onmousedown) {
- attrs.put("onmousedown", onmousedown);
+ attr("onmousedown", onmousedown);
return this;
}
@@ -366,7 +380,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onmouseenter(String onmouseenter) {
- attrs.put("onmouseenter", onmouseenter);
+ attr("onmouseenter", onmouseenter);
return this;
}
@@ -376,7 +390,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onmouseleave(String onmouseleave) {
- attrs.put("onmouseleave", onmouseleave);
+ attr("onmouseleave", onmouseleave);
return this;
}
@@ -386,7 +400,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onmousemove(String onmousemove) {
- attrs.put("onmousemove", onmousemove);
+ attr("onmousemove", onmousemove);
return this;
}
@@ -396,7 +410,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onmouseout(String onmouseout) {
- attrs.put("onmouseout", onmouseout);
+ attr("onmouseout", onmouseout);
return this;
}
@@ -406,7 +420,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onmouseover(String onmouseover) {
- attrs.put("onmouseover", onmouseover);
+ attr("onmouseover", onmouseover);
return this;
}
@@ -416,7 +430,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onmouseup(String onmouseup) {
- attrs.put("onmouseup", onmouseup);
+ attr("onmouseup", onmouseup);
return this;
}
@@ -426,7 +440,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onmousewheel(String onmousewheel) {
- attrs.put("onmousewheel", onmousewheel);
+ attr("onmousewheel", onmousewheel);
return this;
}
@@ -436,7 +450,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onpause(String onpause) {
- attrs.put("onpause", onpause);
+ attr("onpause", onpause);
return this;
}
@@ -446,7 +460,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onplay(String onplay) {
- attrs.put("onplay", onplay);
+ attr("onplay", onplay);
return this;
}
@@ -456,7 +470,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onplaying(String onplaying) {
- attrs.put("onplaying", onplaying);
+ attr("onplaying", onplaying);
return this;
}
@@ -466,7 +480,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onprogress(String onprogress) {
- attrs.put("onprogress", onprogress);
+ attr("onprogress", onprogress);
return this;
}
@@ -476,7 +490,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onratechange(String onratechange) {
- attrs.put("onratechange", onratechange);
+ attr("onratechange", onratechange);
return this;
}
@@ -486,7 +500,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onreset(String onreset) {
- attrs.put("onreset", onreset);
+ attr("onreset", onreset);
return this;
}
@@ -496,7 +510,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onresize(String onresize) {
- attrs.put("onresize", onresize);
+ attr("onresize", onresize);
return this;
}
@@ -506,7 +520,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onscroll(String onscroll) {
- attrs.put("onscroll", onscroll);
+ attr("onscroll", onscroll);
return this;
}
@@ -516,7 +530,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onseeked(String onseeked) {
- attrs.put("onseeked", onseeked);
+ attr("onseeked", onseeked);
return this;
}
@@ -526,7 +540,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onseeking(String onseeking) {
- attrs.put("onseeking", onseeking);
+ attr("onseeking", onseeking);
return this;
}
@@ -536,7 +550,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onselect(String onselect) {
- attrs.put("onselect", onselect);
+ attr("onselect", onselect);
return this;
}
@@ -546,7 +560,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onshow(String onshow) {
- attrs.put("onshow", onshow);
+ attr("onshow", onshow);
return this;
}
@@ -556,7 +570,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onstalled(String onstalled) {
- attrs.put("onstalled", onstalled);
+ attr("onstalled", onstalled);
return this;
}
@@ -566,7 +580,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onsubmit(String onsubmit) {
- attrs.put("onsubmit", onsubmit);
+ attr("onsubmit", onsubmit);
return this;
}
@@ -576,7 +590,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onsuspend(String onsuspend) {
- attrs.put("onsuspend", onsuspend);
+ attr("onsuspend", onsuspend);
return this;
}
@@ -586,7 +600,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement ontimeupdate(String ontimeupdate) {
- attrs.put("ontimeupdate", ontimeupdate);
+ attr("ontimeupdate", ontimeupdate);
return this;
}
@@ -596,7 +610,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement ontoggle(String ontoggle) {
- attrs.put("ontoggle", ontoggle);
+ attr("ontoggle", ontoggle);
return this;
}
@@ -606,7 +620,7 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onvolumechange(String onvolumechange) {
- attrs.put("onvolumechange", onvolumechange);
+ attr("onvolumechange", onvolumechange);
return this;
}
@@ -616,17 +630,18 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public final HtmlElement onwaiting(String onwaiting) {
- attrs.put("onwaiting", onwaiting);
+ attr("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.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final HtmlElement spellcheck(String spellcheck) {
- attrs.put("spellcheck", spellcheck);
+ public final HtmlElement spellcheck(Object spellcheck) {
+ attr("spellcheck", spellcheck);
return this;
}
@@ -635,18 +650,19 @@ public abstract class HtmlElement {
* @param style - The new value for this attribute.
* @return This object (for method chaining).
*/
- public final HtmlElement style(String style) {
- attrs.put("style", style);
+ public HtmlElement style(String style) {
+ attr("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.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final HtmlElement tabindex(String tabindex) {
- attrs.put("tabindex", tabindex);
+ public final HtmlElement tabindex(Object tabindex) {
+ attr("tabindex", tabindex);
return this;
}
@@ -656,17 +672,18 @@ public abstract class HtmlElement {
* @return This object (for method chaining).
*/
public HtmlElement title(String title) {
- attrs.put("title", title);
+ attr("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.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final HtmlElement translate(String translate) {
- attrs.put("translate", translate);
+ public final HtmlElement translate(Object translate) {
+ attr("translate", translate);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/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
index 6847303..11dd1a4 100644
--- 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
@@ -24,7 +24,7 @@ import org.apache.juneau.xml.annotation.*;
*/
public class HtmlElementContainer extends HtmlElement {
- final List<Object> children = new LinkedList<Object>();
+ private LinkedList<Object> children;
/**
* The children of this element.
@@ -32,9 +32,20 @@ public class HtmlElementContainer extends HtmlElement {
*/
@Xml(format=ELEMENTS)
@BeanProperty(beanDictionary=HtmlBeanDictionary.class)
- public List<Object> getChildren() {
+ public LinkedList<Object> getChildren() {
return children;
}
+
+ /**
+ * Sets the children for this container.
+ * @param children The new children for this container.
+ * @return This object (for method chaining).
+ */
+ public HtmlElementContainer setChildren(LinkedList<Object> children) {
+ this.children = children;
+ return this;
+ }
+
/**
* Adds one or more child elements to this element.
* @param children The children to add as child elements.
@@ -42,8 +53,12 @@ public class HtmlElementContainer extends HtmlElement {
*/
@SuppressWarnings("hiding")
public HtmlElement children(Object...children) {
- for (Object c : children)
- this.children.add(c);
+ if (children.length > 0) {
+ if (this.children == null)
+ this.children = new LinkedList<Object>();
+ for (Object c : children)
+ this.children.add(c);
+ }
return this;
}
@@ -53,6 +68,8 @@ public class HtmlElementContainer extends HtmlElement {
* @return This object (for method chaining).
*/
public HtmlElement child(Object child) {
+ if (this.children == null)
+ this.children = new LinkedList<Object>();
this.children.add(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/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
index 7673385..d1b2b8f 100644
--- 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
@@ -24,7 +24,7 @@ import org.apache.juneau.xml.annotation.*;
*/
public class HtmlElementMixed extends HtmlElement {
- final List<Object> children = new LinkedList<Object>();
+ private LinkedList<Object> children;
/**
* The children of this element.
@@ -32,11 +32,22 @@ public class HtmlElementMixed extends HtmlElement {
*/
@Xml(format=MIXED)
@BeanProperty(beanDictionary=HtmlBeanDictionary.class)
- public List<Object> getChildren() {
+ public LinkedList<Object> getChildren() {
return children;
}
/**
+ * Sets the children of this element.
+ *
+ * @param children The new children of this element.
+ * @return This object (for method chaining).
+ */
+ public HtmlElement setChildren(LinkedList<Object> children) {
+ this.children = children;
+ return this;
+ }
+
+ /**
* 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.
@@ -44,8 +55,12 @@ public class HtmlElementMixed extends HtmlElement {
*/
@SuppressWarnings("hiding")
public HtmlElement children(Object...children) {
- for (Object c : children)
- this.children.add(c);
+ if (children.length != 0) {
+ if (this.children == null)
+ this.children = new LinkedList<Object>();
+ for (Object c : children)
+ this.children.add(c);
+ }
return this;
}
@@ -56,6 +71,8 @@ public class HtmlElementMixed extends HtmlElement {
* @return This object (for method chaining).
*/
public HtmlElement child(Object child) {
+ if (this.children == null)
+ this.children = new LinkedList<Object>();
this.children.add(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/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
index 7c675c1..1be7d22 100644
--- 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
@@ -27,12 +27,23 @@ public class HtmlElementText extends HtmlElement {
*
* @return The inner text of this element, or <jk>null</jk> if no text is set.
*/
- @Xml(format=XmlFormat.MIXED)
+ @Xml(format=XmlFormat.TEXT)
public Object getText() {
return text;
}
/**
+ * Sets the innter text of this element.
+ *
+ * @param text The inner text of this element, or <jk>null</jk> if no text is set.
+ * @return This object (for method chaining).
+ */
+ public HtmlElement setText(Object text) {
+ this.text = text;
+ return this;
+ }
+
+ /**
* Sets the text node on this element.
*
* @param text - The text node to add to this element.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/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
index 9641447..edeb856 100644
--- 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
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="i")
-@SuppressWarnings("hiding")
public class I extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class I extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public I child(Object child) {
- this.children.add(child);
+ super.child(child);
return this;
}
}
[2/6] incubator-juneau git commit: Continuation of HTML5 support.
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/xml/XmlParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParser.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParser.java
index 85af340..378c22b 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParser.java
@@ -23,7 +23,6 @@ import javax.xml.stream.*;
import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
-import org.apache.juneau.internal.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.transform.*;
import org.apache.juneau.xml.annotation.*;
@@ -81,11 +80,7 @@ public class XmlParser extends ReaderParser {
String wrapperAttr = (isRoot && session.isPreserveRootElement()) ? r.getName().getLocalPart() : null;
String typeAttr = r.getAttributeValue(null, session.getBeanTypePropertyName());
int jsonType = getJsonType(typeAttr);
- String b = r.getAttributeValue(session.getXsiNs(), "nil");
- if (b == null)
- b = r.getAttributeValue(null, "nil");
- boolean isNull = b != null && b.equals("true");
- String elementName = session.decodeString(r.getLocalName());
+ String elementName = session.getElementName(r);
if (jsonType == 0) {
if (elementName == null || elementName.equals(currAttr))
jsonType = UNKNOWN;
@@ -97,7 +92,7 @@ public class XmlParser extends ReaderParser {
if (breg.hasName(typeAttr)) {
sType = eType = (ClassMeta<T>)breg.getClassMeta(typeAttr);
- } else if (breg.hasName(elementName)) {
+ } else if (elementName != null && breg.hasName(elementName) && ! elementName.equals(currAttr)) {
sType = eType = (ClassMeta<T>)breg.getClassMeta(elementName);
}
@@ -107,13 +102,6 @@ public class XmlParser extends ReaderParser {
r.nextTag(); // Discard end tag
return null;
}
- if (isNull) {
- while (true) {
- int e = r.next();
- if (e == END_ELEMENT)
- return null;
- }
- }
if (sType.isObject()) {
if (jsonType == OBJECT) {
@@ -125,22 +113,22 @@ public class XmlParser extends ReaderParser {
} else if (jsonType == ARRAY)
o = parseIntoCollection(session, r, new ObjectList(session), object(), pMeta);
else if (jsonType == STRING) {
- o = session.decodeString(r);
+ o = session.getElementText(r);
if (sType.isChar())
o = o.toString().charAt(0);
}
else if (jsonType == NUMBER)
- o = parseNumber(session.decodeText(r), null);
+ o = parseNumber(session.getElementText(r), null);
else if (jsonType == BOOLEAN)
- o = Boolean.parseBoolean(session.decodeText(r));
+ o = Boolean.parseBoolean(session.getElementText(r));
else if (jsonType == UNKNOWN)
o = getUnknown(session, r);
} else if (sType.isBoolean()) {
- o = Boolean.parseBoolean(session.decodeText(r));
+ o = Boolean.parseBoolean(session.getElementText(r));
} else if (sType.isCharSequence()) {
- o = session.decodeString(r);
+ o = session.getElementText(r);
} else if (sType.isChar()) {
- String s = session.decodeString(r);
+ String s = session.getElementText(r);
o = s.length() == 0 ? 0 : s.charAt(0);
} else if (sType.isMap()) {
Map m = (sType.canCreateNewInstance(outer) ? (Map)sType.newInstance(outer) : new ObjectMap(session));
@@ -151,7 +139,7 @@ public class XmlParser extends ReaderParser {
Collection l = (sType.canCreateNewInstance(outer) ? (Collection)sType.newInstance(outer) : new ObjectList(session));
o = parseIntoCollection(session, r, l, sType.getElementType(), pMeta);
} else if (sType.isNumber()) {
- o = parseNumber(session.decodeText(r), (Class<? extends Number>)sType.getInnerClass());
+ o = parseNumber(session.getElementText(r), (Class<? extends Number>)sType.getInnerClass());
} else if (sType.canCreateNewInstanceFromObjectMap(outer)) {
ObjectMap m = new ObjectMap(session);
parseIntoMap(session, r, m, string(), object(), pMeta);
@@ -174,9 +162,9 @@ public class XmlParser extends ReaderParser {
ArrayList l = (ArrayList)parseIntoCollection(session, r, new ArrayList(), sType.getElementType(), pMeta);
o = session.toArray(sType, l);
} else if (sType.canCreateNewInstanceFromString(outer)) {
- o = sType.newInstanceFromString(outer, session.decodeString(r));
+ o = sType.newInstanceFromString(outer, session.getElementText(r));
} else if (sType.canCreateNewInstanceFromNumber(outer)) {
- o = sType.newInstanceFromNumber(session, outer, parseNumber(session.decodeText(r), sType.getNewInstanceFromNumberClass()));
+ o = sType.newInstanceFromNumber(session, outer, parseNumber(session.getElementText(r), sType.getNewInstanceFromNumberClass()));
} else {
throw new ParseException(session, "Class ''{0}'' could not be instantiated. Reason: ''{1}'', property: ''{2}''", sType.getInnerClass().getName(), sType.getNotABeanReason(), pMeta == null ? null : pMeta.getName());
}
@@ -207,7 +195,7 @@ public class XmlParser extends ReaderParser {
String currAttr;
if (event == START_ELEMENT) {
depth++;
- currAttr = session.decodeString(r.getLocalName());
+ currAttr = session.getElementName(r);
K key = convertAttrToType(session, m, currAttr, keyType);
V value = parseAnything(session, valueType, currAttr, r, m, false, pMeta);
setName(valueType, value, currAttr);
@@ -288,7 +276,7 @@ public class XmlParser extends ReaderParser {
XmlBeanMeta xmlMeta = bMeta.getExtendedMeta(XmlBeanMeta.class);
for (int i = 0; i < r.getAttributeCount(); i++) {
- String key = session.decodeString(r.getAttributeLocalName(i));
+ String key = session.getAttributeName(r, i);
String val = r.getAttributeValue(i);
BeanPropertyMeta bpm = xmlMeta.getPropertyMeta(key);
if (bpm == null) {
@@ -307,8 +295,11 @@ public class XmlParser extends ReaderParser {
BeanPropertyMeta cp = xmlMeta.getContentProperty();
XmlFormat cpf = xmlMeta.getContentFormat();
+ boolean trim = cp == null || ! cpf.isOneOf(MIXED_PWS, TEXT_PWS);
ClassMeta<?> cpcm = (cp == null ? session.object() : cp.getClassMeta());
- StringBuilder sb = (cpf != null && cpf.isOneOf(TEXT,XMLTEXT) ? session.getStringBuilder() : null);
+ StringBuilder sb = null;
+ BeanRegistry breg = cp == null ? null : cp.getBeanRegistry();
+ LinkedList<Object> l = null;
int depth = 0;
do {
@@ -317,41 +308,68 @@ public class XmlParser extends ReaderParser {
// We only care about text in MIXED mode.
// Ignore if in ELEMENTS mode.
if (event == CHARACTERS) {
- if (cpf == MIXED && cp != null) {
- if (cpcm.isCollectionOrArray())
- cp.add(m, session.decodeString(r.getText()));
- else
- cp.set(m, session.decodeString(r.getText()));
- } else if (sb != null) {
- String s = r.getText();
- if (! StringUtils.isEmpty(s))
+ if (cp != null && cpf.isOneOf(MIXED, MIXED_PWS)) {
+ if (cpcm.isCollectionOrArray()) {
+ if (l == null)
+ l = new LinkedList<Object>();
+ l.add(session.getText(r, false));
+ } else {
+ cp.set(m, session.getText(r, trim));
+ }
+ } else if (cpf != ELEMENTS) {
+ String s = session.getText(r, trim);
+ if (s != null) {
+ if (sb == null)
+ sb = session.getStringBuilder();
sb.append(s);
+ }
} else {
// Do nothing...we're in ELEMENTS mode.
}
} else if (event == START_ELEMENT) {
- if (cpf == TEXT) {
- throw new ParseException("Element found where simple text was expected. {0}", XmlUtils.toReadableEvent(r));
- } else if (cpf == XMLTEXT && sb != null) {
- sb.append(session.elementAsString(r));
+ if (cp != null && cpf.isOneOf(TEXT, TEXT_PWS)) {
+ String s = session.parseText(r);
+ if (s != null) {
+ if (sb == null)
+ sb = session.getStringBuilder();
+ sb.append(s);
+ }
+ depth--;
+ } else if (cpf == XMLTEXT) {
+ if (sb == null)
+ sb = session.getStringBuilder();
+ sb.append(session.getElementAsString(r));
depth++;
- } else if (cpf == MIXED && cp != null) {
- if (cpcm.isCollectionOrArray())
- cp.add(m, parseAnything(session, cpcm.getElementType(), cp.getName(), r, m.getBean(false), false, cp));
- else
- cp.set(m, parseAnything(session, cpcm, cp.getName(), r, m.getBean(false), false, cp));
- } else if (cpf == ELEMENTS && cp != null) {
+ } else if (cp != null && cpf.isOneOf(MIXED, MIXED_PWS)) {
+ if (session.isWhitespaceElement(r) && (breg == null || ! breg.hasName(r.getLocalName()))) {
+ if (cpcm.isCollectionOrArray()) {
+ if (l == null)
+ l = new LinkedList<Object>();
+ l.add(session.parseWhitespaceElement(r));
+ } else {
+ cp.set(m, session.parseWhitespaceElement(r));
+ }
+ } else {
+ if (cpcm.isCollectionOrArray()) {
+ if (l == null)
+ l = new LinkedList<Object>();
+ l.add(parseAnything(session, cpcm.getElementType(), cp.getName(), r, m.getBean(false), false, cp));
+ } else {
+ cp.set(m, parseAnything(session, cpcm, cp.getName(), r, m.getBean(false), false, cp));
+ }
+ }
+ } else if (cp != null && cpf == ELEMENTS) {
cp.add(m, parseAnything(session, cpcm.getElementType(), cp.getName(), r, m.getBean(false), false, cp));
} else {
- currAttr = session.decodeString(r.getLocalName());
+ currAttr = session.getElementName(r);
BeanPropertyMeta pMeta = xmlMeta.getPropertyMeta(currAttr);
if (pMeta == null) {
if (m.getMeta().isSubTyped()) {
Object value = parseAnything(session, string(), currAttr, r, m.getBean(false), false, null);
m.put(currAttr, value);
} else {
- Location l = r.getLocation();
- onUnknownProperty(session, currAttr, m, l.getLineNumber(), l.getColumnNumber());
+ Location loc = r.getLocation();
+ onUnknownProperty(session, currAttr, m, loc.getLineNumber(), loc.getColumnNumber());
skipCurrentTag(r);
}
} else {
@@ -363,7 +381,7 @@ public class XmlParser extends ReaderParser {
setName(et, value, currAttr);
pMeta.add(m, value);
} else if (xf == ATTR) {
- pMeta.set(m, session.decodeString(r.getAttributeValue(0)));
+ pMeta.set(m, session.getAttributeValue(r, 0));
r.nextTag();
} else {
ClassMeta<?> cm = pMeta.getClassMeta();
@@ -376,18 +394,25 @@ public class XmlParser extends ReaderParser {
}
} else if (event == END_ELEMENT) {
if (depth > 0) {
- if (cpf == XMLTEXT && sb != null)
- sb.append(session.elementAsString(r));
+ if (cpf == XMLTEXT) {
+ if (sb == null)
+ sb = session.getStringBuilder();
+ sb.append(session.getElementAsString(r));
+ }
else
throw new ParseException("End element found where one was not expected. {0}", XmlUtils.toReadableEvent(r));
}
depth--;
} else {
- throw new ParseException("Unexpected event type: {0}", event);
+ throw new ParseException("Unexpected event type: {0}", XmlUtils.toReadableEvent(r));
}
} while (depth >= 0);
+
if (sb != null && cp != null)
- cp.set(m, session.decodeString(sb.toString()));
+ cp.set(m, sb.toString());
+ else if (l != null && cp != null)
+ cp.set(m, XmlUtils.collapseTextNodes(l));
+
session.returnStringBuilder(sb);
return m;
}
@@ -413,7 +438,7 @@ public class XmlParser extends ReaderParser {
if (r.getAttributeCount() > 0) {
m = new ObjectMap(session);
for (int i = 0; i < r.getAttributeCount(); i++) {
- String key = session.decodeString(r.getAttributeLocalName(i));
+ String key = session.getAttributeName(r, i);
String val = r.getAttributeValue(i);
if (! key.equals(session.getBeanTypePropertyName()))
m.put(key, val);
@@ -439,7 +464,7 @@ public class XmlParser extends ReaderParser {
String currAttr;
if (event == START_ELEMENT) {
depth++;
- currAttr = session.decodeString(r.getLocalName());
+ currAttr = session.getElementName(r);
String key = convertAttrToType(session, null, currAttr, string());
Object value = parseAnything(session, object(), currAttr, r, null, false, null);
if (m.containsKey(key)) {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserContext.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserContext.java
index 7b4ae26..3e67c33 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserContext.java
@@ -48,13 +48,6 @@ import org.apache.juneau.parser.*;
* <td><jk>true</jk></td>
* </tr>
* <tr>
- * <td>{@link #XML_trimWhitespace}</td>
- * <td>Trim whitespace from text elements.</td>
- * <td><code>Boolean<code></td>
- * <td><jk>true</jk></td>
- * <td><jk>true</jk></td>
- * </tr>
- * <tr>
* <td>{@link #XML_validating}</td>
* <td>Enable validation.</td>
* <td><code>Boolean<code></td>
@@ -116,20 +109,6 @@ public class XmlParserContext extends ParserContext {
public static final String XML_xsiNs = "XmlParser.xsiNs";
/**
- * <b>Configuration property:</b> Trim whitespace from text elements.
- * <p>
- * <ul>
- * <li><b>Name:</b> <js>"XmlParser.trimWhitespace"</js>
- * <li><b>Data type:</b> <code>Boolean</code>
- * <li><b>Default:</b> <jk>true</jk>
- * <li><b>Session-overridable:</b> <jk>true</jk>
- * </ul>
- * <p>
- * If <jk>true</jk>, whitespace in text elements will be automatically trimmed.
- */
- public static final String XML_trimWhitespace = "XmlParser.trimWhitespace";
-
- /**
* <b>Configuration property:</b> Enable validation.
* <p>
* <ul>
@@ -219,7 +198,6 @@ public class XmlParserContext extends ParserContext {
final String xsiNs;
final boolean
- trimWhitespace,
validating,
preserveRootElement;
final XMLReporter reporter;
@@ -236,7 +214,6 @@ public class XmlParserContext extends ParserContext {
public XmlParserContext(ContextFactory cf) {
super(cf);
xsiNs = cf.getProperty(XML_xsiNs, String.class, "http://www.w3.org/2001/XMLSchema-instance");
- trimWhitespace = cf.getProperty(XML_trimWhitespace, boolean.class, true);
validating = cf.getProperty(XML_validating, boolean.class, false);
preserveRootElement = cf.getProperty(XML_preserveRootElement, boolean.class, false);
reporter = cf.getProperty(XML_reporter, XMLReporter.class, null);
@@ -249,7 +226,6 @@ public class XmlParserContext extends ParserContext {
return super.asMap()
.append("XmlParserContext", new ObjectMap()
.append("xsiNs", xsiNs)
- .append("trimWhitespace", trimWhitespace)
.append("validating", validating)
.append("preserveRootElement", preserveRootElement)
.append("reporter", reporter)
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserSession.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserSession.java
index 5aeb93d..fce4243 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserSession.java
@@ -13,6 +13,7 @@
package org.apache.juneau.xml;
import static org.apache.juneau.xml.XmlParserContext.*;
+import static javax.xml.stream.XMLStreamConstants.*;
import java.io.*;
import java.lang.reflect.*;
@@ -35,7 +36,6 @@ public class XmlParserSession extends ParserSession {
private final String xsiNs;
private final boolean
- trimWhitespace,
validating,
preserveRootElement;
private final XMLReporter reporter;
@@ -70,7 +70,6 @@ public class XmlParserSession extends ParserSession {
super(ctx, op, input, javaMethod, outer, locale, timeZone);
if (op == null || op.isEmpty()) {
xsiNs = ctx.xsiNs;
- trimWhitespace = ctx.trimWhitespace;
validating = ctx.validating;
reporter = ctx.reporter;
resolver = ctx.resolver;
@@ -78,7 +77,6 @@ public class XmlParserSession extends ParserSession {
preserveRootElement = ctx.preserveRootElement;
} else {
xsiNs = op.getString(XML_xsiNs, ctx.xsiNs);
- trimWhitespace = op.getBoolean(XML_trimWhitespace, ctx.trimWhitespace);
validating = op.getBoolean(XML_validating, ctx.validating);
reporter = (XMLReporter)op.get(XML_reporter, ctx.reporter);
resolver = (XMLResolver)op.get(XML_resolver, ctx.resolver);
@@ -117,7 +115,7 @@ public class XmlParserSession extends ParserSession {
XMLInputFactory factory = XMLInputFactory.newInstance();
factory.setProperty(XMLInputFactory.IS_VALIDATING, validating);
factory.setProperty(XMLInputFactory.IS_COALESCING, true);
- factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, true);
+ factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, true); // This usually has no effect anyway.
if (factory.isPropertySupported(XMLInputFactory.REPORTER) && reporter != null)
factory.setProperty(XMLInputFactory.REPORTER, reporter);
if (factory.isPropertySupported(XMLInputFactory.RESOLVER) && resolver != null)
@@ -139,15 +137,15 @@ public class XmlParserSession extends ParserSession {
/**
* Decodes and trims the specified string.
+ * <p>
+ * Any <js>'_x####_'</js> sequences in the string will be decoded.
*
* @param s The string to be decoded.
* @return The decoded string.
*/
public final String decodeString(String s) {
- if (s == null || s.isEmpty())
- return s;
- if (trimWhitespace)
- s = s.trim();
+ if (s == null)
+ return null;
sb.setLength(0);
s = XmlUtils.decode(s, sb);
if (isTrimStrings())
@@ -156,43 +154,93 @@ public class XmlParserSession extends ParserSession {
}
/**
- * Shortcut for calling <code>decodeString(r.getElementText());</code>.
+ * Returns the name of the current XML element.
+ * <p>
+ * Any <js>'_x####_'</js> sequences in the string will be decoded.
+ *
+ * @param r The reader to read from.
+ * @return The decoded element name.
+ * @throws XMLStreamException
+ */
+ public final String getElementName(XMLStreamReader r) throws XMLStreamException {
+ return decodeString(r.getLocalName());
+ }
+
+ /**
+ * Returns the name of the specified attribute on the current XML element.
+ * <p>
+ * Any <js>'_x####_'</js> sequences in the string will be decoded.
+ *
+ * @param r The reader to read from.
+ * @param i The attribute index.
+ * @return The decoded attribute name.
+ * @throws XMLStreamException
+ */
+ public final String getAttributeName(XMLStreamReader r, int i) throws XMLStreamException {
+ return decodeString(r.getAttributeLocalName(i));
+ }
+
+ /**
+ * Returns the value of the specified attribute on the current XML element.
+ * <p>
+ * Any <js>'_x####_'</js> sequences in the string will be decoded.
+ *
+ * @param r The reader to read from.
+ * @param i The attribute index.
+ * @return The decoded attribute value.
+ * @throws XMLStreamException
+ */
+ public final String getAttributeValue(XMLStreamReader r, int i) throws XMLStreamException {
+ return decodeString(r.getAttributeValue(i));
+ }
+
+ /**
+ * Returns the text content of the current XML element.
+ * <p>
+ * Any <js>'_x####_'</js> sequences in the string will be decoded.
+ * <p>
+ * Leading and trailing whitespace (unencoded) will be trimmed from the result.
*
* @param r The reader to read the element text from.
- * @return The decoded text.
+ * @return The decoded text. <jk>null</jk> if the text consists of the sequence <js>'_x0000_'</js>.
* @throws XMLStreamException
*/
- public final String decodeString(XMLStreamReader r) throws XMLStreamException {
- return decodeString(r.getElementText());
+ public String getElementText(XMLStreamReader r) throws XMLStreamException {
+ String s = r.getElementText().trim();
+ return decodeString(s);
}
/**
- * Decodes the specified literal (e.g. <js>"true"</js>, <js>"123"</js>).
+ * Returns the content of the current CHARACTERS node.
+ * <p>
+ * Any <js>'_x####_'</js> sequences in the string will be decoded.
* <p>
- * Unlike <code>decodeString(String)</code>, the input string is ALWAYS trimmed before decoding, and
- * NEVER trimmed after decoding.
+ * Leading and trailing whitespace (unencoded) will be trimmed from the result.
*
- * @param s The string to trim.
- * @return The trimmed string, or <jk>null</jk> if the string was <jk>null</jk>.
+ * @param r The reader to read the element text from.
+ * @param trim If <jk>true</jk>, trim the contents of the text node BEFORE decoding escape sequences.
+ * Typically <jk>true</jk> for {@link XmlFormat#MIXED_PWS} and {@link XmlFormat#TEXT_PWS}.
+ * @return The decoded text. <jk>null</jk> if the text consists of the sequence <js>'_x0000_'</js>.
+ * @throws XMLStreamException
*/
- public final String decodeLiteral(String s) {
- if (s == null || s.isEmpty())
- return s;
- s = s.trim();
- sb.setLength(0);
- s = XmlUtils.decode(s, sb);
- return s;
+ public String getText(XMLStreamReader r, boolean trim) throws XMLStreamException {
+ String s = r.getText();
+ if (trim)
+ s = s.trim();
+ if (s.isEmpty())
+ return null;
+ return decodeString(s);
}
/**
- * Shortcut for calling <code>decodeLiteral(r.getElementText());</code>.
+ * Shortcut for calling <code>getText(r, <jk>true</jk>);</code>.
*
* @param r The reader to read the element text from.
- * @return The decoded text.
+ * @return The decoded text. <jk>null</jk> if the text consists of the sequence <js>'_x0000_'</js>.
* @throws XMLStreamException
*/
- public final String decodeText(XMLStreamReader r) throws XMLStreamException {
- return decodeLiteral(r.getElementText());
+ public String getText(XMLStreamReader r) throws XMLStreamException {
+ return getText(r, true);
}
/**
@@ -204,7 +252,7 @@ public class XmlParserSession extends ParserSession {
* @return The event as XML.
* @throws RuntimeException if the event is not a start or end tag.
*/
- public final String elementAsString(XMLStreamReader r) {
+ public final String getElementAsString(XMLStreamReader r) {
int t = r.getEventType();
if (t > 2)
throw new RuntimeException("Invalid event type on stream reader for elementToString() method: " + XmlUtils.toReadableEvent(r));
@@ -218,6 +266,66 @@ public class XmlParserSession extends ParserSession {
}
/**
+ * Parses the current element as text.
+ * Note that this is different than {@link #getText(XMLStreamReader)} since it
+ * assumes that we're pointing to a whitespace element.
+ *
+ * @param r
+ * @return The parsed text.
+ * @throws XMLStreamException
+ */
+ public String parseText(XMLStreamReader r) throws XMLStreamException {
+ StringBuilder sb2 = getStringBuilder();
+
+ int depth = 0;
+ while (true) {
+ int et = r.getEventType();
+ if (et == START_ELEMENT) {
+ sb2.append(getElementAsString(r));
+ depth++;
+ } else if (et == CHARACTERS) {
+ sb2.append(getText(r));
+ } else if (et == END_ELEMENT) {
+ sb2.append(getElementAsString(r));
+ depth--;
+ if (depth <= 0)
+ break;
+ }
+ et = r.next();
+ }
+ String s = sb2.toString();
+ returnStringBuilder(sb2);
+ return s;
+ }
+
+ /**
+ * Returns <jk>true</jk> if the current element is a whitespace element.
+ * <p>
+ * For the XML parser, this always returns <jk>false</jk>.
+ * However, the HTML parser defines various whitespace elements such as <js>"br"</js> and <js>"sp"</js>.
+ *
+ * @param r The XML stream reader to read the current event from.
+ * @return <jk>true</jk> if the current element is a whitespace element.
+ */
+ public boolean isWhitespaceElement(XMLStreamReader r) {
+ return false;
+ }
+
+ /**
+ * Parses the current whitespace element.
+ * <p>
+ * For the XML parser, this always returns <jk>null</jk> since there is no concept of a whitespace element.
+ * However, the HTML parser defines various whitespace elements such as <js>"br"</js> and <js>"sp"</js>.
+ *
+ * @param r The XML stream reader to read the current event from.
+ * @return The whitespace character or characters.
+ * @throws XMLStreamException
+ */
+ public String parseWhitespaceElement(XMLStreamReader r) throws XMLStreamException {
+ return null;
+ }
+
+ /**
* Silently closes the XML stream.
*/
@Override /* ParserContext */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializer.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializer.java
index 2e107a5..4a0938e 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializer.java
@@ -336,7 +336,7 @@ public class XmlSchemaSerializer extends XmlSerializer {
// This element can have mixed content if:
// 1) It's a generic Object (so it can theoretically be anything)
// 2) The bean has a property defined with @XmlFormat.CONTENT.
- if ((xbm != null && (xbm.getContentFormat() != null && xbm.getContentFormat().isOneOf(TEXT,MIXED,XMLTEXT))) || ! cm.isMapOrBean())
+ if ((xbm != null && (xbm.getContentFormat() != null && xbm.getContentFormat().isOneOf(TEXT,TEXT_PWS,MIXED,MIXED_PWS,XMLTEXT))) || ! cm.isMapOrBean())
w.attr("mixed", "true");
w.cTag().nl();
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java
index cf5f007..0d07a99 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java
@@ -279,6 +279,7 @@ public class XmlSerializer extends WriterSerializer {
* @param addNamespaceUris Flag indicating that namespace URIs need to be added.
* @param format The format to serialize the output to.
* @param isMixed We're serializing mixed content, so don't use whitespace.
+ * @param preserveWhitespace <jk>true</jk> if we're serializing {@link XmlFormat#MIXED_PWS} or {@link XmlFormat#TEXT_PWS}.
* @param pMeta The bean property metadata if this is a bean property being serialized.
* @return The same writer passed in so that calls to the writer can be chained.
* @throws Exception If a problem occurred trying to convert the output.
@@ -293,6 +294,7 @@ public class XmlSerializer extends WriterSerializer {
boolean addNamespaceUris,
XmlFormat format,
boolean isMixed,
+ boolean preserveWhitespace,
BeanPropertyMeta pMeta) throws Exception {
JsonType type = null; // The type string (e.g. <type> or <x x='type'>
@@ -376,7 +378,7 @@ public class XmlSerializer extends WriterSerializer {
type = STRING;
}
- if (format.isOneOf(MIXED,TEXT,XMLTEXT) && type.isOneOf(NULL,STRING,NUMBER,BOOLEAN))
+ if (format.isOneOf(MIXED,MIXED_PWS,TEXT,TEXT_PWS,XMLTEXT) && type.isOneOf(NULL,STRING,NUMBER,BOOLEAN))
isCollapsed = true;
// Is there a name associated with this bean?
@@ -453,7 +455,7 @@ public class XmlSerializer extends WriterSerializer {
if (format == XMLTEXT)
out.append(o);
else
- out.encodeText(session.trim(o));
+ out.text(o, preserveWhitespace);
} else if (sType.isNumber() || sType.isBoolean()) {
out.append(o);
} else if (sType.isMap() || (wType != null && wType.isMap())) {
@@ -483,7 +485,7 @@ public class XmlSerializer extends WriterSerializer {
if (format == XMLTEXT)
out.append(session.toString(o));
else
- out.encodeText(session.toString(o));
+ out.text(session.toString(o));
}
}
@@ -528,7 +530,7 @@ public class XmlSerializer extends WriterSerializer {
hasChildren = true;
out.append('>').nlIf(! isMixed);
}
- serializeAnything(session, out, value, valueType, session.toString(k), null, false, XmlFormat.DEFAULT, isMixed, null);
+ serializeAnything(session, out, value, valueType, session.toString(k), null, false, XmlFormat.DEFAULT, isMixed, false, null);
}
return hasChildren ? CR_ELEMENTS : CR_EMPTY;
}
@@ -595,7 +597,7 @@ public class XmlSerializer extends WriterSerializer {
}
}
- boolean hasContent = false;
+ boolean hasContent = false, preserveWhitespace = false;
for (BeanPropertyValue p : lp) {
BeanPropertyMeta pMeta = p.getMeta();
@@ -607,8 +609,14 @@ public class XmlSerializer extends WriterSerializer {
contentType = p.getClassMeta();
hasContent = true;
cf = xbm.getContentFormat();
- if (cf.isOneOf(MIXED,TEXT,XMLTEXT))
+ if (cf.isOneOf(MIXED,MIXED_PWS,TEXT,TEXT_PWS,XMLTEXT))
isMixed = true;
+ if (cf.isOneOf(MIXED_PWS, TEXT_PWS))
+ preserveWhitespace = true;
+ if (contentType.isCollection() && ((Collection)content).isEmpty())
+ hasContent = false;
+ else if (contentType.isArray() && Array.getLength(content) == 0)
+ hasContent = false;
} else if (elements.contains(n) || collapsedElements.contains(n)) {
String key = p.getName();
Object value = p.getValue();
@@ -625,10 +633,10 @@ public class XmlSerializer extends WriterSerializer {
}
XmlBeanPropertyMeta xbpm = pMeta.getExtendedMeta(XmlBeanPropertyMeta.class);
- serializeAnything(session, out, value, cMeta, key, xbpm.getNamespace(), false, xbpm.getXmlFormat(), isMixed, pMeta);
+ serializeAnything(session, out, value, cMeta, key, xbpm.getNamespace(), false, xbpm.getXmlFormat(), isMixed, false, pMeta);
}
}
- if ((! hasContent) || session.canIgnoreValue(string(), null, content))
+ if (! hasContent)
return (hasChildren ? CR_ELEMENTS : CR_EMPTY);
out.append('>').nlIf(! isMixed);
@@ -639,22 +647,22 @@ public class XmlSerializer extends WriterSerializer {
Collection c = (Collection)content;
for (Iterator i = c.iterator(); i.hasNext();) {
Object value = i.next();
- serializeAnything(session, out, value, contentType.getElementType(), null, null, false, cf, isMixed, null);
+ serializeAnything(session, out, value, contentType.getElementType(), null, null, false, cf, isMixed, preserveWhitespace, null);
}
} else if (contentType.isArray()) {
Collection c = toList(Object[].class, content);
for (Iterator i = c.iterator(); i.hasNext();) {
Object value = i.next();
- serializeAnything(session, out, value, contentType.getElementType(), null, null, false, cf, isMixed, null);
+ serializeAnything(session, out, value, contentType.getElementType(), null, null, false, cf, isMixed, preserveWhitespace, null);
}
} else {
- serializeAnything(session, out, content, contentType, null, null, false, cf, isMixed, null);
+ serializeAnything(session, out, content, contentType, null, null, false, cf, isMixed, preserveWhitespace, null);
}
} else {
if (! session.isTrimNulls()) {
if (! isMixed)
out.i(session.indent);
- out.encodeText(content);
+ out.text(content);
if (! isMixed)
out.nl();
}
@@ -688,7 +696,7 @@ public class XmlSerializer extends WriterSerializer {
for (Iterator i = c.iterator(); i.hasNext();) {
Object value = i.next();
- serializeAnything(session, out, value, eeType, eName, eNs, false, XmlFormat.DEFAULT, isMixed, null);
+ serializeAnything(session, out, value, eeType, eName, eNs, false, XmlFormat.DEFAULT, isMixed, false, null);
}
return out;
}
@@ -742,7 +750,7 @@ public class XmlSerializer extends WriterSerializer {
XmlSerializerSession s = (XmlSerializerSession)session;
if (s.isEnableNamespaces() && s.isAutoDetectNamespaces())
findNsfMappings(s, o);
- serializeAnything(s, s.getWriter(), o, null, null, null, s.isEnableNamespaces() && s.isAddNamespaceUrlsToRoot(), XmlFormat.DEFAULT, false, null);
+ serializeAnything(s, s.getWriter(), o, null, null, null, s.isEnableNamespaces() && s.isAddNamespaceUrlsToRoot(), XmlFormat.DEFAULT, false, false, null);
}
@Override /* Serializer */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/xml/XmlUtils.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlUtils.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlUtils.java
index 4ca4b20..8220ef3 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlUtils.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlUtils.java
@@ -12,12 +12,9 @@
// ***************************************************************************************************************************
package org.apache.juneau.xml;
-import static javax.xml.stream.XMLStreamConstants.*;
-
import java.io.*;
import java.util.*;
-import javax.xml.namespace.*;
import javax.xml.stream.*;
import org.apache.juneau.*;
@@ -34,15 +31,12 @@ public final class XmlUtils {
//--------------------------------------------------------------------------------
/**
- * Encodes invalid XML text characters.
- * <p>
- * Encodes <js>'&'</js>, <js>'<'</js>, and <js>'>'</js> as XML entities.<br>
- * Encodes any other invalid XML text characters to <code>_x####_</code> sequences.
+ * Encodes invalid XML text characters to <code>_x####_</code> sequences.
*
* @param o The object being encoded.
* @return The encoded string.
*/
- public static final String encodeText(Object o) {
+ public static final String encodeInvalidCharsForText(Object o) {
if (o == null)
return "_x0000_";
@@ -50,166 +44,81 @@ public final class XmlUtils {
String s = o.toString();
try {
- if (needsTextEncoding(s))
- return encodeTextInner(new StringBuilderWriter(s.length()*2), s).toString();
- } catch (IOException e) {
- throw new RuntimeException(e); // Never happens
- }
-
- return s;
- }
-
- /**
- * Same as {@link #encodeText(Object)}, but does not convert <js>'&'</js>, <js>'<'</js>, and <js>'>'</js>
- * to entities.
- *
- * @param o The object being encoded.
- * @return The encoded string.
- */
- public static final String encodeTextInvalidChars(Object o) {
-
- if (o == null)
- return "_x0000_";
-
- String s = o.toString();
-
- try {
- if (needsTextEncoding(s))
- return encodeTextInvalidCharsInner(new StringBuilderWriter(s.length()*2), s).toString();
+ if (! needsTextEncoding(s))
+ return s;
+ final int len = s.length();
+ StringWriter sw = new StringWriter(s.length()*2);
+ for (int i = 0; i < len; i++) {
+ char c = s.charAt(i);
+ if ((i == 0 || i == len-1) && Character.isWhitespace(c))
+ appendPaddedHexChar(sw, c);
+ else if (c == '_' && isEscapeSequence(s,i))
+ appendPaddedHexChar(sw, c);
+ else if (isValidXmlCharacter(c))
+ sw.append(c);
+ else
+ appendPaddedHexChar(sw, c);
+ }
+ return sw.toString();
} catch (IOException e) {
throw new RuntimeException(e); // Never happens
}
-
- return s;
}
/**
* Encodes any invalid XML text characters to <code>_x####_</code> sequences and sends the response
* to the specified writer.
+ * Encodes <js>'&'</js>, <js>'<'</js>, and <js>'>'</js> as XML entities.<br>
+ * Encodes invalid XML text characters to <code>_x####_</code> sequences.
*
* @param w The writer to send the output to.
* @param o The object being encoded.
+ * @param trim Trim the text before serializing it.
+ * @param preserveWhitespace Specifies whether we're in preserve-whitespace mode.
+ * (e.g. {@link XmlFormat#MIXED_PWS} or {@link XmlFormat#TEXT_PWS}.
+ * If <jk>true</jk>, leading and trailing whitespace characters will be encoded.
* @return The same writer passed in.
* @throws IOException Thrown from the writer.
*/
- public static final Writer encodeText(Writer w, Object o) throws IOException {
+ public static final Writer encodeText(Writer w, Object o, boolean trim, boolean preserveWhitespace) throws IOException {
if (o == null)
return w.append("_x0000_");
String s = o.toString();
-
- if (needsTextEncoding(s))
- return encodeTextInner(w, s);
-
- w.append(s);
-
- return w;
- }
-
- /**
- * Same as {@link #encodeText(Object)}, but does not convert <js>'&'</js>, <js>'<'</js>, and <js>'>'</js>
- * to entities.
- *
- * @param w The writer to write to.
- * @param o The object being encoded.
- * @return The encoded string.
- * @throws IOException
- */
- public static final Writer encodeTextInvalidChars(Writer w, Object o) throws IOException {
-
- if (o == null)
- return w.append("_x0000_");
-
- String s = o.toString();
-
- if (needsTextEncoding(s))
- return encodeTextInvalidCharsInner(w, s);
-
- w.append(s);
-
- return w;
- }
-
- /**
- * Same as {@link #encodeText(Object)}, but only converts <js>'&'</js>, <js>'<'</js>, and <js>'>'</js>
- * to entities.
- *
- * @param w The writer to write to.
- * @param o The object being encoded.
- * @return The encoded string.
- * @throws IOException
- */
- public static final Writer encodeTextXmlChars(Writer w, Object o) throws IOException {
- if (o == null)
- return w;
-
- String s = o.toString();
-
- if (needsTextEncoding(s))
- return encodeTextXmlCharsInner(w, s);
-
- w.append(s);
-
- return w;
-
- }
-
- private static final Writer encodeTextInner(Writer w, String s) throws IOException {
- final int len = s.length();
- for (int i = 0; i < len; i++) {
- char c = s.charAt(i);
- if (c == '&')
- w.append("&");
- else if (c == '<')
- w.append("<");
- else if (c == '>')
- w.append(">");
- else if (c == '_' && isEscapeSequence(s,i))
- appendPaddedHexChar(w, c);
- else if ((i == 0 || i == len-1) && Character.isWhitespace(c))
- appendPaddedHexChar(w, c);
- else if (isValidXmlCharacter(c))
- w.append(c);
- else if (c == 0x09 || c == 0x0A || c == 0x0D)
- w.append("�").append(Integer.toHexString(c)).append(";");
- else
- appendPaddedHexChar(w, c);
+ if (s.isEmpty())
+ return w.append("_xE000_");
+ if (trim)
+ s = s.trim();
+
+ if (needsTextEncoding(s)) {
+ final int len = s.length();
+ for (int i = 0; i < len; i++) {
+ char c = s.charAt(i);
+ if ((i == 0 || i == len-1) && Character.isWhitespace(c) && ! preserveWhitespace)
+ appendPaddedHexChar(w, c);
+ else if (c == '&')
+ w.append("&");
+ else if (c == '<')
+ w.append("<");
+ else if (c == '>')
+ w.append(">");
+ else if (c == '_' && isEscapeSequence(s,i))
+ appendPaddedHexChar(w, c);
+ else if (isValidXmlCharacter(c))
+ w.append(c);
+ else if (c == 0x09 || c == 0x0A || c == 0x0D)
+ w.append("�").append(Integer.toHexString(c)).append(";");
+ else
+ appendPaddedHexChar(w, c);
+ }
+ } else {
+ w.append(s);
}
- return w;
- }
- private static final Writer encodeTextInvalidCharsInner(Writer w, String s) throws IOException {
- final int len = s.length();
- for (int i = 0; i < len; i++) {
- char c = s.charAt(i);
- if ((i == 0 || i == len-1) && Character.isWhitespace(c))
- appendPaddedHexChar(w, c);
- else if (c == '_' && isEscapeSequence(s,i))
- appendPaddedHexChar(w, c);
- else if (isValidXmlCharacter(c))
- w.append(c);
- else
- appendPaddedHexChar(w, c);
- }
return w;
}
- private static final Writer encodeTextXmlCharsInner(Writer w, String s) throws IOException {
- final int len = s.length();
- for (int i = 0; i < len; i++) {
- char c = s.charAt(i);
- if (c == '&')
- w.append("&");
- else if (c == '<')
- w.append("<");
- else if (c == '>')
- w.append(">");
- else
- w.append(c);
- }
- return w;
- }
private static final boolean needsTextEncoding(String s) {
// See if we need to convert the string.
@@ -253,10 +162,12 @@ public final class XmlUtils {
int x = Integer.parseInt(s.substring(i+2, i+6), 16);
// If we find _x0000_, then that means a null.
+ // If we find _xE000_, then that means an empty string.
if (x == 0)
return null;
+ else if (x != 0xE000)
+ sb.append((char)x);
- sb.append((char)x);
i+=6;
} else {
sb.append(c);
@@ -266,6 +177,34 @@ public final class XmlUtils {
}
+ /**
+ * Given a list of Strings and other Objects, combines Strings that are next to each other in the list.
+ *
+ * @param l The list of text nodes to collapse.
+ * @return The same list.
+ */
+ public static LinkedList<Object> collapseTextNodes(LinkedList<Object> l) {
+
+ String prev = null;
+ for (ListIterator<Object> i = l.listIterator(); i.hasNext();) {
+ Object o = i.next();
+ if (o instanceof String) {
+ if (prev == null)
+ prev = o.toString();
+ else {
+ prev += o;
+ i.remove();
+ i.previous();
+ i.remove();
+ i.add(prev);
+ }
+ } else {
+ prev = null;
+ }
+ }
+ return l;
+ }
+
//--------------------------------------------------------------------------------
// Encode XML attributes
//--------------------------------------------------------------------------------
@@ -285,35 +224,33 @@ public final class XmlUtils {
String s = o.toString();
- if (needsAttributeEncoding(s))
- return encodeAttrInner(w, s);
+ if (needsAttributeEncoding(s)) {
+ for (int i = 0; i < s.length(); i++) {
+ char c = s.charAt(i);
+ if (c == '&')
+ w.append("&");
+ else if (c == '<')
+ w.append("<");
+ else if (c == '>')
+ w.append(">");
+ else if (c == '\'')
+ w.append("'");
+ else if (c == '"')
+ w.append(""");
+ else if (c == '_' && isEscapeSequence(s,i))
+ appendPaddedHexChar(w, c);
+ else if (isValidXmlCharacter(c))
+ w.append(c);
+ else
+ appendPaddedHexChar(w, c);
+ }
+ } else {
+ w.append(s);
+ }
- w.append(s);
return w;
}
- private static final Writer encodeAttrInner(Writer w, String s) throws IOException {
- for (int i = 0; i < s.length(); i++) {
- char c = s.charAt(i);
- if (c == '&')
- w.append("&");
- else if (c == '<')
- w.append("<");
- else if (c == '>')
- w.append(">");
- else if (c == '\'')
- w.append("'");
- else if (c == '"')
- w.append(""");
- else if (c == '_' && isEscapeSequence(s,i))
- appendPaddedHexChar(w, c);
- else if (isValidXmlCharacter(c))
- w.append(c);
- else
- appendPaddedHexChar(w, c);
- }
- return w;
- }
private static boolean needsAttributeEncoding(String s) {
// See if we need to convert the string.
@@ -364,7 +301,8 @@ public final class XmlUtils {
return "_x0000_";
String s = o.toString();
-
+ if (s.isEmpty())
+ return "_xE000_";
try {
if (needsElementNameEncoding(s))
return encodeElementNameInner(new StringBuilderWriter(s.length() * 2), s).toString();
@@ -425,48 +363,6 @@ public final class XmlUtils {
// Other methods
//--------------------------------------------------------------------------------
- /**
- * Utility method for reading XML mixed content from an XML element and returning it as text.
- *
- * @param r The reader to read from.
- * @return The contents read as a string.
- * @throws XMLStreamException
- * @throws IOException
- */
- public static String readXmlContents(XMLStreamReader r) throws XMLStreamException, IOException {
- StringWriter sw = new StringWriter();
- XmlWriter w = new XmlWriter(sw, false, false, '"', null, null, false, null);
- try {
- int depth = 0;
- do {
- int event = r.next();
- if (event == START_ELEMENT) {
- depth++;
- QName n = r.getName();
- w.oTag(n.getPrefix(), n.getLocalPart());
- for (int i = 0; i < r.getNamespaceCount(); i++)
- w.attr(r.getNamespacePrefix(i), "xmlns", r.getNamespaceURI(i));
- for (int i = 0; i < r.getAttributeCount(); i++)
- w.attr(r.getAttributePrefix(i), r.getAttributeLocalName(i), r.getAttributeValue(i));
- w.append('>');
- } else if (r.hasText()) {
- w.encodeTextXmlChars(r.getText());
- } else if (event == ATTRIBUTE) {
- // attributes handled above.
- } else if (event == END_ELEMENT) {
- QName n = r.getName();
- if (depth > 0)
- w.eTag(n.getPrefix(), n.getLocalPart());
- depth--;
- }
- if (depth < 0)
- return sw.toString();
- } while (true);
- } finally {
- w.close();
- }
- }
-
// Returns true if the specified character can safely be used in XML text or an attribute.
private static final boolean isValidXmlCharacter(char c) {
return (c >= 0x20 && c <= 0xD7FF) /*|| c == 0xA || c == 0xD*/ || (c >= 0xE000 && c <= 0xFFFD);
@@ -493,17 +389,8 @@ public final class XmlUtils {
// Converts an integer to a hexadecimal string padded to 4 places.
private static final Writer appendPaddedHexChar(Writer out, int num) throws IOException {
out.append("_x");
- char[] n = new char[4];
- int a = num%16;
- n[3] = (char)(a > 9 ? 'A'+a-10 : '0'+a);
- int base = 16;
- for (int i = 1; i < 4; i++) {
- a = (num/base)%16;
- base <<= 4;
- n[3-i] = (char)(a > 9 ? 'A'+a-10 : '0'+a);
- }
- for (int i = 0; i < 4; i++)
- out.append(n[i]);
+ for (char c : StringUtils.toHex(num))
+ out.append(c);
return out.append('_');
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/xml/XmlWriter.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlWriter.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlWriter.java
index 7610c1c..281e664 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlWriter.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlWriter.java
@@ -15,6 +15,7 @@ package org.apache.juneau.xml;
import java.io.*;
import org.apache.juneau.serializer.*;
+import org.apache.juneau.xml.annotation.*;
/**
* Specialized writer for serializing XML.
@@ -58,7 +59,7 @@ public class XmlWriter extends SerializerWriter {
if (enableNs && ns != null && ! (ns.isEmpty() || ns.equals(defaultNsPrefix)))
append(ns).append(':');
if (needsEncoding)
- encodeElement(name);
+ XmlUtils.encodeElementName(out, name);
else
append(name);
return this;
@@ -164,7 +165,7 @@ public class XmlWriter extends SerializerWriter {
if (enableNs && ns != null && ! (ns.isEmpty() || ns.equals(defaultNsPrefix)))
append(ns).append(':');
if (needsEncoding)
- encodeElement(name);
+ XmlUtils.encodeElementName(out, name);
else
append(name);
return append('/').append('>');
@@ -323,7 +324,7 @@ public class XmlWriter extends SerializerWriter {
if (enableNs && ns != null && ! (ns.isEmpty() || ns.equals(defaultNsPrefix)))
append(ns).append(':');
if (needsEncoding)
- encodeElement(name);
+ XmlUtils.encodeElementName(out, name);
else
append(name);
return append('>');
@@ -519,46 +520,27 @@ public class XmlWriter extends SerializerWriter {
}
/**
- * Serializes and encodes the specified object as valid XML text.
- *
- * @param o The object being serialized.
- * @return This object (for method chaining).
- * @throws IOException If a problem occurred.
- */
- public XmlWriter encodeText(Object o) throws IOException {
- XmlUtils.encodeText(this, o);
- return this;
- }
-
- /**
- * Serializes and encodes the specified object as valid XML text.
- * <p>
- * Does NOT encode XML characters (<js>'<'</js>, <js>'>'</js>, and <js>'&'</js>).
- * <p>
- * Use on XML text that you just want to replace invalid XML characters with <js>"_x####_"</js> sequences.
+ * Shortcut for calling <code>text(o, <jk>false</jk>);</code>
*
* @param o The object being serialized.
* @return This object (for method chaining).
* @throws IOException If a problem occurred.
*/
- public XmlWriter encodeTextInvalidChars(Object o) throws IOException {
- XmlUtils.encodeTextInvalidChars(this, o);
+ public XmlWriter text(Object o) throws IOException {
+ text(o, false);
return this;
}
/**
* Serializes and encodes the specified object as valid XML text.
- * <p>
- * Only encodes XML characters (<js>'<'</js>, <js>'>'</js>, and <js>'&'</js>).
- * <p>
- * Use on XML text where the invalid characters have already been replaced.
*
* @param o The object being serialized.
+ * @param preserveWhitespace If <jk>true</jk>, then we're serializing {@link XmlFormat#MIXED_PWS} or {@link XmlFormat#TEXT_PWS} content.
* @return This object (for method chaining).
- * @throws IOException If a problem occurred.
+ * @throws IOException
*/
- public XmlWriter encodeTextXmlChars(Object o) throws IOException {
- XmlUtils.encodeTextXmlChars(this, o);
+ public XmlWriter text(Object o, boolean preserveWhitespace) throws IOException {
+ XmlUtils.encodeText(this, o, trimStrings, preserveWhitespace);
return this;
}
@@ -574,18 +556,6 @@ public class XmlWriter extends SerializerWriter {
return this;
}
- /**
- * Serializes and encodes the specified object as valid XML element name.
- *
- * @param o The object being serialized.
- * @return This object (for method chaining).
- * @throws IOException If a problem occurred.
- */
- public XmlWriter encodeElement(Object o) throws IOException {
- XmlUtils.encodeElementName(out, o);
- return this;
- }
-
@Override /* SerializerWriter */
public XmlWriter cr(int depth) throws IOException {
super.cr(depth);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/xml/annotation/XmlFormat.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/annotation/XmlFormat.java b/juneau-core/src/main/java/org/apache/juneau/xml/annotation/XmlFormat.java
index 98140b6..905cc40 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/annotation/XmlFormat.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/annotation/XmlFormat.java
@@ -79,6 +79,13 @@ public enum XmlFormat {
MIXED,
/**
+ * Same as {@link XmlFormat#MIXED}, but whitespace in text nodes are not trimmed during parsing.
+ * <p>
+ * An example use is HTML5 <xt><pre></xt> where whitespace should not be discarded.
+ */
+ MIXED_PWS,
+
+ /**
* Render property value as the text content of the element.
* <p>
* Similar to {@link #MIXED} but value must be a single value, not a collection.
@@ -90,6 +97,11 @@ public enum XmlFormat {
TEXT,
/**
+ * Same as {@link XmlFormat#TEXT}, but whitespace in text node is not trimmed during parsing.
+ */
+ TEXT_PWS,
+
+ /**
* Same as {@link #TEXT} except the content is expected to be fully-formed XML that will
* get serialized as-is.
* <p>
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/xml/package.html
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/package.html b/juneau-core/src/main/java/org/apache/juneau/xml/package.html
index d6b48b9..9c23da6 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/package.html
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/package.html
@@ -1124,6 +1124,10 @@
</table>
<p>
On a side note, characters that cannot be represented in XML 1.0 are encoded using a simple encoding.
+ Note in the examples below, some characters such as <js>'\n'</js>, <js>'\t</js>', and <js>'\r'</js>
+ can be represented as XML entities when used in text but not in element names. Other characters such as
+ <js>'\b'</js> and <js>'\f'</js> cannot be encoded in XML 1.0 at all without inventing our own notation.
+ Whitespace characters in element names are encoded as well as whitespace end characters in text.
</p>
<table class='styled' style='width:auto'>
<tr>
@@ -1133,30 +1137,36 @@
<tr>
<td class='code'>
<jk>class</jk> BeanWithSpecialCharacters {
- <jk>public</jk> String a = <js>"\n\b\f\t"</js>;
+ <jk>public</jk> String a = <js>" \b\f\n\t\r "</js>;
}
</td>
<td class='code'><xt>
<object>
- <a><xv>_x000A__x0008__x000C__x0009_</xv></a>
+ <a><xv>_x0020_ _x0008__x000C_&#x000a;&#x0009;&#x000d; _x0020_</xv></a>
</object>
</xt></td>
</tr>
<tr>
<td class='code'>
- <ja>@Bean</ja>(typeName=<js>"$#!"</js>)
+ <ja>@Bean</ja>(typeName=<js>" \b\f\n\t\r "</js>)
<jk>class</jk> BeanWithNamesWithSpecialCharacters {
- <ja>@BeanProperty</ja>(name=<js>"*()"</js>)
- <jk>public</jk> String a = <js>"\n\b\f\t"</js>;
+ <ja>@BeanProperty</ja>(name=<js>" \b\f\n\t\r "</js>)
+ <jk>public</jk> String a = <js>" \b\f\n\t\r "</js>;
}
</td>
<td class='code'><xt>
- <_x0024__x0023__x0021_>
- <_x002A__x0028__x0029_><xv>_x000A__x0008__x000C__x0009_</xv></_x002A__x0028__x0029_>
- </_x0024__x0023__x0021_>
+ <_x0020__x0020__x0008__x000C__x000A__x0009__x000D__x0020__x0020_>
+ <_x0020__x0020__x0008__x000C__x000A__x0009__x000D__x0020__x0020_><xv>_x0020_ _x0008__x000C_&#x000a;&#x0009;&#x000d; _x0020_</xv></_x0020__x0020__x0008__x000C__x000A__x0009__x000D__x0020__x0020_>
+ </_x0020__x0020__x0008__x000C__x000A__x0009__x000D__x0020__x0020_>
</xt></td>
</tr>
</table>
+ <p>
+ While it's true that these characters CAN be represented in XML 1.1, it's impossible to parse XML 1.1 text in
+ Java without the XML containing an XML declaration.
+ Unfortunately, this, and the uselessness of the {@link javax.xml.stream.XMLInputFactory#IS_REPLACING_ENTITY_REFERENCES} setting in Java
+ forced us to make some hard design decisions that may not be the most elegant.
+ </p>
</div>
@@ -1539,6 +1549,10 @@
This format particularly useful when combined with bean dictionaries to produce mixed content.
<br>The bean dictionary isn't used during serialization, but it is needed during parsing to resolve bean types.
</p>
+ <p>
+ The {@link org.apache.juneau.xml.annotation.XmlFormat#MIXED_PWS} format identical to {@link org.apache.juneau.xml.annotation.XmlFormat#MIXED}
+ except whitespace characters are preserved in the output.
+ </p>
<table class='styled' style='width:auto'>
<tr>
<th>Data type</th>
@@ -1598,6 +1612,272 @@
</tr>
</table>
<p>
+ Whitespace (tabs and newlines) are not added to MIXED child nodes in readable-output mode.
+ This helps ensures strings in the serialized output can be losslessly parsed back into their original forms when they contain whitespace characters.
+ If the {@link javax.xml.stream.XMLInputFactory#IS_REPLACING_ENTITY_REFERENCES} setting was not useless in Java, we could support lossless
+ readable XML for MIXED content. But as of Java 8, it still does not work.
+ </p>
+ <p>
+ XML suffers from other deficiencies as well that affect MIXED content. For example, <xt><X></X></xt> and <xt><X/></xt> are
+ equivalent in XML and indistinguishable by the Java XML parsers. This makes it impossible to differentiate between an empty element and an
+ element containing an empty string. This causes empty strings to get lost in translation. To alleviate this, we use the constructs <js>"_xE000_"</js> to
+ represent an empty string, and <js>"_x0020_"</js> to represent leading and trailing spaces.
+ </p>
+ <p>
+ The examples below show how whitespace is handled under various circumstances:
+ </p>
+ <table class='styled' style='width:auto'>
+ <tr>
+ <th>Data type</th>
+ <th>XML</th>
+ </tr>
+ <tr>
+ <td class='code'>
+ <ja>@Bean</ja>(typeName=<js>"X"</js>)
+ <jk>class</jk> MyBean {
+ <ja>@Xml</ja>(format=XmlFormat.<jsf>TEXT</jsf>)
+ <jk>public</jk> String a = <jk>null</jk>;
+ }
+ </td>
+ <td class='code'><xt>
+ <X/>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ <ja>@Bean</ja>(typeName=<js>"X"</js>)
+ <jk>class</jk> MyBean {
+ <ja>@Xml</ja>(format=XmlFormat.<jsf>TEXT</jsf>)
+ <jk>public</jk> String a = <js>""</js>;
+ }
+ </td>
+ <td class='code'><xt>
+ <X><xv>_xE000_</xv></X>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ <ja>@Bean</ja>(typeName=<js>"X"</js>)
+ <jk>class</jk> MyBean {
+ <ja>@Xml</ja>(format=XmlFormat.<jsf>TEXT</jsf>)
+ <jk>public</jk> String a = <js>" "</js>;
+ }
+ </td>
+ <td class='code'><xt>
+ <X><xv>_x0020_</xv></X>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ <ja>@Bean</ja>(typeName=<js>"X"</js>)
+ <jk>class</jk> MyBean {
+ <ja>@Xml</ja>(format=XmlFormat.<jsf>TEXT</jsf>)
+ <jk>public</jk> String a = <js>" "</js>;
+ }
+ </td>
+ <td class='code'><xt>
+ <X><xv>_x0020__x0020_</xv></X>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ <ja>@Bean</ja>(typeName=<js>"X"</js>)
+ <jk>class</jk> MyBean {
+ <ja>@Xml</ja>(format=XmlFormat.<jsf>TEXT</jsf>)
+ <jk>public</jk> String a = <js>" foobar "</js>;
+ }
+ </td>
+ <td class='code'><xt>
+ <X><xv>_x0020_ foobar _x0020_</xv></X>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ <ja>@Bean</ja>(typeName=<js>"X"</js>)
+ <jk>class</jk> MyBean {
+ <ja>@Xml</ja>(format=XmlFormat.<jsf>TEXT_PWS</jsf>)
+ <jk>public</jk> String a = <jk>null</jk>;
+ }
+ </td>
+ <td class='code'><xt>
+ <X/>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ <ja>@Bean</ja>(typeName=<js>"X"</js>)
+ <jk>class</jk> MyBean {
+ <ja>@Xml</ja>(format=XmlFormat.<jsf>TEXT_PWS</jsf>)
+ <jk>public</jk> String a = <js>""</js>;
+ }
+ </td>
+ <td class='code'><xt>
+ <X><xv>_xE000_</xv></X>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ <ja>@Bean</ja>(typeName=<js>"X"</js>)
+ <jk>class</jk> MyBean {
+ <ja>@Xml</ja>(format=XmlFormat.<jsf>TEXT_PWS</jsf>)
+ <jk>public</jk> String a = <js>" "</js>;
+ }
+ </td>
+ <td class='code'><xt>
+ <X><xv> </xv></X>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ <ja>@Bean</ja>(typeName=<js>"X"</js>)
+ <jk>class</jk> MyBean {
+ <ja>@Xml</ja>(format=XmlFormat.<jsf>TEXT_PWS</jsf>)
+ <jk>public</jk> String a = <js>" "</js>;
+ }
+ </td>
+ <td class='code'><xt>
+ <X><xv> </xv></X>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ <ja>@Bean</ja>(typeName=<js>"X"</js>)
+ <jk>class</jk> MyBean {
+ <ja>@Xml</ja>(format=XmlFormat.<jsf>TEXT_PWS</jsf>)
+ <jk>public</jk> String a = <js>" foobar "</js>;
+ }
+ </td>
+ <td class='code'><xt>
+ <X><xv> foobar </xv></X>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ <ja>@Bean</ja>(typeName=<js>"X"</js>)
+ <jk>class</jk> MyBean {
+ <ja>@Xml</ja>(format=XmlFormat.<jsf>MIXED</jsf>)
+ <jk>public</jk> String[] a = <jk>null</jk>;
+ }
+ </td>
+ <td class='code'><xt>
+ <X/>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ <ja>@Bean</ja>(typeName=<js>"X"</js>)
+ <jk>class</jk> MyBean {
+ <ja>@Xml</ja>(format=XmlFormat.<jsf>MIXED</jsf>)
+ <jk>public</jk> String a[] = <jk>new</jk> String[]{<js>""</js>};
+ }
+ </td>
+ <td class='code'><xt>
+ <X><xv>_xE000_</xv></X>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ <ja>@Bean</ja>(typeName=<js>"X"</js>)
+ <jk>class</jk> MyBean {
+ <ja>@Xml</ja>(format=XmlFormat.<jsf>MIXED</jsf>)
+ <jk>public</jk> String a[] = <jk>new</jk> String[]{<js>" "</js>};
+ }
+ </td>
+ <td class='code'><xt>
+ <X><xv>_x0020_</xv></X>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ <ja>@Bean</ja>(typeName=<js>"X"</js>)
+ <jk>class</jk> MyBean {
+ <ja>@Xml</ja>(format=XmlFormat.<jsf>MIXED</jsf>)
+ <jk>public</jk> String a[] = <jk>new</jk> String[]{<js>" "</js>};
+ }
+ </td>
+ <td class='code'><xt>
+ <X><xv>_x0020__x0020_</xv></X>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ <ja>@Bean</ja>(typeName=<js>"X"</js>)
+ <jk>class</jk> MyBean {
+ <ja>@Xml</ja>(format=XmlFormat.<jsf>MIXED</jsf>)
+ <jk>public</jk> String a[] = <jk>new</jk> String[]{
+ <js>" foobar "</js>
+ };
+ }
+ </td>
+ <td class='code'><xt>
+ <X><xv>_x0020_ foobar _x0020_</xv></X>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ <ja>@Bean</ja>(typeName=<js>"X"</js>)
+ <jk>class</jk> MyBean {
+ <ja>@Xml</ja>(format=XmlFormat.<jsf>MIXED_PWS</jsf>)
+ <jk>public</jk> String[] a = <jk>null</jk>;
+ }
+ </td>
+ <td class='code'><xt>
+ <X/>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ <ja>@Bean</ja>(typeName=<js>"X"</js>)
+ <jk>class</jk> MyBean {
+ <ja>@Xml</ja>(format=XmlFormat.<jsf>MIXED_PWS</jsf>)
+ <jk>public</jk> String a[] = <jk>new</jk> String[]{<js>""</js>};
+ }
+ </td>
+ <td class='code'><xt>
+ <X><xv>_xE000_</xv></X>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ <ja>@Bean</ja>(typeName=<js>"X"</js>)
+ <jk>class</jk> MyBean {
+ <ja>@Xml</ja>(format=XmlFormat.<jsf>MIXED_PWS</jsf>)
+ <jk>public</jk> String a[] = <jk>new</jk> String[]{<js>" "</js>};
+ }
+ </td>
+ <td class='code'><xt>
+ <X><xv> </xv></X>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ <ja>@Bean</ja>(typeName=<js>"X"</js>)
+ <jk>class</jk> MyBean {
+ <ja>@Xml</ja>(format=XmlFormat.<jsf>MIXED_PWS</jsf>)
+ <jk>public</jk> String a[] = <jk>new</jk> String[]{<js>" "</js>};
+ }
+ </td>
+ <td class='code'><xt>
+ <X><xv> </xv></X>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ <ja>@Bean</ja>(typeName=<js>"X"</js>)
+ <jk>class</jk> MyBean {
+ <ja>@Xml</ja>(format=XmlFormat.<jsf>MIXED_PWS</jsf>)
+ <jk>public</jk> String a[] = <jk>new</jk> String[]{
+ <js>" foobar "</js>
+ };
+ }
+ </td>
+ <td class='code'><xt>
+ <X><xv> foobar </xv></X>
+ </xt></td>
+ </tr>
+ </table>
+
+ <p>
It should be noted that when using <jsf>MIXED</jsf>, you are not guaranteed to parse back the exact same content
since side-by-side strings in the content will end up concatenated when parsed.
</p>
@@ -1605,6 +1885,7 @@
The {@link org.apache.juneau.xml.annotation.XmlFormat#TEXT} format is similar to {@link org.apache.juneau.xml.annotation.XmlFormat#MIXED}
except it's meant for solitary objects that get serialized as simple child text nodes.
<br>Any object that can be serialize to a <code>String</code> can be used.
+ <br>The {@link org.apache.juneau.xml.annotation.XmlFormat#TEXT_PWS} is the same except whitespace is preserved in the output.
</p>
<table class='styled' style='width:auto'>
<tr>
@@ -2560,6 +2841,7 @@
When the map or list type is not specified, or is the abstract <code>Map</code>, <code>Collection</code>, or <code>List</code> types,
the parser will use <code>ObjectMap</code> and <code>ObjectList</code> by default.
</p>
+ </div>
<!-- ======================================================================================================== -->
@@ -2989,4 +3271,4 @@
<p align="center"><i><b>*** f�n ***</b></i></p>
</body>
-</html>
\ No newline at end of file
+</html>
\ No newline at end of file
[3/6] incubator-juneau git commit: Continuation of HTML5 support.
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/Table.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Table.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Table.java
index 8eb34b5..9ecac12 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Table.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Table.java
@@ -19,17 +19,17 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="table")
-@SuppressWarnings("hiding")
public class Table extends HtmlElementContainer {
/**
* <a class='doclink' href='https://www.w3.org/TR/html5/tabular-data.html#attr-table-border'>border</a> attribute.
* //sortable - Enables a sorting interface for the table.
* @param border - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Table border(String border) {
- attrs.put("border", border);
+ public final Table border(Object border) {
+ attr("border", border);
return this;
}
@@ -38,12 +38,6 @@ public class Table extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@Override /* HtmlElement */
- public Table children(Object...children) {
- super.children(children);
- return this;
- }
-
- @Override /* HtmlElement */
public final Table _class(String _class) {
super._class(_class);
return this;
@@ -54,4 +48,16 @@ public class Table extends HtmlElementContainer {
super.id(id);
return this;
}
+
+ @Override /* HtmlElementContainer */
+ public final Table children(Object...children) {
+ super.children(children);
+ return this;
+ }
+
+ @Override /* HtmlElementContainer */
+ public final Table 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/Tbody.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Tbody.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Tbody.java
index 60dc549..0612943 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Tbody.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Tbody.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="tbody")
-@SuppressWarnings("hiding")
public class Tbody extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@@ -27,12 +26,6 @@ public class Tbody extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@Override /* HtmlElement */
- public Tbody children(Object...children) {
- super.children(children);
- return this;
- }
-
- @Override /* HtmlElement */
public final Tbody _class(String _class) {
super._class(_class);
return this;
@@ -43,4 +36,16 @@ public class Tbody extends HtmlElementContainer {
super.id(id);
return this;
}
+
+ @Override /* HtmlElementContainer */
+ public final Tbody children(Object...children) {
+ super.children(children);
+ return this;
+ }
+
+ @Override /* HtmlElementContainer */
+ public final Tbody 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/Td.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Td.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Td.java
index 26b79e9..d26c845 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Td.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Td.java
@@ -19,17 +19,17 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="td")
-@SuppressWarnings("hiding")
public class Td extends HtmlElementMixed {
/**
* <a class='doclink' href='https://www.w3.org/TR/html5/tabular-data.html#attr-tdth-colspan'>colspan</a> attribute.
* Number of columns that the cell is to span.
* @param colspan - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Td colspan(String colspan) {
- attrs.put("colspan", colspan);
+ public final Td colspan(Object colspan) {
+ attr("colspan", colspan);
return this;
}
@@ -40,7 +40,7 @@ public class Td extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Td headers(String headers) {
- attrs.put("headers", headers);
+ attr("headers", headers);
return this;
}
@@ -48,10 +48,11 @@ public class Td extends HtmlElementMixed {
* <a class='doclink' href='https://www.w3.org/TR/html5/tabular-data.html#attr-tdth-rowspan'>rowspan</a> attribute.
* Number of rows that the cell is to span.
* @param rowspan - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Td rowspan(String rowspan) {
- attrs.put("rowspan", rowspan);
+ public final Td rowspan(Object rowspan) {
+ attr("rowspan", rowspan);
return this;
}
@@ -79,7 +80,7 @@ public class Td extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Td 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/Template.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Template.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Template.java
index a3d914a..98b77e8 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Template.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Template.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="template")
-@SuppressWarnings("hiding")
public class Template extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Template extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Template 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/Textarea.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Textarea.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Textarea.java
index ec4819a..c6f9acd 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Textarea.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Textarea.java
@@ -28,7 +28,7 @@ public class Textarea extends HtmlElementText {
* @return This object (for method chaining).
*/
public final Textarea autocomplete(String autocomplete) {
- attrs.put("autocomplete", autocomplete);
+ attr("autocomplete", autocomplete);
return this;
}
@@ -36,10 +36,11 @@ public class Textarea extends HtmlElementText {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-fe-autofocus'>autofocus</a> attribute.
* Automatically focus the form control when the page is loaded.
* @param autofocus - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Textarea autofocus(String autofocus) {
- attrs.put("autofocus", autofocus);
+ public final Textarea autofocus(Boolean autofocus) {
+ attr("autofocus", autofocus);
return this;
}
@@ -47,10 +48,11 @@ public class Textarea extends HtmlElementText {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-textarea-cols'>cols</a> attribute.
* Maximum number of characters per line.
* @param cols - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Textarea cols(String cols) {
- attrs.put("cols", cols);
+ public final Textarea cols(Object cols) {
+ attr("cols", cols);
return this;
}
@@ -61,7 +63,7 @@ public class Textarea extends HtmlElementText {
* @return This object (for method chaining).
*/
public final Textarea dirname(String dirname) {
- attrs.put("dirname", dirname);
+ attr("dirname", dirname);
return this;
}
@@ -69,10 +71,11 @@ public class Textarea extends HtmlElementText {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-fe-disabled'>disabled</a> attribute.
* Whether the form control is disabled.
* @param disabled - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Textarea disabled(String disabled) {
- attrs.put("disabled", disabled);
+ public final Textarea disabled(Object disabled) {
+ attr("disabled", disabled);
return this;
}
@@ -83,7 +86,7 @@ public class Textarea extends HtmlElementText {
* @return This object (for method chaining).
*/
public final Textarea form(String form) {
- attrs.put("form", form);
+ attr("form", form);
return this;
}
@@ -94,7 +97,7 @@ public class Textarea extends HtmlElementText {
* @return This object (for method chaining).
*/
public final Textarea inputmode(String inputmode) {
- attrs.put("inputmode", inputmode);
+ attr("inputmode", inputmode);
return this;
}
@@ -102,10 +105,11 @@ public class Textarea extends HtmlElementText {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-textarea-maxlength'>maxlength</a> attribute.
* Maximum length of value.
* @param maxlength - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Textarea maxlength(String maxlength) {
- attrs.put("maxlength", maxlength);
+ public final Textarea maxlength(Object maxlength) {
+ attr("maxlength", maxlength);
return this;
}
@@ -113,10 +117,11 @@ public class Textarea extends HtmlElementText {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-textarea-minlength'>minlength</a> attribute.
* Minimum length of value.
* @param minlength - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Textarea minlength(String minlength) {
- attrs.put("minlength", minlength);
+ public final Textarea minlength(Object minlength) {
+ attr("minlength", minlength);
return this;
}
@@ -127,7 +132,7 @@ public class Textarea extends HtmlElementText {
* @return This object (for method chaining).
*/
public final Textarea name(String name) {
- attrs.put("name", name);
+ attr("name", name);
return this;
}
@@ -138,7 +143,7 @@ public class Textarea extends HtmlElementText {
* @return This object (for method chaining).
*/
public final Textarea placeholder(String placeholder) {
- attrs.put("placeholder", placeholder);
+ attr("placeholder", placeholder);
return this;
}
@@ -146,10 +151,11 @@ public class Textarea extends HtmlElementText {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-textarea-readonly'>readonly</a> attribute.
* Whether to allow the value to be edited by the user.
* @param readonly - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Textarea readonly(String readonly) {
- attrs.put("readonly", readonly);
+ public final Textarea readonly(Object readonly) {
+ attr("readonly", readonly);
return this;
}
@@ -157,10 +163,11 @@ public class Textarea extends HtmlElementText {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-textarea-required'>required</a> attribute.
* Whether the control is required for form submission.
* @param required - The new value for this attribute.
+ * Typically a {@link Boolean} or {@link String}.
* @return This object (for method chaining).
*/
- public final Textarea required(String required) {
- attrs.put("required", required);
+ public final Textarea required(Object required) {
+ attr("required", required);
return this;
}
@@ -168,10 +175,11 @@ public class Textarea extends HtmlElementText {
* <a class='doclink' href='https://www.w3.org/TR/html5/forms.html#attr-textarea-rows'>rows</a> attribute.
* Number of lines to show.
* @param rows - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Textarea rows(String rows) {
- attrs.put("rows", rows);
+ public final Textarea rows(Number rows) {
+ attr("rows", rows);
return this;
}
@@ -182,7 +190,7 @@ public class Textarea extends HtmlElementText {
* @return This object (for method chaining).
*/
public final Textarea wrap(String wrap) {
- attrs.put("wrap", wrap);
+ attr("wrap", wrap);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/Tfoot.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Tfoot.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Tfoot.java
index a34478d..b4bfa19 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Tfoot.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Tfoot.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="tfoot")
-@SuppressWarnings("hiding")
public class Tfoot extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@@ -27,12 +26,6 @@ public class Tfoot extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@Override /* HtmlElement */
- public Tfoot children(Object...children) {
- super.children(children);
- return this;
- }
-
- @Override /* HtmlElement */
public final Tfoot _class(String _class) {
super._class(_class);
return this;
@@ -43,4 +36,16 @@ public class Tfoot extends HtmlElementContainer {
super.id(id);
return this;
}
+
+ @Override /* HtmlElementContainer */
+ public final Tfoot children(Object...children) {
+ super.children(children);
+ return this;
+ }
+
+ @Override /* HtmlElementContainer */
+ public final Tfoot 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/Th.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Th.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Th.java
index b05af38..500ae81 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Th.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Th.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="th")
-@SuppressWarnings("hiding")
public class Th extends HtmlElementMixed {
/**
@@ -29,7 +28,7 @@ public class Th extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Th abbr(String abbr) {
- attrs.put("abbr", abbr);
+ attr("abbr", abbr);
return this;
}
@@ -37,10 +36,11 @@ public class Th extends HtmlElementMixed {
* <a class='doclink' href='https://www.w3.org/TR/html5/tabular-data.html#attr-tdth-colspan'>colspan</a> attribute.
* Number of columns that the cell is to span.
* @param colspan - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Th colspan(String colspan) {
- attrs.put("colspan", colspan);
+ public final Th colspan(Object colspan) {
+ attr("colspan", colspan);
return this;
}
@@ -51,7 +51,7 @@ public class Th extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Th headers(String headers) {
- attrs.put("headers", headers);
+ attr("headers", headers);
return this;
}
@@ -59,10 +59,11 @@ public class Th extends HtmlElementMixed {
* <a class='doclink' href='https://www.w3.org/TR/html5/tabular-data.html#attr-tdth-rowspan'>rowspan</a> attribute.
* Number of rows that the cell is to span.
* @param rowspan - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Th rowspan(String rowspan) {
- attrs.put("rowspan", rowspan);
+ public final Th rowspan(Object rowspan) {
+ attr("rowspan", rowspan);
return this;
}
@@ -73,7 +74,7 @@ public class Th extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Th scope(String scope) {
- attrs.put("scope", scope);
+ attr("scope", scope);
return this;
}
@@ -84,7 +85,7 @@ public class Th extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Th sorted(String sorted) {
- attrs.put("sorted", sorted);
+ attr("sorted", sorted);
return this;
}
@@ -112,7 +113,7 @@ public class Th extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Th 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/Thead.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Thead.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Thead.java
index 26cf935..231955e 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Thead.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Thead.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="thead")
-@SuppressWarnings("hiding")
public class Thead extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@@ -27,12 +26,6 @@ public class Thead extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@Override /* HtmlElement */
- public Thead children(Object...children) {
- super.children(children);
- return this;
- }
-
- @Override /* HtmlElement */
public final Thead _class(String _class) {
super._class(_class);
return this;
@@ -43,4 +36,16 @@ public class Thead extends HtmlElementContainer {
super.id(id);
return this;
}
+
+ @Override /* HtmlElementContainer */
+ public final Thead children(Object...children) {
+ super.children(children);
+ return this;
+ }
+
+ @Override /* HtmlElementContainer */
+ public final Thead 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/Time.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Time.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Time.java
index 48a736e..3a176b3 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Time.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Time.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="time")
-@SuppressWarnings("hiding")
public class Time extends HtmlElementMixed {
/**
@@ -29,7 +28,7 @@ public class Time extends HtmlElementMixed {
* @return This object (for method chaining).
*/
public final Time datetime(String datetime) {
- attrs.put("datetime", datetime);
+ attr("datetime", datetime);
return this;
}
@@ -57,7 +56,7 @@ public class Time extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Time 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/Tr.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Tr.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Tr.java
index 4a0dd10..e3ed4ad 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Tr.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Tr.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="tr")
-@SuppressWarnings("hiding")
public class Tr extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@@ -27,12 +26,6 @@ public class Tr extends HtmlElementContainer {
//--------------------------------------------------------------------------------
@Override /* HtmlElement */
- public Tr children(Object...children) {
- super.children(children);
- return this;
- }
-
- @Override /* HtmlElement */
public final Tr _class(String _class) {
super._class(_class);
return this;
@@ -43,4 +36,16 @@ public class Tr extends HtmlElementContainer {
super.id(id);
return this;
}
+
+ @Override /* HtmlElementContainer */
+ public final Tr children(Object...children) {
+ super.children(children);
+ return this;
+ }
+
+ @Override /* HtmlElementContainer */
+ public final Tr 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/Track.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Track.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Track.java
index fc10b7d..2c02600 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Track.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Track.java
@@ -12,6 +12,8 @@
// ***************************************************************************************************************************
package org.apache.juneau.dto.html5;
+import java.net.*;
+
import org.apache.juneau.annotation.*;
/**
@@ -28,7 +30,7 @@ public class Track extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Track _default(String _default) {
- attrs.put("default", _default);
+ attr("default", _default);
return this;
}
@@ -39,7 +41,7 @@ public class Track extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Track kind(String kind) {
- attrs.put("kind", kind);
+ attr("kind", kind);
return this;
}
@@ -50,7 +52,7 @@ public class Track extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Track label(String label) {
- attrs.put("label", label);
+ attr("label", label);
return this;
}
@@ -58,10 +60,11 @@ public class Track extends HtmlElementEmpty {
* <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-track-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 Track src(String src) {
- attrs.put("src", src);
+ public final Track src(Object src) {
+ attr("src", src);
return this;
}
@@ -72,7 +75,7 @@ public class Track extends HtmlElementEmpty {
* @return This object (for method chaining).
*/
public final Track srclang(String srclang) {
- attrs.put("srclang", srclang);
+ attr("srclang", srclang);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/dto/html5/U.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/U.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/U.java
index 20b5c07..2e1774f 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/U.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/U.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="u")
-@SuppressWarnings("hiding")
public class U extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class U extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public U 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/Ul.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Ul.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Ul.java
index 014254f..8b6c129 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Ul.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Ul.java
@@ -19,8 +19,7 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="ul")
-@SuppressWarnings("hiding")
-public class Ul extends HtmlElementMixed {
+public class Ul extends HtmlElementContainer {
//--------------------------------------------------------------------------------
// Overridden methods
@@ -38,15 +37,15 @@ public class Ul extends HtmlElementMixed {
return this;
}
- @Override /* HtmlElementMixed */
- public Ul children(Object...children) {
+ @Override /* HtmlElementContainer */
+ public final Ul children(Object...children) {
super.children(children);
return this;
}
- @Override /* HtmlElementMixed */
- public Ul child(Object child) {
- this.children.add(child);
+ @Override /* HtmlElementContainer */
+ public final Ul 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/Var.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Var.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Var.java
index 11464f2..69361a7 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Var.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Var.java
@@ -19,7 +19,6 @@ import org.apache.juneau.annotation.*;
* <p>
*/
@Bean(typeName="var")
-@SuppressWarnings("hiding")
public class Var extends HtmlElementMixed {
//--------------------------------------------------------------------------------
@@ -46,7 +45,7 @@ public class Var extends HtmlElementMixed {
@Override /* HtmlElementMixed */
public Var 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/Video.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Video.java b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Video.java
index f92ccd4..23ac865 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/Video.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/Video.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="video")
-public class Video extends HtmlElement {
+public class Video 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 Video autoplay(String autoplay) {
- attrs.put("autoplay", autoplay);
+ public final Video autoplay(Object autoplay) {
+ attr("autoplay", autoplay);
return this;
}
@@ -36,10 +39,11 @@ public class Video extends HtmlElement {
* <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 Video controls(String controls) {
- attrs.put("controls", controls);
+ public final Video controls(Object controls) {
+ attr("controls", controls);
return this;
}
@@ -50,7 +54,7 @@ public class Video extends HtmlElement {
* @return This object (for method chaining).
*/
public final Video crossorigin(String crossorigin) {
- attrs.put("crossorigin", crossorigin);
+ attr("crossorigin", crossorigin);
return this;
}
@@ -58,10 +62,11 @@ public class Video extends HtmlElement {
* <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-height'>height</a> attribute.
* Vertical dimension.
* @param height - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Video height(String height) {
- attrs.put("height", height);
+ public final Video height(Object height) {
+ attr("height", height);
return this;
}
@@ -69,10 +74,11 @@ public class Video extends HtmlElement {
* <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 Video loop(String loop) {
- attrs.put("loop", loop);
+ public final Video loop(Object loop) {
+ attr("loop", loop);
return this;
}
@@ -83,7 +89,7 @@ public class Video extends HtmlElement {
* @return This object (for method chaining).
*/
public final Video mediagroup(String mediagroup) {
- attrs.put("mediagroup", mediagroup);
+ attr("mediagroup", mediagroup);
return this;
}
@@ -91,10 +97,11 @@ public class Video extends HtmlElement {
* <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 Video muted(String muted) {
- attrs.put("muted", muted);
+ public final Video muted(Object muted) {
+ attr("muted", muted);
return this;
}
@@ -105,7 +112,7 @@ public class Video extends HtmlElement {
* @return This object (for method chaining).
*/
public final Video poster(String poster) {
- attrs.put("poster", poster);
+ attr("poster", poster);
return this;
}
@@ -116,7 +123,7 @@ public class Video extends HtmlElement {
* @return This object (for method chaining).
*/
public final Video preload(String preload) {
- attrs.put("preload", preload);
+ attr("preload", preload);
return this;
}
@@ -124,10 +131,11 @@ public class Video extends HtmlElement {
* <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 Video src(String src) {
- attrs.put("src", src);
+ public final Video src(Object src) {
+ attr("src", src);
return this;
}
@@ -135,10 +143,11 @@ public class Video extends HtmlElement {
* <a class='doclink' href='https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-width'>width</a> attribute.
* Horizontal dimension.
* @param width - The new value for this attribute.
+ * Typically a {@link Number} or {@link String}.
* @return This object (for method chaining).
*/
- public final Video width(String width) {
- attrs.put("width", width);
+ public final Video width(Object width) {
+ attr("width", width);
return this;
}
@@ -157,4 +166,16 @@ public class Video extends HtmlElement {
super.id(id);
return this;
}
+
+ @Override /* HtmlElementContainer */
+ public final Video children(Object...children) {
+ super.children(children);
+ return this;
+ }
+
+ @Override /* HtmlElementContainer */
+ public final Video 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/package.html
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/html5/package.html b/juneau-core/src/main/java/org/apache/juneau/dto/html5/package.html
index a721d71..f5b39d9 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/html5/package.html
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/html5/package.html
@@ -36,6 +36,160 @@
</script>
</head>
<body>
-<p>HTML Data Transfer Objects</p>
+<p>HTML5 Data Transfer Objects</p>
+<script>
+ function toggle(x) {
+ var div = x.nextSibling;
+ while (div != null && div.nodeType != 1)
+ div = div.nextSibling;
+ if (div != null) {
+ var d = div.style.display;
+ if (d == 'block' || d == '') {
+ div.style.display = 'none';
+ x.className += " closed";
+ } else {
+ div.style.display = 'block';
+ x.className = x.className.replace(/(?:^|\s)closed(?!\S)/g , '' );
+ }
+ }
+ }
+</script>
+<a id='TOC'></a><h5 class='toc'>Table of Contents</h5>
+<ol class='toc'>
+ <li><p><a class='doclink' href='#Overview'>Overview</a></p>
+ <ol>
+ <li><p><a class='doclink' href='#Serialize'>Generating HTML5</a></p>
+ <li><p><a class='doclink' href='#Parse'>Parsing HTML5</a></p>
+ </ol>
+</ol>
+
+
+<!-- ======================================================================================================== -->
+<a id="Overview"></a>
+<h2 class='topic' onclick='toggle(this)'>1 - Overview</h2>
+<div class='topic'>
+ <p>
+ Juneau supports generation and consumption of HTML5 documents and fragments through the use of DTOs (Data Transfer Objects).<br>
+ It uses existing support for serializing and parsing POJOs to and from HTML to define these HTML objects.
+ </p>
+
+
+ <!-- ======================================================================================================== -->
+ <a id="Serialize"></a>
+ <h3 class='topic' onclick='toggle(this)'>1.1 - Generating HTML5</h3>
+ <div class='topic'>
+ <p>
+ The Juneau HTML5 DTOs are simply beans with fluent-style setters that allow you to quickly construct HTML
+ fragments as Java objects. These object can then be serialized to HTML using one of the existing HTML serializers,
+ or to other languages such as JSON using the JSON serializers.
+ </p>
+ <p>
+ The {@link org.apache.juneau.dto.html5.HtmlBuilder} class is a utility class with predefined static methods
+ that allow you to easily construct DTO instances in a minimal amount of code.
+ </p>
+ <p>
+ The following examples show how to create HTML tables.
+ </p>
+ <table class='styled' style='width:auto'>
+ <tr>
+ <th>Java code</th>
+ <th>HTML</th>
+ </tr>
+ <tr>
+ <td class='code'>
+ <jk>import static</jk> org.apache.juneau.dto.html5.HtmlBuilder.*;
+
+ Object mytable =
+ table(
+ tr(th(<js>"c1"</js>),th(<js>"c2"</js>)),
+ tr(td(<js>"v1"</js>),td(<js>"v2"</js>))
+ );
+
+ String html = HtmlSerializer.<jsf>DEFAULT</jsf>.serialize(mytable);
+ </td>
+ <td class='code'><xt>
+ <table>
+ <tr>
+ <th><xv>c1</xv></th>
+ <th><xv>c2</xv></th>
+ </tr>
+ <tr>
+ <td><xv>v1</xv></td>
+ <td><xv>v2</xv></td>
+ </tr>
+ </table>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ <jk>import static</jk> org.apache.juneau.dto.html5.HtmlBuilder.*;
+
+ Object mytable =
+ table(
+ caption(<js>"mytable"</js>),
+ colgroup(
+ col()._class(<js>"foo"</js>),
+ col()._class(<js>"bar"</js>)
+ ),
+ thead(tr(th(<js>"c1"</js>),th(<js>"c2"</js>))),
+ tbody(tr(td(<js>"v1"</js>),td(<js>"v2"</js>))),
+ tfoot(tr(td(<js>"f1"</js>),td(<js>"f2"</js>)))
+ );
+
+ String html = HtmlSerializer.<jsf>DEFAULT</jsf>.serialize(mytable);
+ </td>
+ <td class='code'><xt>
+ <table>
+ <caption><xv>mytable</xv></caption>
+ <colgroup>
+ <col <xa>class</xa>=<xs>'foo'</xs>/>
+ <col <xa>class</xa>=<xs>'bar'</xs>/>
+ </colgroup>
+ <thead>
+ <tr>
+ <th><xv>c1</xv></th>
+ <th><xv>c2</xv></th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><xv>v1</xv></td>
+ <td><xv>v2</xv></td>
+ </tr>
+ </tbody>
+ <tfoot>
+ <tr>
+ <td><xv>f1</xv></td>
+ <td><xv>f2</xv></td>
+ </tr>
+ </tfoot>
+ </table>
+ </xt></td>
+ </tr>
+ </table>
+</div>
+
+ <!-- ======================================================================================================== -->
+ <a id="Parse"></a>
+ <h3 class='topic' onclick='toggle(this)'>1.2 - Parsing HTML5</h3>
+ <div class='topic'>
+ <p>
+ Use the {@link org.apache.juneau.xml.HtmlParser} to convert HTML5 documents back into their original POJOs:
+ </p>
+ <p class='bcode'>
+ <jc>// Get an HTML parser to convert our generated HTML5 documents back into POJOs.</jc>
+ HtmlParser p = HtmlParser.<jsf>DEFAULT</jsf>;
+
+ <jc>// Convert an HTML table back into a Table object.</jc>
+ Table table = p.parse(tableHtml, Table.<jk>class</jk>);
+ </p>
+ <p>
+ HTML5 objects can also be constructed from the other media types using the appropriate parsers.
+ </p>
+ </div>
+
+</div>
+<p align="center"><i><b>*** f�n ***</b></i></p>
+
</body>
</html>
\ 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/html/HtmlDocSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializer.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializer.java
index 7a4d6dd..badac2a 100644
--- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializer.java
@@ -101,9 +101,9 @@ public class HtmlDocSerializer extends HtmlStrippedDocSerializer {
title = "Options";
String description = s.getDescription();
if (title != null)
- w.oTag(1, "h3").attr("class", "title").append('>').encodeText(title).eTag("h3").nl();
+ w.oTag(1, "h3").attr("class", "title").append('>').text(title).eTag("h3").nl();
if (description != null)
- w.oTag(1, "h5").attr("class", "description").append('>').encodeText(description).eTag("h5").nl();
+ w.oTag(1, "h5").attr("class", "description").append('>').text(description).eTag("h5").nl();
// Write the action links that render above the results.
List<Link> actions = new LinkedList<Link>();
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/html/HtmlParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlParser.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlParser.java
index f2fd9e0..4afe08c 100644
--- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlParser.java
@@ -13,7 +13,7 @@
package org.apache.juneau.html;
import static javax.xml.stream.XMLStreamConstants.*;
-import static org.apache.juneau.html.HtmlParser.Tag.*;
+import static org.apache.juneau.html.HtmlTag.*;
import static org.apache.juneau.internal.StringUtils.*;
import java.lang.reflect.*;
@@ -93,12 +93,12 @@ public final class HtmlParser extends XmlParser {
Object o = null;
boolean isValid = true;
- Tag tag = (event == CHARACTERS ? null : Tag.forString(r.getName().getLocalPart(), false));
+ HtmlTag tag = (event == CHARACTERS ? null : HtmlTag.forString(r.getName().getLocalPart(), false));
if (isEmpty) {
o = "";
- } else if (tag == null || tag.isOneOf(BR,BS,TB,FF)) {
- String text = parseCharacters(session, r);
+ } else if (tag == null || tag.isOneOf(BR,BS,FF,SP)) {
+ String text = session.parseText(r);
if (sType.isObject() || sType.isCharSequence())
o = text;
else if (sType.isChar())
@@ -115,7 +115,7 @@ public final class HtmlParser extends XmlParser {
isValid = false;
} else if (tag == STRING) {
- String text = parseElementText(session, r);
+ String text = session.getElementText(r);
if (sType.isObject() || sType.isCharSequence())
o = text;
else if (sType.isChar())
@@ -129,7 +129,7 @@ public final class HtmlParser extends XmlParser {
skipTag(r, xSTRING);
} else if (tag == NUMBER) {
- String text = parseElementText(session, r);
+ String text = session.getElementText(r);
if (sType.isObject())
o = parseNumber(text, Number.class);
else if (sType.isNumber())
@@ -141,7 +141,7 @@ public final class HtmlParser extends XmlParser {
skipTag(r, xNUMBER);
} else if (tag == BOOLEAN) {
- String text = parseElementText(session, r);
+ String text = session.getElementText(r);
if (sType.isObject() || sType.isBoolean())
o = Boolean.parseBoolean(text);
else
@@ -245,7 +245,7 @@ public final class HtmlParser extends XmlParser {
*/
private <T> T parseAnchor(HtmlParserSession session, XMLStreamReader r, ClassMeta<T> beanType) throws XMLStreamException {
String href = r.getAttributeValue(null, "href");
- String name = parseElementText(session, r);
+ String name = session.getElementText(r);
Class<T> beanClass = beanType.getInnerClass();
if (beanClass.isAnnotationPresent(HtmlLink.class)) {
HtmlLink h = beanClass.getAnnotation(HtmlLink.class);
@@ -271,23 +271,22 @@ public final class HtmlParser extends XmlParser {
*/
private <K,V> Map<K,V> parseIntoMap(HtmlParserSession session, XMLStreamReader r, Map<K,V> m, ClassMeta<K> keyType, ClassMeta<V> valueType, BeanPropertyMeta pMeta) throws Exception {
while (true) {
- Tag tag = nextTag(r, TR, xTABLE);
+ HtmlTag tag = nextTag(r, TR, xTABLE);
if (tag == xTABLE)
break;
tag = nextTag(r, TD, TH);
// Skip over the column headers.
if (tag == TH) {
- skipElementText(r);
- nextTag(r, TH);
- skipElementText(r);
- nextTag(r, xTR);
- continue;
+ skipTag(r);
+ r.nextTag();
+ skipTag(r);
+ } else {
+ K key = parseAnything(session, keyType, r, m, false, pMeta);
+ nextTag(r, TD);
+ V value = parseAnything(session, valueType, r, m, false, pMeta);
+ setName(valueType, value, key);
+ m.put(key, value);
}
- K key = parseAnything(session, keyType, r, m, false, pMeta);
- nextTag(r, TD);
- V value = parseAnything(session, valueType, r, m, false, pMeta);
- setName(valueType, value, key);
- m.put(key, value);
nextTag(r, xTR);
}
@@ -301,7 +300,7 @@ public final class HtmlParser extends XmlParser {
*/
private <E> Collection<E> parseIntoCollection(HtmlParserSession session, XMLStreamReader r, Collection<E> l, ClassMeta<E> elementType, BeanPropertyMeta pMeta) throws Exception {
while (true) {
- Tag tag = nextTag(r, LI, xUL);
+ HtmlTag tag = nextTag(r, LI, xUL);
if (tag == xUL)
break;
l.add(parseAnything(session, elementType, r, l, false, pMeta));
@@ -318,7 +317,7 @@ public final class HtmlParser extends XmlParser {
Object[] o = new Object[argTypes.length];
int i = 0;
while (true) {
- Tag tag = nextTag(r, LI, xUL);
+ HtmlTag tag = nextTag(r, LI, xUL);
if (tag == xUL)
break;
o[i] = parseAnything(session, argTypes[i], r, session.getOuter(), false, null);
@@ -338,18 +337,18 @@ public final class HtmlParser extends XmlParser {
elementType = (ClassMeta<E>)object();
BeanRegistry breg = (pMeta == null ? session.getBeanRegistry() : pMeta.getBeanRegistry());
- Tag tag = nextTag(r, TR);
+ HtmlTag tag = nextTag(r, TR);
List<String> keys = new ArrayList<String>();
while (true) {
tag = nextTag(r, TH, xTR);
if (tag == xTR)
break;
- keys.add(parseElementText(session, r));
+ keys.add(session.getElementText(r));
}
while (true) {
r.nextTag();
- tag = Tag.forEvent(r);
+ tag = HtmlTag.forEvent(r);
if (tag == xTABLE)
break;
@@ -419,34 +418,33 @@ public final class HtmlParser extends XmlParser {
*/
private <T> BeanMap<T> parseIntoBean(HtmlParserSession session, XMLStreamReader r, BeanMap<T> m) throws Exception {
while (true) {
- Tag tag = nextTag(r, TR, xTABLE);
+ HtmlTag tag = nextTag(r, TR, xTABLE);
if (tag == xTABLE)
break;
tag = nextTag(r, TD, TH);
// Skip over the column headers.
if (tag == TH) {
- skipElementText(r);
- nextTag(r, TH);
- skipElementText(r);
- nextTag(r, xTR);
- continue;
- }
- String key = parseElementText(session, r);
- nextTag(r, TD);
- BeanPropertyMeta pMeta = m.getPropertyMeta(key);
- if (pMeta == null) {
- if (m.getMeta().isSubTyped()) {
- Object value = parseAnything(session, object(), r, m.getBean(false), false, null);
- m.put(key, value);
+ skipTag(r);
+ r.nextTag();
+ skipTag(r);
+ } else {
+ String key = session.getElementText(r);
+ nextTag(r, TD);
+ BeanPropertyMeta pMeta = m.getPropertyMeta(key);
+ if (pMeta == null) {
+ if (m.getMeta().isSubTyped()) {
+ Object value = parseAnything(session, object(), r, m.getBean(false), false, null);
+ m.put(key, value);
+ } else {
+ onUnknownProperty(session, key, m, -1, -1);
+ parseAnything(session, object(), r, null, false, null);
+ }
} else {
- onUnknownProperty(session, key, m, -1, -1);
- parseAnything(session, object(), r, null, false, null);
+ ClassMeta<?> cm = pMeta.getClassMeta();
+ Object value = parseAnything(session, cm, r, m.getBean(false), false, pMeta);
+ setName(cm, value, key);
+ pMeta.set(m, value);
}
- } else {
- ClassMeta<?> cm = pMeta.getClassMeta();
- Object value = parseAnything(session, cm, r, m.getBean(false), false, pMeta);
- setName(cm, value, key);
- pMeta.set(m, value);
}
nextTag(r, xTR);
}
@@ -454,195 +452,6 @@ public final class HtmlParser extends XmlParser {
}
- /*
- * Parse until the next event is an end tag.
- */
- private String parseCharacters(HtmlParserSession session, XMLStreamReader r) throws XMLStreamException {
-
- StringBuilder sb = session.getStringBuilder();
-
- int et = r.getEventType();
- int depth = (et == START_ELEMENT ? 1 : et == END_ELEMENT ? -1 : 0);
-
- while (depth >= 0) {
- if (et == START_ELEMENT) {
- Tag tag = Tag.forEvent(r);
- if (tag == BR) {
- sb.append("\n");
- } else if (tag == BS) {
- sb.append("\b");
- } else if (tag == TB) {
- sb.append("\t");
- r.next();
- } else if (tag == FF) {
- sb.append("\f");
- } else if (! tag.isOneOf(STRING, NUMBER, BOOLEAN)) {
- sb.append('<').append(r.getLocalName());
- for (int i = 0; i < r.getAttributeCount(); i++)
- sb.append(' ').append(r.getAttributeName(i)).append('=').append('\'').append(r.getAttributeValue(i)).append('\'');
- sb.append('>');
- }
- } else if (et == END_ELEMENT) {
- Tag tag = Tag.forEvent(r);
- if (! tag.isOneOf(xBR, xBS, xTB, xFF, xSTRING, xNUMBER, xBOOLEAN)) {
- sb.append('<').append(r.getLocalName()).append('>');
- }
- } else if (et == CHARACTERS && ! r.isWhiteSpace()) {
- sb.append(r.getText().trim());
- }
- et = r.next();
- if (et == START_ELEMENT)
- depth++;
- else if (et == END_ELEMENT)
- depth--;
- }
-
- String s = sb.toString();
- session.returnStringBuilder(sb);
- return s;
- }
-
- private void skipCharacters(XMLStreamReader r) throws XMLStreamException {
-
- int et = r.getEventType();
-
- int depth = (et == START_ELEMENT ? 1 : et == END_ELEMENT ? -1 : 0);
- while (depth >= 0) {
- et = r.next();
- if (et == START_ELEMENT)
- depth++;
- else if (et == END_ELEMENT)
- depth--;
- }
- }
-
- /*
- * Reads the element text of the current element, accounting for <a> and <br> tags.
- * Precondition: Must be pointing at parent START_ELEMENT tag.
- * Postcondition: Pointing at next START_ELEMENT or END_DOCUMENT event.
- */
- private String parseElementText(HtmlParserSession session, XMLStreamReader r/*, Tag endTag*/) throws XMLStreamException {
- r.next();
- return parseCharacters(session, r);
- }
-
- private void skipElementText(XMLStreamReader r) throws XMLStreamException {
- r.next();
- skipCharacters(r);
- }
-
- enum Tag {
-
- TABLE(1,"<table>"),
- TR(2,"<tr>"),
- TH(3,"<th>"),
- TD(4,"<td>"),
- UL(5,"<ul>"),
- LI(6,"<li>"),
- STRING(7,"<string>"),
- NUMBER(8,"<number>"),
- BOOLEAN(9,"<boolean>"),
- NULL(10,"<null>"),
- A(11,"<a>"),
- BR(12,"<br>"), // newline
- FF(13,"<ff>"), // formfeed
- BS(14,"<bs>"), // backspace
- TB(15,"<tb>"), // tab
- xTABLE(-1,"</table>"),
- xTR(-2,"</tr>"),
- xTH(-3,"</th>"),
- xTD(-4,"</td>"),
- xUL(-5,"</ul>"),
- xLI(-6,"</li>"),
- xSTRING(-7,"</string>"),
- xNUMBER(-8,"</number>"),
- xBOOLEAN(-9,"</boolean>"),
- xNULL(-10,"</null>"),
- xA(-11,"</a>"),
- xBR(-12,"</br>"),
- xFF(-13,"</ff>"),
- xBS(-14,"</bs>"),
- xTB(-15,"</tb>");
-
- private Map<Integer,Tag> cache = new HashMap<Integer,Tag>();
-
- int id;
- String label;
-
- Tag(int id, String label) {
- this.id = id;
- this.label = label;
- cache.put(id, this);
- }
-
- static Tag forEvent(XMLStreamReader r) throws XMLStreamException {
- int et = r.getEventType();
- if (et == START_ELEMENT)
- return forString(r.getLocalName(), false);
- else if (et == END_ELEMENT)
- return forString(r.getLocalName(), true);
- throw new XMLStreamException("Invalid call to Tag.forEvent on event of type ["+et+"]");
- }
-
- private static Tag forString(String tag, boolean end) throws XMLStreamException {
- char c = tag.charAt(0);
- Tag t = null;
- if (c == 'u')
- t = (end ? xUL : UL);
- else if (c == 'l')
- t = (end ? xLI : LI);
- else if (c == 's')
- t = (end ? xSTRING : STRING);
- else if (c == 'b') {
- c = tag.charAt(1);
- if (c == 'o')
- t = (end ? xBOOLEAN : BOOLEAN);
- else if (c == 'r')
- t = (end ? xBR : BR);
- else if (c == 's')
- t = (end ? xBS : BS);
- }
- else if (c == 'a')
- t = (end ? xA : A);
- else if (c == 'n') {
- c = tag.charAt(2);
- if (c == 'm')
- t = (end ? xNUMBER : NUMBER);
- else if (c == 'l')
- t = (end ? xNULL : NULL);
- }
- else if (c == 't') {
- c = tag.charAt(1);
- if (c == 'a')
- t = (end ? xTABLE : TABLE);
- else if (c == 'r')
- t = (end ? xTR : TR);
- else if (c == 'h')
- t = (end ? xTH : TH);
- else if (c == 'd')
- t = (end ? xTD : TD);
- else if (c == 'b')
- t = (end ? xTB : TB);
- }
- else if (c == 'f')
- t = (end ? xFF : FF);
- if (t == null)
- throw new XMLStreamException("Unknown tag '"+tag+"' encountered");
- return t;
- }
-
- @Override /* Object */
- public String toString() {
- return label;
- }
-
- public boolean isOneOf(Tag...tags) {
- for (Tag tag : tags)
- if (tag == this)
- return true;
- return false;
- }
- }
/*
* Reads the next tag. Advances past anything that's not a start or end tag. Throws an exception if
@@ -650,7 +459,7 @@ public final class HtmlParser extends XmlParser {
* Precondition: Must be pointing before the event we want to parse.
* Postcondition: Pointing at the tag just parsed.
*/
- private Tag nextTag(XMLStreamReader r, Tag...expected) throws XMLStreamException {
+ private HtmlTag nextTag(XMLStreamReader r, HtmlTag...expected) throws XMLStreamException {
int et = r.next();
while (et != START_ELEMENT && et != END_ELEMENT && et != END_DOCUMENT)
@@ -659,25 +468,58 @@ public final class HtmlParser extends XmlParser {
if (et == END_DOCUMENT)
throw new XMLStreamException("Unexpected end of document: " + r.getLocation());
- Tag tag = Tag.forEvent(r);
+ HtmlTag tag = HtmlTag.forEvent(r);
if (expected.length == 0)
return tag;
- for (Tag t : expected)
+ for (HtmlTag t : expected)
if (t == tag)
return tag;
throw new XMLStreamException("Unexpected tag: " + tag + ". Expected one of the following: " + JsonSerializer.DEFAULT.toString(expected), r.getLocation());
}
- private void skipTag(XMLStreamReader r, Tag...expected) throws XMLStreamException {
- Tag tag = Tag.forEvent(r);
+ /**
+ * Skips over the current element and advances to the next element.
+ * <p>
+ * Precondition: Pointing to opening tag.
+ * Postcondition: Pointing to next opening tag.
+ *
+ * @param r The stream being read from.
+ * @throws XMLStreamException
+ */
+ private void skipTag(XMLStreamReader r) throws XMLStreamException {
+ int et = r.getEventType();
+
+ if (et != START_ELEMENT)
+ throw new XMLStreamException("skipToNextTag() call on invalid event ["+XmlUtils.toReadableEvent(r)+"]. Must only be called on START_ELEMENT events.");
+
+ String n = r.getLocalName();
+
+ int depth = 0;
+ while (true) {
+ et = r.next();
+ if (et == START_ELEMENT) {
+ String n2 = r.getLocalName();
+ if (n.equals(n2))
+ depth++;
+ } else if (et == END_ELEMENT) {
+ String n2 = r.getLocalName();
+ if (n.equals(n2))
+ depth--;
+ if (depth < 0)
+ return;
+ }
+ }
+ }
+
+ private void skipTag(XMLStreamReader r, HtmlTag...expected) throws XMLStreamException {
+ HtmlTag tag = HtmlTag.forEvent(r);
if (tag.isOneOf(expected))
r.next();
else
throw new XMLStreamException("Unexpected tag: " + tag + ". Expected one of the following: " + JsonSerializer.DEFAULT.toString(expected), r.getLocation());
}
-
private int skipWs(XMLStreamReader r) throws XMLStreamException {
int event = r.getEventType();
while (event != START_ELEMENT && event != END_ELEMENT && event != END_DOCUMENT && r.isWhiteSpace())
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/html/HtmlParserSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlParserSession.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlParserSession.java
index 5d3c3bf..95febd7 100644
--- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlParserSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlParserSession.java
@@ -12,6 +12,9 @@
// ***************************************************************************************************************************
package org.apache.juneau.html;
+import static javax.xml.stream.XMLStreamConstants.*;
+import static org.apache.juneau.html.HtmlTag.*;
+
import java.io.*;
import java.lang.reflect.*;
import java.util.*;
@@ -19,6 +22,7 @@ import java.util.*;
import javax.xml.stream.*;
import org.apache.juneau.*;
+import org.apache.juneau.internal.*;
import org.apache.juneau.xml.*;
/**
@@ -29,6 +33,11 @@ import org.apache.juneau.xml.*;
public final class HtmlParserSession extends XmlParserSession {
private XMLEventReader xmlEventReader;
+ private static final Set<String> whitespaceElements = new HashSet<String>(
+ Arrays.asList(
+ new String[]{"br","bs","sp","ff"}
+ )
+ );
/**
* Create a new session using properties specified in the context.
@@ -56,6 +65,144 @@ public final class HtmlParserSession extends XmlParserSession {
super(ctx, op, input, javaMethod, outer, locale, timeZone);
}
+ /**
+ * Parses CHARACTERS data.
+ * <p>
+ * Precondition: Pointing to event immediately following opening tag.
+ * Postcondition: Pointing to closing tag.
+ *
+ * @param r The stream being read from.
+ * @return The parsed string.
+ * @throws XMLStreamException
+ */
+ @Override /* XmlParserSession */
+ public String parseText(XMLStreamReader r) throws XMLStreamException {
+
+ StringBuilder sb = getStringBuilder();
+
+ int et = r.getEventType();
+ if (et == END_ELEMENT)
+ return "";
+
+ int depth = 0;
+
+ String characters = null;
+
+ while (true) {
+ if (et == START_ELEMENT) {
+ if (characters != null) {
+ if (sb.length() == 0)
+ characters = StringUtils.trimStart(characters);
+ sb.append(characters);
+ characters = null;
+ }
+ HtmlTag tag = HtmlTag.forEvent(r);
+ if (tag == BR) {
+ sb.append('\n');
+ r.nextTag();
+ } else if (tag == BS) {
+ sb.append('\b');
+ r.nextTag();
+ } else if (tag == SP) {
+ et = r.next();
+ if (et == CHARACTERS) {
+ String s = r.getText();
+ if (s.length() > 0) {
+ char c = r.getText().charAt(0);
+ if (c == '\u2003')
+ c = '\t';
+ sb.append(c);
+ }
+ r.nextTag();
+ }
+ } else if (tag == FF) {
+ sb.append('\f');
+ r.nextTag();
+ } else if (tag.isOneOf(STRING, NUMBER, BOOLEAN)) {
+ et = r.next();
+ if (et == CHARACTERS) {
+ sb.append(r.getText());
+ r.nextTag();
+ }
+ } else {
+ sb.append('<').append(r.getLocalName());
+ for (int i = 0; i < r.getAttributeCount(); i++)
+ sb.append(' ').append(r.getAttributeName(i)).append('=').append('\'').append(r.getAttributeValue(i)).append('\'');
+ sb.append('>');
+ depth++;
+ }
+ } else if (et == END_ELEMENT) {
+ if (characters != null) {
+ if (sb.length() == 0)
+ characters = StringUtils.trimStart(characters);
+ if (depth == 0)
+ characters = StringUtils.trimEnd(characters);
+ sb.append(characters);
+ characters = null;
+ }
+ if (depth == 0)
+ break;
+ sb.append('<').append(r.getLocalName()).append('>');
+ depth--;
+ } else if (et == CHARACTERS) {
+ characters = r.getText();
+ }
+ et = r.next();
+ }
+
+ String s = trim(sb.toString());
+ returnStringBuilder(sb);
+ return s;
+ }
+
+ /**
+ * Identical to {@link #parseText(XMLStreamReader)} except assumes the current event
+ * is the opening tag.
+ * <p>
+ * Precondition: Pointing to opening tag.
+ * Postcondition: Pointing to closing tag.
+ *
+ * @param r The stream being read from.
+ * @return The parsed string.
+ * @throws XMLStreamException
+ */
+ @Override /* XmlParserSession */
+ public String getElementText(XMLStreamReader r) throws XMLStreamException {
+ r.next();
+ return parseText(r);
+ }
+
+ @Override /* XmlParserSession */
+ public boolean isWhitespaceElement(XMLStreamReader r) {
+ String s = r.getLocalName();
+ return whitespaceElements.contains(s);
+ }
+
+ @Override /* XmlParserSession */
+ public String parseWhitespaceElement(XMLStreamReader r) throws XMLStreamException {
+
+ HtmlTag tag = HtmlTag.forEvent(r);
+ int et = r.next();
+ if (tag == BR) {
+ return "\n";
+ } else if (tag == BS) {
+ return "\b";
+ } else if (tag == FF) {
+ return "\f";
+ } else if (tag == SP) {
+ if (et == CHARACTERS) {
+ String s = r.getText();
+ if (s.charAt(0) == '\u2003')
+ s = "\t";
+ r.next();
+ return decodeString(s);
+ }
+ return "";
+ } else {
+ throw new XMLStreamException("Invalid tag found in parseWhitespaceElement(): " + tag);
+ }
+ }
+
@Override /* ParserSession */
public boolean close() {
if (super.close()) {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializer.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializer.java
index adcb891..b835030 100644
--- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializer.java
@@ -237,7 +237,7 @@ public class HtmlSerializer extends XmlSerializer {
HtmlClassMeta html = sType.getExtendedMeta(HtmlClassMeta.class);
if (html.isAsXml() || (pMeta != null && pMeta.getExtendedMeta(HtmlBeanPropertyMeta.class).isAsXml())) {
- super.serializeAnything(session, out, o, null, null, null, false, XmlFormat.MIXED, false, null);
+ super.serializeAnything(session, out, o, null, null, null, false, XmlFormat.MIXED, false, false, null);
} else if (html.isAsPlainText() || (pMeta != null && pMeta.getExtendedMeta(HtmlBeanPropertyMeta.class).isAsPlainText())) {
out.write(o == null ? "null" : o.toString());
@@ -279,7 +279,7 @@ public class HtmlSerializer extends XmlSerializer {
HtmlLink h = o.getClass().getAnnotation(HtmlLink.class);
Object urlProp = m.get(h.hrefProperty());
Object nameProp = m.get(h.nameProperty());
- out.oTag("a").attrUri("href", urlProp).append('>').encodeText(nameProp).eTag("a");
+ out.oTag("a").attrUri("href", urlProp).append('>').text(nameProp).eTag("a");
cr = CR_SIMPLE;
} else {
out.nlIf(! isRoot);
@@ -299,9 +299,9 @@ public class HtmlSerializer extends XmlSerializer {
} else {
if (isRoot)
- out.sTag("string").encodeText(session.toString(o)).eTag("string");
+ out.sTag("string").text(session.toString(o)).eTag("string");
else
- out.encodeText(session.toString(o));
+ out.text(session.toString(o));
cr = CR_SIMPLE;
}
}
@@ -398,7 +398,7 @@ public class HtmlSerializer extends XmlSerializer {
continue;
out.sTag(i+1, "tr").nl();
- out.sTag(i+2, "td").encodeText(key).eTag("td").nl();
+ out.sTag(i+2, "td").text(key).eTag("td").nl();
out.sTag(i+2, "td");
try {
ContentResult cr = serializeAnything(session, out, value, cMeta, key, 2, pMeta, false);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/html/HtmlTag.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlTag.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlTag.java
new file mode 100644
index 0000000..efa36e2
--- /dev/null
+++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlTag.java
@@ -0,0 +1,140 @@
+// ***************************************************************************************************************************
+// * 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.html;
+
+import static javax.xml.stream.XMLStreamConstants.*;
+
+import java.util.*;
+
+import javax.xml.stream.*;
+
+import org.apache.juneau.xml.*;
+
+/**
+ * Predefined tags that occur in the serialized output of the HTML serializer.
+ */
+enum HtmlTag {
+
+ TABLE(1,"<table>"),
+ TR(2,"<tr>"),
+ TH(3,"<th>"),
+ TD(4,"<td>"),
+ UL(5,"<ul>"),
+ LI(6,"<li>"),
+ STRING(7,"<string>"),
+ NUMBER(8,"<number>"),
+ BOOLEAN(9,"<boolean>"),
+ NULL(10,"<null>"),
+ A(11,"<a>"),
+ BR(12,"<br>"), // newline
+ FF(13,"<ff>"), // formfeed
+ BS(14,"<bs>"), // backspace
+ SP(17, "<sp>"), // space
+ xTABLE(-1,"</table>"),
+ xTR(-2,"</tr>"),
+ xTH(-3,"</th>"),
+ xTD(-4,"</td>"),
+ xUL(-5,"</ul>"),
+ xLI(-6,"</li>"),
+ xSTRING(-7,"</string>"),
+ xNUMBER(-8,"</number>"),
+ xBOOLEAN(-9,"</boolean>"),
+ xNULL(-10,"</null>"),
+ xA(-11,"</a>"),
+ xBR(-12,"</br>"),
+ xFF(-13,"</ff>"),
+ xBS(-14,"</bs>"),
+ xSP(-17, "</sp>");
+
+ private Map<Integer,HtmlTag> cache = new HashMap<Integer,HtmlTag>();
+
+ int id;
+ String label;
+
+ HtmlTag(int id, String label) {
+ this.id = id;
+ this.label = label;
+ cache.put(id, this);
+ }
+
+ static HtmlTag forEvent(XMLStreamReader r) throws XMLStreamException {
+ int et = r.getEventType();
+ if (et == START_ELEMENT)
+ return forString(r.getLocalName(), false);
+ else if (et == END_ELEMENT)
+ return forString(r.getLocalName(), true);
+ throw new XMLStreamException("Invalid call to HtmlTag.forEvent on event of type ["+XmlUtils.toReadableEvent(r)+"]");
+ }
+
+ static HtmlTag forString(String tag, boolean end) throws XMLStreamException {
+ char c = tag.charAt(0);
+ HtmlTag t = null;
+ if (c == 'u')
+ t = (end ? xUL : UL);
+ else if (c == 'l')
+ t = (end ? xLI : LI);
+ else if (c == 's') {
+ c = tag.charAt(1);
+ if (c == 'p')
+ t = (end ? xSP : SP);
+ else if (c == 't')
+ t = (end ? xSTRING : STRING);
+ }
+ else if (c == 'b') {
+ c = tag.charAt(1);
+ if (c == 'o')
+ t = (end ? xBOOLEAN : BOOLEAN);
+ else if (c == 'r')
+ t = (end ? xBR : BR);
+ else if (c == 's')
+ t = (end ? xBS : BS);
+ }
+ else if (c == 'a')
+ t = (end ? xA : A);
+ else if (c == 'n') {
+ c = tag.charAt(2);
+ if (c == 'm')
+ t = (end ? xNUMBER : NUMBER);
+ else if (c == 'l')
+ t = (end ? xNULL : NULL);
+ }
+ else if (c == 't') {
+ c = tag.charAt(1);
+ if (c == 'a')
+ t = (end ? xTABLE : TABLE);
+ else if (c == 'r')
+ t = (end ? xTR : TR);
+ else if (c == 'h')
+ t = (end ? xTH : TH);
+ else if (c == 'd')
+ t = (end ? xTD : TD);
+ }
+ else if (c == 'f')
+ t = (end ? xFF : FF);
+ if (t == null)
+ throw new XMLStreamException("Unknown tag '"+tag+"' encountered");
+ return t;
+ }
+
+ @Override /* Object */
+ public String toString() {
+ return label;
+ }
+
+ public boolean isOneOf(HtmlTag...tags) {
+ for (HtmlTag tag : tags)
+ if (tag == this)
+ return true;
+ return false;
+ }
+}
\ 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/html/HtmlWriter.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlWriter.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlWriter.java
index 5da552e..3a2a810 100644
--- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlWriter.java
+++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlWriter.java
@@ -14,6 +14,7 @@ package org.apache.juneau.html;
import java.io.*;
+import org.apache.juneau.internal.*;
import org.apache.juneau.xml.*;
/**
@@ -54,9 +55,18 @@ public class HtmlWriter extends XmlWriter {
//--------------------------------------------------------------------------------
@Override /* XmlSerializerWriter */
- public HtmlWriter encodeText(Object o) throws IOException {
+ public HtmlWriter text(Object o, boolean preserveWhitespace) throws IOException {
+ if (o == null) {
+ append("<null/>");
+ return this;
+ }
String s = o.toString();
+ if (s.isEmpty()) {
+ append("<sp/>");
+ return this;
+ }
+
for (int i = 0; i < s.length(); i++) {
char test = s.charAt(i);
if (test == '&')
@@ -66,13 +76,21 @@ public class HtmlWriter extends XmlWriter {
else if (test == '>')
append(">");
else if (test == '\n')
- append("<br/>");
+ append(preserveWhitespace ? "\n" : "<br/>");
else if (test == '\f') // XML 1.0 doesn't support formfeeds or backslashes, so we have to invent something.
- append("<ff/>");
+ append(preserveWhitespace ? "\f" : "<ff/>");
else if (test == '\b')
- append("<bs/>");
+ append(preserveWhitespace ? "\b" : "<bs/>");
else if (test == '\t')
- append("<tb> </tb>");
+ append(preserveWhitespace ? "\t" : "<sp> </sp>");
+ else if ((i == 0 || i == s.length()-1) && Character.isWhitespace(test)) {
+ if (preserveWhitespace)
+ append(test);
+ else if (test == ' ')
+ append("<sp> </sp>");
+ else
+ append("<sp>&#x").append(StringUtils.toHex(test)).append(";</sp>");
+ }
else if (Character.isISOControl(test))
append("&#" + (int) test + ";");
else
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/internal/StringUtils.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/internal/StringUtils.java b/juneau-core/src/main/java/org/apache/juneau/internal/StringUtils.java
index 6d3811d..cd2a76b 100644
--- a/juneau-core/src/main/java/org/apache/juneau/internal/StringUtils.java
+++ b/juneau-core/src/main/java/org/apache/juneau/internal/StringUtils.java
@@ -647,6 +647,25 @@ public final class StringUtils {
}
/**
+ * Converts the specified number into a 4 hexadecimal characters.
+ *
+ * @param num The number to convert to hex.
+ * @return A <code><jk>char</jk>[4]</code> containing the specified characters.
+ */
+ public static final char[] toHex(int num) {
+ char[] n = new char[4];
+ int a = num%16;
+ n[3] = (char)(a > 9 ? 'A'+a-10 : '0'+a);
+ int base = 16;
+ for (int i = 1; i < 4; i++) {
+ a = (num/base)%16;
+ base <<= 4;
+ n[3-i] = (char)(a > 9 ? 'A'+a-10 : '0'+a);
+ }
+ return n;
+ }
+
+ /**
* Tests two strings for equality, but gracefully handles nulls.
*
* @param s1 String 1.
@@ -1069,4 +1088,30 @@ public final class StringUtils {
sb.append(pattern);
return sb.toString();
}
+
+ /**
+ * Trims whitespace characters from the beginning of the specified string.
+ *
+ * @param s The string to trim.
+ * @return The trimmed string, or <jk>null</jk> if the string was <jk>null</jk>.
+ */
+ public static String trimStart(String s) {
+ if (s != null)
+ while (s.length() > 0 && Character.isWhitespace(s.charAt(0)))
+ s = s.substring(1);
+ return s;
+ }
+
+ /**
+ * Trims whitespace characters from the end of the specified string.
+ *
+ * @param s The string to trim.
+ * @return The trimmed string, or <jk>null</jk> if the string was <jk>null</jk>.
+ */
+ public static String trimEnd(String s) {
+ if (s != null)
+ while (s.length() > 0 && Character.isWhitespace(s.charAt(s.length()-1)))
+ s = s.substring(0, s.length()-1);
+ return s;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerWriter.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerWriter.java b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerWriter.java
index 2460e88..115608b 100644
--- a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerWriter.java
+++ b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerWriter.java
@@ -39,7 +39,7 @@ public class SerializerWriter extends Writer {
/** Use-whitespace flag. */
protected final boolean useWhitespace;
- /** Use-whitespace flag. */
+ /** Trim strings flag. */
protected final boolean trimStrings;
/** The quote character being used by this writer. */
@@ -186,6 +186,19 @@ public class SerializerWriter extends Writer {
}
/**
+ * Appends the specified characters to this writer.
+ *
+ * @param characters The characters to append to this writer.
+ * @return This object (for method chaining).
+ * @throws IOException
+ */
+ public SerializerWriter append(char[] characters) throws IOException {
+ for (char c : characters)
+ append(c);
+ return this;
+ }
+
+ /**
* Adds a whitespace character to the output if the {@code useWhitespace} setting is enabled.
*
* @return This object (for method chaining).
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializer.java b/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializer.java
index e51f8f9..26f8357 100644
--- a/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializer.java
@@ -90,4 +90,15 @@ public abstract class WriterSerializer extends Serializer {
public final StringObject toStringObject(Object o) {
return new StringObject(this, o);
}
+
+ /**
+ * Convenience method for serializing an object and sending it to STDOUT.
+ *
+ * @param o The object to serialize.
+ * @return This object (for method chaining).
+ */
+ public final WriterSerializer println(Object o) {
+ System.out.println(toString(o));
+ return this;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/21c0e1ea/juneau-core/src/main/java/org/apache/juneau/xml/XmlBeanMeta.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlBeanMeta.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlBeanMeta.java
index 6ffbdf4..4e69c54 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlBeanMeta.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlBeanMeta.java
@@ -41,7 +41,7 @@ public class XmlBeanMeta extends BeanMetaExtended {
Class<?> c = beanMeta.getClassMeta().getInnerClass();
Xml xml = c.getAnnotation(Xml.class);
XmlFormat defaultFormat = null;
- XmlFormat _contentFormat = null;
+ XmlFormat _contentFormat = DEFAULT;
if (xml != null) {
XmlFormat xf = xml.format();
@@ -78,8 +78,8 @@ public class XmlBeanMeta extends BeanMetaExtended {
if (! pcm.isMapOrBean())
throw new BeanRuntimeException(c, "Invalid type for ATTRS property. Only properties of type Map and bean can be used.");
_attrsProperty = p;
- } else if (xf.isOneOf(ELEMENTS, MIXED, TEXT, XMLTEXT)) {
- if (xf.isOneOf(ELEMENTS, MIXED) && ! pcm.isCollectionOrArray())
+ } else if (xf.isOneOf(ELEMENTS, MIXED, MIXED_PWS, TEXT, TEXT_PWS, XMLTEXT)) {
+ if (xf.isOneOf(ELEMENTS, MIXED, MIXED_PWS) && ! pcm.isCollectionOrArray())
throw new BeanRuntimeException(c, "Invalid type for {0} property. Only properties of type Collection and array can be used.", xf);
if (_contentProperty != null) {
if (xf == _contentFormat)
@@ -217,7 +217,9 @@ public class XmlBeanMeta extends BeanMetaExtended {
* <ul>
* <li>{@link XmlFormat#ELEMENTS}
* <li>{@link XmlFormat#MIXED}
+ * <li>{@link XmlFormat#MIXED_PWS}
* <li>{@link XmlFormat#TEXT}
+ * <li>{@link XmlFormat#TEXT_PWS}
* <li>{@link XmlFormat#XMLTEXT}
* <li><jk>null</jk>
*
[6/6] incubator-juneau git commit: Continuation of HTML5 support.
Posted by ja...@apache.org.
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 <ja...@apache.org>
Authored: Sun Jan 29 20:51:52 2017 -0500
Committer: JamesBognar <ja...@apache.org>
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("\u0625\u064a\u0627\u0646"), "bar"),
+ "<p>foo<bdi>\u0625\u064a\u0627\u0646</bdi>bar</p>",
+ "<p>foo<bdi>\u0625\u064a\u0627\u0646</bdi>bar</p>\n",
+ "<p>foo<bdi>\u0625\u064a\u0627\u0646</bdi>bar</p>",
+ "<p>foo<bdi>\u0625\u064a\u0627\u0646</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(
+ "\u6cd5",rb("\u83ef"),"\u7d4c",rtc("\u304d",rp("\u3051"),"\u3087")
+ ),
+ "<ruby>\u6cd5<rb>\u83ef</rb>\u7d4c<rtc>\u304d<rp>\u3051</rp>\u3087</rtc></ruby>",
+ "<ruby>\u6cd5<rb>\u83ef</rb>\u7d4c<rtc>\u304d<rp>\u3051</rp>\u3087</rtc></ruby>\n",
+ "<ruby>\u6cd5<rb>\u83ef</rb>\u7d4c<rtc>\u304d<rp>\u3051</rp>\u3087</rtc></ruby>",
+ "<ruby>\u6cd5<rb>\u83ef</rb>\u7d4c<rtc>\u304d<rp>\u3051</rp>\u3087</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;
}
}