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/21 22:25:08 UTC
[09/21] incubator-juneau git commit: HTML and XML serialization
support improvements.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Title.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Title.java b/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Title.java
deleted file mode 100644
index ec91f06..0000000
--- a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Title.java
+++ /dev/null
@@ -1,23 +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.html.dto.proto;
-
-import org.apache.juneau.annotation.*;
-
-/**
- * DTO for an HTML <a href='https://www.w3.org/TR/html5/document-metadata.html#the-title-element'><title></a> element.
- * <p>
- */
-@Bean(typeName="title")
-public class Title extends HtmlElement {
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Tr.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Tr.java b/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Tr.java
deleted file mode 100644
index 35f356a..0000000
--- a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Tr.java
+++ /dev/null
@@ -1,23 +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.html.dto.proto;
-
-import org.apache.juneau.annotation.*;
-
-/**
- * DTO for an HTML <a href='https://www.w3.org/TR/html5/tabular-data.html#the-tr-element'><tr></a> element.
- * <p>
- */
-@Bean(typeName="tr")
-public class Tr extends HtmlElement {
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Track.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Track.java b/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Track.java
deleted file mode 100644
index de20de4..0000000
--- a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Track.java
+++ /dev/null
@@ -1,23 +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.html.dto.proto;
-
-import org.apache.juneau.annotation.*;
-
-/**
- * DTO for an HTML <a href='https://www.w3.org/TR/html5/embedded-content-0.html#the-track-element'><track></a> element.
- * <p>
- */
-@Bean(typeName="track")
-public class Track extends HtmlElement {
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/U.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/U.java b/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/U.java
deleted file mode 100644
index 83a7919..0000000
--- a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/U.java
+++ /dev/null
@@ -1,23 +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.html.dto.proto;
-
-import org.apache.juneau.annotation.*;
-
-/**
- * DTO for an HTML <a href='https://www.w3.org/TR/html5/text-level-semantics.html#the-u-element'><u></a> element.
- * <p>
- */
-@Bean(typeName="u")
-public class U extends HtmlElement {
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Ul.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Ul.java b/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Ul.java
deleted file mode 100644
index 1fe271e..0000000
--- a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Ul.java
+++ /dev/null
@@ -1,23 +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.html.dto.proto;
-
-import org.apache.juneau.annotation.*;
-
-/**
- * DTO for an HTML <a href='https://www.w3.org/TR/html5/grouping-content.html#the-ul-element'><ul></a> element.
- * <p>
- */
-@Bean(typeName="ul")
-public class Ul extends HtmlElement {
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Var.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Var.java b/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Var.java
deleted file mode 100644
index de7671f..0000000
--- a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Var.java
+++ /dev/null
@@ -1,23 +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.html.dto.proto;
-
-import org.apache.juneau.annotation.*;
-
-/**
- * DTO for an HTML <a href='https://www.w3.org/TR/html5/text-level-semantics.html#the-var-element'><var></a> element.
- * <p>
- */
-@Bean(typeName="var")
-public class Var extends HtmlElement {
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Video.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Video.java b/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Video.java
deleted file mode 100644
index b4471ec..0000000
--- a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Video.java
+++ /dev/null
@@ -1,23 +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.html.dto.proto;
-
-import org.apache.juneau.annotation.*;
-
-/**
- * DTO for an HTML <a href='https://www.w3.org/TR/html5/embedded-content-0.html#the-video-element'><video></a> element.
- * <p>
- */
-@Bean(typeName="video")
-public class Video extends HtmlElement {
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Wbr.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Wbr.java b/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Wbr.java
deleted file mode 100644
index 3a61a49..0000000
--- a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/Wbr.java
+++ /dev/null
@@ -1,23 +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.html.dto.proto;
-
-import org.apache.juneau.annotation.*;
-
-/**
- * DTO for an HTML <a href='https://www.w3.org/TR/html5/text-level-semantics.html#the-wbr-element'><wbr></a> element.
- * <p>
- */
-@Bean(typeName="wbr")
-public class Wbr extends HtmlElement {
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/package.html
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/package.html b/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/package.html
deleted file mode 100644
index a721d71..0000000
--- a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/package.html
+++ /dev/null
@@ -1,41 +0,0 @@
-<!DOCTYPE HTML>
-<!--
-/***************************************************************************************************************************
- * 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.
- *
- ***************************************************************************************************************************/
- -->
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <style type="text/css">
- /* For viewing in Page Designer */
- @IMPORT url("../../../../../../../javadoc.css");
-
- /* For viewing in REST interface */
- @IMPORT url("../htdocs/javadoc.css");
- body {
- margin: 20px;
- }
- </style>
- <script>
- /* Replace all @code and @link tags. */
- window.onload = function() {
- document.body.innerHTML = document.body.innerHTML.replace(/\{\@code ([^\}]+)\}/g, '<code>$1</code>');
- document.body.innerHTML = document.body.innerHTML.replace(/\{\@link (([^\}]+)\.)?([^\.\}]+)\}/g, '<code>$3</code>');
- }
- </script>
-</head>
-<body>
-<p>HTML Data Transfer Objects</p>
-</body>
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/temp.txt
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/temp.txt b/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/temp.txt
deleted file mode 100644
index 78a05e0..0000000
--- a/juneau-core/src/main/java/org/apache/juneau/html/dto/proto/temp.txt
+++ /dev/null
@@ -1,154 +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. *
-// ***************************************************************************************************************************
-a \u2013 hyperlink CHANGED
-abbr \u2013 abbreviation
-address \u2013 contact information
-area \u2013 image-map hyperlink
-article \u2013 article NEW
-aside \u2013 tangential content NEW
-audio \u2013 audio stream NEW
-b \u2013 offset text conventionally styled in bold CHANGED
-base \u2013 base URL
-bdi \u2013 BiDi isolate NEW
-bdo \u2013 BiDi override
-blockquote \u2013 block quotation
-body \u2013 document body
-br \u2013 line break
-button \u2013 button
-button type=submit \u2013 submit button
-button type=reset \u2013 reset button
-button type=button \u2013 button with no additional semantics
-canvas \u2013 canvas for dynamic graphics NEW
-caption \u2013 table title
-cite \u2013 cited title of a work CHANGED
-code \u2013 code fragment
-col \u2013 table column
-colgroup \u2013 table column group
-command \u2013 command NEW
-command type=command \u2013 command with an associated action NEW
-command type=radio \u2013 selection of one item from a list of items NEW
-command type=checkbox \u2013 state or option that can be toggled NEW
-datalist \u2013 predefined options for other controls NEW
-dd \u2013 description or value
-del \u2013 deleted text
-details \u2013 control for additional on-demand information NEW
-dfn \u2013 defining instance
-div \u2013 generic flow container
-dl \u2013 description list
-dt \u2013 term or name
-em \u2013 emphatic stress
-embed \u2013 integration point for plugins NEW
-fieldset \u2013 set of related form controls
-figcaption \u2013 figure caption NEW
-figure \u2013 figure with optional caption NEW
-footer \u2013 footer NEW
-form \u2013 user-submittable form
-h1 \u2013 heading
-h2 \u2013 heading
-h3 \u2013 heading
-h4 \u2013 heading
-h5 \u2013 heading
-h6 \u2013 heading
-head \u2013 document metadata container
-header \u2013 header NEW
-hgroup \u2013 heading group NEW
-hr \u2013 thematic break CHANGED
-html \u2013 root element
-i \u2013 offset text conventionally styled in italic CHANGED
-iframe \u2013 nested browsing context (inline frame)
-img \u2013 image
-input \u2013 input control CHANGED
-input type=text \u2013 text-input field
-input type=password \u2013 password-input field
-input type=checkbox \u2013 checkbox
-input type=radio \u2013 radio button
-input type=button \u2013 button
-input type=submit \u2013 submit button
-input type=reset \u2013 reset button
-input type=file \u2013 file upload control
-input type=hidden \u2013 hidden input control
-input type=image \u2013 image-coordinates input control
-input type=datetime \u2013 global date-and-time input control NEW
-input type=datetime-local \u2013 local date-and-time input control NEW
-input type=date \u2013 date input control NEW
-input type=month \u2013 year-and-month input control NEW
-input type=time \u2013 time input control NEW
-input type=week \u2013 year-and-week input control NEW
-input type=number \u2013 number input control NEW
-input type=range \u2013 imprecise number-input control NEW
-input type=email \u2013 e-mail address input control NEW
-input type=url \u2013 URL input control NEW
-input type=search \u2013 search field NEW
-input type=tel \u2013 telephone-number-input field NEW
-input type=color \u2013 color-well control NEW
-ins \u2013 inserted text
-kbd \u2013 user input
-keygen \u2013 key-pair generator/input control NEW
-label \u2013 caption for a form control
-legend \u2013 title or explanatory caption
-li \u2013 list item
-link \u2013 inter-document relationship metadata
-map \u2013 image-map definition
-mark \u2013 marked (highlighted) text NEW
-menu \u2013 list of commands CHANGED
-meta \u2013 metadata CHANGED
-meta name \u2013 name-value metadata
-meta http-equiv=refresh \u2013 \u201crefresh\u201d pragma directive
-meta http-equiv=default-style \u2013 \u201cpreferred stylesheet\u201d pragma directive
-meta charset \u2013 document character-encoding declaration NEW
-meta http-equiv=content-type \u2013 document character-encoding declaration
-meter \u2013 scalar gauge NEW
-nav \u2013 group of navigational links NEW
-noscript \u2013 fallback content for script
-object \u2013 generic external content
-ol \u2013 ordered list
-optgroup \u2013 group of options
-option \u2013 option
-output \u2013 result of a calculation in a form NEW
-p \u2013 paragraph
-param \u2013 initialization parameters for plugins
-pre \u2013 preformatted text
-progress \u2013 progress indicator NEW
-q \u2013 quoted text
-rp \u2013 ruby parenthesis NEW
-rt \u2013 ruby text NEW
-ruby \u2013 ruby annotation NEW
-s \u2013 struck text CHANGED
-samp \u2013 (sample) output
-script \u2013 embedded script
-section \u2013 section NEW
-select \u2013 option-selection form control
-small \u2013 small print CHANGED
-source \u2013 media source NEW
-span \u2013 generic span
-strong \u2013 strong importance
-style \u2013 style (presentation) information
-sub \u2013 subscript
-summary \u2013 summary, caption, or legend for a details control NEW
-sup \u2013 superscript
-table \u2013 table
-tbody \u2013 table row group
-td \u2013 table cell
-textarea \u2013 text input area
-tfoot \u2013 table footer row group
-th \u2013 table header cell
-thead \u2013 table heading group
-time \u2013 date and/or time NEW
-title \u2013 document title
-tr \u2013 table row
-track \u2013 supplementary media track NEW
-u \u2013 offset text conventionally styled with an underline CHANGED
-ul \u2013 unordered list
-var \u2013 variable or placeholder text
-video \u2013 video NEW
-wbr \u2013 line-break opportunity NEW
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/html/package.html
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/package.html b/juneau-core/src/main/java/org/apache/juneau/html/package.html
index 371c8c4..c07f97a 100644
--- a/juneau-core/src/main/java/org/apache/juneau/html/package.html
+++ b/juneau-core/src/main/java/org/apache/juneau/html/package.html
@@ -65,14 +65,528 @@
<a id="HtmlSerializer"></a>
<h2 class='topic' onclick='toggle(this)'>1 - HTML serialization support</h2>
<div class='topic'>
- TODO
+
+ <!-- ======================================================================================================== -->
+ <a id="Methodology"></a>
+ <h3 class='topic' onclick='toggle(this)'>1.1 - HTML support methodology</h3>
+ <div class='topic'>
+ <p>
+ The following examples show how different data types are represented in HTML.
+ They mirror how the data structures are represented in JSON.
+ </p>
+ <h6 class='topic'>Simple types</h6>
+ <p>
+ The representation for simple types mirror those produced by the XML serializer.
+ Tags are added to help differentiate data types when they cannot be inferred through reflection.
+ These tags are ignored by browsers and treated as plain text.
+ </p>
+ <table class='styled' style='width:auto'>
+ <tr>
+ <th>Data type</th>
+ <th>JSON example</th>
+ <th>HTML</th>
+ </tr>
+ <tr>
+ <td>string</td>
+ <td class='code'><js>'foo'</js></td>
+ <td class='code'><xt><string></xt>foo<xt></string></xt></td>
+ </tr>
+ <tr>
+ <td>boolean</td>
+ <td class='code'><jk>true</jk></td>
+ <td class='code'><xt><boolean></xt>true<xt></boolean></xt></td>
+ </tr>
+ <tr>
+ <td>integer</td>
+ <td class='code'>123</td>
+ <td class='code'><xt><number></xt>123<xt></number></xt></td>
+ </tr>
+ <tr>
+ <td>float</td>
+ <td class='code'>1.23</td>
+ <td class='code'><xt><number></xt>1.23<xt></number></xt></td>
+ </tr>
+ <tr>
+ <td>null</td>
+ <td class='code'><jk>null</jk></td>
+ <td class='code'><xt><null/></xt></td>
+ </tr>
+ </table>
+ <h6 class='topic'>Maps</h6>
+ <p>
+ Maps and beans are represented as tables.
+ </p>
+ <p>
+ The <xa>_type</xa> attribute is added to differentiate between objects (maps/beans) and arrays (arrays/collections).
+ </p>
+ <table class='styled' style='width:auto'>
+ <tr>
+ <th>Data type</th>
+ <th>JSON example</th>
+ <th>HTML</th>
+ </tr>
+ <tr>
+ <td class='code'>
+ Map<String,String>
+ </td>
+ <td class='code'>
+ {
+ k1: <js>'v1'</js>
+ k2: <jk>null</jk>
+ }
+ </td>
+ <td class='code'><xt>
+ <table <xa>_type</xa>=<xs>'object'</xs>>
+ <tr>
+ <td><xv>k1</xv></td>
+ <td><xv>v1</xv></td>
+ </tr>
+ <tr>
+ <td><xv>k2</xv></td>
+ <td><null/></td>
+ </tr>
+ </table>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ Map<String,Number>
+ </td>
+ <td class='code'>
+ {
+ k1: 123,
+ k2: 1.23,
+ k3: <jk>null</jk>
+ }
+ </td>
+ <td class='code'><xt>
+ <table <xa>_type</xa>=<xs>'object'</xs>>
+ <tr>
+ <td><xv>k1</xv></td>
+ <td><xv>123</xv></td>
+ </tr>
+ <tr>
+ <td><xv>k2</xv></td>
+ <td><xv>1.23</xv></td>
+ </tr>
+ <tr>
+ <td><xv>k3</xv></td>
+ <td><null/></td>
+ </tr>
+ </table>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ Map<String,Object>
+ </td>
+ <td class='code'>
+ {
+ k1: <js>'v1'</js>
+ k2: 123,
+ k3: 1.23,
+ k4: <jk>true</jk>,
+ k5: <jk>null</jk>
+ }
+ </td>
+ <td class='code'><xt>
+ <table <xa>_type</xa>=<xs>'object'</xs>>
+ <tr>
+ <td><xv>k1</xv></td>
+ <td><xv>v1</xv></td>
+ </tr>
+ <tr>
+ <td><xv>k2</xv></td>
+ <td><number><xv>123</xv></number></td>
+ </tr>
+ <tr>
+ <td><xv>k3</xv></td>
+ <td><number><xv>1.23</xv></number></td>
+ </tr>
+ <tr>
+ <td><xv>k4</xv></td>
+ <td><boolean><xv>true</xv></boolean></td>
+ </tr>
+ <tr>
+ <td><xv>k5</xv></td>
+ <td><null/></td>
+ </tr>
+ </table>
+ </xt></td>
+ </tr>
+ </table>
+
+ <h6 class='topic'>Arrays</h6>
+ <p>
+ Collections and arrays are represented as ordered lists.
+ </p>
+ <table class='styled' style='width:auto'>
+ <tr>
+ <th>Data type</th>
+ <th>JSON example</th>
+ <th>HTML</th>
+ </tr>
+ <tr>
+ <td class='code'>
+ String[]
+ </td>
+ <td class='code'>
+ [
+ <js>'foo'</js>
+ <jk>null</jk>
+ ]
+ </td>
+ <td class='code'><xt>
+ <ul>
+ <li><xv>foo</xv></li>
+ <li><null/></li>
+ </ul>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ Number[]
+ </td>
+ <td class='code'>
+ [
+ 123,
+ 1.23,
+ <jk>null</jk>
+ ]
+ </td>
+ <td class='code'><xt>
+ <ul>
+ <li><xv>123</xv></li>
+ <li><xv>1.23</xv></li>
+ <li><null/></li>
+ </ul>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ Object[]
+ </td>
+ <td class='code'>
+ [
+ <js>'foo'</js>,
+ 123,
+ 1.23,
+ <jk>true</jk>,
+ <jk>null</jk>
+ ]
+ </td>
+ <td class='code'><xt>
+ <ul>
+ <li><xv>foo</xv></li>
+ <li><number><xv>123</xv></number></li>
+ <li><number><xv>1.23</xv></number></li>
+ <li><boolean><xv>true</xv></boolean></li>
+ <li><null/></li>
+ </ul>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ String[][]
+ </td>
+ <td class='code'>
+ [
+ [<js>'foo'</js>, <jk>null</jk>],
+ <jk>null</jk>,
+ ]
+ </td>
+ <td class='code'><xt>
+ <ul>
+ <li>
+ <ul>
+ <li><xv>foo</xv></li>
+ <li><null/></li>
+ </ul>
+ </li>
+ <li><null/></li>
+ </ul>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ <jk>int</jk>[]
+ </td>
+ <td class='code'>
+ [
+ 123
+ ]
+ </td>
+ <td class='code'><xt>
+ <ul>
+ <li><xv>123</xv></li>
+ </ul>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ <jk>boolean</jk>[]
+ </td>
+ <td class='code'>
+ [
+ <jk>true</jk>
+ ]
+ </td>
+ <td class='code'><xt>
+ <ul>
+ <li><xv>true</xv></li>
+ </ul>
+ </xt></td>
+ </tr>
+ </table>
+
+ <h6 class='topic'>Collections</h6>
+ <table class='styled' style='width:auto'>
+ <tr>
+ <th>Data type</th>
+ <th>JSON example</th>
+ <th>HTML</th>
+ </tr>
+ <tr>
+ <td class='code'>
+ List<String>
+ </td>
+ <td class='code'>
+ [
+ <js>'foo'</js>
+ <jk>null</jk>
+ ]
+ </td>
+ <td class='code'><xt>
+ <ul>
+ <li><xv>foo</xv></li>
+ <li><null/></li>
+ </ul>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ List<Number>
+ </td>
+ <td class='code'>
+ [
+ 123,
+ 1.23,
+ <jk>null</jk>
+ ]
+ </td>
+ <td class='code'><xt>
+ <ul>
+ <li><xv>123</xv></li>
+ <li><xv>1.23</xv></li>
+ <li><null/></li>
+ </ul>
+ </xt></td>
+ </tr>
+ <tr>
+ <td class='code'>
+ List<Object>
+ </td>
+ <td class='code'>
+ [
+ <js>'foo'</js>,
+ 123,
+ 1.23,
+ <jk>true</jk>,
+ <jk>null</jk>
+ ]
+ </td>
+ <td class='code'><xt>
+ <ul>
+ <li><xv>foo</xv></li>
+ <li><number><xv>123</xv></number></li>
+ <li><number><xv>1.23</xv></number></li>
+ <li><boolean><xv>true</xv></boolean></li>
+ <li><null/></li>
+ </ul>
+ </xt></td>
+ </tr>
+ </table>
+
+ <h6 class='topic'>Beans</h6>
+ <table class='styled' style='width:auto'>
+ <tr>
+ <th>Data type</th>
+ <th>JSON example</th>
+ <th>HTML</th>
+ </tr>
+ <tr>
+ <td class='code'>
+ <jk>class</jk> MyBean {
+ <jk>public</jk> String a;
+ <jk>public</jk> <jk>int</jk> b;
+ <jk>public</jk> Object c; <jc>// String value</jc>
+ <jk>public</jk> Object d; <jc>// Integer value</jc>
+ <jk>public</jk> MyBean2 e;
+ <jk>public</jk> String[] f;
+ <jk>public</jk> <jk>int</jk>[] g;
+ }
+ <jk>class</jk> MyBean2 {
+ String h;
+ }
+ </td>
+ <td class='code'>
+ {
+ a: <js>'foo'</js>,
+ b: 123,
+ c: <js>'bar'</js>,
+ d: 456,
+ e: {
+ h: <js>'baz'</js>
+ }
+ f: [<js>'qux'</js>]
+ g: [789]
+ }
+ </td>
+ <td class='code'><xt>
+ <table <xa>_type</xa>=<xs>'object'</xs>>
+ <tr>
+ <td><xv>a</xv></td>
+ <td><xv>foo</xv></td>
+ </tr>
+ <tr>
+ <td><xv>b</xv></td>
+ <td><xv>123</xv></td>
+ </tr>
+ <tr>
+ <td><xv>c</xv></td>
+ <td><xv>bar</xv></td>
+ </tr>
+ <tr>
+ <td><xv>d</xv></td>
+ <td><number><xv>456</xv></number></td>
+ </tr>
+ <tr>
+ <td><xv>e</xv></td>
+ <td>
+ <table <xa>_type</xa>=<xs>'object'</xs>>
+ <tr>
+ <td><xv>h</xv></td>
+ <td><xv>qux</xv></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td><xv>f</xv></td>
+ <td>
+ <ul>
+ <li><xv>baz</xv></li>
+ </ul>
+ </td>
+ </tr>
+ <tr>
+ <td><xv>g</xv></td>
+ <td>
+ <ul>
+ <li><xv>789</xv></li>
+ </ul>
+ </td>
+ </tr>
+ </table>
+ </xt></td>
+ </tr>
+ </table>
+ <h6 class='topic'>Beans with Map properties</h6>
+ <table class='styled' style='width:auto'>
+ <tr>
+ <th>Data type</th>
+ <th>JSON example</th>
+ <th>HTML</th>
+ </tr>
+ <tr>
+ <td class='code'>
+ <jk>class</jk> MyBean {
+ <jk>public</jk> Map<String,String> a;
+ <jk>public</jk> Map<String,Number> b;
+ <jk>public</jk> Map<String,Object> c;
+ }
+ </td>
+ <td class='code'>
+ {
+ a: {
+ k1: <js>'foo'</js>
+ },
+ b: {
+ k2: 123
+ },
+ c: {
+ k3: <js>'bar'</js>,
+ k4: 456,
+ k5: <jk>true</jk>,
+ k6: <jk>null</jk>
+ }
+ }
+ </td>
+ <td class='code'><xt>
+ <table <xa>_type</xa>=<xs>'object'</xs>>
+ <tr>
+ <td><xv>a</xv></td>
+ <td>
+ <table _type='object'>
+ <tr>
+ <td><xv>k1</xv></td>
+ <td><xv>foo</xv></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td><xv>b</xv></td>
+ <td>
+ <table _type='object'>
+ <tr>
+ <td><xv>k2</xv></td>
+ <td><xv>123</xv></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td><xv>c</xv></td>
+ <td>
+ <table <xa>_type</xa>=<xs>'object'</xs>>
+ <tr>
+ <td><xv>k3</xv></td>
+ <td><xv>bar</xv></td>
+ </tr>
+ <tr>
+ <td><xv>k4</xv></td>
+ <td><number><xv>456</xv></number></td>
+ </tr>
+ <tr>
+ <td><xv>k5</xv></td>
+ <td><boolean><xv>true</xv></boolean></td>
+ </tr>
+ <tr>
+ <td><xv>k6</xv></td>
+ <td><null/></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </xt></td>
+ </tr>
+ </table>
+
+ TODO - Special characters - \n\t\b\f
+ TODO BeanWithPropertiesWithTypeNames...
+ TODO
+
+ </div>
+
</div>
<!-- ======================================================================================================== -->
<a id="HtmlParser"></a>
<h2 class='topic' onclick='toggle(this)'>2 - HTML parsing support</h2>
<div class='topic'>
- TODO
+ The parser will handle anything produced by the serializer.
</div>
</body>
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/internal/ClassUtils.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/internal/ClassUtils.java b/juneau-core/src/main/java/org/apache/juneau/internal/ClassUtils.java
index 6585dd3..49c1083 100644
--- a/juneau-core/src/main/java/org/apache/juneau/internal/ClassUtils.java
+++ b/juneau-core/src/main/java/org/apache/juneau/internal/ClassUtils.java
@@ -315,4 +315,92 @@ public final class ClassUtils {
public static boolean isPublic(Constructor<?> c) {
return Modifier.isPublic(c.getModifiers());
}
+
+ /**
+ * Finds the real parameter type of the specified class.
+ *
+ * @param c The class containing the parameters (e.g. PojoSwap<T,S>)
+ * @param index The zero-based index of the parameter to resolve.
+ * @param o The object we're trying to resolve the parameter type for.
+ * @return The resolved real class.
+ */
+ public static Class<?> resolveParameterType(Class<?> c, int index, Object o) {
+
+ // We need to make up a mapping of type names.
+ Map<Type,Type> typeMap = new HashMap<Type,Type>();
+ Class<?> oc = o.getClass();
+ while (c != oc.getSuperclass()) {
+ extractTypes(typeMap, oc);
+ oc = oc.getSuperclass();
+ }
+
+ ParameterizedType opt = (ParameterizedType)oc.getGenericSuperclass();
+ Type actualType = opt.getActualTypeArguments()[index];
+
+ if (typeMap.containsKey(actualType))
+ actualType = typeMap.get(actualType);
+
+ if (actualType instanceof Class) {
+ return (Class<?>)actualType;
+
+ } else if (actualType instanceof GenericArrayType) {
+ Class<?> cmpntType = (Class<?>)((GenericArrayType)actualType).getGenericComponentType();
+ return Array.newInstance(cmpntType, 0).getClass();
+
+ } else if (actualType instanceof TypeVariable) {
+ TypeVariable<?> typeVariable = (TypeVariable<?>)actualType;
+ List<Class<?>> nestedOuterTypes = new LinkedList<Class<?>>();
+ for (Class<?> ec = oc.getEnclosingClass(); ec != null; ec = ec.getEnclosingClass()) {
+ try {
+ Field this$0 = oc.getDeclaredField("this$0");
+ Object outerInstance = this$0.get(o);
+ Class<?> outerClass = outerInstance.getClass();
+ nestedOuterTypes.add(outerClass);
+ Map<Type,Type> outerTypeMap = new HashMap<Type,Type>();
+ extractTypes(outerTypeMap, outerClass);
+ for (Map.Entry<Type,Type> entry : outerTypeMap.entrySet()) {
+ Type key = entry.getKey(), value = entry.getValue();
+ if (key instanceof TypeVariable) {
+ TypeVariable<?> keyType = (TypeVariable<?>)key;
+ if (keyType.getName().equals(typeVariable.getName()) && isInnerClass(keyType.getGenericDeclaration(), typeVariable.getGenericDeclaration())) {
+ if (value instanceof Class)
+ return (Class<?>)value;
+ typeVariable = (TypeVariable<?>)entry.getValue();
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ throw new RuntimeException("Could not resolve type: " + actualType);
+ } else {
+ throw new RuntimeException("Invalid type found in resolveParameterType: " + actualType);
+ }
+ }
+
+ private static boolean isInnerClass(GenericDeclaration od, GenericDeclaration id) {
+ if (od instanceof Class && id instanceof Class) {
+ Class<?> oc = (Class<?>)od;
+ Class<?> ic = (Class<?>)id;
+ while ((ic = ic.getEnclosingClass()) != null)
+ if (ic == oc)
+ return true;
+ }
+ return false;
+ }
+
+ private static void extractTypes(Map<Type,Type> typeMap, Class<?> c) {
+ Type gs = c.getGenericSuperclass();
+ if (gs instanceof ParameterizedType) {
+ ParameterizedType pt = (ParameterizedType)gs;
+ Type[] typeParameters = ((Class<?>)pt.getRawType()).getTypeParameters();
+ Type[] actualTypeArguments = pt.getActualTypeArguments();
+ for (int i = 0; i < typeParameters.length; i++) {
+ if (typeMap.containsKey(actualTypeArguments[i]))
+ actualTypeArguments[i] = typeMap.get(actualTypeArguments[i]);
+ typeMap.put(typeParameters[i], actualTypeArguments[i]);
+ }
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/internal/DelegateList.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/internal/DelegateList.java b/juneau-core/src/main/java/org/apache/juneau/internal/DelegateList.java
index 7923299..35e6b11 100644
--- a/juneau-core/src/main/java/org/apache/juneau/internal/DelegateList.java
+++ b/juneau-core/src/main/java/org/apache/juneau/internal/DelegateList.java
@@ -25,14 +25,17 @@ import org.apache.juneau.*;
public class DelegateList<T extends Collection<?>> extends ObjectList implements Delegate<T> {
private static final long serialVersionUID = 1L;
- private transient ClassMeta<T> classMeta;
+ private final ClassMeta<T> classMeta;
/**
* Constructor.
*
- * @param classMeta The metadata object that created this delegate list.
+ * @param classMeta The data type represented by this delegate.
*/
+ @SuppressWarnings("unchecked")
public DelegateList(ClassMeta<T> classMeta) {
+ if (classMeta.isArray())
+ classMeta = classMeta.getBeanContext().getCollectionClassMeta(List.class, classMeta.getElementType());
this.classMeta = classMeta;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/internal/FilteredMap.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/internal/FilteredMap.java b/juneau-core/src/main/java/org/apache/juneau/internal/FilteredMap.java
index 49c45ae..5783227 100644
--- a/juneau-core/src/main/java/org/apache/juneau/internal/FilteredMap.java
+++ b/juneau-core/src/main/java/org/apache/juneau/internal/FilteredMap.java
@@ -16,27 +16,32 @@ import static org.apache.juneau.internal.ThrowableUtils.*;
import java.util.*;
+import org.apache.juneau.*;
+
/**
* Wrapper around a map where the key names are overridden.
*
* @param <K> The key class type.
* @param <V> The value class type.
*/
-public final class FilteredMap<K,V> extends AbstractMap<K,V> {
+public final class FilteredMap<K,V> extends AbstractMap<K,V> implements Delegate<Map<K,V>> {
private Map<K,V> innerMap;
private Set<Map.Entry<K,V>> entries;
+ private final ClassMeta<Map<K,V>> classMeta;
/**
* Constructor.
- *
+ *
+ * @param classMeta The class type of the map being wrapped.
* @param innerMap The map being wrapped. Must not be <jk>null</jk>.
* @param keys The keys in the new map. Must not be <jk>null</jk>.
*/
- public FilteredMap(Map<K,V> innerMap, K[] keys) {
+ public FilteredMap(ClassMeta<Map<K,V>> classMeta, Map<K,V> innerMap, K[] keys) {
assertFieldNotNull(innerMap, "innerMap");
assertFieldNotNull(keys, "keys");
+ this.classMeta = classMeta;
this.innerMap = innerMap;
List<Map.Entry<K,V>> l = new ArrayList<Map.Entry<K,V>>(keys.length);
for (K k : keys)
@@ -92,4 +97,9 @@ public final class FilteredMap<K,V> extends AbstractMap<K,V> {
return entries.size();
}
}
+
+ @Override /* Delegate */
+ public ClassMeta<Map<K,V>> getClassMeta() {
+ return classMeta;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/jena/RdfParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/jena/RdfParser.java b/juneau-core/src/main/java/org/apache/juneau/jena/RdfParser.java
index 0d5446c..604d98a 100644
--- a/juneau-core/src/main/java/org/apache/juneau/jena/RdfParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/jena/RdfParser.java
@@ -117,7 +117,7 @@ public class RdfParser extends ReaderParser {
List<Resource> roots = getRoots(s, model);
// Special case where we're parsing a loose collection of resources.
- if (s.isLooseCollections() && (type.isCollection() || type.isArray())) {
+ if (s.isLooseCollections() && type.isCollectionOrArray()) {
Collection c = null;
if (type.isArray())
c = new ArrayList();
@@ -200,7 +200,7 @@ public class RdfParser extends ReaderParser {
if (pMeta != null) {
RDFNode o = st.getObject();
ClassMeta<?> cm = pMeta.getClassMeta();
- if ((cm.isArray() || cm.isCollection()) && isMultiValuedCollections(session, pMeta)) {
+ if (cm.isCollectionOrArray() && isMultiValuedCollections(session, pMeta)) {
ClassMeta<?> et = cm.getElementType();
Object value = parseAnything(session, et, o, m.getBean(false));
setName(et, value, key);
@@ -302,7 +302,7 @@ public class RdfParser extends ReaderParser {
return null;
Map m = (sType.canCreateNewInstance(outer) ? (Map)sType.newInstance(outer) : new ObjectMap(session));
o = parseIntoMap(session, r, m, eType.getKeyType(), eType.getValueType());
- } else if (sType.isCollection() || sType.isArray()) {
+ } else if (sType.isCollectionOrArray()) {
if (sType.isArray())
o = new ArrayList();
else
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserSession.java b/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserSession.java
index 017e45e..2c73a00 100644
--- a/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserSession.java
@@ -226,7 +226,7 @@ public class RdfParserSession extends ParserSession {
return s;
if (trimWhitespace)
s = s.trim();
- s = XmlUtils.decode(s);
+ s = XmlUtils.decode(s, null);
if (isTrimStrings())
s = s.trim();
return s;
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializer.java b/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializer.java
index fcd522d..0728b39 100644
--- a/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializer.java
@@ -125,7 +125,7 @@ public class RdfSerializer extends WriterSerializer {
Resource r = null;
ClassMeta<?> cm = session.getClassMetaForObject(o);
- if (s.isLooseCollections() && cm != null && (cm.isCollection() || cm.isArray())) {
+ if (s.isLooseCollections() && cm != null && cm.isCollectionOrArray()) {
Collection c = s.sort(cm.isCollection() ? (Collection)o : toList(cm.getInnerClass(), o));
for (Object o2 : c)
serializeAnything(s, o2, false, object(), "root", null, null);
@@ -240,7 +240,7 @@ public class RdfSerializer extends WriterSerializer {
n = m.createResource(uri2);
serializeBeanMap(session, bm, (Resource)n);
- } else if (sType.isCollection() || sType.isArray() || (wType != null && wType.isCollection())) {
+ } else if (sType.isCollectionOrArray() || (wType != null && wType.isCollection())) {
Collection c = session.sort(sType.isCollection() ? (Collection)o : toList(sType.getInnerClass(), o));
RdfCollectionFormat f = session.getCollectionFormat();
RdfClassMeta rcm = sType.getExtendedMeta(RdfClassMeta.class);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/jena/package.html
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/jena/package.html b/juneau-core/src/main/java/org/apache/juneau/jena/package.html
index 788b25d..6036583 100644
--- a/juneau-core/src/main/java/org/apache/juneau/jena/package.html
+++ b/juneau-core/src/main/java/org/apache/juneau/jena/package.html
@@ -125,7 +125,7 @@
These can be associated with serializers/parsers, or can be associated with classes or bean properties through type and method annotations.
</p>
<p>
- Refer to <a href='../package-summary.html#PojoCategories' class='doclink'>POJO Categories</a> for a complete definition of supported POJOs.
+ Refer to <a href='../../../../overview-summary.html#Core.PojoCategories' class='doclink'>POJO Categories</a> for a complete definition of supported POJOs.
</p>
<h6 class='topic'>Prerequisites</h6>
<p>
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/json/JsonParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonParser.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonParser.java
index 5a5d098..be41f20 100644
--- a/juneau-core/src/main/java/org/apache/juneau/json/JsonParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonParser.java
@@ -103,7 +103,7 @@ public final class JsonParser extends ReaderParser {
ClassMeta<?> sType = eType.getSerializedClassMeta();
session.setCurrentClass(sType);
String wrapperAttr = sType.getExtendedMeta(JsonClassMeta.class).getWrapperAttr();
- BeanDictionary bd = pMeta == null ? session.getBeanDictionary() : pMeta.getBeanDictionary();
+ BeanRegistry breg = pMeta == null ? session.getBeanRegistry() : pMeta.getBeanRegistry();
Object o = null;
@@ -126,7 +126,7 @@ public final class JsonParser extends ReaderParser {
if (c == '{') {
ObjectMap m2 = new ObjectMap(session);
parseIntoMap2(session, r, m2, string(), object(), pMeta);
- o = bd.cast(m2);
+ o = breg.cast(m2);
} else if (c == '[') {
o = parseIntoCollection2(session, r, new ObjectList(session), object(), pMeta);
} else if (c == '\'' || c == '"') {
@@ -157,7 +157,7 @@ public final class JsonParser extends ReaderParser {
if (c == '{') {
ObjectMap m = new ObjectMap(session);
parseIntoMap2(session, r, m, string(), object(), pMeta);
- o = bd.cast(m);
+ o = breg.cast(m);
} else {
Collection l = (sType.canCreateNewInstance(outer) ? (Collection)sType.newInstance() : new ObjectList(session));
o = parseIntoCollection2(session, r, l, sType.getElementType(), pMeta);
@@ -177,7 +177,7 @@ public final class JsonParser extends ReaderParser {
if (c == '{') {
ObjectMap m = new ObjectMap(session);
parseIntoMap2(session, r, m, string(), object(), pMeta);
- o = bd.cast(m);
+ o = breg.cast(m);
} else {
ArrayList l = (ArrayList)parseIntoCollection2(session, r, new ArrayList(), sType.getElementType(), pMeta);
o = session.toArray(sType, l);
@@ -186,7 +186,7 @@ public final class JsonParser extends ReaderParser {
Map m = new ObjectMap(session);
parseIntoMap2(session, r, m, sType.getKeyType(), sType.getValueType(), pMeta);
if (m.containsKey(session.getBeanTypePropertyName()))
- o = bd.cast((ObjectMap)m);
+ o = breg.cast((ObjectMap)m);
else
throw new ParseException(session, "Class ''{0}'' could not be instantiated. Reason: ''{1}''", sType.getInnerClass().getName(), sType.getNotABeanReason());
} else if (sType.canCreateNewInstanceFromString(outer) && ! session.isStrict()) {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java
index 3740adb..4b2b6d1 100644
--- a/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java
@@ -98,9 +98,9 @@ public final class JsonSchemaSerializer extends JsonSerializer {
type = "number";
else if (sType.isBoolean())
type = "boolean";
- else if (sType.isBean() || sType.isMap())
+ else if (sType.isMapOrBean())
type = "object";
- else if (sType.isCollection() || sType.isArray())
+ else if (sType.isCollectionOrArray())
type = "array";
else
type = "any";
@@ -114,7 +114,7 @@ public final class JsonSchemaSerializer extends JsonSerializer {
if (aType != null) {
if (sType.isEnum())
out.put("enum", getEnumStrings((Class<Enum<?>>)sType.getInnerClass()));
- else if (sType.isCollection() || sType.isArray()) {
+ else if (sType.isCollectionOrArray()) {
ClassMeta componentType = sType.getElementType();
if (sType.isCollection() && isParentClass(Set.class, sType.getInnerClass()))
out.put("uniqueItems", true);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializer.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializer.java
index 55693a5..ed87019 100644
--- a/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializer.java
@@ -162,7 +162,7 @@ public class JsonSerializer extends WriterSerializer {
if (eType == null)
eType = object();
- boolean addTypeProperty; // Add "_type" attribute to element?
+ boolean addTypeProperty; // Add "_type" attribute to element?
ClassMeta<?> aType; // The actual type
ClassMeta<?> sType; // The serialized type
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/json/package.html
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/json/package.html b/juneau-core/src/main/java/org/apache/juneau/json/package.html
index 13ae665..6c238cd 100644
--- a/juneau-core/src/main/java/org/apache/juneau/json/package.html
+++ b/juneau-core/src/main/java/org/apache/juneau/json/package.html
@@ -110,7 +110,7 @@
<li>Non-serializable classes and properties with associated <code>PojoSwaps</code> that convert them to serializable forms.
</ul>
<p>
- Refer to <a href='../package-summary.html#PojoCategories' class='doclink'>POJO Categories</a> for a complete definition of supported POJOs.
+ Refer to <a href='../../../../overview-summary.html#Core.PojoCategories' class='doclink'>POJO Categories</a> for a complete definition of supported POJOs.
</p>
<h6 class='topic'>Prerequisites</h6>
<p>
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParser.java b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParser.java
index fff316c..2d1c764 100644
--- a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParser.java
@@ -53,7 +53,7 @@ public final class MsgPackParser extends InputStreamParser {
PojoSwap<T,Object> transform = (PojoSwap<T,Object>)eType.getPojoSwap();
ClassMeta<?> sType = eType.getSerializedClassMeta();
session.setCurrentClass(sType);
- BeanDictionary bd = (pMeta == null ? session.getBeanDictionary() : pMeta.getBeanDictionary());
+ BeanRegistry breg = (pMeta == null ? session.getBeanRegistry() : pMeta.getBeanRegistry());
Object o = null;
DataType dt = is.readDataType();
@@ -83,7 +83,7 @@ public final class MsgPackParser extends InputStreamParser {
ObjectMap om = new ObjectMap(session);
for (int i = 0; i < length; i++)
om.put(parseAnything(session, string(), is, outer, pMeta), parseAnything(session, object(), is, om, pMeta));
- o = bd.cast(om);
+ o = breg.cast(om);
}
if (sType.isObject()) {
@@ -140,7 +140,7 @@ public final class MsgPackParser extends InputStreamParser {
ObjectMap m = new ObjectMap(session);
for (int i = 0; i < length; i++)
m.put(parseAnything(session, string(), is, outer, pMeta), parseAnything(session, object(), is, m, pMeta));
- o = bd.cast(m);
+ o = breg.cast(m);
} else if (dt == ARRAY) {
Collection l = (sType.canCreateNewInstance(outer) ? (Collection)sType.newInstance() : new ObjectList(session));
for (int i = 0; i < length; i++)
@@ -154,7 +154,7 @@ public final class MsgPackParser extends InputStreamParser {
ObjectMap m = new ObjectMap(session);
for (int i = 0; i < length; i++)
m.put(parseAnything(session, string(), is, outer, pMeta), parseAnything(session, object(), is, m, pMeta));
- o = bd.cast(m);
+ o = breg.cast(m);
} else if (dt == ARRAY) {
Collection l = (sType.isCollection() && sType.canCreateNewInstance(outer) ? (Collection)sType.newInstance() : new ObjectList(session));
for (int i = 0; i < length; i++)
@@ -168,7 +168,7 @@ public final class MsgPackParser extends InputStreamParser {
for (int i = 0; i < length; i++)
m.put(parseAnything(session, string(), is, outer, pMeta), parseAnything(session, object(), is, m, pMeta));
if (m.containsKey(session.getBeanTypePropertyName()))
- o = bd.cast(m);
+ o = breg.cast(m);
else
throw new ParseException(session, "Class ''{0}'' could not be instantiated. Reason: ''{1}''", sType.getInnerClass().getName(), sType.getNotABeanReason());
} else {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/package.html
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/package.html b/juneau-core/src/main/java/org/apache/juneau/package.html
index ac78fda..8f80569 100644
--- a/juneau-core/src/main/java/org/apache/juneau/package.html
+++ b/juneau-core/src/main/java/org/apache/juneau/package.html
@@ -64,8 +64,6 @@
<li><p><a class='doclink' href='#BeanContext'>The BeanContext class</a></p>
<li><p><a class='doclink' href='#Bean'>Bean annotations</a></p>
</ol>
- <li><p><a class='doclink' href='#ObjectMap_ObjectList'>ObjectMap and ObjectList APIs</a></p>
- <li><p><a class='doclink' href='#PojoCategories'>POJO Categories</a></p>
</ol>
<!-- ======================================================================================================== -->
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/parser/Parser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/parser/Parser.java b/juneau-core/src/main/java/org/apache/juneau/parser/Parser.java
index 8178ea4..8256a74 100644
--- a/juneau-core/src/main/java/org/apache/juneau/parser/Parser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/parser/Parser.java
@@ -36,7 +36,7 @@ import org.apache.juneau.utils.*;
* However, the media types can also be specified programmatically by overriding the {@link #getMediaTypes()} method.
*
* <a id='ValidDataConversions'></a><h6 class='topic'>Valid data conversions</h6>
- * Parsers can parse any parsable POJO types, as specified in the <a class='doclink' href='../package-summary.html#PojoCategories'>POJO Categories</a>.
+ * Parsers can parse any parsable POJO types, as specified in the <a class='doclink' href='../../../../overview-summary.html#Core.PojoCategories'>POJO Categories</a>.
* <p>
* Some examples of conversions are shown below...
* </p>
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextParser.java b/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextParser.java
index 7d6b30f..4a8cc65 100644
--- a/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextParser.java
@@ -19,7 +19,7 @@ import org.apache.juneau.parser.*;
import org.apache.juneau.transform.*;
/**
- * Parsers HTTP plain text request bodies into <a href='../package-summary.html#PojoCategories'>Group 5</a> POJOs.
+ * Parsers HTTP plain text request bodies into <a href='../../../../overview-summary.html#Core.PojoCategories'>Group 5</a> POJOs.
*
* <h6 class='topic'>Media types</h6>
* <p>
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java
index d64efb8..d0f72f9 100644
--- a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java
@@ -569,12 +569,7 @@ public class SerializerSession extends BeanSession {
public String resolveUri(String uri) {
if (uri.indexOf("://") != -1 || (absolutePathUriBase == null && relativeUriBase == null))
return uri;
- StringBuilder sb = new StringBuilder(
- uri.length()
- + (absolutePathUriBase == null ? 0 : absolutePathUriBase.length())
- + 1
- + (relativeUriBase == null ? 0 : relativeUriBase.length())
- );
+ StringBuilder sb = getStringBuilder();
if (StringUtils.startsWith(uri, '/')) {
if (absolutePathUriBase != null)
sb.append(absolutePathUriBase);
@@ -586,7 +581,9 @@ public class SerializerSession extends BeanSession {
}
}
sb.append(uri);
- return sb.toString();
+ String s = sb.toString();
+ returnStringBuilder(sb);
+ return s;
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/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 fb86ef0..2460e88 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
@@ -235,6 +235,19 @@ public class SerializerWriter extends Writer {
}
/**
+ * Writes a newline to the writer if the {@code useIndentation} setting is enabled and the boolean flag is true.
+ *
+ * @param b The boolean flag.
+ * @return This object (for method chaining).
+ * @throws IOException If a problem occurred trying to write to the writer.
+ */
+ public SerializerWriter nlIf(boolean b) throws IOException {
+ if (b && useIndentation)
+ out.write('\n');
+ return this;
+ }
+
+ /**
* Writes the specified text to the writer.
*
* @param text The text to write.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/transform/MapSwap.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/transform/MapSwap.java b/juneau-core/src/main/java/org/apache/juneau/transform/MapSwap.java
new file mode 100644
index 0000000..f0713f6
--- /dev/null
+++ b/juneau-core/src/main/java/org/apache/juneau/transform/MapSwap.java
@@ -0,0 +1,35 @@
+// ***************************************************************************************************************************
+// * 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.transform;
+
+import org.apache.juneau.*;
+import org.apache.juneau.parser.*;
+import org.apache.juneau.serializer.*;
+
+/**
+ * Abstract subclass for POJO swaps that swap objects for object maps.
+ *
+ * @param <T> The normal form of the class.
+ */
+public abstract class MapSwap<T> extends PojoSwap<T,ObjectMap> {
+
+ @Override /* PojoSwap */
+ public ObjectMap swap(BeanSession session, T o) throws SerializeException {
+ return super.swap(session, o);
+ }
+
+ @Override /* PojoSwap */
+ public T unswap(BeanSession session, ObjectMap f, ClassMeta<?> hint) throws ParseException {
+ return super.unswap(session, f, hint);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/transform/PojoSwap.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/transform/PojoSwap.java b/juneau-core/src/main/java/org/apache/juneau/transform/PojoSwap.java
index d49d00a..e1239b3 100644
--- a/juneau-core/src/main/java/org/apache/juneau/transform/PojoSwap.java
+++ b/juneau-core/src/main/java/org/apache/juneau/transform/PojoSwap.java
@@ -12,7 +12,6 @@
// ***************************************************************************************************************************
package org.apache.juneau.transform;
-import java.lang.reflect.*;
import java.util.*;
import org.apache.juneau.*;
@@ -47,6 +46,14 @@ import org.apache.juneau.serializer.*;
* {@link Serializer Serializers} use swaps to convert objects of type T into objects of type S, and on calls to {@link BeanMap#get(Object)}.<br>
* {@link Parser Parsers} use swaps to convert objects of type S into objects of type T, and on calls to {@link BeanMap#put(String,Object)}.
*
+ * <h6 class='topic'>Subtypes</h6>
+ * <p>
+ * The following abstract subclasses are provided for common swap types:
+ * <ol>
+ * <li>{@link StringSwap} - Objects swapped with strings.
+ * <li>{@link MapSwap} - Objects swapped with {@link ObjectMap ObjectMaps}.
+ * </ol>
+ *
* <h6 class='topic'>Localization</h6>
* <p>
* Swaps have access to the session locale and timezone through the {@link BeanSession#getLocale()} and {@link BeanSession#getTimeZone()}
@@ -100,48 +107,8 @@ public abstract class PojoSwap<T,S> {
*/
@SuppressWarnings("unchecked")
protected PojoSwap() {
-
- Class<?> t_normalClass = null, t_swapClass = null;
-
- Class<?> c = this.getClass().getSuperclass();
- Type t = this.getClass().getGenericSuperclass();
- while (c != PojoSwap.class) {
- t = c.getGenericSuperclass();
- c = c.getSuperclass();
- }
-
- // Attempt to determine the T and G classes using reflection.
- if (t instanceof ParameterizedType) {
- ParameterizedType pt = (ParameterizedType)t;
- Type[] pta = pt.getActualTypeArguments();
- if (pta.length == 2) {
- Type nType = pta[0];
- if (nType instanceof Class) {
- t_normalClass = (Class<T>)nType;
-
- // <byte[],x> ends up containing a GenericArrayType, so it has to
- // be handled as a special case.
- } else if (nType instanceof GenericArrayType) {
- Class<?> cmpntType = (Class<?>)((GenericArrayType)nType).getGenericComponentType();
- t_normalClass = Array.newInstance(cmpntType, 0).getClass();
-
- // <Class<?>,x> ends up containing a ParameterizedType, so just use the raw type.
- } else if (nType instanceof ParameterizedType) {
- t_normalClass = (Class<T>)((ParameterizedType)nType).getRawType();
-
- } else
- throw new RuntimeException("Unsupported parameter type: " + nType);
- if (pta[1] instanceof Class)
- t_swapClass = (Class<S>)pta[1];
- else if (pta[1] instanceof ParameterizedType)
- t_swapClass = (Class<S>)((ParameterizedType)pta[1]).getRawType();
- else
- throw new RuntimeException("Unexpected transformed class type: " + pta[1].getClass().getName());
- }
- }
-
- this.normalClass = (Class<T>)t_normalClass;
- this.swapClass = (Class<S>)t_swapClass;
+ normalClass = (Class<T>)ClassUtils.resolveParameterType(PojoSwap.class, 0, this);
+ swapClass = (Class<S>)ClassUtils.resolveParameterType(PojoSwap.class, 1, this);
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/transform/StringSwap.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/transform/StringSwap.java b/juneau-core/src/main/java/org/apache/juneau/transform/StringSwap.java
new file mode 100644
index 0000000..0d9b47d
--- /dev/null
+++ b/juneau-core/src/main/java/org/apache/juneau/transform/StringSwap.java
@@ -0,0 +1,35 @@
+// ***************************************************************************************************************************
+// * 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.transform;
+
+import org.apache.juneau.*;
+import org.apache.juneau.parser.*;
+import org.apache.juneau.serializer.*;
+
+/**
+ * Abstract subclass for POJO swaps that swap objects for strings.
+ *
+ * @param <T> The normal form of the class.
+ */
+public abstract class StringSwap<T> extends PojoSwap<T,String> {
+
+ @Override /* PojoSwap */
+ public String swap(BeanSession session, T o) throws SerializeException {
+ return super.swap(session, o);
+ }
+
+ @Override /* PojoSwap */
+ public T unswap(BeanSession session, String f, ClassMeta<?> hint) throws ParseException {
+ return super.unswap(session, f, hint);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/transform/package.html
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/transform/package.html b/juneau-core/src/main/java/org/apache/juneau/transform/package.html
index ad7c412..063f3c4 100644
--- a/juneau-core/src/main/java/org/apache/juneau/transform/package.html
+++ b/juneau-core/src/main/java/org/apache/juneau/transform/package.html
@@ -82,6 +82,11 @@
<li>{@link org.apache.juneau.transform.BeanFilter} - Transforms that alter the way beans are handled.
<li>{@link org.apache.juneau.transform.PojoSwap} - Transforms that swap non-serializable POJOs with serializable POJOs during serialization
(and optionally vis-versa during parsing).
+ <ol>
+ <li>{@link org.apache.juneau.transform.StringSwap} - Convenience subclass for swaps that convert objects to strings.
+ <li>{@link org.apache.juneau.transform.MapSwap} - Convenience subclass for swaps that convert objects to maps.
+ </ol>
+ </li>
</ul>
<p>
Transforms are added to serializers and parsers in a variety of ways:
@@ -426,7 +431,7 @@
</p>
<p class='bcode'>
<jc>// Sample swap for converting Dates to ISO8601 strings.</jc>
- <jk>public class</jk> MyDateSwap <jk>extends</jk> PojoSwap<Date,String> {
+ <jk>public class</jk> MyDateSwap <jk>extends</jk> StringSwap<Date> {
<jc>// ISO8601 formatter.</jc>
<jk>private</jk> DateFormat <jf>format</jf> = <jk>new</jk> SimpleDateFormat(<js>"yyyy-MM-dd'T'HH:mm:ssZ"</js>);
@@ -492,7 +497,7 @@
Another example of a <code>PojoSwap</code> is one that converts <code><jk>byte</jk>[]</code> arrays to BASE64-encoded strings:
</p>
<p class='bcode'>
- <jk>public class</jk> ByteArrayBase64Swap <jk>extends</jk> PojoSwap<<jk>byte</jk>[],String> {
+ <jk>public class</jk> ByteArrayBase64Swap <jk>extends</jk> StringSwap<<jk>byte</jk>[]> {
<ja>@Override</ja>
<jk>public</jk> String swap(<jk>byte</jk>[] b) <jk>throws</jk> SerializeException {
@@ -556,7 +561,7 @@
<h6 class='topic'>Valid swapped class types</h6>
<p>
- The swapped class type can be any serializable class type as defined in the <a href='../package-summary.html#PojoCategories'>POJO categories</a> table.
+ The swapped class type can be any serializable class type as defined in the <a href='../../../../overview-summary.html#Core.PojoCategories'>POJO categories</a> table.
</p>
</div>
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/transforms/BeanStringSwap.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/transforms/BeanStringSwap.java b/juneau-core/src/main/java/org/apache/juneau/transforms/BeanStringSwap.java
index 68a68e0..f6d38f7 100644
--- a/juneau-core/src/main/java/org/apache/juneau/transforms/BeanStringSwap.java
+++ b/juneau-core/src/main/java/org/apache/juneau/transforms/BeanStringSwap.java
@@ -22,11 +22,11 @@ import org.apache.juneau.transform.*;
* being turned into Maps by the {@link BeanContext} (or worse, throwing {@link BeanRuntimeException BeanRuntimeExceptions}).
* <p>
* This is usually a one-way transform.
- * Beans serialized as strings cannot be reconstituted using a parser unless it is a <a class='doclink' href='../package-summary.html#PojoCategories'>Type 5 POJO</a>.
+ * Beans serialized as strings cannot be reconstituted using a parser unless it is a <a class='doclink' href='../../../../overview-summary.html#Core.PojoCategories'>Type 5 POJO</a>.
*
* @param <T> The class type of the bean.
*/
-public class BeanStringSwap<T> extends PojoSwap<T,String> {
+public class BeanStringSwap<T> extends StringSwap<T> {
/**
* Converts the specified bean to a {@link String}.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/transforms/ByteArrayBase64Swap.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/transforms/ByteArrayBase64Swap.java b/juneau-core/src/main/java/org/apache/juneau/transforms/ByteArrayBase64Swap.java
index 6f50488..2eea048 100644
--- a/juneau-core/src/main/java/org/apache/juneau/transforms/ByteArrayBase64Swap.java
+++ b/juneau-core/src/main/java/org/apache/juneau/transforms/ByteArrayBase64Swap.java
@@ -21,7 +21,7 @@ import org.apache.juneau.transform.*;
/**
* Transforms <code><jk>byte</jk>[]</code> arrays to BASE-64 encoded {@link String Strings}.
*/
-public class ByteArrayBase64Swap extends PojoSwap<byte[],String> {
+public class ByteArrayBase64Swap extends StringSwap<byte[]> {
/**
* Converts the specified <code><jk>byte</jk>[]</code> to a {@link String}.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/transforms/CalendarSwap.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/transforms/CalendarSwap.java b/juneau-core/src/main/java/org/apache/juneau/transforms/CalendarSwap.java
index 1d6a917..f6b1f3e 100644
--- a/juneau-core/src/main/java/org/apache/juneau/transforms/CalendarSwap.java
+++ b/juneau-core/src/main/java/org/apache/juneau/transforms/CalendarSwap.java
@@ -54,7 +54,7 @@ import org.apache.juneau.transform.*;
* <li>{@link DateTimeShort} - To {@link DateFormat#SHORT} date-time strings.
* </ul>
*/
-public class CalendarSwap extends PojoSwap<Calendar,String> {
+public class CalendarSwap extends StringSwap<Calendar> {
private static final TimeZone GMT = TimeZone.getTimeZone("GMT");
private final int dateStyle, timeStyle;
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/transforms/DateSwap.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/transforms/DateSwap.java b/juneau-core/src/main/java/org/apache/juneau/transforms/DateSwap.java
index 48fc66f..95673df 100644
--- a/juneau-core/src/main/java/org/apache/juneau/transforms/DateSwap.java
+++ b/juneau-core/src/main/java/org/apache/juneau/transforms/DateSwap.java
@@ -54,7 +54,7 @@ import org.apache.juneau.transform.*;
* <li>{@link DateTimeShort} - To {@link DateFormat#SHORT} date-time strings.
* </ul>
*/
-public class DateSwap extends PojoSwap<Date,String> {
+public class DateSwap extends StringSwap<Date> {
private static final TimeZone GMT = TimeZone.getTimeZone("GMT");
private final int dateStyle, timeStyle;
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/transforms/XMLGregorianCalendarSwap.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/transforms/XMLGregorianCalendarSwap.java b/juneau-core/src/main/java/org/apache/juneau/transforms/XMLGregorianCalendarSwap.java
index 99a17b0..d29327e 100644
--- a/juneau-core/src/main/java/org/apache/juneau/transforms/XMLGregorianCalendarSwap.java
+++ b/juneau-core/src/main/java/org/apache/juneau/transforms/XMLGregorianCalendarSwap.java
@@ -27,7 +27,7 @@ import org.apache.juneau.transform.*;
* <p>
* Strings are converted to objects using {@link DatatypeFactory#newXMLGregorianCalendar(String)}.
*/
-public class XMLGregorianCalendarSwap extends PojoSwap<XMLGregorianCalendar,String> {
+public class XMLGregorianCalendarSwap extends StringSwap<XMLGregorianCalendar> {
private DatatypeFactory dtf;
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonParser.java b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonParser.java
index 28ba828..42d4ee8 100644
--- a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonParser.java
@@ -89,7 +89,7 @@ public class UonParser extends ReaderParser {
eType = (ClassMeta<T>)object();
PojoSwap<T,Object> transform = (PojoSwap<T,Object>)eType.getPojoSwap();
ClassMeta<?> sType = eType.getSerializedClassMeta();
- BeanDictionary bd = (pMeta == null ? session.getBeanDictionary() : pMeta.getBeanDictionary());
+ BeanRegistry breg = (pMeta == null ? session.getBeanRegistry() : pMeta.getBeanRegistry());
Object o = null;
@@ -100,7 +100,7 @@ public class UonParser extends ReaderParser {
if (c == -1 || c == AMP) {
// If parameter is blank and it's an array or collection, return an empty list.
- if (sType.isArray() || sType.isCollection())
+ if (sType.isCollectionOrArray())
o = sType.newInstance();
else if (sType.isString() || sType.isObject())
o = "";
@@ -117,7 +117,7 @@ public class UonParser extends ReaderParser {
} else if (flag == 'o') {
ObjectMap m = new ObjectMap(session);
parseIntoMap(session, r, m, string(), object(), pMeta);
- o = bd.cast(m);
+ o = breg.cast(m);
} else if (flag == 'a') {
Collection l = new ObjectList(session);
o = parseIntoCollection(session, r, l, sType.getElementType(), isUrlParamValue, pMeta);
@@ -142,7 +142,7 @@ public class UonParser extends ReaderParser {
parseIntoMap(session, r, m, string(), object(), pMeta);
// Handle case where it's a collection, but serialized as a map with a _type or _value key.
if (m.containsKey(session.getBeanTypePropertyName()))
- o = bd.cast(m);
+ o = breg.cast(m);
// Handle case where it's a collection, but only a single value was specified.
else {
Collection l = (sType.canCreateNewInstance(outer) ? (Collection)sType.newInstance(outer) : new ObjectList(session));
@@ -173,7 +173,7 @@ public class UonParser extends ReaderParser {
parseIntoMap(session, r, m, string(), object(), pMeta);
// Handle case where it's an array, but serialized as a map with a _type or _value key.
if (m.containsKey(session.getBeanTypePropertyName()))
- o = bd.cast(m);
+ o = breg.cast(m);
// Handle case where it's an array, but only a single value was specified.
else {
ArrayList l = new ArrayList(1);
@@ -189,7 +189,7 @@ public class UonParser extends ReaderParser {
ObjectMap m = new ObjectMap(session);
parseIntoMap(session, r, m, string(), object(), pMeta);
if (m.containsKey(session.getBeanTypePropertyName()))
- o = bd.cast(m);
+ o = breg.cast(m);
else
throw new ParseException(session, "Class ''{0}'' could not be instantiated. Reason: ''{1}''", sType.getInnerClass().getName(), sType.getNotABeanReason());
} else {