Repository: incubator-juneau-website Updated Branches: refs/heads/asf-site 824eb75b7 -> e53bcce45
Virtual Beans. Project: http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/commit/e53bcce4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/tree/e53bcce4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/diff/e53bcce4 Branch: refs/heads/asf-site Commit: e53bcce45a251fcdd2196b2dee6b86a8195b4795 Parents: 824eb75 Author: JamesBognar <[email protected]> Authored: Mon May 15 19:15:42 2017 -0400 Committer: JamesBognar <[email protected]> Committed: Mon May 15 19:15:42 2017 -0400 ---------------------------------------------------------------------- content/site/apidocs/overview-summary.html | 95 ++++++++++++++++++++----- 1 file changed, 78 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/blob/e53bcce4/content/site/apidocs/overview-summary.html ---------------------------------------------------------------------- diff --git a/content/site/apidocs/overview-summary.html b/content/site/apidocs/overview-summary.html index b8ebb43..bf32050 100644 --- a/content/site/apidocs/overview-summary.html +++ b/content/site/apidocs/overview-summary.html @@ -436,6 +436,7 @@ <ol> <li><p><a class='doclink' href='#Core.BeanSubTypes'>Bean Subtypes</a></p> </ol> + <li><p><a class='doclink' href='#Core.VirtualBeans'>Virtual Beans</a></p> <li><p><a class='doclink' href='#Core.PojoCategories'>POJO Categories</a></p> <li><p><a class='doclink' href='#Core.SimpleVarLanguage'>Simple Variable Language</a></p> <li><p><a class='doclink' href='#Core.ConfigFile'>Configuration Files</a></p> @@ -1461,8 +1462,61 @@ </div> <!-- ======================================================================================================== --> + <a id="Core.VirtualBeans"></a> + <h3 class='topic' onclick='toggle(this)'>2.8 - Virtual Beans</h3> + <div class='topic'> + <p> + The <a href="org/apache/juneau/BeanContext.html#BEAN_useInterfaceProxies"><code>BeanContext.BEAN_useInterfaceProxies</code></a> setting (enabled by default) allows + the Juneau parsers to parse content into virtual beans (bean interfaces without implementation classes). + </p> + <p> + For example, the following code creates an instance of the specified unimplemented interface: + </p> + <p class='bcode'> + <jc>// Our unimplemented interface</jc> + <jk>public interface</jk> Address { + + String getStreet(); + <jk>void</jk> setStreet(String x); + + String getCity(); + <jk>void</jk> setCity(String x); + + StateEnum getState(); + <jk>void</jk> setState(StateEnum x); + + <jk>int</jk> getZip(); + <jk>void</jk> setZip(<jk>int</jk> zip); + } + + <jc>// Our code</jc> + Address address = JsonParser.<jsf>DEFAULT</jsf>.parse( + <js>"{street:'123 Main St', city:'Anywhere', state:'PR', zip:12345}"</js>, + Address.<jk>class</jk> + ); + + <jk>int</jk> zip = address.getZip(); + address.setState(StateEnum.<jsf>NY</jsf>); + </p> + <p> + Getter and setter values can be any parsable values, even other virtual beans. + </p> + <p> + Under-the-covers, a virtual bean is simply a proxy interface on top of an existing <code>BeanMap</code> + instance. From a programmatic point-of-view, they're indistinguishable from real beans, and can be + manipulated and serialized like any other bean. + </p> + <p> + Virtual beans can also be created programmatically using the <code>BeanContext</code> class: + </p> + <p class='bcode'> + Address address = BeanContext.<jsf>DEFAULT</jsf>.createSession().newBean(Address.<jk>class</jk>); + </p> + </div> + + <!-- ======================================================================================================== --> <a id="Core.PojoCategories"></a> - <h3 class='topic' onclick='toggle(this)'>2.8 - POJO Categories</h3> + <h3 class='topic' onclick='toggle(this)'>2.9 - POJO Categories</h3> <div class='topic'> <p> The following chart shows POJOs categorized into groups and whether they can be serialized or parsed: @@ -1495,7 +1549,7 @@ <td> <b>With standard keys/values</b><br> Map keys are group [1, 4a, 5a] objects.<br> - Map, Collection, and array values are group [1, 2, 3a, 4a, 5a] objects. + Map, Collection, and array values are group [1, 2, 3ac, 4a, 5a] objects. </td> <td> <ul class='normal'> @@ -1536,7 +1590,7 @@ <td> <b>With standard properties</b><br> These are beans that have no-arg constructors and one or more properties defined by public getter and setter methods or public fields.<br> - Property values are group [1, 2, 3a, 4a, 5a] objects. + Property values are group [1, 2, 3ac, 4a, 5a] objects. </td> <td> </td> <td style='background-color:lightgreen;text-align:center'><b>yes</b></td> @@ -1555,6 +1609,17 @@ <td style='background-color:lightgreen;text-align:center'><b>yes</b></td> <td style='background-color:salmon;text-align:center'><b>no</b></td> </tr> + <tr class='light bb'> + <td style='text-align:center'>3c</td> + <td> + <b>Virtual beans</b><br> + These are unimplemented bean interfaces with properties of type [1, 2, 3ac, 4a, 5a] objects.<br> + Parsers will automatically create interface proxies on top of BeanMap instances. + </td> + <td> </td> + <td style='background-color:lightgreen;text-align:center'><b>yes</b></td> + <td style='background-color:lightgreen;text-align:center'><b>yes</b></td> + </tr> <tr class='dark bb' style='background-color:lightyellow'> <td style='text-align:center'>4</td> <td> @@ -1571,7 +1636,7 @@ <tr class='light bb'> <td style='text-align:center'>4a</td> <td> - <b>2-way swapped to group [1, 2a, 3a] objects</b><br> + <b>2-way swapped to group [1, 2a, 3ac] objects</b><br> For example, a swap that converts a <code>Date</code> to a <code>String</code>. </td> <td> @@ -1612,7 +1677,7 @@ <td> Classes with a method that converts it to a serializable form: <ul> - <li><code><jk>public</jk> X swap(BeanSession);</code> where <code>X</code> is in groups [1, 2a, 3a]. + <li><code><jk>public</jk> X swap(BeanSession);</code> where <code>X</code> is in groups [1, 2a, 3ac]. <li><code><jk>public</jk> String toString();</code> where the string is any meaningful data. </ul> And a method that converts it back into the original object: @@ -1623,8 +1688,8 @@ <li><code><jk>public static</jk> T parseString(String);</code> <li><code><jk>public static</jk> T forName(String);</code> <li><code><jk>public static</jk> T forString(String);</code> - <li><code><jk>public</jk> T(X);</code> where <code>X</code> is in groups [1, 2a, 3a]. - <li><code><jk>public static</jk> T unswap(BeanSession,X);</code> where <code>X</code> is in groups [1, 2a, 3a]. + <li><code><jk>public</jk> T(X);</code> where <code>X</code> is in groups [1, 2a, 3ac]. + <li><code><jk>public static</jk> T unswap(BeanSession,X);</code> where <code>X</code> is in groups [1, 2a, 3ac]. </ul> </td> <td> @@ -1677,7 +1742,7 @@ <!-- ======================================================================================================== --> <a id="Core.SVL"></a> - <h4 class='topic' onclick='toggle(this)'>2.9 - Simple Variable Language</h4> + <h4 class='topic' onclick='toggle(this)'>2.10 - Simple Variable Language</h4> <div class='topic'> <p> The <a class='doclink' href='org/apache/juneau/svl/package-summary.html#TOC'>org.apache.juneau.svl</a> package defines an API for a language called "Simple Variable Language". @@ -1713,7 +1778,7 @@ <!-- ======================================================================================================== --> <a id="Core.ConfigFile"></a> - <h3 class='topic' onclick='toggle(this)'>2.10 - Configuration Files</h3> + <h3 class='topic' onclick='toggle(this)'>2.11 - Configuration Files</h3> <div class='topic'> <p> The <a class='doclink' href='org/apache/juneau/ini/package-summary.html#TOC'>org.apache.juneau.ini</a> package contains a powerful API for creating and using INI-style config files. @@ -1941,11 +2006,6 @@ ci.setBean(<jk>new</jk> MyBean()); cf.save(); </p> - - - - - <h6 class='topic'>Additional Information</h6> <ul class='javahierarchy'> <li class='p'><a class='doclink' href='org/apache/juneau/ini/package-summary.html#TOC'>org.apache.juneau.ini</a> - Config API Javadocs. @@ -1954,7 +2014,7 @@ <!-- ======================================================================================================== --> <a id="Core.SupportedLanguages"></a> - <h3 class='topic' onclick='toggle(this)'>2.11 - Supported Languages</h3> + <h3 class='topic' onclick='toggle(this)'>2.12 - Supported Languages</h3> <div class='topic'> <p> Extensive javadocs exist for individual language support. @@ -1978,7 +2038,7 @@ <!-- ======================================================================================================== --> <a id="Core.JacksonComparison"></a> - <h3 class='topic' onclick='toggle(this)'>2.12 - Comparison with Jackson</h3> + <h3 class='topic' onclick='toggle(this)'>2.13 - Comparison with Jackson</h3> <div class='topic'> <p> Juneau was developed independently from Jackson, but shares many of the same features and capabilities. @@ -6396,7 +6456,8 @@ <ul class='spaced-list'> <li>New package: <a href="org/apache/juneau/http/package-summary.html"><code>org.apache.juneau.http</code></a>. <li>Support for dynamic beans. See <a href="org/apache/juneau/annotation/BeanProperty.html#name--"><code>@BeanProperty.name()</code></a>. - <li>New doc: <a class='doclink' href='#Core.JacksonComparison'>2.12 - Comparison with Jackson</a> + <li>New doc: <a class='doclink' href='#Core.VirtualBeans'>2.8 - Virtual Beans</a> + <li>New doc: <a class='doclink' href='#Core.JacksonComparison'>2.13 - Comparison with Jackson</a> <li>All parsers now allow for numeric types with <js>'K'</js>/<js>'M'</js>/<js>'G'</js> suffixes to represent kilobytes, megabytes, and gigabytes. <p class='bcode'>
