http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core-test/src/test/java/org/apache/juneau/transforms/ReaderObjectSwapTest.java ---------------------------------------------------------------------- diff --git a/juneau-core-test/src/test/java/org/apache/juneau/transforms/ReaderObjectSwapTest.java b/juneau-core-test/src/test/java/org/apache/juneau/transforms/ReaderObjectSwapTest.java new file mode 100644 index 0000000..5bc0e65 --- /dev/null +++ b/juneau-core-test/src/test/java/org/apache/juneau/transforms/ReaderObjectSwapTest.java @@ -0,0 +1,494 @@ +// *************************************************************************************************************************** +// * 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.transforms; + +import java.io.*; +import java.util.*; + +import org.apache.juneau.*; +import org.apache.juneau.annotation.*; +import org.apache.juneau.http.*; +import org.apache.juneau.transform.*; +import org.apache.juneau.utils.*; +import org.junit.runner.*; +import org.junit.runners.*; + +/** + * Verifies that Reader and InputStream objects are serialized correctly. + * Note that these are one-way serializations and you're not guaranteed to produce parsable output. + */ +@RunWith(Parameterized.class) +@SuppressWarnings({"javadoc"}) +public class ReaderObjectSwapTest extends ComboSerializeTest { + + @Parameterized.Parameters + public static Collection<Object[]> getParameters() { + return Arrays.asList(new Object[][] { + { /* 0 */ + new ComboInput<PojoToSimpleReader>( + "PojoToSimpleReader", + PojoToSimpleReader.class, + new PojoToSimpleReader(), + /* Json */ "foo", + /* JsonT */ "foo", + /* JsonR */ "foo", + /* Xml */ "foo", + /* XmlT */ "foo", + /* XmlR */ "foo\n", + /* XmlNs */ "foo", + /* Html */ "foo", + /* HtmlT */ "foo", + /* HtmlR */ "foo", + /* Uon */ "foo", + /* UonT */ "foo", + /* UonR */ "foo", + /* UrlEnc */ "foo", + /* UrlEncT */ "foo", + /* UrlEncR */ "foo", + /* MsgPack */ "666F6F", + /* MsgPackT */ "666F6F", + /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<j:value>foo</j:value>\n</rdf:Description>\n</rdf:RDF>\n", + /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<j:value>foo</j:value>\n</rdf:Description>\n</rdf:RDF>\n", + /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <j:value>foo</j:value>\n </rdf:Description>\n</rdf:RDF>\n" + ) + }, + { /* 1 */ + new ComboInput<PojoToDynamicReader>( + "PojoToDynamicReader", + PojoToDynamicReader.class, + new PojoToDynamicReader("foo"), + /* Json */ "foo-json", + /* JsonT */ "foo-json", + /* JsonR */ "foo-json", + /* Xml */ "foo-xml", + /* XmlT */ "foo-xml", + /* XmlR */ "foo-xml\n", + /* XmlNs */ "foo-xml", + /* Html */ "foo-html", + /* HtmlT */ "foo-html", + /* HtmlR */ "foo-html", + /* Uon */ "foo-uon", + /* UonT */ "foo-uon", + /* UonR */ "foo-uon", + /* UrlEnc */ "foo-x-www-form-urlencoded", + /* UrlEncT */ "foo-x-www-form-urlencoded", + /* UrlEncR */ "foo-x-www-form-urlencoded", + /* MsgPack */ "666F6F2D6D73677061636B", + /* MsgPackT */ "666F6F2D6D73677061636B", + /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<j:value>foo-xml</j:value>\n</rdf:Description>\n</rdf:RDF>\n", + /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<j:value>foo-xml</j:value>\n</rdf:Description>\n</rdf:RDF>\n", + /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <j:value>foo-xml</j:value>\n </rdf:Description>\n</rdf:RDF>\n" + ) + }, + { /* 2 */ + new ComboInput<SometimesSwappedBean1>( + "SometimesSwappedBean1", + SometimesSwappedBean1.class, + new SometimesSwappedBean1("foo"), + /* Json */ "foo-application/json", + /* JsonT */ "foo-application/json", + /* JsonR */ "foo-application/json", + /* Xml */ "foo-text/xml", + /* XmlT */ "foo-text/xml", + /* XmlR */ "foo-text/xml\n", + /* XmlNs */ "foo-text/xml", + /* Html */ "<table><tr><td>f</td><td>foo</td></tr></table>", + /* HtmlT */ "<table><tr><td>f</td><td>foo</td></tr></table>", + /* HtmlR */ "<table>\n\t<tr>\n\t\t<td>f</td>\n\t\t<td>foo</td>\n\t</tr>\n</table>\n", + /* Uon */ "(f=foo)", + /* UonT */ "(f=foo)", + /* UonR */ "(\n\tf=foo\n)", + /* UrlEnc */ "f=foo", + /* UrlEncT */ "f=foo", + /* UrlEncR */ "f=foo", + /* MsgPack */ "81A166A3666F6F", + /* MsgPackT */ "81A166A3666F6F", + /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<j:value>foo-text/xml+rdf</j:value>\n</rdf:Description>\n</rdf:RDF>\n", + /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<j:value>foo-text/xml+rdf</j:value>\n</rdf:Description>\n</rdf:RDF>\n", + /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <j:value>foo-text/xml+rdf</j:value>\n </rdf:Description>\n</rdf:RDF>\n" + ) + }, + { /* 3 */ + new ComboInput<SometimesSwappedBean2>( + "SometimesSwappedBean2", + SometimesSwappedBean2.class, + new SometimesSwappedBean2("foo"), + /* Json */ "{f:'foo'}", + /* JsonT */ "{f:'foo'}", + /* JsonR */ "{\n\tf: 'foo'\n}", + /* Xml */ "<object><f>foo</f></object>", + /* XmlT */ "<object><f>foo</f></object>", + /* XmlR */ "<object>\n\t<f>foo</f>\n</object>\n", + /* XmlNs */ "<object><f>foo</f></object>", + /* Html */ "foo-text/html", + /* HtmlT */ "foo-text/html", + /* HtmlR */ "foo-text/html", + /* Uon */ "foo-text/uon", + /* UonT */ "foo-text/uon", + /* UonR */ "foo-text/uon", + /* UrlEnc */ "foo-application/x-www-form-urlencoded", + /* UrlEncT */ "foo-application/x-www-form-urlencoded", + /* UrlEncR */ "foo-application/x-www-form-urlencoded", + /* MsgPack */ "666F6F2D6F6374616C2F6D73677061636B", + /* MsgPackT */ "666F6F2D6F6374616C2F6D73677061636B", + /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>foo</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", + /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>foo</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", + /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <jp:f>foo</jp:f>\n </rdf:Description>\n</rdf:RDF>\n" + ) + }, + { /* 4 */ + new ComboInput<BeanWithSwappedField>( + "BeanWithSwappedField", + BeanWithSwappedField.class, + new BeanWithSwappedField("x"), + /* Json */ "{f:x-json}", + /* JsonT */ "{f:x-json}", + /* JsonR */ "{\n\tf: x-json\n}", + /* Xml */ "<object><f>x-xml</f></object>", + /* XmlT */ "<object><f>x-xml</f></object>", + /* XmlR */ "<object>\n\t<f>x-xml</f>\n</object>\n", + /* XmlNs */ "<object><f>x-xml</f></object>", + /* Html */ "<table><tr><td>f</td><td>x-html</td></tr></table>", + /* HtmlT */ "<table><tr><td>f</td><td>x-html</td></tr></table>", + /* HtmlR */ "<table>\n\t<tr>\n\t\t<td>f</td>\n\t\t<td>x-html</td>\n\t</tr>\n</table>\n", + /* Uon */ "(f=x-uon)", + /* UonT */ "(f=x-uon)", + /* UonR */ "(\n\tf=x-uon\n)", + /* UrlEnc */ "f=x-x-www-form-urlencoded", + /* UrlEncT */ "f=x-x-www-form-urlencoded", + /* UrlEncR */ "f=x-x-www-form-urlencoded", + /* MsgPack */ "81A166782D6D73677061636B", + /* MsgPackT */ "81A166782D6D73677061636B", + /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>x-xml</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", + /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>x-xml</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", + /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <jp:f>x-xml</jp:f>\n </rdf:Description>\n</rdf:RDF>\n" + ) + }, + { /* 5 */ + new ComboInput<BeanWithSwapped1dField>( + "BeanWithSwapped1dField", + BeanWithSwapped1dField.class, + new BeanWithSwapped1dField("x"), + /* Json */ "{f:[x1-json,x2-json,null]}", + /* JsonT */ "{f:[x1-json,x2-json,null]}", + /* JsonR */ "{\n\tf: [\n\t\tx1-json,\n\t\tx2-json,\n\t\tnull\n\t]\n}", + /* Xml */ "<object><f>x1-xmlx2-xml<null/></f></object>", + /* XmlT */ "<object><f>x1-xmlx2-xml<null/></f></object>", + /* XmlR */ "<object>\n\t<f>\n\t\tx1-xml\n\t\tx2-xml\n\t\t<null/>\n\t</f>\n</object>\n", + /* XmlNs */ "<object><f>x1-xmlx2-xml<null/></f></object>", + /* Html */ "<table><tr><td>f</td><td><ul><li>x1-html</li><li>x2-html</li><li><null/></li></ul></td></tr></table>", + /* HtmlT */ "<table><tr><td>f</td><td><ul><li>x1-html</li><li>x2-html</li><li><null/></li></ul></td></tr></table>", + /* HtmlR */ "<table>\n\t<tr>\n\t\t<td>f</td>\n\t\t<td>\n\t\t\t<ul>\n\t\t\t\t<li>x1-html</li>\n\t\t\t\t<li>x2-html</li>\n\t\t\t\t<li><null/></li>\n\t\t\t</ul>\n\t\t</td>\n\t</tr>\n</table>\n", + /* Uon */ "(f=@(x1-uon,x2-uon,null))", + /* UonT */ "(f=@(x1-uon,x2-uon,null))", + /* UonR */ "(\n\tf=@(\n\t\tx1-uon,\n\t\tx2-uon,\n\t\tnull\n\t)\n)", + /* UrlEnc */ "f=@(x1-x-www-form-urlencoded,x2-x-www-form-urlencoded,null)", + /* UrlEncT */ "f=@(x1-x-www-form-urlencoded,x2-x-www-form-urlencoded,null)", + /* UrlEncR */ "f=@(\n\tx1-x-www-form-urlencoded,\n\tx2-x-www-form-urlencoded,\n\tnull\n)", + /* MsgPack */ "81A1669378312D6D73677061636B78322D6D73677061636BC0", + /* MsgPackT */ "81A1669378312D6D73677061636B78322D6D73677061636BC0", + /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>\n<rdf:Seq>\n<rdf:li>x1-xml</rdf:li>\n<rdf:li>x2-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", + /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>\n<rdf:Seq>\n<rdf:li>x1-xml</rdf:li>\n<rdf:li>x2-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", + /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <jp:f>\n <rdf:Seq>\n <rdf:li>x1-xml</rdf:li>\n <rdf:li>x2-xml</rdf:li>\n <rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n </rdf:Seq>\n </jp:f>\n </rdf:Description>\n</rdf:RDF>\n" + ) + }, + { /* 6 */ + new ComboInput<BeanWithSwappedNullField>( + "BeanWithSwappedNullField", + BeanWithSwappedNullField.class, + new BeanWithSwappedNullField(), + /* Json */ "{}", + /* JsonT */ "{}", + /* JsonR */ "{\n}", + /* Xml */ "<object/>", + /* XmlT */ "<object/>", + /* XmlR */ "<object/>\n", + /* XmlNs */ "<object/>", + /* Html */ "<table></table>", + /* HtmlT */ "<table></table>", + /* HtmlR */ "<table>\n</table>\n", + /* Uon */ "()", + /* UonT */ "()", + /* UonR */ "(\n)", + /* UrlEnc */ "", + /* UrlEncT */ "", + /* UrlEncR */ "", + /* MsgPack */ "80", + /* MsgPackT */ "80", + /* RdfXml */ "<rdf:RDF>\n</rdf:RDF>\n", + /* RdfXmlT */ "<rdf:RDF>\n</rdf:RDF>\n", + /* RdfXmlR */ "<rdf:RDF>\n</rdf:RDF>\n" + ) + }, + { /* 7 */ + new ComboInput<BeanWithSwappedListField>( + "BeanWithSwappedListField", + BeanWithSwappedListField.class, + new BeanWithSwappedListField("x"), + /* Json */ "{f:[x1-json,x2-json,null]}", + /* JsonT */ "{f:[x1-json,x2-json,null]}", + /* JsonR */ "{\n\tf: [\n\t\tx1-json,\n\t\tx2-json,\n\t\tnull\n\t]\n}", + /* Xml */ "<object><f>x1-xmlx2-xml<null/></f></object>", + /* XmlT */ "<object><f>x1-xmlx2-xml<null/></f></object>", + /* XmlR */ "<object>\n\t<f>\n\t\tx1-xml\n\t\tx2-xml\n\t\t<null/>\n\t</f>\n</object>\n", + /* XmlNs */ "<object><f>x1-xmlx2-xml<null/></f></object>", + /* Html */ "<table><tr><td>f</td><td><ul><li>x1-html</li><li>x2-html</li><li><null/></li></ul></td></tr></table>", + /* HtmlT */ "<table><tr><td>f</td><td><ul><li>x1-html</li><li>x2-html</li><li><null/></li></ul></td></tr></table>", + /* HtmlR */ "<table>\n\t<tr>\n\t\t<td>f</td>\n\t\t<td>\n\t\t\t<ul>\n\t\t\t\t<li>x1-html</li>\n\t\t\t\t<li>x2-html</li>\n\t\t\t\t<li><null/></li>\n\t\t\t</ul>\n\t\t</td>\n\t</tr>\n</table>\n", + /* Uon */ "(f=@(x1-uon,x2-uon,null))", + /* UonT */ "(f=@(x1-uon,x2-uon,null))", + /* UonR */ "(\n\tf=@(\n\t\tx1-uon,\n\t\tx2-uon,\n\t\tnull\n\t)\n)", + /* UrlEnc */ "f=@(x1-x-www-form-urlencoded,x2-x-www-form-urlencoded,null)", + /* UrlEncT */ "f=@(x1-x-www-form-urlencoded,x2-x-www-form-urlencoded,null)", + /* UrlEncR */ "f=@(\n\tx1-x-www-form-urlencoded,\n\tx2-x-www-form-urlencoded,\n\tnull\n)", + /* MsgPack */ "81A1669378312D6D73677061636B78322D6D73677061636BC0", + /* MsgPackT */ "81A1669378312D6D73677061636B78322D6D73677061636BC0", + /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>\n<rdf:Seq>\n<rdf:li>x1-xml</rdf:li>\n<rdf:li>x2-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", + /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>\n<rdf:Seq>\n<rdf:li>x1-xml</rdf:li>\n<rdf:li>x2-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", + /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <jp:f>\n <rdf:Seq>\n <rdf:li>x1-xml</rdf:li>\n <rdf:li>x2-xml</rdf:li>\n <rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n </rdf:Seq>\n </jp:f>\n </rdf:Description>\n</rdf:RDF>\n" + ) + }, + { /* 8 */ + new ComboInput<BeanWithSwappedMapField>( + "BeanWithSwappedMapField", + BeanWithSwappedMapField.class, + new BeanWithSwappedMapField("x"), + /* Json */ "{f:{foo:x1-json,bar:null,null:x2-json}}", + /* JsonT */ "{f:{foo:x1-json,bar:null,null:x2-json}}", + /* JsonR */ "{\n\tf: {\n\t\tfoo: x1-json,\n\t\tbar: null,\n\t\tnull: x2-json\n\t}\n}", + /* Xml */ "<object><f><foo>x1-xml</foo><bar _type='null'/><_x0000_>x2-xml</_x0000_></f></object>", + /* XmlT */ "<object><f><foo>x1-xml</foo><bar t='null'/><_x0000_>x2-xml</_x0000_></f></object>", + /* XmlR */ "<object>\n\t<f>\n\t\t<foo>x1-xml</foo>\n\t\t<bar _type='null'/>\n\t\t<_x0000_>x2-xml</_x0000_>\n\t</f>\n</object>\n", + /* XmlNs */ "<object><f><foo>x1-xml</foo><bar _type='null'/><_x0000_>x2-xml</_x0000_></f></object>", + /* Html */ "<table><tr><td>f</td><td><table><tr><td>foo</td><td>x1-html</td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td>x2-html</td></tr></table></td></tr></table>", + /* HtmlT */ "<table><tr><td>f</td><td><table><tr><td>foo</td><td>x1-html</td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td>x2-html</td></tr></table></td></tr></table>", + /* HtmlR */ "<table>\n\t<tr>\n\t\t<td>f</td>\n\t\t<td>\n\t\t\t<table>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>foo</td>\n\t\t\t\t\t<td>x1-html</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>bar</td>\n\t\t\t\t\t<td><null/></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td><null/></td>\n\t\t\t\t\t<td>x2-html</td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t</td>\n\t</tr>\n</table>\n", + /* Uon */ "(f=(foo=x1-uon,bar=null,null=x2-uon))", + /* UonT */ "(f=(foo=x1-uon,bar=null,null=x2-uon))", + /* UonR */ "(\n\tf=(\n\t\tfoo=x1-uon,\n\t\tbar=null,\n\t\tnull=x2-uon\n\t)\n)", + /* UrlEnc */ "f=(foo=x1-x-www-form-urlencoded,bar=null,null=x2-x-www-form-urlencoded)", + /* UrlEncT */ "f=(foo=x1-x-www-form-urlencoded,bar=null,null=x2-x-www-form-urlencoded)", + /* UrlEncR */ "f=(\n\tfoo=x1-x-www-form-urlencoded,\n\tbar=null,\n\tnull=x2-x-www-form-urlencoded\n)", + /* MsgPack */ "81A16683A3666F6F78312D6D73677061636BA3626172C0C078322D6D73677061636B", + /* MsgPackT */ "81A16683A3666F6F78312D6D73677061636BA3626172C0C078322D6D73677061636B", + /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<jp:f rdf:parseType='Resource'>\n<jp:foo>x1-xml</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_>x2-xml</jp:_x0000_>\n</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", + /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<jp:f rdf:parseType='Resource'>\n<jp:foo>x1-xml</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_>x2-xml</jp:_x0000_>\n</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", + /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <jp:f rdf:parseType='Resource'>\n <jp:foo>x1-xml</jp:foo>\n <jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n <jp:_x0000_>x2-xml</jp:_x0000_>\n </jp:f>\n </rdf:Description>\n</rdf:RDF>\n" + ) + }, + { /* 9 */ + new ComboInput<BeanWithListBeanSwappedField>( + "BeanWithListBeanSwappedField", + BeanWithListBeanSwappedField.class, + new BeanWithListBeanSwappedField("x"), + /* Json */ "{f:[{f1:x1a-json,f2:[x2a-json,x2b-json,null],f4:[x4a-json,x4b-json,null],f5:{foo:x5a-json,bar:null,null:x5c-json}},null]}", + /* JsonT */ "{f:[{f1:x1a-json,f2:[x2a-json,x2b-json,null],f4:[x4a-json,x4b-json,null],f5:{foo:x5a-json,bar:null,null:x5c-json}},null]}", + /* JsonR */ "{\n\tf: [\n\t\t{\n\t\t\tf1: x1a-json,\n\t\t\tf2: [\n\t\t\t\tx2a-json,\n\t\t\t\tx2b-json,\n\t\t\t\tnull\n\t\t\t],\n\t\t\tf4: [\n\t\t\t\tx4a-json,\n\t\t\t\tx4b-json,\n\t\t\t\tnull\n\t\t\t],\n\t\t\tf5: {\n\t\t\t\tfoo: x5a-json,\n\t\t\t\tbar: null,\n\t\t\t\tnull: x5c-json\n\t\t\t}\n\t\t},\n\t\tnull\n\t]\n}", + /* Xml */ "<object><f><object><f1>x1a-xml</f1><f2>x2a-xmlx2b-xml<null/></f2><f4>x4a-xmlx4b-xml<null/></f4><f5><foo>x5a-xml</foo><bar _type='null'/><_x0000_>x5c-xml</_x0000_></f5></object><null/></f></object>", + /* XmlT */ "<object><f><object><f1>x1a-xml</f1><f2>x2a-xmlx2b-xml<null/></f2><f4>x4a-xmlx4b-xml<null/></f4><f5><foo>x5a-xml</foo><bar t='null'/><_x0000_>x5c-xml</_x0000_></f5></object><null/></f></object>", + /* XmlR */ "<object>\n\t<f>\n\t\t<object>\n\t\t\t<f1>x1a-xml</f1>\n\t\t\t<f2>\n\t\t\t\tx2a-xml\n\t\t\t\tx2b-xml\n\t\t\t\t<null/>\n\t\t\t</f2>\n\t\t\t<f4>\n\t\t\t\tx4a-xml\n\t\t\t\tx4b-xml\n\t\t\t\t<null/>\n\t\t\t</f4>\n\t\t\t<f5>\n\t\t\t\t<foo>x5a-xml</foo>\n\t\t\t\t<bar _type='null'/>\n\t\t\t\t<_x0000_>x5c-xml</_x0000_>\n\t\t\t</f5>\n\t\t</object>\n\t\t<null/>\n\t</f>\n</object>\n", + /* XmlNs */ "<object><f><object><f1>x1a-xml</f1><f2>x2a-xmlx2b-xml<null/></f2><f4>x4a-xmlx4b-xml<null/></f4><f5><foo>x5a-xml</foo><bar _type='null'/><_x0000_>x5c-xml</_x0000_></f5></object><null/></f></object>", + /* Html */ "<table><tr><td>f</td><td><table _type='array'><tr><th>f1</th><th>f2</th><th>f4</th><th>f5</th></tr><tr><td>x1a-html</td><td><ul><li>x2a-html</li><li>x2b-html</li><li><null/></li></ul></td><td><ul><li>x4a-html</li><li>x4b-html</li><li><null/></li></ul></td><td><table><tr><td>foo</td><td>x5a-html</td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td>x5c-html</td></tr></table></td></tr><tr><null/></tr></table></td></tr></table>", + /* HtmlT */ "<table><tr><td>f</td><td><table t='array'><tr><th>f1</th><th>f2</th><th>f4</th><th>f5</th></tr><tr><td>x1a-html</td><td><ul><li>x2a-html</li><li>x2b-html</li><li><null/></li></ul></td><td><ul><li>x4a-html</li><li>x4b-html</li><li><null/></li></ul></td><td><table><tr><td>foo</td><td>x5a-html</td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td>x5c-html</td></tr></table></td></tr><tr><null/></tr></table></td></tr></table>", + /* HtmlR */ "<table>\n\t<tr>\n\t\t<td>f</td>\n\t\t<td>\n\t\t\t<table _type='array'>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>f1</th>\n\t\t\t\t\t<th>f2</th>\n\t\t\t\t\t<th>f4</th>\n\t\t\t\t\t<th>f5</th>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>x1a-html</td>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t<li>x2a-html</li>\n\t\t\t\t\t\t\t<li>x2b-html</li>\n\t\t\t\t\t\t\t<li><null/></li>\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t<li>x4a-html</li>\n\t\t\t\t\t\t\t<li>x4b-html</li>\n\t\t\t\t\t\t\t<li><null/></li>\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<table>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td>foo</td>\n\t\t\t\t\t\t\t\t<td>x5a-html</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td>bar</td>\n\t\t\t\t\t\t\t\t<td><null/></td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td><null/></td>\n\t\t\t\t\t\t\t\t<td>x5c-html</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</td>\n\t\t\t\t< /tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<null/>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t</td>\n\t</tr>\n</table>\n", + /* Uon */ "(f=@((f1=x1a-uon,f2=@(x2a-uon,x2b-uon,null),f4=@(x4a-uon,x4b-uon,null),f5=(foo=x5a-uon,bar=null,null=x5c-uon)),null))", + /* UonT */ "(f=@((f1=x1a-uon,f2=@(x2a-uon,x2b-uon,null),f4=@(x4a-uon,x4b-uon,null),f5=(foo=x5a-uon,bar=null,null=x5c-uon)),null))", + /* UonR */ "(\n\tf=@(\n\t\t(\n\t\t\tf1=x1a-uon,\n\t\t\tf2=@(\n\t\t\t\tx2a-uon,\n\t\t\t\tx2b-uon,\n\t\t\t\tnull\n\t\t\t),\n\t\t\tf4=@(\n\t\t\t\tx4a-uon,\n\t\t\t\tx4b-uon,\n\t\t\t\tnull\n\t\t\t),\n\t\t\tf5=(\n\t\t\t\tfoo=x5a-uon,\n\t\t\t\tbar=null,\n\t\t\t\tnull=x5c-uon\n\t\t\t)\n\t\t),\n\t\tnull\n\t)\n)", + /* UrlEnc */ "f=@((f1=x1a-x-www-form-urlencoded,f2=@(x2a-x-www-form-urlencoded,x2b-x-www-form-urlencoded,null),f4=@(x4a-x-www-form-urlencoded,x4b-x-www-form-urlencoded,null),f5=(foo=x5a-x-www-form-urlencoded,bar=null,null=x5c-x-www-form-urlencoded)),null)", + /* UrlEncT */ "f=@((f1=x1a-x-www-form-urlencoded,f2=@(x2a-x-www-form-urlencoded,x2b-x-www-form-urlencoded,null),f4=@(x4a-x-www-form-urlencoded,x4b-x-www-form-urlencoded,null),f5=(foo=x5a-x-www-form-urlencoded,bar=null,null=x5c-x-www-form-urlencoded)),null)", + /* UrlEncR */ "f=@(\n\t(\n\t\tf1=x1a-x-www-form-urlencoded,\n\t\tf2=@(\n\t\t\tx2a-x-www-form-urlencoded,\n\t\t\tx2b-x-www-form-urlencoded,\n\t\t\tnull\n\t\t),\n\t\tf4=@(\n\t\t\tx4a-x-www-form-urlencoded,\n\t\t\tx4b-x-www-form-urlencoded,\n\t\t\tnull\n\t\t),\n\t\tf5=(\n\t\t\tfoo=x5a-x-www-form-urlencoded,\n\t\t\tbar=null,\n\t\t\tnull=x5c-x-www-form-urlencoded\n\t\t)\n\t),\n\tnull\n)", + /* MsgPack */ "81A1669284A266317831612D6D73677061636BA26632937832612D6D73677061636B7832622D6D73677061636BC0A26634937834612D6D73677061636B7834622D6D73677061636BC0A2663583A3666F6F7835612D6D73677061636BA3626172C0C07835632D6D73677061636BC0", + /* MsgPackT */ "81A1669284A266317831612D6D73677061636BA26632937832612D6D73677061636B7832622D6D73677061636BC0A26634937834612D6D73677061636B7834622D6D73677061636BC0A2663583A3666F6F7835612D6D73677061636BA3626172C0C07835632D6D73677061636BC0", + /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>\n<rdf:Seq>\n<rdf:li rdf:parseType='Resource'>\n<jp:f1>x1a-xml</jp:f1>\n<jp:f2>\n<rdf:Seq>\n<rdf:li>x2a-xml</rdf:li>\n<rdf:li>x2b-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f2>\n<jp:f4>\n<rdf:Seq>\n<rdf:li>x4a-xml</rdf:li>\n<rdf:li>x4b-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f4>\n<jp:f5 rdf:parseType='Resource'>\n<jp:foo>x5a-xml</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_>x5c-xml</jp:_x0000_>\n</jp:f5>\n</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", + /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>\n<rdf:Seq>\n<rdf:li rdf:parseType='Resource'>\n<jp:f1>x1a-xml</jp:f1>\n<jp:f2>\n<rdf:Seq>\n<rdf:li>x2a-xml</rdf:li>\n<rdf:li>x2b-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f2>\n<jp:f4>\n<rdf:Seq>\n<rdf:li>x4a-xml</rdf:li>\n<rdf:li>x4b-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f4>\n<jp:f5 rdf:parseType='Resource'>\n<jp:foo>x5a-xml</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_>x5c-xml</jp:_x0000_>\n</jp:f5>\n</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", + /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <jp:f>\n <rdf:Seq>\n <rdf:li rdf:parseType='Resource'>\n <jp:f1>x1a-xml</jp:f1>\n <jp:f2>\n <rdf:Seq>\n <rdf:li>x2a-xml</rdf:li>\n <rdf:li>x2b-xml</rdf:li>\n <rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n </rdf:Seq>\n </jp:f2>\n <jp:f4>\n <rdf:Seq>\n <rdf:li>x4a-xml</rdf:li>\n <rdf:li>x4b-xml</rdf:li>\n <rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n </rdf:Seq>\n </jp:f4>\n <jp:f5 rdf:parseType='Resource'>\n <jp:foo>x5a-xml</jp:foo>\n <jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n <jp:_x0000_>x5c-xml</jp:_x0000_>\n </jp:f5>\n </rdf:li>\n <rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n </rdf:Seq>\n </jp:f>\n </rdf:Description>\n</rdf:RDF>\n" + ) + }, + { /* 10 */ + new ComboInput<BeanWithMapBeanSwappedField>( + "BeanWithMapBeanSwappedField", + BeanWithMapBeanSwappedField.class, + new BeanWithMapBeanSwappedField("x"), + /* Json */ "{f:{foo:{f1:x1a-json,f2:[x2a-json,x2b-json,null],f4:[x4a-json,x4b-json,null],f5:{foo:x5a-json,bar:null,null:x5c-json}},bar:null,null:{f1:x1a-json,f2:[x2a-json,x2b-json,null],f4:[x4a-json,x4b-json,null],f5:{foo:x5a-json,bar:null,null:x5c-json}}}}", + /* JsonT */ "{f:{foo:{f1:x1a-json,f2:[x2a-json,x2b-json,null],f4:[x4a-json,x4b-json,null],f5:{foo:x5a-json,bar:null,null:x5c-json}},bar:null,null:{f1:x1a-json,f2:[x2a-json,x2b-json,null],f4:[x4a-json,x4b-json,null],f5:{foo:x5a-json,bar:null,null:x5c-json}}}}", + /* JsonR */ "{\n\tf: {\n\t\tfoo: {\n\t\t\tf1: x1a-json,\n\t\t\tf2: [\n\t\t\t\tx2a-json,\n\t\t\t\tx2b-json,\n\t\t\t\tnull\n\t\t\t],\n\t\t\tf4: [\n\t\t\t\tx4a-json,\n\t\t\t\tx4b-json,\n\t\t\t\tnull\n\t\t\t],\n\t\t\tf5: {\n\t\t\t\tfoo: x5a-json,\n\t\t\t\tbar: null,\n\t\t\t\tnull: x5c-json\n\t\t\t}\n\t\t},\n\t\tbar: null,\n\t\tnull: {\n\t\t\tf1: x1a-json,\n\t\t\tf2: [\n\t\t\t\tx2a-json,\n\t\t\t\tx2b-json,\n\t\t\t\tnull\n\t\t\t],\n\t\t\tf4: [\n\t\t\t\tx4a-json,\n\t\t\t\tx4b-json,\n\t\t\t\tnull\n\t\t\t],\n\t\t\tf5: {\n\t\t\t\tfoo: x5a-json,\n\t\t\t\tbar: null,\n\t\t\t\tnull: x5c-json\n\t\t\t}\n\t\t}\n\t}\n}", + /* Xml */ "<object><f><foo><f1>x1a-xml</f1><f2>x2a-xmlx2b-xml<null/></f2><f4>x4a-xmlx4b-xml<null/></f4><f5><foo>x5a-xml</foo><bar _type='null'/><_x0000_>x5c-xml</_x0000_></f5></foo><bar _type='null'/><_x0000_><f1>x1a-xml</f1><f2>x2a-xmlx2b-xml<null/></f2><f4>x4a-xmlx4b-xml<null/></f4><f5><foo>x5a-xml</foo><bar _type='null'/><_x0000_>x5c-xml</_x0000_></f5></_x0000_></f></object>", + /* XmlT */ "<object><f><foo><f1>x1a-xml</f1><f2>x2a-xmlx2b-xml<null/></f2><f4>x4a-xmlx4b-xml<null/></f4><f5><foo>x5a-xml</foo><bar t='null'/><_x0000_>x5c-xml</_x0000_></f5></foo><bar t='null'/><_x0000_><f1>x1a-xml</f1><f2>x2a-xmlx2b-xml<null/></f2><f4>x4a-xmlx4b-xml<null/></f4><f5><foo>x5a-xml</foo><bar t='null'/><_x0000_>x5c-xml</_x0000_></f5></_x0000_></f></object>", + /* XmlR */ "<object>\n\t<f>\n\t\t<foo>\n\t\t\t<f1>x1a-xml</f1>\n\t\t\t<f2>\n\t\t\t\tx2a-xml\n\t\t\t\tx2b-xml\n\t\t\t\t<null/>\n\t\t\t</f2>\n\t\t\t<f4>\n\t\t\t\tx4a-xml\n\t\t\t\tx4b-xml\n\t\t\t\t<null/>\n\t\t\t</f4>\n\t\t\t<f5>\n\t\t\t\t<foo>x5a-xml</foo>\n\t\t\t\t<bar _type='null'/>\n\t\t\t\t<_x0000_>x5c-xml</_x0000_>\n\t\t\t</f5>\n\t\t</foo>\n\t\t<bar _type='null'/>\n\t\t<_x0000_>\n\t\t\t<f1>x1a-xml</f1>\n\t\t\t<f2>\n\t\t\t\tx2a-xml\n\t\t\t\tx2b-xml\n\t\t\t\t<null/>\n\t\t\t</f2>\n\t\t\t<f4>\n\t\t\t\tx4a-xml\n\t\t\t\tx4b-xml\n\t\t\t\t<null/>\n\t\t\t</f4>\n\t\t\t<f5>\n\t\t\t\t<foo>x5a-xml</foo>\n\t\t\t\t<bar _type='null'/>\n\t\t\t\t<_x0000_>x5c-xml</_x0000_>\n\t\t\t</f5>\n\t\t</_x0000_>\n\t</f>\n</object>\n", + /* XmlNs */ "<object><f><foo><f1>x1a-xml</f1><f2>x2a-xmlx2b-xml<null/></f2><f4>x4a-xmlx4b-xml<null/></f4><f5><foo>x5a-xml</foo><bar _type='null'/><_x0000_>x5c-xml</_x0000_></f5></foo><bar _type='null'/><_x0000_><f1>x1a-xml</f1><f2>x2a-xmlx2b-xml<null/></f2><f4>x4a-xmlx4b-xml<null/></f4><f5><foo>x5a-xml</foo><bar _type='null'/><_x0000_>x5c-xml</_x0000_></f5></_x0000_></f></object>", + /* Html */ "<table><tr><td>f</td><td><table><tr><td>foo</td><td><table><tr><td>f1</td><td>x1a-html</td></tr><tr><td>f2</td><td><ul><li>x2a-html</li><li>x2b-html</li><li><null/></li></ul></td></tr><tr><td>f4</td><td><ul><li>x4a-html</li><li>x4b-html</li><li><null/></li></ul></td></tr><tr><td>f5</td><td><table><tr><td>foo</td><td>x5a-html</td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td>x5c-html</td></tr></table></td></tr></table></td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td><table><tr><td>f1</td><td>x1a-html</td></tr><tr><td>f2</td><td><ul><li>x2a-html</li><li>x2b-html</li><li><null/></li></ul></td></tr><tr><td>f4</td><td><ul><li>x4a-html</li><li>x4b-html</li><li><null/></li></ul></td></tr><tr><td>f5</td><td><table><tr><td>foo</td><td>x5a-html</td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td>x5c-html</td></tr></table></td></tr></table></td></tr></table></td></tr></table>", + /* HtmlT */ "<table><tr><td>f</td><td><table><tr><td>foo</td><td><table><tr><td>f1</td><td>x1a-html</td></tr><tr><td>f2</td><td><ul><li>x2a-html</li><li>x2b-html</li><li><null/></li></ul></td></tr><tr><td>f4</td><td><ul><li>x4a-html</li><li>x4b-html</li><li><null/></li></ul></td></tr><tr><td>f5</td><td><table><tr><td>foo</td><td>x5a-html</td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td>x5c-html</td></tr></table></td></tr></table></td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td><table><tr><td>f1</td><td>x1a-html</td></tr><tr><td>f2</td><td><ul><li>x2a-html</li><li>x2b-html</li><li><null/></li></ul></td></tr><tr><td>f4</td><td><ul><li>x4a-html</li><li>x4b-html</li><li><null/></li></ul></td></tr><tr><td>f5</td><td><table><tr><td>foo</td><td>x5a-html</td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td>x5c-html</td></tr></table></td></tr></table></td></tr></table></td></tr></table>", + /* HtmlR */ "<table>\n\t<tr>\n\t\t<td>f</td>\n\t\t<td>\n\t\t\t<table>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>foo</td>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<table>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td>f1</td>\n\t\t\t\t\t\t\t\t<td>x1a-html</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td>f2</td>\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t\t\t\t<li>x2a-html</li>\n\t\t\t\t\t\t\t\t\t\t<li>x2b-html</li>\n\t\t\t\t\t\t\t\t\t\t<li><null/></li>\n\t\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td>f4</td>\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t\t\t\t<li>x4a-html</li>\n\t\t\t\t\t\t\t\t\t\t<li>x4b-html</li>\n\t\t\t\t\t\t\t\t\t\t<li><null/></li>\n\t\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td>f5</td>\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t<table>\n\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t<td>foo</td>\n\t\t\t\t\t\t\t\t\t\t \t<td>x5a-html</td>\n\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t<td>bar</td>\n\t\t\t\t\t\t\t\t\t\t\t<td><null/></td>\n\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t<td><null/></td>\n\t\t\t\t\t\t\t\t\t\t\t<td>x5c-html</td>\n\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>bar</td>\n\t\t\t\t\t<td><null/></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td><null/></td>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<table>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td>f1</td>\n\t\t\t\t\t\t\t\t<td>x1a-html</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td>f2</td>\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t\t\t\t<li>x2a-html</li>\n\t\t\t\t\t\t\t\t\t\t<li>x2b-html</li>\n\t\t\t\t\t\t\t\t\t\t<li><null/></li>\n\t\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t< tr>\n\t\t\t\t\t\t\t\t<td>f4</td>\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t\t\t\t<li>x4a-html</li>\n\t\t\t\t\t\t\t\t\t\t<li>x4b-html</li>\n\t\t\t\t\t\t\t\t\t\t<li><null/></li>\n\t\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td>f5</td>\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t<table>\n\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t<td>foo</td>\n\t\t\t\t\t\t\t\t\t\t\t<td>x5a-html</td>\n\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t<td>bar</td>\n\t\t\t\t\t\t\t\t\t\t\t<td><null/></td>\n\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t<td><null/></td>\n\t\t\t\t\t\t\t\t\t\t\t<td>x5c-html</td>\n\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t</td>\n\t</tr>\n</table>\n", + /* Uon */ "(f=(foo=(f1=x1a-uon,f2=@(x2a-uon,x2b-uon,null),f4=@(x4a-uon,x4b-uon,null),f5=(foo=x5a-uon,bar=null,null=x5c-uon)),bar=null,null=(f1=x1a-uon,f2=@(x2a-uon,x2b-uon,null),f4=@(x4a-uon,x4b-uon,null),f5=(foo=x5a-uon,bar=null,null=x5c-uon))))", + /* UonT */ "(f=(foo=(f1=x1a-uon,f2=@(x2a-uon,x2b-uon,null),f4=@(x4a-uon,x4b-uon,null),f5=(foo=x5a-uon,bar=null,null=x5c-uon)),bar=null,null=(f1=x1a-uon,f2=@(x2a-uon,x2b-uon,null),f4=@(x4a-uon,x4b-uon,null),f5=(foo=x5a-uon,bar=null,null=x5c-uon))))", + /* UonR */ "(\n\tf=(\n\t\tfoo=(\n\t\t\tf1=x1a-uon,\n\t\t\tf2=@(\n\t\t\t\tx2a-uon,\n\t\t\t\tx2b-uon,\n\t\t\t\tnull\n\t\t\t),\n\t\t\tf4=@(\n\t\t\t\tx4a-uon,\n\t\t\t\tx4b-uon,\n\t\t\t\tnull\n\t\t\t),\n\t\t\tf5=(\n\t\t\t\tfoo=x5a-uon,\n\t\t\t\tbar=null,\n\t\t\t\tnull=x5c-uon\n\t\t\t)\n\t\t),\n\t\tbar=null,\n\t\tnull=(\n\t\t\tf1=x1a-uon,\n\t\t\tf2=@(\n\t\t\t\tx2a-uon,\n\t\t\t\tx2b-uon,\n\t\t\t\tnull\n\t\t\t),\n\t\t\tf4=@(\n\t\t\t\tx4a-uon,\n\t\t\t\tx4b-uon,\n\t\t\t\tnull\n\t\t\t),\n\t\t\tf5=(\n\t\t\t\tfoo=x5a-uon,\n\t\t\t\tbar=null,\n\t\t\t\tnull=x5c-uon\n\t\t\t)\n\t\t)\n\t)\n)", + /* UrlEnc */ "f=(foo=(f1=x1a-x-www-form-urlencoded,f2=@(x2a-x-www-form-urlencoded,x2b-x-www-form-urlencoded,null),f4=@(x4a-x-www-form-urlencoded,x4b-x-www-form-urlencoded,null),f5=(foo=x5a-x-www-form-urlencoded,bar=null,null=x5c-x-www-form-urlencoded)),bar=null,null=(f1=x1a-x-www-form-urlencoded,f2=@(x2a-x-www-form-urlencoded,x2b-x-www-form-urlencoded,null),f4=@(x4a-x-www-form-urlencoded,x4b-x-www-form-urlencoded,null),f5=(foo=x5a-x-www-form-urlencoded,bar=null,null=x5c-x-www-form-urlencoded)))", + /* UrlEncT */ "f=(foo=(f1=x1a-x-www-form-urlencoded,f2=@(x2a-x-www-form-urlencoded,x2b-x-www-form-urlencoded,null),f4=@(x4a-x-www-form-urlencoded,x4b-x-www-form-urlencoded,null),f5=(foo=x5a-x-www-form-urlencoded,bar=null,null=x5c-x-www-form-urlencoded)),bar=null,null=(f1=x1a-x-www-form-urlencoded,f2=@(x2a-x-www-form-urlencoded,x2b-x-www-form-urlencoded,null),f4=@(x4a-x-www-form-urlencoded,x4b-x-www-form-urlencoded,null),f5=(foo=x5a-x-www-form-urlencoded,bar=null,null=x5c-x-www-form-urlencoded)))", + /* UrlEncR */ "f=(\n\tfoo=(\n\t\tf1=x1a-x-www-form-urlencoded,\n\t\tf2=@(\n\t\t\tx2a-x-www-form-urlencoded,\n\t\t\tx2b-x-www-form-urlencoded,\n\t\t\tnull\n\t\t),\n\t\tf4=@(\n\t\t\tx4a-x-www-form-urlencoded,\n\t\t\tx4b-x-www-form-urlencoded,\n\t\t\tnull\n\t\t),\n\t\tf5=(\n\t\t\tfoo=x5a-x-www-form-urlencoded,\n\t\t\tbar=null,\n\t\t\tnull=x5c-x-www-form-urlencoded\n\t\t)\n\t),\n\tbar=null,\n\tnull=(\n\t\tf1=x1a-x-www-form-urlencoded,\n\t\tf2=@(\n\t\t\tx2a-x-www-form-urlencoded,\n\t\t\tx2b-x-www-form-urlencoded,\n\t\t\tnull\n\t\t),\n\t\tf4=@(\n\t\t\tx4a-x-www-form-urlencoded,\n\t\t\tx4b-x-www-form-urlencoded,\n\t\t\tnull\n\t\t),\n\t\tf5=(\n\t\t\tfoo=x5a-x-www-form-urlencoded,\n\t\t\tbar=null,\n\t\t\tnull=x5c-x-www-form-urlencoded\n\t\t)\n\t)\n)", + /* MsgPack */ "81A16683A3666F6F84A266317831612D6D73677061636BA26632937832612D6D73677061636B7832622D6D73677061636BC0A26634937834612D6D73677061636B7834622D6D73677061636BC0A2663583A3666F6F7835612D6D73677061636BA3626172C0C07835632D6D73677061636BA3626172C0C084A266317831612D6D73677061636BA26632937832612D6D73677061636B7832622D6D73677061636BC0A26634937834612D6D73677061636B7834622D6D73677061636BC0A2663583A3666F6F7835612D6D73677061636BA3626172C0C07835632D6D73677061636B", + /* MsgPackT */ "81A16683A3666F6F84A266317831612D6D73677061636BA26632937832612D6D73677061636B7832622D6D73677061636BC0A26634937834612D6D73677061636B7834622D6D73677061636BC0A2663583A3666F6F7835612D6D73677061636BA3626172C0C07835632D6D73677061636BA3626172C0C084A266317831612D6D73677061636BA26632937832612D6D73677061636B7832622D6D73677061636BC0A26634937834612D6D73677061636B7834622D6D73677061636BC0A2663583A3666F6F7835612D6D73677061636BA3626172C0C07835632D6D73677061636B", + /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<jp:f rdf:parseType='Resource'>\n<jp:foo rdf:parseType='Resource'>\n<jp:f1>x1a-xml</jp:f1>\n<jp:f2>\n<rdf:Seq>\n<rdf:li>x2a-xml</rdf:li>\n<rdf:li>x2b-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f2>\n<jp:f4>\n<rdf:Seq>\n<rdf:li>x4a-xml</rdf:li>\n<rdf:li>x4b-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f4>\n<jp:f5 rdf:parseType='Resource'>\n<jp:foo>x5a-xml</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_>x5c-xml</jp:_x0000_>\n</jp:f5>\n</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_ rdf:parseType='Resource'>\n<jp:f1>x1a-xml</jp:f1>\n<jp:f2>\n<rdf:Seq>\n<rdf:li>x2a-xml</rdf:li>\n<rdf:li>x2b-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f2>\n<jp:f4>\n<rdf:Seq>\n<rdf:li>x4a -xml</rdf:li>\n<rdf:li>x4b-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f4>\n<jp:f5 rdf:parseType='Resource'>\n<jp:foo>x5a-xml</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_>x5c-xml</jp:_x0000_>\n</jp:f5>\n</jp:_x0000_>\n</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", + /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<jp:f rdf:parseType='Resource'>\n<jp:foo rdf:parseType='Resource'>\n<jp:f1>x1a-xml</jp:f1>\n<jp:f2>\n<rdf:Seq>\n<rdf:li>x2a-xml</rdf:li>\n<rdf:li>x2b-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f2>\n<jp:f4>\n<rdf:Seq>\n<rdf:li>x4a-xml</rdf:li>\n<rdf:li>x4b-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f4>\n<jp:f5 rdf:parseType='Resource'>\n<jp:foo>x5a-xml</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_>x5c-xml</jp:_x0000_>\n</jp:f5>\n</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_ rdf:parseType='Resource'>\n<jp:f1>x1a-xml</jp:f1>\n<jp:f2>\n<rdf:Seq>\n<rdf:li>x2a-xml</rdf:li>\n<rdf:li>x2b-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f2>\n<jp:f4>\n<rdf:Seq>\n<rdf:li>x4 a-xml</rdf:li>\n<rdf:li>x4b-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f4>\n<jp:f5 rdf:parseType='Resource'>\n<jp:foo>x5a-xml</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_>x5c-xml</jp:_x0000_>\n</jp:f5>\n</jp:_x0000_>\n</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", + /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <jp:f rdf:parseType='Resource'>\n <jp:foo rdf:parseType='Resource'>\n <jp:f1>x1a-xml</jp:f1>\n <jp:f2>\n <rdf:Seq>\n <rdf:li>x2a-xml</rdf:li>\n <rdf:li>x2b-xml</rdf:li>\n <rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n </rdf:Seq>\n </jp:f2>\n <jp:f4>\n <rdf:Seq>\n <rdf:li>x4a-xml</rdf:li>\n <rdf:li>x4b-xml</rdf:li>\n <rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n </rdf:Seq>\n </jp:f4>\n <jp:f5 rdf:parseType='Resource'>\n <jp:foo>x5a-xml</jp:foo>\n <jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n <jp:_x0000_>x5c-xml</jp:_x0000_>\n </jp:f5>\n </jp:foo>\n <jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n <jp:_x0000_ rdf:parseType='Resou rce'>\n <jp:f1>x1a-xml</jp:f1>\n <jp:f2>\n <rdf:Seq>\n <rdf:li>x2a-xml</rdf:li>\n <rdf:li>x2b-xml</rdf:li>\n <rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n </rdf:Seq>\n </jp:f2>\n <jp:f4>\n <rdf:Seq>\n <rdf:li>x4a-xml</rdf:li>\n <rdf:li>x4b-xml</rdf:li>\n <rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n </rdf:Seq>\n </jp:f4>\n <jp:f5 rdf:parseType='Resource'>\n <jp:foo>x5a-xml</jp:foo>\n <jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n <jp:_x0000_>x5c-xml</jp:_x0000_>\n </jp:f5>\n </jp:_x0000_>\n </jp:f>\n </rdf:Description>\n</rdf:RDF>\n" + ) + }, + }); + } + + public ReaderObjectSwapTest(ComboInput<?> comboInput) { + super(comboInput); + } + + @Pojo(swap=PojoToSimpleReaderSwap.class) + public static class PojoToSimpleReader {} + + public static class PojoToSimpleReaderSwap extends PojoSwap<PojoToSimpleReader,Reader> { + public Reader swap(BeanSession session, PojoToSimpleReader o) throws Exception { + return new StringReader("foo"); + } + } + + @Pojo(swap=PojoToDynamicReaderSwap.class) + public static class PojoToDynamicReader { + private String f; + public PojoToDynamicReader(String f) { + this.f = f; + } + } + + public static class PojoToDynamicReaderSwap extends PojoSwap<PojoToDynamicReader,Object> { + public Object swap(BeanSession session, PojoToDynamicReader o) throws Exception { + return new StringReader(o.f + "-" + session.getMediaType().getSubTypes().get(0)); + } + } + + @Pojo(swap=SometimesSwappedBeanSwap1.class) + public static class SometimesSwappedBean1 { + public String f; + public SometimesSwappedBean1(String f) { + this.f = f; + } + } + + public static class SometimesSwappedBeanSwap1 extends PojoSwap<SometimesSwappedBean1,Object> { + public Object swap(BeanSession session, SometimesSwappedBean1 o) throws Exception { + MediaType mt = session.getMediaType(); + if (mt.hasSubType("json") || mt.hasSubType("xml")) + return new StringReader(o.f + "-" + mt); + return o; + } + } + + @Pojo(swap=SometimesSwappedBeanSwap2.class) + public static class SometimesSwappedBean2 { + public String f; + public SometimesSwappedBean2(String f) { + this.f = f; + } + } + + public static class SometimesSwappedBeanSwap2 extends PojoSwap<SometimesSwappedBean2,Object> { + public Object swap(BeanSession session, SometimesSwappedBean2 o) throws Exception { + MediaType mt = session.getMediaType(); + if (mt.hasSubType("json") || mt.hasSubType("xml")) + return o; + return new StringReader(o.f + "-" + mt); + } + } + + + public static class BeanWithSwappedField { + public PojoToDynamicReader f; + public BeanWithSwappedField(String f) { + this.f = new PojoToDynamicReader(f); + } + } + + public static class BeanWithSwapped1dField { + public PojoToDynamicReader[] f; + public BeanWithSwapped1dField(String f) { + this.f = new PojoToDynamicReader[]{new PojoToDynamicReader(f + "1"),new PojoToDynamicReader(f + 2),null}; + } + } + + public static class BeanWithSwappedNullField { + public PojoToDynamicReader f; + } + + public static class BeanWithSwappedListField { + public List<PojoToDynamicReader> f; + public BeanWithSwappedListField(String f) { + this.f = new AList<PojoToDynamicReader>() + .append(new PojoToDynamicReader(f + "1")) + .append(new PojoToDynamicReader(f + "2")) + .append(null) + ; + } + } + + public static class BeanWithSwappedMapField { + public Map<String,PojoToDynamicReader> f; + public BeanWithSwappedMapField(String f) { + this.f = new AMap<String,PojoToDynamicReader>() + .append("foo", new PojoToDynamicReader(f + "1")) + .append("bar", null) + .append(null, new PojoToDynamicReader(f + "2")) + ; + } + } + + public static class BeanWithListBeanSwappedField { + public List<B> f; + public BeanWithListBeanSwappedField(String f) { + this.f = new AList<B>() + .append(new B(f)) + .append(null) + ; + } + } + + public static class BeanWithMapBeanSwappedField { + public Map<String,B> f; + public BeanWithMapBeanSwappedField(String f) { + this.f = new AMap<String,B>() + .append("foo", new B(f)) + .append("bar", null) + .append(null, new B(f)) + ; + } + } + + public static class B { + public PojoToDynamicReader f1; + public PojoToDynamicReader[] f2; + public PojoToDynamicReader f3; + public List<PojoToDynamicReader> f4; + public Map<String,PojoToDynamicReader> f5; + + public B(String f) { + f1 = new PojoToDynamicReader(f + "1a"); + f2 = new PojoToDynamicReader[]{new PojoToDynamicReader(f + "2a"),new PojoToDynamicReader(f + "2b"),null}; + f3 = null; + f4 = new AList<PojoToDynamicReader>() + .append(new PojoToDynamicReader(f + "4a")) + .append(new PojoToDynamicReader(f + "4b")) + .append(null) + ; + f5 = new AMap<String,PojoToDynamicReader>() + .append("foo", new PojoToDynamicReader(f + "5a")) + .append("bar", null) + .append(null, new PojoToDynamicReader(f + "5c")) + ; + } + } +}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/annotation/Consumes.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/annotation/Consumes.java b/juneau-core/src/main/java/org/apache/juneau/annotation/Consumes.java deleted file mode 100644 index 835005d..0000000 --- a/juneau-core/src/main/java/org/apache/juneau/annotation/Consumes.java +++ /dev/null @@ -1,72 +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.annotation; - -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.*; - -import java.lang.annotation.*; - -import org.apache.juneau.parser.*; - -/** - * Annotation used on subclasses of {@link Parser} to identify the media types that it consumes. - * - * <h5 class='section'>Description:</h5> - * - * Provides a way to define the contents of {@link Parser#getMediaTypes()} through an annotation. - * - * <p> - * The {@link Parser#getMediaTypes()} default implementation gathers the media types by looking for this annotation. - * It should be noted that this annotation is optional and that the {@link Parser#getMediaTypes()} method can be - * overridden by subclasses to return the media types programmatically. - * - * <h5 class='section'>Example:</h5> - * - * Standard example: - * <p class='bcode'> - * <ja>@Consumes</ja>(<js>"application/json,text/json"</js>) - * <jk>public class</jk> JsonParser <jk>extends</jk> ReaderParser {...} - * </p> - * - * <p> - * The media types can also be <code>media-range</code> values per - * <a class="doclink" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1">RFC2616/14.1</a>. - * - * <p class='bcode'> - * <jc>// Consumes any text</jc> - * <ja>@Consumes</ja>(<js>"text\/*"</js>) - * <jk>public class</jk> AnythingParser <jk>extends</jk> ReaderParser {...} - * - * <jc>// Consumes anything</jc> - * <ja>@Consumes</ja>(<js>"*\/*"</js>) - * <jk>public class</jk> AnythingParser <jk>extends</jk> ReaderParser {...} - * </p> - */ -@Documented -@Target(TYPE) -@Retention(RUNTIME) -@Inherited -public @interface Consumes { - - /** - * A comma-delimited list of media types that the parser can handle. - * - * <p> - * Can contain meta-characters per the <code>media-type</code> specification of - * <a class="doclink" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1">RFC2616/14.1</a> - * - * @return The media types that the parser can handle. - */ - String value() default ""; -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/annotation/Produces.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/annotation/Produces.java b/juneau-core/src/main/java/org/apache/juneau/annotation/Produces.java deleted file mode 100644 index 1bbb37e..0000000 --- a/juneau-core/src/main/java/org/apache/juneau/annotation/Produces.java +++ /dev/null @@ -1,85 +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.annotation; - -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.*; - -import java.lang.annotation.*; - -import org.apache.juneau.serializer.*; - -/** - * Annotation used on subclasses of {@link Serializer} to identify the media types that it produces. - * - * <h5 class='section'>Description:</h5> - * - * Provides a way to define the contents of {@link Serializer#getMediaTypes()} through an annotation. - * - * <p> - * The {@link Serializer#getMediaTypes()} default implementation gathers the media types by looking for this annotation. - * <br>It should be noted that this annotation is optional and that the {@link Serializer#getMediaTypes()} method can - * be overridden by subclasses to return the media types programmatically. - * - * <h5 class='section'>Example:</h5> - * - * Standard example: - * <p class='bcode'> - * <ja>@Produces</ja>(<js>"application/json,text/json"</js>) - * <jk>public class</jk> JsonSerializer <jk>extends</jk> WriterSerializer {...} - * </p> - * - * <p> - * The media types can also be <code>media-range</code> values per - * <a class="doclink" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1">RFC2616/14.1</a>. - * <br>When meta-characters are used, you should specify the {@link #contentType()} value to indicate the real media type - * value that can be set on the <code>Content-Type</code> response header. - * - * <p class='bcode'> - * <jc>// Produces any text</jc> - * <ja>@Produces</ja>(value=<js>"text\/*"</js>, contentType=<js>"text/plain"</js>) - * <jk>public class</jk> AnythingSerializer <jk>extends</jk> WriterSerializer {...} - * - * <jc>// Produces anything</jc> - * <ja>@Produces</ja>(value=<js>"*\/*"</js>, contentType=<js>"text/plain"</js>) - * <jk>public class</jk> AnythingSerializer <jk>extends</jk> WriterSerializer {...} - * </p> - */ -@Documented -@Target(TYPE) -@Retention(RUNTIME) -@Inherited -public @interface Produces { - - /** - * A comma-delimited list of the media types that the serializer can handle. - * - * <p> - * Can contain meta-characters per the <code>media-type</code> specification of - * <a class="doclink" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1">RFC2616/14.1</a> - * - * @return The media types that the parser can handle. - */ - String value() default ""; - - /** - * The content type that this serializer produces. - * - * <p> - * Can be used to override the <code>Content-Type</code> response type if the media types are - * <code>media-ranges</code> with meta-characters, or the <code>Content-Type</code> differs from the media type for some reason. - * - * @return The content type that this serializer produces, or blank if no overriding value exists. - */ - String contentType() default ""; -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/csv/CsvParser.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/csv/CsvParser.java b/juneau-core/src/main/java/org/apache/juneau/csv/CsvParser.java index 6a63d0e..450902a 100644 --- a/juneau-core/src/main/java/org/apache/juneau/csv/CsvParser.java +++ b/juneau-core/src/main/java/org/apache/juneau/csv/CsvParser.java @@ -13,13 +13,11 @@ package org.apache.juneau.csv; import org.apache.juneau.*; -import org.apache.juneau.annotation.*; import org.apache.juneau.parser.*; /** * TODO - Work in progress. CSV parser. */ -@Consumes("text/csv") public class CsvParser extends ReaderParser { /** Default parser, all default settings.*/ @@ -33,7 +31,7 @@ public class CsvParser extends ReaderParser { * @param propertyStore The property store containing all the settings for this object. */ public CsvParser(PropertyStore propertyStore) { - super(propertyStore); + super(propertyStore, "text/csv"); this.ctx = createContext(CsvParserContext.class); } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/csv/CsvSerializer.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/csv/CsvSerializer.java b/juneau-core/src/main/java/org/apache/juneau/csv/CsvSerializer.java index ac59ae0..2593175 100644 --- a/juneau-core/src/main/java/org/apache/juneau/csv/CsvSerializer.java +++ b/juneau-core/src/main/java/org/apache/juneau/csv/CsvSerializer.java @@ -13,13 +13,11 @@ package org.apache.juneau.csv; import org.apache.juneau.*; -import org.apache.juneau.annotation.*; import org.apache.juneau.serializer.*; /** * TODO - Work in progress. CSV serializer. */ -@Produces("text/csv") public final class CsvSerializer extends WriterSerializer { /** Default serializer, all default settings.*/ @@ -33,7 +31,7 @@ public final class CsvSerializer extends WriterSerializer { * @param propertyStore The property store containing all the settings for this object. */ public CsvSerializer(PropertyStore propertyStore) { - super(propertyStore); + super(propertyStore, "text/csv"); this.ctx = createContext(CsvSerializerContext.class); } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/csv/CsvSerializerSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/csv/CsvSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/csv/CsvSerializerSession.java index 80986ea..0a1478b 100644 --- a/juneau-core/src/main/java/org/apache/juneau/csv/CsvSerializerSession.java +++ b/juneau-core/src/main/java/org/apache/juneau/csv/CsvSerializerSession.java @@ -38,7 +38,6 @@ public final class CsvSerializerSession extends WriterSerializerSession { * These specify session-level information such as locale and URI context. * It also include session-level properties that override the properties defined on the bean and * serializer contexts. - * <br>If <jk>null</jk>, defaults to {@link SerializerSessionArgs#DEFAULT}. */ protected CsvSerializerSession(CsvSerializerContext ctx, SerializerSessionArgs args) { super(ctx, args); http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/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 69d6f44..63cfcf2 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 @@ -13,7 +13,6 @@ package org.apache.juneau.html; import org.apache.juneau.*; -import org.apache.juneau.annotation.*; import org.apache.juneau.serializer.*; /** @@ -38,7 +37,6 @@ import org.apache.juneau.serializer.*; * <li>{@link BeanContext} * </ul> */ -@Produces("text/html") @SuppressWarnings("hiding") public class HtmlDocSerializer extends HtmlStrippedDocSerializer { @@ -54,7 +52,32 @@ public class HtmlDocSerializer extends HtmlStrippedDocSerializer { * @param propertyStore The property store containing all the settings for this object. */ public HtmlDocSerializer(PropertyStore propertyStore) { - super(propertyStore); + this(propertyStore, "text/html"); + } + + /** + * Constructor. + * + * @param propertyStore + * The property store containing all the settings for this object. + * @param produces + * The media type that this serializer produces. + * @param accept + * The accept media types that the serializer can handle. + * <p> + * Can contain meta-characters per the <code>media-type</code> specification of + * <a class="doclink" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1">RFC2616/14.1</a> + * <p> + * If empty, then assumes the only media type supported is <code>produces</code>. + * <p> + * For example, if this serializer produces <js>"application/json"</js> but should handle media types of + * <js>"application/json"</js> and <js>"text/json"</js>, then the arguments should be: + * <br><code><jk>super</jk>(propertyStore, <js>"application/json"</js>, <js>"application/json"</js>, <js>"text/json"</js>);</code> + * <br>...or... + * <br><code><jk>super</jk>(propertyStore, <js>"application/json"</js>, <js>"*​/json"</js>);</code> + */ + public HtmlDocSerializer(PropertyStore propertyStore, String produces, String...accept) { + super(propertyStore, produces, accept); this.ctx = createContext(HtmlDocSerializerContext.class); } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/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 28a895a..a18dbc4 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,6 @@ package org.apache.juneau.html; import org.apache.juneau.*; -import org.apache.juneau.annotation.*; import org.apache.juneau.parser.*; import org.apache.juneau.xml.*; @@ -38,7 +37,6 @@ import org.apache.juneau.xml.*; * </ul> */ @SuppressWarnings({ "hiding" }) -@Consumes("text/html,text/html+stripped") public class HtmlParser extends XmlParser { /** Default parser, all default settings.*/ @@ -53,7 +51,7 @@ public class HtmlParser extends XmlParser { * @param propertyStore The property store containing all the settings for this object. */ public HtmlParser(PropertyStore propertyStore) { - super(propertyStore); + super(propertyStore, "text/html", "text/html+stripped"); this.ctx = createContext(HtmlParserContext.class); } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/html/HtmlSchemaDocSerializer.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlSchemaDocSerializer.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlSchemaDocSerializer.java index ca452f6..a20778c 100644 --- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlSchemaDocSerializer.java +++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlSchemaDocSerializer.java @@ -15,7 +15,6 @@ package org.apache.juneau.html; import static org.apache.juneau.serializer.SerializerContext.*; import org.apache.juneau.*; -import org.apache.juneau.annotation.*; import org.apache.juneau.serializer.*; /** @@ -39,7 +38,6 @@ import org.apache.juneau.serializer.*; * The easiest way to create instances of this class is through the {@link HtmlSerializer#getSchemaSerializer()}, * which will create a schema serializer with the same settings as the originating serializer. */ -@Produces(value="text/html+schema", contentType="text/html") public final class HtmlSchemaDocSerializer extends HtmlDocSerializer { @SuppressWarnings("hiding") @@ -48,10 +46,36 @@ public final class HtmlSchemaDocSerializer extends HtmlDocSerializer { /** * Constructor. * - * @param propertyStore The property store to use for creating the context for this serializer. + * @param propertyStore + * The property store to use for creating the context for this serializer. */ public HtmlSchemaDocSerializer(PropertyStore propertyStore) { - super(propertyStore.copy().append(SERIALIZER_detectRecursions, true).append(SERIALIZER_ignoreRecursions, true)); + this(propertyStore, "text/html", "text/html+schema"); + } + + /** + * Constructor. + * + * @param propertyStore + * The property store containing all the settings for this object. + * @param produces + * The media type that this serializer produces. + * @param accept + * The accept media types that the serializer can handle. + * <p> + * Can contain meta-characters per the <code>media-type</code> specification of + * <a class="doclink" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1">RFC2616/14.1</a> + * <p> + * If empty, then assumes the only media type supported is <code>produces</code>. + * <p> + * For example, if this serializer produces <js>"application/json"</js> but should handle media types of + * <js>"application/json"</js> and <js>"text/json"</js>, then the arguments should be: + * <br><code><jk>super</jk>(propertyStore, <js>"application/json"</js>, <js>"application/json"</js>, <js>"text/json"</js>);</code> + * <br>...or... + * <br><code><jk>super</jk>(propertyStore, <js>"application/json"</js>, <js>"*​/json"</js>);</code> + */ + public HtmlSchemaDocSerializer(PropertyStore propertyStore, String produces, String...accept) { + super(propertyStore.copy().append(SERIALIZER_detectRecursions, true).append(SERIALIZER_ignoreRecursions, true), produces, accept); this.ctx = createContext(HtmlDocSerializerContext.class); } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/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 aa8b6d0..9a1f302 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 @@ -17,7 +17,6 @@ import static org.apache.juneau.serializer.SerializerContext.*; import java.util.*; import org.apache.juneau.*; -import org.apache.juneau.annotation.*; import org.apache.juneau.serializer.*; import org.apache.juneau.xml.*; @@ -133,7 +132,6 @@ import org.apache.juneau.xml.*; * String html = HtmlSerializer.<jsf>DEFAULT</jsf>.serialize(m); * </p> */ -@Produces("text/html") @SuppressWarnings("hiding") public class HtmlSerializer extends XmlSerializer { @@ -180,10 +178,36 @@ public class HtmlSerializer extends XmlSerializer { /** * Constructor. * - * @param propertyStore The property store containing all the settings for this object. + * @param propertyStore + * The property store containing all the settings for this object. */ public HtmlSerializer(PropertyStore propertyStore) { - super(propertyStore); + this(propertyStore, "text/html"); + } + + /** + * Constructor. + * + * @param propertyStore + * The property store containing all the settings for this object. + * @param produces + * The media type that this serializer produces. + * @param accept + * The accept media types that the serializer can handle. + * <p> + * Can contain meta-characters per the <code>media-type</code> specification of + * <a class="doclink" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1">RFC2616/14.1</a> + * <p> + * If empty, then assumes the only media type supported is <code>produces</code>. + * <p> + * For example, if this serializer produces <js>"application/json"</js> but should handle media types of + * <js>"application/json"</js> and <js>"text/json"</js>, then the arguments should be: + * <br><code><jk>super</jk>(propertyStore, <js>"application/json"</js>, <js>"application/json"</js>, <js>"text/json"</js>);</code> + * <br>...or... + * <br><code><jk>super</jk>(propertyStore, <js>"application/json"</js>, <js>"*​/json"</js>);</code> + */ + public HtmlSerializer(PropertyStore propertyStore, String produces, String...accept) { + super(propertyStore, produces, accept); this.ctx = createContext(HtmlSerializerContext.class); } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java index 8d38885..8cbbb83 100644 --- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java +++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java @@ -63,7 +63,6 @@ public class HtmlSerializerSession extends XmlSerializerSession { * These specify session-level information such as locale and URI context. * It also include session-level properties that override the properties defined on the bean and * serializer contexts. - * <br>If <jk>null</jk>, defaults to {@link SerializerSessionArgs#DEFAULT}. */ protected HtmlSerializerSession(HtmlSerializerContext ctx, SerializerSessionArgs args) { super(ctx, args); @@ -280,6 +279,14 @@ public class HtmlSerializerSession extends XmlSerializerSession { sType = getClassMetaForObject(o); } + // Handle the case where we're serializing a raw stream. + if (sType.isReader() || sType.isInputStream()) { + pop(); + indent -= xIndent; + IOUtils.pipe(o, out); + return ContentResult.CR_SIMPLE; + } + HtmlClassMeta html = sType.getExtendedMeta(HtmlClassMeta.class); HtmlRender render = (pMeta == null ? null : pMeta.getExtendedMeta(HtmlBeanPropertyMeta.class).getRender()); if (render == null) @@ -572,7 +579,9 @@ public class HtmlSerializerSession extends XmlSerializerSession { out.cTag().nl(i+2); if (cm == null) { + out.i(i+2); serializeAnything(out, o, null, null, 1, null, false); + out.nl(0); } else if (cm.isMap() && ! (cm.isBeanMap())) { Map m2 = sort((Map)o); http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializer.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializer.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializer.java index 2d61aab..062f99f 100644 --- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializer.java +++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializer.java @@ -13,7 +13,6 @@ package org.apache.juneau.html; import org.apache.juneau.*; -import org.apache.juneau.annotation.*; import org.apache.juneau.serializer.*; /** @@ -32,7 +31,6 @@ import org.apache.juneau.serializer.*; * description. * Used primarily for JUnit testing the {@link HtmlDocSerializer} class. */ -@Produces(value="text/html+stripped",contentType="text/html") public class HtmlStrippedDocSerializer extends HtmlSerializer { /** @@ -41,7 +39,32 @@ public class HtmlStrippedDocSerializer extends HtmlSerializer { * @param propertyStore The property store containing all the settings for this object. */ public HtmlStrippedDocSerializer(PropertyStore propertyStore) { - super(propertyStore); + this(propertyStore, "text/html", "text/html+stripped"); + } + + /** + * Constructor. + * + * @param propertyStore + * The property store containing all the settings for this object. + * @param produces + * The media type that this serializer produces. + * @param accept + * The accept media types that the serializer can handle. + * <p> + * Can contain meta-characters per the <code>media-type</code> specification of + * <a class="doclink" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1">RFC2616/14.1</a> + * <p> + * If empty, then assumes the only media type supported is <code>produces</code>. + * <p> + * For example, if this serializer produces <js>"application/json"</js> but should handle media types of + * <js>"application/json"</js> and <js>"text/json"</js>, then the arguments should be: + * <br><code><jk>super</jk>(propertyStore, <js>"application/json"</js>, <js>"application/json"</js>, <js>"text/json"</js>);</code> + * <br>...or... + * <br><code><jk>super</jk>(propertyStore, <js>"application/json"</js>, <js>"*​/json"</js>);</code> + */ + public HtmlStrippedDocSerializer(PropertyStore propertyStore, String produces, String...accept) { + super(propertyStore, produces, accept); } @Override /* Serializer */ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/http/MediaType.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/http/MediaType.java b/juneau-core/src/main/java/org/apache/juneau/http/MediaType.java index 7c6531f..3548113 100644 --- a/juneau-core/src/main/java/org/apache/juneau/http/MediaType.java +++ b/juneau-core/src/main/java/org/apache/juneau/http/MediaType.java @@ -157,7 +157,7 @@ public class MediaType implements Comparable<MediaType> { * * @return The media type. */ - public String getType() { + public final String getType() { return type; } @@ -166,11 +166,27 @@ public class MediaType implements Comparable<MediaType> { * * @return The media subtype. */ - public String getSubType() { + public final String getSubType() { return subType; } /** + * Returns <jk>true</jk> if the subtype contains the specified <js>'+'</js> delimited subtype value. + * + * @param st + * The subtype string. + * Case is ignored. + * @return <jk>true</jk> if the subtype contains the specified subtype string. + */ + public final boolean hasSubType(String st) { + if (st != null) + for (String s : subTypes) + if (st.equalsIgnoreCase(s)) + return true; + return false; + } + + /** * Returns the subtypes broken down by fragments delimited by <js>"'"</js>. * * <P> @@ -179,7 +195,7 @@ public class MediaType implements Comparable<MediaType> { * * @return An unmodifiable list of subtype fragments. Never <jk>null</jk>. */ - public List<String> getSubTypes() { + public final List<String> getSubTypes() { return subTypesList; } @@ -267,12 +283,12 @@ public class MediaType implements Comparable<MediaType> { * * @return The map of additional parameters, or an empty map if there are no parameters. */ - public Map<String,Set<String>> getParameters() { + public final Map<String,Set<String>> getParameters() { return parameters; } @Override /* Object */ - public String toString() { + public final String toString() { if (parameters.isEmpty()) return mediaType; StringBuilder sb = new StringBuilder(mediaType); @@ -283,17 +299,17 @@ public class MediaType implements Comparable<MediaType> { } @Override /* Object */ - public int hashCode() { + public final int hashCode() { return mediaType.hashCode(); } @Override /* Object */ - public boolean equals(Object o) { + public final boolean equals(Object o) { return this == o; } @Override - public int compareTo(MediaType o) { + public final int compareTo(MediaType o) { return mediaType.compareTo(o.mediaType); } } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/internal/IOUtils.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/internal/IOUtils.java b/juneau-core/src/main/java/org/apache/juneau/internal/IOUtils.java index 1c3626e..c8018bf 100644 --- a/juneau-core/src/main/java/org/apache/juneau/internal/IOUtils.java +++ b/juneau-core/src/main/java/org/apache/juneau/internal/IOUtils.java @@ -17,6 +17,7 @@ import static org.apache.juneau.internal.ThrowableUtils.*; import java.io.*; import java.nio.charset.*; +import org.apache.juneau.*; import org.apache.juneau.utils.*; /** @@ -242,8 +243,10 @@ public final class IOUtils { * <p> * The reader is closed, the writer is not. * - * @param in The reader to pipe from. - * @param out The writer to pipe to. + * @param in + * The reader to pipe from. + * @param out + * The writer to pipe to. * @throws IOException */ public static void pipe(Reader in, Writer out) throws IOException { @@ -253,6 +256,58 @@ public final class IOUtils { } /** + * Pipes the contents of the specified object into the writer. + * + * <p> + * The reader is closed, the writer is not. + * + * @param in + * The input to pipe from. + * Can be any of the types defined by {@link #toReader(Object)}. + * @param out + * The writer to pipe to. + * @throws IOException + */ + public static void pipe(Object in, Writer out) throws IOException { + pipe(toReader(in), out); + } + + /** + * Pipes the contents of the specified streams. + * + * <p> + * The input stream is closed, the output stream is not. + * + * @param in + * The reader to pipe from. + * @param out + * The writer to pipe to. + * @throws IOException + */ + public static void pipe(InputStream in, OutputStream out) throws IOException { + assertFieldNotNull(out, "out"); + assertFieldNotNull(in, "in"); + IOPipe.create(in, out).run(); + } + + /** + * Pipes the contents of the specified object into the output stream. + * + * <p> + * The input stream is closed, the output stream is not. + * + * @param in + * The input to pipe from. + * Can be any of the types defined by {@link #toInputStream(Object)}. + * @param out + * The writer to pipe to. + * @throws IOException + */ + public static void pipe(Object in, OutputStream out) throws IOException { + pipe(toInputStream(in), out); + } + + /** * Wraps the specified reader in a buffered reader. * * @param r The reader being wrapped. @@ -461,6 +516,39 @@ public final class IOUtils { throw ex; } + /** + * Converts an object to a <code>Reader</code>. + * + * @param o + * The object to convert to a reader. + * Can be any of the following: + * <ul> + * <li>{@link InputStream} + * <li>{@link Reader} + * <li>{@link File} + * <li>{@link CharSequence} + * <li><code><jk>byte</jk>[]</code> + * <li><code><jk>null</jk></code> - Returns <jk>null</jk>. + * </ul> + * @return The object converted to a reader. + * @throws IOException If file could not be read. + * @throws IllegalArgumentException If invalid object passed in. + */ + public static Reader toReader(Object o) throws IOException { + if (o == null) + return null; + if (o instanceof CharSequence) + return new StringReader(o.toString()); + if (o instanceof File) + return new FileReader((File)o); + if (o instanceof Reader) + return (Reader)o; + if (o instanceof InputStream) + return new InputStreamReader((InputStream)o, "UTF-8"); + if (o instanceof byte[]) + return new InputStreamReader(new ByteArrayInputStream((byte[])o), "UTF-8"); + throw new FormattedIllegalArgumentException("Invalid object of type {0} passed to IOUtils.toReader(Object)", o.getClass()); + } /** * Converts an object to an <code>InputStream</code>. @@ -474,10 +562,11 @@ public final class IOUtils { * <li>{@link File} * <li>{@link CharSequence} - Converted to UTF-8 stream. * <li><code><jk>byte</jk>[]</code> - * <li><code><jk>null</jk></code> - Returns null. + * <li><code><jk>null</jk></code> - Returns <jk>null</jk>. * </ul> * @return The object converted to an input stream. - * @throws IOException If invalid object passed in or file could not be read. + * @throws IOException If file could not be read. + * @throws IllegalArgumentException If invalid object passed in. */ public static InputStream toInputStream(Object o) throws IOException { if (o == null) @@ -492,6 +581,6 @@ public final class IOUtils { return new ByteArrayInputStream(((CharSequence)o).toString().getBytes(UTF8)); if (o instanceof Reader) return new ByteArrayInputStream(IOUtils.read((Reader)o).getBytes(UTF8)); - throw new IOException("Invalid object type passed to IOUtils.toInputStream(Object): " + o.getClass().getName()); + throw new FormattedIllegalArgumentException("Invalid object of type {0} passed to IOUtils.toInputStream(Object)", o.getClass()); } } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/jso/JsoParser.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/jso/JsoParser.java b/juneau-core/src/main/java/org/apache/juneau/jso/JsoParser.java index 599fa17..835ca36 100644 --- a/juneau-core/src/main/java/org/apache/juneau/jso/JsoParser.java +++ b/juneau-core/src/main/java/org/apache/juneau/jso/JsoParser.java @@ -15,7 +15,6 @@ package org.apache.juneau.jso; import java.io.*; import org.apache.juneau.*; -import org.apache.juneau.annotation.*; import org.apache.juneau.parser.*; /** @@ -25,7 +24,6 @@ import org.apache.juneau.parser.*; * * Consumes <code>Content-Type</code> types: <code>application/x-java-serialized-object</code> */ -@Consumes("application/x-java-serialized-object") public final class JsoParser extends InputStreamParser { /** Default parser, all default settings.*/ @@ -38,7 +36,7 @@ public final class JsoParser extends InputStreamParser { * @param propertyStore The property store containing all the settings for this object. */ public JsoParser(PropertyStore propertyStore) { - super(propertyStore); + super(propertyStore, "application/x-java-serialized-object"); } @Override /* CoreObject */ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/jso/JsoSerializer.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/jso/JsoSerializer.java b/juneau-core/src/main/java/org/apache/juneau/jso/JsoSerializer.java index 6e3ceb8..2fa50fb 100644 --- a/juneau-core/src/main/java/org/apache/juneau/jso/JsoSerializer.java +++ b/juneau-core/src/main/java/org/apache/juneau/jso/JsoSerializer.java @@ -15,7 +15,6 @@ package org.apache.juneau.jso; import java.io.*; import org.apache.juneau.*; -import org.apache.juneau.annotation.*; import org.apache.juneau.serializer.*; /** @@ -28,7 +27,6 @@ import org.apache.juneau.serializer.*; * <p> * Produces <code>Content-Type</code> types: <code>application/x-java-serialized-object</code> */ -@Produces("application/x-java-serialized-object") public class JsoSerializer extends OutputStreamSerializer { /** Default serializer, all default settings.*/ @@ -42,7 +40,7 @@ public class JsoSerializer extends OutputStreamSerializer { * @param propertyStore The property store containing all the settings for this object. */ public JsoSerializer(PropertyStore propertyStore) { - super(propertyStore); + super(propertyStore, "application/x-java-serialized-object"); this.ctx = createContext(SerializerContext.class); } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/jso/JsoSerializerSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/jso/JsoSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/jso/JsoSerializerSession.java index a445ac4..5aef62a 100644 --- a/juneau-core/src/main/java/org/apache/juneau/jso/JsoSerializerSession.java +++ b/juneau-core/src/main/java/org/apache/juneau/jso/JsoSerializerSession.java @@ -20,7 +20,7 @@ import org.apache.juneau.serializer.*; * Session object that lives for the duration of a single use of {@link JsoSerializer}. * * <p> - * This class is NOT thread safe. + * This class is NOT thread safe. * It is typically discarded after one-time use although it can be reused within the same thread. */ public class JsoSerializerSession extends OutputStreamSerializerSession { @@ -36,7 +36,6 @@ public class JsoSerializerSession extends OutputStreamSerializerSession { * These specify session-level information such as locale and URI context. * It also include session-level properties that override the properties defined on the bean and * serializer contexts. - * <br>If <jk>null</jk>, defaults to {@link SerializerSessionArgs#DEFAULT}. */ protected JsoSerializerSession(SerializerContext ctx, SerializerSessionArgs args) { super(ctx, args); http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/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 460ae5d..5fa9c85 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 @@ -15,7 +15,6 @@ package org.apache.juneau.json; import static org.apache.juneau.parser.ParserContext.*; import org.apache.juneau.*; -import org.apache.juneau.annotation.*; import org.apache.juneau.parser.*; /** @@ -108,7 +107,6 @@ import org.apache.juneau.parser.*; * <li>{@link JsonParserContext} * </ul> */ -@Consumes("application/json,text/json") public class JsonParser extends ReaderParser { /** Default parser, all default settings.*/ @@ -139,7 +137,17 @@ public class JsonParser extends ReaderParser { * @param propertyStore The property store containing all the settings for this object. */ public JsonParser(PropertyStore propertyStore) { - super(propertyStore); + this(propertyStore, "application/json", "text/json"); + } + + /** + * Constructor. + * + * @param propertyStore The property store containing all the settings for this object. + * @param consumes The list of media types that this parser consumes (e.g. <js>"application/json"</js>). + */ + public JsonParser(PropertyStore propertyStore, String...consumes) { + super(propertyStore, consumes); this.ctx = createContext(JsonParserContext.class); }
