You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2017/08/27 22:22:17 UTC
[1/6] incubator-juneau git commit: Support serializing directly from
Readers and InputStreams.
Repository: incubator-juneau
Updated Branches:
refs/heads/master 23fe563dd -> b37d99bac
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PhotosResource.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PhotosResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PhotosResource.java
index d622593..475ef07 100644
--- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PhotosResource.java
+++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PhotosResource.java
@@ -24,7 +24,6 @@ import java.util.*;
import javax.imageio.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.microservice.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.rest.*;
@@ -131,7 +130,6 @@ public class PhotosResource extends Resource {
}
/** Serializer for converting images to byte streams */
- @Produces("image/png,image/jpeg")
public static class ImageSerializer extends OutputStreamSerializer {
/**
@@ -139,7 +137,7 @@ public class PhotosResource extends Resource {
* @param propertyStore The property store containing all the settings for this object.
*/
public ImageSerializer(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, null, "image/png", "image/jpeg");
}
@Override /* Serializer */
@@ -157,7 +155,6 @@ public class PhotosResource extends Resource {
}
/** Parser for converting byte streams to images */
- @Consumes("image/png,image/jpeg")
public static class ImageParser extends InputStreamParser {
/**
@@ -165,7 +162,7 @@ public class PhotosResource extends Resource {
* @param propertyStore The property store containing all the settings for this object.
*/
public ImageParser(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "image/png", "image/jpeg");
}
@Override /* Parser */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/AcceptCharsetResource.java
----------------------------------------------------------------------
diff --git a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/AcceptCharsetResource.java b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/AcceptCharsetResource.java
index 27add70..2281896 100644
--- a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/AcceptCharsetResource.java
+++ b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/AcceptCharsetResource.java
@@ -17,7 +17,6 @@ import static org.apache.juneau.rest.RestContext.*;
import java.io.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.plaintext.*;
import org.apache.juneau.rest.*;
@@ -54,11 +53,10 @@ public class AcceptCharsetResource extends RestServlet {
return in;
}
- @Consumes("text/plain")
public static class TestParser extends InputStreamParser {
public TestParser(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/plain");
}
@Override /* Parser */
@@ -74,11 +72,10 @@ public class AcceptCharsetResource extends RestServlet {
}
}
- @Produces("text/plain")
public static class TestSerializer extends OutputStreamSerializer {
public TestSerializer(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/plain");
}
@Override /* Serializer */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/CharsetEncodingsResource.java
----------------------------------------------------------------------
diff --git a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/CharsetEncodingsResource.java b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/CharsetEncodingsResource.java
index e9ed395..d9906f4 100644
--- a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/CharsetEncodingsResource.java
+++ b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/CharsetEncodingsResource.java
@@ -15,7 +15,6 @@ package org.apache.juneau.rest.test;
import static org.apache.juneau.internal.IOUtils.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.rest.*;
import org.apache.juneau.rest.annotation.*;
@@ -32,11 +31,10 @@ import org.apache.juneau.serializer.*;
public class CharsetEncodingsResource extends RestServlet {
private static final long serialVersionUID = 1L;
- @Consumes("text/p")
public static class CtParser extends ReaderParser {
public CtParser(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/p");
}
@Override /* Parser */
@@ -52,11 +50,10 @@ public class CharsetEncodingsResource extends RestServlet {
}
}
- @Produces("text/s")
public static class ASerializer extends WriterSerializer {
public ASerializer(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/s");
}
@Override /* Serializer */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/DefaultContentTypesResource.java
----------------------------------------------------------------------
diff --git a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/DefaultContentTypesResource.java b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/DefaultContentTypesResource.java
index 22fd963..dbd3d05 100644
--- a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/DefaultContentTypesResource.java
+++ b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/DefaultContentTypesResource.java
@@ -15,7 +15,6 @@ package org.apache.juneau.rest.test;
import static org.apache.juneau.rest.annotation.Inherit.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.rest.*;
import org.apache.juneau.rest.annotation.*;
@@ -33,23 +32,17 @@ import org.apache.juneau.serializer.*;
public class DefaultContentTypesResource extends RestServlet {
private static final long serialVersionUID = 1L;
- @Consumes("text/p1")
- public static class P1 extends DummyParser { public P1(PropertyStore ps) {super(ps, "p1");}}
+ public static class P1 extends DummyParser { public P1(PropertyStore ps) {super(ps, "p1", "text/p1");}}
- @Consumes("text/p2")
- public static class P2 extends DummyParser { public P2(PropertyStore ps) {super(ps, "p2");}}
+ public static class P2 extends DummyParser { public P2(PropertyStore ps) {super(ps, "p2", "text/p2");}}
- @Consumes("text/p3")
- public static class P3 extends DummyParser { public P3(PropertyStore ps) {super(ps, "p3");}}
+ public static class P3 extends DummyParser { public P3(PropertyStore ps) {super(ps, "p3", "text/p3");}}
- @Produces("text/s1")
- public static class S1 extends DummySerializer { public S1(PropertyStore ps) {super(ps, "s1");}}
+ public static class S1 extends DummySerializer { public S1(PropertyStore ps) {super(ps, "s1", "text/s1");}}
- @Produces("text/s2")
- public static class S2 extends DummySerializer { public S2(PropertyStore ps) {super(ps, "s2");}}
+ public static class S2 extends DummySerializer { public S2(PropertyStore ps) {super(ps, "s2", "text/s2");}}
- @Produces("text/s3")
- public static class S3 extends DummySerializer { public S3(PropertyStore ps) {super(ps, "s3");}}
+ public static class S3 extends DummySerializer { public S3(PropertyStore ps) {super(ps, "s3", "text/s3");}}
/**
* Test that default Accept and Content-Type headers on servlet annotation are picked up.
@@ -107,8 +100,8 @@ public class DefaultContentTypesResource extends RestServlet {
private String name;
- private DummyParser(PropertyStore propertyStore, String name) {
- super(propertyStore);
+ private DummyParser(PropertyStore propertyStore, String name, String...consumes) {
+ super(propertyStore, consumes);
this.name = name;
}
@@ -129,8 +122,8 @@ public class DefaultContentTypesResource extends RestServlet {
private String name;
- private DummySerializer(PropertyStore propertyStore, String name) {
- super(propertyStore);
+ private DummySerializer(PropertyStore propertyStore, String name, String produces) {
+ super(propertyStore, produces);
this.name = name;
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/GroupsResource.java
----------------------------------------------------------------------
diff --git a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/GroupsResource.java b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/GroupsResource.java
index acaa410..6bd6454 100644
--- a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/GroupsResource.java
+++ b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/GroupsResource.java
@@ -16,7 +16,6 @@ import static org.apache.juneau.internal.IOUtils.*;
import static org.apache.juneau.rest.annotation.HookEvent.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.rest.*;
import org.apache.juneau.rest.annotation.*;
@@ -36,11 +35,10 @@ public class GroupsResource extends RestServlet {
config.addSerializers(SSerializer.class).addParsers(PParser.class);
}
- @Produces("text/s1,text/s2")
public static class SSerializer extends WriterSerializer {
public SSerializer(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/s1", "text/s1", "text/s2");
}
@Override /* Serializer */
@@ -55,11 +53,10 @@ public class GroupsResource extends RestServlet {
}
}
- @Consumes("text/p1,text/p2")
public static class PParser extends ReaderParser {
public PParser(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/p1", "text/p2");
}
@Override /* Parser */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/HeadersResource.java
----------------------------------------------------------------------
diff --git a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/HeadersResource.java b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/HeadersResource.java
index 1949a96..8af0fd3 100644
--- a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/HeadersResource.java
+++ b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/HeadersResource.java
@@ -13,7 +13,6 @@
package org.apache.juneau.rest.test;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.encoders.*;
import org.apache.juneau.http.*;
import org.apache.juneau.plaintext.*;
@@ -171,17 +170,15 @@ public class HeadersResource extends RestServlet {
}
}
- @Produces("*/*")
public static class PlainTextAnythingSerializer extends PlainTextSerializer {
public PlainTextAnythingSerializer(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/plain", "*/*");
}
}
- @Consumes("*/*")
public static class PlainTextAnythingParser extends PlainTextParser {
public PlainTextAnythingParser(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "*/*");
}
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/InheritanceResource.java
----------------------------------------------------------------------
diff --git a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/InheritanceResource.java b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/InheritanceResource.java
index 5b25414..72bb164 100644
--- a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/InheritanceResource.java
+++ b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/InheritanceResource.java
@@ -18,7 +18,6 @@ import java.io.*;
import java.util.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.encoders.*;
import org.apache.juneau.json.*;
import org.apache.juneau.parser.*;
@@ -224,8 +223,8 @@ public class InheritanceResource extends RestServlet {
public static class DummyParser extends ReaderParser {
- public DummyParser() {
- super(PropertyStore.create());
+ public DummyParser(String...consumes) {
+ super(PropertyStore.create(), consumes);
}
@Override /* Parser */
@@ -242,8 +241,8 @@ public class InheritanceResource extends RestServlet {
public static class DummySerializer extends WriterSerializer {
- public DummySerializer() {
- super(PropertyStore.create());
+ public DummySerializer(String produces) {
+ super(PropertyStore.create(), produces);
}
@Override /* Serializer */
@@ -258,35 +257,25 @@ public class InheritanceResource extends RestServlet {
}
}
- @Consumes("text/p1")
- public static class P1 extends DummyParser{ public P1(PropertyStore ps) {super();} }
+ public static class P1 extends DummyParser{ public P1(PropertyStore ps) {super("text/p1");} }
- @Consumes("text/p2")
- public static class P2 extends DummyParser{ public P2(PropertyStore ps) {super();} }
+ public static class P2 extends DummyParser{ public P2(PropertyStore ps) {super("text/p2");} }
- @Consumes("text/p3")
- public static class P3 extends DummyParser{ public P3(PropertyStore ps) {super();} }
+ public static class P3 extends DummyParser{ public P3(PropertyStore ps) {super("text/p3");} }
- @Consumes("text/p4")
- public static class P4 extends DummyParser{ public P4(PropertyStore ps) {super();} }
+ public static class P4 extends DummyParser{ public P4(PropertyStore ps) {super("text/p4");} }
- @Consumes("text/p5")
- public static class P5 extends DummyParser{ public P5(PropertyStore ps) {super();} }
+ public static class P5 extends DummyParser{ public P5(PropertyStore ps) {super("text/p5");} }
- @Produces("text/s1")
- public static class S1 extends DummySerializer{ public S1(PropertyStore ps) {super();} }
+ public static class S1 extends DummySerializer{ public S1(PropertyStore ps) {super("text/s1");} }
- @Produces("text/s2")
- public static class S2 extends DummySerializer{ public S2(PropertyStore ps) {super();} }
+ public static class S2 extends DummySerializer{ public S2(PropertyStore ps) {super("text/s2");} }
- @Produces("text/s3")
- public static class S3 extends DummySerializer{ public S3(PropertyStore ps) {super();} }
+ public static class S3 extends DummySerializer{ public S3(PropertyStore ps) {super("text/s3");} }
- @Produces("text/s4")
- public static class S4 extends DummySerializer{ public S4(PropertyStore ps) {super();} }
+ public static class S4 extends DummySerializer{ public S4(PropertyStore ps) {super("text/s4");} }
- @Produces("text/s5")
- public static class S5 extends DummySerializer{ public S5(PropertyStore ps) {super();} }
+ public static class S5 extends DummySerializer{ public S5(PropertyStore ps) {super("text/s5");} }
public static class E1 extends IdentityEncoder {
@Override public String[] getCodings() {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/NlsPropertyResource.java
----------------------------------------------------------------------
diff --git a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/NlsPropertyResource.java b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/NlsPropertyResource.java
index 7c5f1b4..3472634 100644
--- a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/NlsPropertyResource.java
+++ b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/NlsPropertyResource.java
@@ -13,7 +13,6 @@
package org.apache.juneau.rest.test;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.rest.*;
import org.apache.juneau.rest.annotation.*;
import org.apache.juneau.serializer.*;
@@ -52,11 +51,10 @@ public class NlsPropertyResource extends RestServlet {
return null;
}
- @Produces("text/plain")
public static class TestSerializer extends WriterSerializer {
public TestSerializer(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/plain");
}
@Override /* Serializer */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/OnPostCallResource.java
----------------------------------------------------------------------
diff --git a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/OnPostCallResource.java b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/OnPostCallResource.java
index fb38931..a9414b0 100644
--- a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/OnPostCallResource.java
+++ b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/OnPostCallResource.java
@@ -17,7 +17,6 @@ import static org.apache.juneau.rest.annotation.HookEvent.*;
import java.util.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.rest.*;
import org.apache.juneau.rest.annotation.*;
import org.apache.juneau.rest.annotation.Properties;
@@ -41,11 +40,10 @@ import org.apache.juneau.utils.*;
public class OnPostCallResource extends RestServlet {
private static final long serialVersionUID = 1L;
- @Produces("text/s1,text/s2,text/s3")
public static class TestSerializer extends WriterSerializer {
public TestSerializer(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "test/s1", "text/s1", "text/s2", "text/s3");
}
@Override /* Serializer */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/OnPreCallResource.java
----------------------------------------------------------------------
diff --git a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/OnPreCallResource.java b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/OnPreCallResource.java
index 9390051..9fa9469 100644
--- a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/OnPreCallResource.java
+++ b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/OnPreCallResource.java
@@ -15,7 +15,6 @@ package org.apache.juneau.rest.test;
import static org.apache.juneau.rest.annotation.HookEvent.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.plaintext.*;
import org.apache.juneau.rest.*;
@@ -39,11 +38,10 @@ import org.apache.juneau.rest.annotation.*;
public class OnPreCallResource extends RestServlet {
private static final long serialVersionUID = 1L;
- @Consumes("text/a1,text/a2,text/a3")
public static class TestParserA extends ReaderParser {
public TestParserA(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/a1", "text/a2", "text/a3");
}
@Override /* Parser */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/ParsersResource.java
----------------------------------------------------------------------
diff --git a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/ParsersResource.java b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/ParsersResource.java
index 1142263..ad6e0b2 100644
--- a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/ParsersResource.java
+++ b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/ParsersResource.java
@@ -16,7 +16,6 @@ import static org.apache.juneau.internal.IOUtils.*;
import static org.apache.juneau.rest.annotation.Inherit.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.plaintext.*;
import org.apache.juneau.rest.*;
@@ -34,11 +33,10 @@ import org.apache.juneau.rest.annotation.*;
public class ParsersResource extends RestServletDefault {
private static final long serialVersionUID = 1L;
- @Consumes("text/a")
public static class TestParserA extends ReaderParser {
public TestParserA(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/a");
}
@Override /* Parser */
@@ -70,11 +68,10 @@ public class ParsersResource extends RestServletDefault {
return in;
}
- @Consumes("text/b")
public static class TestParserB extends ReaderParser {
public TestParserB(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/b");
}
@Override /* Parser */
@@ -98,11 +95,10 @@ public class ParsersResource extends RestServletDefault {
return in;
}
- @Consumes("text/c")
public static class TestParserC extends ReaderParser {
public TestParserC(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/c");
}
@Override /* Parser */
@@ -126,11 +122,10 @@ public class ParsersResource extends RestServletDefault {
return in;
}
- @Consumes("text/a,text/d")
public static class TestParserD extends ReaderParser {
public TestParserD(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/a", "text/d");
}
@Override /* Parser */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/PropertiesResource.java
----------------------------------------------------------------------
diff --git a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/PropertiesResource.java b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/PropertiesResource.java
index 2b47160..c608a68 100644
--- a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/PropertiesResource.java
+++ b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/PropertiesResource.java
@@ -15,7 +15,6 @@ package org.apache.juneau.rest.test;
import static java.lang.String.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.rest.*;
import org.apache.juneau.rest.annotation.*;
import org.apache.juneau.serializer.*;
@@ -59,11 +58,10 @@ public class PropertiesResource extends RestServletDefault {
res.setOutput(null);
}
- @Produces("application/json,text/json")
public static class PropertySerializer1 extends WriterSerializer {
public PropertySerializer1(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "application/json", "*/json");
}
@Override /* Serializer */
@@ -88,11 +86,10 @@ public class PropertiesResource extends RestServletDefault {
res.setOutput(null);
}
- @Produces("application/json,text/json")
public static class PropertySerializer2 extends WriterSerializer {
public PropertySerializer2(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "application/json", "*/json");
}
@Override /* Serializer */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/SerializersResource.java
----------------------------------------------------------------------
diff --git a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/SerializersResource.java b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/SerializersResource.java
index c4578c2..21b1f37 100644
--- a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/SerializersResource.java
+++ b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/SerializersResource.java
@@ -15,7 +15,6 @@ package org.apache.juneau.rest.test;
import static org.apache.juneau.rest.annotation.Inherit.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.rest.*;
import org.apache.juneau.rest.annotation.*;
import org.apache.juneau.serializer.*;
@@ -30,11 +29,10 @@ import org.apache.juneau.serializer.*;
public class SerializersResource extends RestServletDefault {
private static final long serialVersionUID = 1L;
- @Produces("text/a")
public static class TestSerializerA extends WriterSerializer {
public TestSerializerA(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/a");
}
@Override /* Serializer */
@@ -49,11 +47,10 @@ public class SerializersResource extends RestServletDefault {
}
}
- @Produces("text/b")
public static class TestSerializerB extends WriterSerializer {
public TestSerializerB(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/b");
}
@Override /* Serializer */
@@ -92,11 +89,10 @@ public class SerializersResource extends RestServletDefault {
return "test3";
}
- @Produces("text/a")
public static class TestSerializerC extends WriterSerializer {
public TestSerializerC(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/a");
}
@Override /* Serializer */
@@ -119,11 +115,10 @@ public class SerializersResource extends RestServletDefault {
return "test4";
}
- @Produces(value="text/a,text/d",contentType="text/d")
public static class TestSerializerD extends WriterSerializer {
public TestSerializerD(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/d", "text/a", "text/d");
}
@Override /* Serializer */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-rest/src/main/java/org/apache/juneau/rest/package.html
----------------------------------------------------------------------
diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/package.html b/juneau-rest/src/main/java/org/apache/juneau/rest/package.html
index 82b694f..73b8e68 100644
--- a/juneau-rest/src/main/java/org/apache/juneau/rest/package.html
+++ b/juneau-rest/src/main/java/org/apache/juneau/rest/package.html
@@ -1517,8 +1517,7 @@
</p>
<p>
The servlet will pick which serializer to use by matching the request <l>Accept</l> header with the
- media types defined through the {@link org.apache.juneau.serializer.Serializer#getMediaTypes()} method
- (which itself usually comes from the {@link org.apache.juneau.annotation.Produces @Produces} annotation).
+ media types defined through the {@link org.apache.juneau.serializer.Serializer#getMediaTypes()} method.
</p>
<p>
Serializers can be associated with REST servlets in the following ways:
@@ -1587,8 +1586,7 @@
</p>
<p>
The servlet will pick which parser to use by matching the request <l>Content-Type</l> header with the
- media types defined through the {@link org.apache.juneau.parser.Parser#getMediaTypes()} method (which itself
- usually comes from the {@link org.apache.juneau.annotation.Consumes @Consumes} annotation).
+ media types defined through the {@link org.apache.juneau.parser.Parser#getMediaTypes()} method.
</p>
<p>
Parsers can be associated with REST servlets in the following ways:
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-rest/src/main/java/org/apache/juneau/rest/response/DefaultHandler.java
----------------------------------------------------------------------
diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/response/DefaultHandler.java b/juneau-rest/src/main/java/org/apache/juneau/rest/response/DefaultHandler.java
index aac9172..b5b16b5 100644
--- a/juneau-rest/src/main/java/org/apache/juneau/rest/response/DefaultHandler.java
+++ b/juneau-rest/src/main/java/org/apache/juneau/rest/response/DefaultHandler.java
@@ -18,7 +18,6 @@ import java.io.*;
import java.util.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.http.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.rest.*;
@@ -35,7 +34,7 @@ import org.apache.juneau.serializer.*;
*
* <p>
* The <code>Content-Type</code> header is set to the mime-type defined on the selected serializer based on the
- * {@link Produces#contentType() @Produces.contentType} annotation.
+ * <code>produces</code> value passed in through the constructor.
*/
public class DefaultHandler implements ResponseHandler {
[4/6] incubator-juneau git commit: Support serializing directly from
Readers and InputStreams.
Posted by ja...@apache.org.
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);
}
[2/6] incubator-juneau git commit: Support serializing directly from
Readers and InputStreams.
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/javadoc/overview.html
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/javadoc/overview.html b/juneau-core/src/main/javadoc/overview.html
index 91e552e..53a62d4 100644
--- a/juneau-core/src/main/javadoc/overview.html
+++ b/juneau-core/src/main/javadoc/overview.html
@@ -1,11248 +1,11377 @@
-<!DOCTYPE HTML>
-<!--
-/***************************************************************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- ***************************************************************************************************************************/
- -->
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <style type="text/css">
- /* For viewing in file system and page designer */
- @IMPORT url("../../../../juneau-core/java/src/main/javadoc/javadoc.css");
- @IMPORT url("../../../../juneau-core/java/src/main/javadoc/resources/juneau-doc.css");
- @IMPORT url("../../../../juneau-core/java/src/main/javadoc/resources/juneau-code.css");
-
- body {
- margin: 20px;
- }
- .spaced-list li { padding:5px; }
- .footer .spaced-list ul { margin:0 }
- </style>
- <script type="text/javascript">
- /* Replace all @code and @link tags. */
- window.onload = function() {
- document.body.innerHTML = document.body.innerHTML.replace(/\{\@code ([^\}]+)\}/g, '<code>$1<\/code>');
- document.body.innerHTML = document.body.innerHTML.replace(/\{\@link (([^\}]+)\.)?([^\.\}]+)\}/g, '<code>$3<\/code>');
- }
- </script>
-</head>
-<body>
-<p>Apache Juneau Overview</p>
-<script type="text/javascript">
- function toggle(x) {
- var div = x.nextSibling;
- while (div != null && div.nodeType != 1)
- div = div.nextSibling;
- if (div != null) {
- var d = div.style.display;
- if (d == 'block' || d == '') {
- div.style.display = 'none';
- x.className += " closed";
- } else {
- div.style.display = 'block';
- x.className = x.className.replace(/(?:^|\s)closed(?!\S)/g , '' );
- }
- }
- }
-</script>
-<ul class='spaced-list'>
- <li>
- A toolkit for marshalling POJOs to a wide variety of content types using a common framework.
- <li>
- A REST server API for creating self-documenting REST interfaces using POJOs.
- <li>
- A REST client API for interacting with REST interfaces using POJOs.
- <li>
- A remote proxy API built on top of REST.
- <li>
- A sophisticated INI config file API.
- <li>
- A REST microservice API that combines all the features above for creating lightweight stand-alone REST
- interfaces that start up in milliseconds.
-</ul>
-
-<a id='TOC'></a><h5 class='toc'>Table of Contents</h5>
-<ol class='toc'>
- <li><p><a class='doclink' href='#Intro'>Juneau - What is it?</a></p>
- <li><p><a class='doclink' href='#Core'>Juneau Core (org.apache.juneau)</a></p>
- <ol>
- <li><p><a class='doclink' href='#Core.Serializers'>Serializers</a></p>
- <li><p><a class='doclink' href='#Core.Parsers'>Parsers</a></p>
- <li><p><a class='doclink' href='#Core.SerializerAndParserGroups'>SerializerGroups and ParserGroups</a></p>
- <li><p><a class='doclink' href='#Core.ObjectMap'>ObjectMap and ObjectList</a></p>
- <li><p><a class='doclink' href='#Core.ConfigurableProperties'>Configurable Properties</a></p>
- <li><p><a class='doclink' href='#Core.Transforms'>Transforms</a></p>
- <ol>
- <li><p><a class='doclink' href='#Core.PojoSwaps'>PojoSwaps</a></p>
- <li><p><a class='doclink' href='#Core.SwapMethods'>Swap methods</a></p>
- <li><p><a class='doclink' href='#Core.BeanFilters'>BeanFilters and @Bean annotations</a></p>
- </ol>
- <li><p><a class='doclink' href='#Core.BeanDictionaries'>Bean Name and Dictionaries</a></p>
- <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>
- <li><p><a class='doclink' href='#Core.SupportedLanguages'>Supported Languages</a></p>
- <li><p><a class='doclink' href='#Core.JacksonComparison'>Comparison with Jackson</a></p>
- </ol>
- <li><p><a class='doclink' href='#DTOs'>Juneau Data Transfer Objects (org.apache.juneau.dto)</a></p>
- <ol>
- <li><p><a class='doclink' href='#DTOs.HTML5'>HTML5</a></p>
- <li><p><a class='doclink' href='#DTOs.Atom'>Atom</a></p>
- <li><p><a class='doclink' href='#DTOs.Swagger'>Swagger</a></p>
- <li><p><a class='doclink' href='#DTOs.JsonSchema'>JSON-Schema</a></p>
- </ol>
- <li><p><a class='doclink' href='#Server'>Juneau Server (org.apache.juneau.rest)</a></p>
- <li><p><a class='doclink' href='#Client'>Juneau Client (org.apache.juneau.rest.client)</a></p>
- <li><p><a class='doclink' href='#Remoteable'>Remoteable services (org.apache.juneau.rest.remoteable)</a></p>
- <ol>
- <li><p><a class='doclink' href='#Remoteable.3rdParty'>Interface proxies against 3rd-party REST interfaces</a></p>
- </ol>
- <li><p><a class='doclink' href='#Microservices'>Juneau Microservices (org.apache.juneau.microservice)</a></p>
- <li><p><a class='doclink' href='#Samples'>Samples</a></p>
- <ol>
- <li><p><a class='doclink' href='#Samples.Installing'>Installing in Eclipse</a></p>
- <li><p><a class='doclink' href='#Samples.Running'>Running in Eclipse</a></p>
- <li><p><a class='doclink' href='#Samples.Building'>Building and Running from Command-Line</a></p>
- <li><p><a class='doclink' href='#Samples.RestResource'>MANIFEST.MF</a></p>
- <li><p><a class='doclink' href='#Samples.RootResources'>RootResources</a></p>
- <li><p><a class='doclink' href='#Samples.HelloWorldResource'>HelloWorldResource</a></p>
- <li><p><a class='doclink' href='#Samples.MethodExampleResource'>MethodExampleResource</a></p>
- <li><p><a class='doclink' href='#Samples.UrlEncodedFormResource'>UrlEncodedFormResource</a></p>
- <li><p><a class='doclink' href='#Samples.RequestEchoResource'>RequestEchoResource</a></p>
- <li><p><a class='doclink' href='#Samples.AddressBookResource'>AddressBookResource</a></p>
- <ol>
- <li><p><a class='doclink' href='#Samples.AddressBookResource.Classes'>Classes</a></p>
- <li><p><a class='doclink' href='#Samples.AddressBookResource.Demo'>Demo</a></p>
- <li><p><a class='doclink' href='#Samples.AddressBookResource.Traversable'>Traversable</a></p>
- <li><p><a class='doclink' href='#Samples.AddressBookResource.Queryable'>Queryable</a></p>
- <li><p><a class='doclink' href='#Samples.AddressBookResource.Introspectable'>Introspectable</a></p>
- <li><p><a class='doclink' href='#Samples.AddressBookResource.RestClient'>ClientTest</a></p>
- <li><p><a class='doclink' href='#Samples.AddressBookResource.Browser'>Browser Tips</a></p>
- </ol>
- <li><p><a class='doclink' href='#Samples.SampleRemoteableServlet'>SampleRemoteableServlet</a></p>
- <li><p><a class='doclink' href='#Samples.TempDirResource'>TempDirResource</a></p>
- <li><p><a class='doclink' href='#Samples.AtomFeedResource'>AtomFeedResource</a></p>
- <li><p><a class='doclink' href='#Samples.DockerRegistryResource'>DockerRegistryResource</a></p>
- <li><p><a class='doclink' href='#Samples.TumblrParserResource'>TumblrParserResource</a></p>
- <li><p><a class='doclink' href='#Samples.PhotosResource'>PhotosResource</a></p>
- <li><p><a class='doclink' href='#Samples.JsonSchemaResource'>JsonSchemaResource</a></p>
- <li><p><a class='doclink' href='#Samples.SqlQueryResource'>SqlQueryResource</a></p>
- <li><p><a class='doclink' href='#Samples.ConfigResource'>ConfigResource</a></p>
- <li><p><a class='doclink' href='#Samples.LogsResource'>LogsResource</a></p>
- </ol>
- <li><p><a class='doclink' href='#Cookbook'>Cookbook Examples</a></p>
- <ol>
- <li><p><a class='doclink' href='#Cookbook.Core'>Core API</a></p>
- <li><p><a class='doclink' href='#Cookbook.Server'>Server API</a></p>
- <ol>
- <li><p><a class='doclink' href='#Cookbook.Server.applyDoubletransform'>Apply a transform that changes the
- format of doubles</a></p>
- <li><p><a class='doclink' href='#Cookbook.Server.applyTransformsSubset'>Apply transforms to a subset of
- serializers or parsers</a></p>
- </ol>
- <li><p><a class='doclink' href='#Cookbook.Client'>Client API</a></p>
- <ol>
- </ol>
- <li><p><a class='doclink' href='#Cookbook.Microservice'>Microservice API</a></p>
- <ol>
- </ol>
- </ol>
- <li><p><a class='doclink' href='#BestPractices'>Best Practices</a></p>
- <li><p><a class='doclink' href='#ImportantLinks'>Important Documentation Links</a></p>
- <li><p><a class='doclink' href='#ReleaseNotes'>Release Notes</a></p>
-</ol>
-
-<!-- ======================================================================================================== -->
-<a id="Intro"></a>
-<h2 class='topic' onclick='toggle(this)'>1 - Juneau - What is it?</h2>
-<div class='topic'>
- <p>
- Juneau started off as a popular internal IBM toolkit called Juno.
- Originally used for serializing POJOs to and from JSON, it later expanded in scope to include a variety of
- content types, and then later REST servlet, client, and microservice APIs.
- It's use grew to more than 50 projects and was one of the most popular community source projects within IBM.
- </p>
- <p>
- In 2016, the code was donated to the Apache Foundation under the project <l>Apache Juneau</l>.
- </p>
-
- <h5 class='toc'>Features</h5>
- <ol class='toc'>
- <li>
- <p>Extensive and extensible support for a large variety of POJOs, including structured data (beans) and
- unstructured data (<code>Maps</code> and <code>Collections</code>).</p>
- <li>
- <p>Serialization support:</p>
- <ul>
- <li>JSON (including variants)
- <li>XML
- <li>HTML
- <li>URL-Encoding
- <li>UON (URL-Encoded Object Notation)
- <li>MessagePack
- <li>RDF/XML
- <li>RDF/XML-Abbrev
- <li>N-Triple
- <li>Turtle
- <li>N3
- <li>SOAP/XML
- </ul>
- <li>
- <p>Parsing support:</p>
- <ul>
- <li>JSON (including lax syntax, comments, concatenated strings)
- <li>XML
- <li>HTML
- <li>URL-Encoding
- <li>UON (URL-Encoded Object Notation)
- <li>MessagePack
- <li>RDF/XML
- <li>RDF/XML-Abbrev
- <li>N-Triple
- <li>Turtle
- <li>N3
- </ul>
- <li>
- <p>Data Transfer Objects:</p>
- <ul>
- <li>HTML5
- <li>ATOM
- <li>Swagger
- <li>Cognos
- <li>JSON-Schema
- </ul>
- <p>DTOs can be used with any serializers and parsers (e.g. ATOM as JSON).
- <li>
- <p>Serialization of POJO meta-models (e.g. the POJO class structure itself) to:</p>
- <ul>
- <li>JSON-Schema
- <li>XML-Schema
- <li>HTML-Schema
- </ul>
- <li>
- <p>
- Serializers/parsers require only Java 6+.
- (RDF support requires Jena 2.7.1+)
- </p>
- <li>
- <p>
- REST APIs require only Java 6+ and JEE 1.3+.
- (JAX/RS integration component requires JAX/RS provider)
- </p>
- </ol>
-
- <h5 class='topic'>Components</h5>
- <p>
- Juneau ships as a single Java library called <l>juneau.jar</l>.
- </p>
- <p>
- Juneau requires Java 6+. The majority of the code has no other dependencies except for the following packages:
- </p>
- <ul class='doctree'>
- <li class='jp'>
- <a class='doclink' href='org/apache/juneau/jena/package-summary.html#TOC'>org.apache.juneau.jena</a>
- - RDF support. Requires Apache Jena 2.7.1+.
- <li class='jp'>
- <a class='doclink' href='org/apache/juneau/rest/package-summary.html#TOC'>org.apache.juneau.rest</a>
- - REST servlet support. Requires JEE 1.3+.
- <li class='jp'>
- <a class='doclink' href='org/apache/juneau/rest/client/package-summary.html#TOC'>org.apache.juneau.rest.client</a>
- - REST client support. Requires Apache HttpClient 4.5+.
- </ul>
- <p>
- OSGi bundles are also provided that break down Juneau into the following components:
- </p>
- <ul class='spaced-list'>
- <li>
- <l>org.apache.juneau.core.jar</l> - Serializers, parsers, INI file support.
- <li>
- <l>org.apache.juneau.rest.jar</l> - REST servlet support.
- <li>
- <l>org.apache.juneau.rest.client.jar</l> - REST client support.
- <li>
- <l>org.apache.juneau.microservice.jar</l> - Microservice support.
- </ul>
- <p>
- The following zip files are also provided:
- </p>
- <ul class='spaced-list'>
- <li>
- <l>microservice-project.zip</l> - Contains a template Eclipse project for quickly creating REST resources
- as executable jars.
- <li>
- <l>microservice-samples-project.zip</l> - Contains sample code demonstrating various aspects of Juneau.
- <br>These are discussed in detail in the <a class='doclink' href="#Samples">Samples</a> section.
- </ul>
-
- <ul class='doctree'>
- <li class='info'>
- Many of the examples below use beans with public field properties instead of standard getters/setters.
- This is to simplify the examples.
- </ul>
-</div>
-
-<!-- ======================================================================================================== -->
-<a id="Core"></a>
-<h2 class='topic' onclick='toggle(this)'>2 - Juneau Core (org.apache.juneau)</h2>
-<div class='topic'>
- <p>
- The core packages of Juneau contains serializers and parsers for converting POJOs to and from a wide variety of
- content types.
- It uses a common API for defining serializers and parsers.
- </p>
- <p>
- One of the goals of Juneau was to make serialization as simple as possible.
- In a single line of code, you should be able to serialize and parse most POJOs.
- Despite this simplicity, Juneau provides lots of extensibility and configuration properties for tailoring how
- POJOs are serialized and parsed.
- </p>
-
- <!-- ======================================================================================================== -->
- <a id="Core.Serializers"></a>
- <h3 class='topic' onclick='toggle(this)'>2.1 - Serializers</h3>
- <div class='topic'>
- <p>
- The built-in serializers in Juneau are fast, efficient, and highly configurable.
- They work by serializing POJOs directly to streams instead of using intermediate Document Object Model
- objects.
- </p>
- <p>
- In most cases, you can serialize objects in one line of code by using one of the default serializers:
- </p>
- <p class='bcode'>
- <jc>// A simple bean</jc>
- <jk>public class</jk> Person {
- <jk>public</jk> String <jf>name</jf> = <js>"John Smith"</js>;
- <jk>public int</jk> <jf>age</jf> = 21;
- }
-
- <jc>// Serialize to JSON, XML, or HTML</jc>
- Person p = <jk>new</jk> Person();
-
- <jc>// Produces:
- // "{name:'John Smith',age:21}"</jc>
- String json = JsonSerializer.<jsf>DEFAULT</jsf>.serialize(p);
-
- <jc>// Produces:
- // <object>
- // <name>John Smith</name>
- // <age>21</age>
- // </object></jc>
- String xml = XmlSerializer.<jsf>DEFAULT</jsf>.serialize(p);
-
- <jc>// Produces:
- // <table>
- // <tr><th>key</th><th>value</th></tr>
- // <tr><td>name</td><td>John Smith</td></tr>
- // <tr><td>age</td><td>21</td></tr>
- // </table></jc>
- String html = HtmlSerializer.<jsf>DEFAULT</jsf>.serialize(p);
-
- <jc>// Produces:
- // "(name='John Smith',age=21)"</jc>
- String uon = UonSerializer.<jsf>DEFAULT</jsf>.serialize(p);
-
- <jc>// Produces:
- // "name='John+Smith'&age=21"</jc>
- String urlencoding = UrlEncodingSerializer.<jsf>DEFAULT</jsf>.serialize(p);
-
- <jc>// Produces:
- // 82 A4 6E 61 6D 65 AA 4A 6F 68 6E 20 53 6D 69 74 68 A3 61 67 65 15 </jc>
- <jk>byte</jk>[] b = MsgPackSerializer.<jsf>DEFAULT</jsf>.serialize(p);
- </p>
-
- <p>
- In addition to the default serializers, customized serializers can be created using various built-in options:
- </p>
-
- <p class='bcode'>
- <jc>// Use one of the default serializers to serialize a POJO</jc>
- String json = JsonSerializer.<jsf>DEFAULT</jsf>.serialize(someObject);
-
- <jc>// Create a custom serializer for lax syntax using single quote characters</jc>
- JsonSerializer serializer = <jk>new</jk> JsonSerializerBuilder().simple().sq().build();
-
- <jc>// Clone an existing serializer and modify it to use single-quotes</jc>
- JsonSerializer serializer = JsonSerializer.<jsf>DEFAULT</jsf>.builder().sq().build();
-
- <jc>// Serialize a POJO to JSON</jc>
- String json = serializer.serialize(someObject);
- </p>
- <p>
- Default serialization support is provided for Java primitives, <code>Maps</code>, <code>Collections</code>,
- beans, and arrays.
- <br>Extensible support for other data types such as <code>Calendars</code>, <code>Dates</code>,
- <code>Iterators</code> is available through the use of POJO swaps (described later).
- </p>
-
- <h6 class='topic'>Additional Information</h6>
- <ul class='doctree'>
- <li class='jp'>
- <a class='doclink' href='org/apache/juneau/serializer/package-summary.html#TOC'>org.apache.juneau.serializer</a>
- - Serializer API Javadoc
- </ul>
- </div>
-
- <!-- ======================================================================================================== -->
- <a id="Core.Parsers"></a>
- <h3 class='topic' onclick='toggle(this)'>2.2 - Parsers</h3>
- <div class='topic'>
- <p>
- Parsers work by parsing input directly into POJOs instead of having to create intermediate Document Object
- Models.
- This allows them to parse input with minimal object creation.
- </p>
- <p>
- Like the serializers, you can often parse objects in one line of code by using one of the default parsers:
- </p>
- <p class='bcode'>
- <jc>// Use one of the predefined parsers.</jc>
- Parser parser = JsonParser.<jsf>DEFAULT</jsf>;
-
- <jc>// Parse a JSON object as a bean.</jc>
- String json = <js>"{name:'John Smith',age:21}"</js>;
- Person p = parser.parse(json, Person.<jk>class</jk>);
-
- <jc>// Or parse it into a generic Map.</jc>
- Map m1 = parser.parse(json, Map.<jk>class</jk>);
-
- <jc>// Parse a JSON string.</jc>
- json = <js>"'foobar'"</js>;
- String s2 = parser.parse(json, String.<jk>class</jk>);
-
- <jc>// Parse a JSON number as a Long or Float.</jc>
- json = <js>"123"</js>;
- Long l3 = parser.parse(json, Long.<jk>class</jk>);
- Float f3 = parser.parse(json, Float.<jk>class</jk>);
-
- <jc>// Parse a JSON object as a HashMap<String,Person>.</jc>
- json = <js>"{a:{name:'John Smith',age:21},b:{name:'Joe Smith',age:42}}"</js>;
- Map<String,Person> m4 = parser.parse(json, HashMap.<jk>class</jk>, String.<jk>class</jk>, Person.<jk>class</jk>)
-
- <jc>// Parse a JSON object as a HashMap<String,LinkedList<Person>>.</jc>
- json = <js>"{a:[{name:'John Smith',age:21},{name:'Joe Smith',age:42}]}"</js>;
- Map<String,List<Person>> m5 = parser.parse(json, HashMap.<jk>class</jk>, String.<jk>class</jk>,
- LinkedList.<jk>class</jk>, Person.<jk>class</jk>)
-
- <jc>// Parse a JSON array of integers as a Collection of Integers or int[] array.</jc>
- json = <js>"[1,2,3]"</js>;
- List<Integer> l6 = parser.parse(json, LinkedList.<jk>class</jk>, Integer.<jk>class</jk>);
- <jk>int</jk>[] i7 = parser.parse(json, <jk>int</jk>[].<jk>class</jk>);
- </p>
- <p>
- The parsers can also be used to populating existing bean and collection objects:
- </p>
- <p class='bcode'>
- <jc>// Use one of the predefined parsers.</jc>
- Parser parser = JsonParser.<jsf>DEFAULT</jsf>;
-
- <jc>// Populate the properties on an existing bean from a JSON object.</jc>
- String json = <js>"{name:'John Smith',age:21}"</js>;
- Person p = <jk>new</jk> Person();
- parser.parseIntoBean(json, p);
-
- <jc>// Populate an existing list from a JSON array of numbers.</jc>
- json = <js>"[1,2,3]"</js>;
- List<Integer> l2 = <jk>new</jk> LinkedList<Integer>();
- parser.parseIntoCollection(json, l2, Integer.<jk>class</jk>);
-
- <jc>// Populate an existing map from a JSON object containing beans.</jc>
- json = <js>"{a:{name:'John Smith',age:21},b:{name:'Joe Smith',age:42}}"</js>;
- Map<String,Person> m3 = <jk>new</jk> TreeMap<String,Person>();
- parser.parseIntoMap(json, m3, String.<jk>class</jk>, Person.<jk>class</jk>);
- </p>
- <ul class='doctree'>
- <li class='info'>
- In the example above, we're parsing "lax" JSON (single quotes, unquoted attributes).
- The JSON parser can handle any valid JSON syntax (such as quoted or unquoted attributes, single or double
- quotes).
- <br>It can also handle JSON fragments and embedded Javascript comments.
- Many of the JSON examples provided will use lax syntax which is easier to read since we don't have to deal
- with escapes.
- </ul>
-
- <h6 class='topic'>Additional Information</h6>
- <ul class='doctree'>
- <li class='jp'>
- <a class='doclink' href='org/apache/juneau/parser/package-summary.html#TOC'>org.apache.juneau.parser</a>
- - Parser API Javadoc
- </ul>
- </div>
-
- <!-- ======================================================================================================== -->
- <a id="Core.SerializerAndParserGroups"></a>
- <h3 class='topic' onclick='toggle(this)'>2.3 - SerializerGroups and ParserGroups</h3>
- <div class='topic'>
- <p>
- Above the serializers and parsers are the {@link org.apache.juneau.serializer.SerializerGroup} and
- {@link org.apache.juneau.parser.ParserGroup} classes.
- These classes allow serializers and parsers to be retrieved by W3C-compliant HTTP <code>Accept</code>
- and <code>Content-Type</code> values...
- </p>
- <p class='bcode'>
- <jc>// Construct a new serializer group with configuration parameters that get applied to all serializers.</jc>
- SerializerGroup sg = <jk>new</jk> SerializerGroupBuilder()
- .append(JsonSerializer.<jk>class</jk>, UrlEncodingSerializer.<jk>class</jk>);
- .ws <jc>// or .useWhitespace(true)</jc>
- .pojoSwaps(CalendarSwap.ISO8601DT.<jk>class</jk>)
- .build();
-
- <jc>// Find the appropriate serializer by Accept type and serialize our POJO to the specified writer.</jc>
- sg.getSerializer(<js>"text/invalid, text/json;q=0.8, text/*;q:0.6, *\/*;q=0.0"</js>)
- .serialize(myPersonObject, myWriter);
-
- <jc>// Construct a new parser group with configuration parameters that get applied to all parsers.</jc>
- ParserGroup pg = <jk>new</jk> ParserGroupBuilder()
- .append(JsonSerializer.<jk>class</jk>, UrlEncodingSerializer.<jk>class</jk>);
- .pojoSwaps(CalendarSwap.ISO8601DT.<jk>class</jk>)
- .build();
-
- Person p = pg.getParser(<js>"text/json"</js>).parse(myReader, Person.<jk>class</jk>);
- </p>
- <p>
- The REST servlet API builds upon the <code>SerializerGroup</code> and <code>ParserGroup</code> classes
- to provide annotated REST servlets that automatically negotiate the HTTP media types and allow the developer
- to work with requests and responses as POJOs.
- </p>
-
- <h6 class='topic'>Additional Information</h6>
- <ul class='doctree'>
- <li class='jc'>
- {@link org.apache.juneau.serializer.SerializerGroup}
- <li class='jc'>
- {@link org.apache.juneau.parser.ParserGroup}
- </ul>
- </div>
-
- <!-- ======================================================================================================== -->
- <a id="Core.ObjectMap"></a>
- <h3 class='topic' onclick='toggle(this)'>2.4 - ObjectMap and ObjectList</h3>
- <div class='topic'>
- <p>
- The {@link org.apache.juneau.ObjectMap} and {@link org.apache.juneau.ObjectList} classes are generic Java
- representations of JSON objects and arrays.
- These classes can be used to create "unstructured" models for serialization (as opposed to "structured"
- models consisting of beans).
- If you want to quickly generate JSON/XML/HTML from generic maps/collections, or parse JSON/XML/HTML into
- generic maps/collections, these classes work well.
- </p>
- <p>
- These classes extend directly from the following JCF classes:
- </p>
- <ul class='doctree'>
- <li class='jc'>
- {@link java.util.LinkedHashMap java.util.LinkedHashMap}
- <ul>
- <li class='jc'>
- {@link org.apache.juneau.ObjectMap org.apache.juneau.ObjectMap}
- </ul>
- </li>
- <li class='jc'>
- {@link java.util.LinkedList java.util.LinkedList}
- <ul>
- <li class='jc'>
- {@link org.apache.juneau.ObjectMap org.apache.juneau.ObjectList}
- </ul>
- </li>
- </ul>
- <p>
- The <l>ObjectMap</l> and <l>ObjectList</l> classes are very similar to the <l>JSONObject</l> and
- <l>JSONArray</l> classes found in other libraries.
- However, the names were chosen because the concepts of <l>Maps</l> and <l>Lists</l> are already familiar to
- Java programmers, and these classes can be used with any of the serializers or parsers.
- </p>
- <p>
- These object can be serialized in one of two ways:
- </p>
- <ol class='spaced-list'>
- <li>
- Using the provided {@link org.apache.juneau.ObjectMap#serializeTo(java.io.Writer)} or
- {@link org.apache.juneau.ObjectList#serializeTo(java.io.Writer)} methods.
- <li>
- Passing them to one of the {@link org.apache.juneau.serializer.Serializer} serialize methods.
- <li>
- Simply calling the {@link org.apache.juneau.ObjectMap#toString()} or {@link org.apache.juneau.ObjectList#toString()}
- methods which will serialize it as Simplified JSON.
- </ol>
- <p>
- Any valid JSON can be parsed into an unstructured model consisting of generic
- {@link org.apache.juneau.ObjectMap} and {@link org.apache.juneau.ObjectList} objects.
- <br>
- (In theory, any valid XML can also be parsed into an unstructured model, although this has not been
- officially 'tested')
- </p>
- <p class='bcode'>
- <jc>// Parse an arbitrary JSON document into an unstructered data model
- // consisting of ObjectMaps, ObjectLists, and java primitive objects.</jc>
- Parser parser = JsonParser.<jsf>DEFAULT</jsf>;
- String json = <js>"{a:{name:'John Smith',age:21},b:{name:'Joe Smith',age:42}}"</js>;
- ObjectMap m = parser.parse(json, ObjectMap.<jk>class</jk>);
-
- <jc>// Use ObjectMap API to extract data from the unstructured model.</jc>
- <jk>int</jk> johnSmithAge = m.getObjectMap(<js>"a"</js>).getInt(<js>"age"</js>);
-
- <jc>// Convert it back into JSON.</jc>
- json = JsonSerializer.<jsf>DEFAULT</jsf>.serialize(m);
-
- <jc>// Or convert it to XML.</jc>
- String xml = XmlSerializer.<jsf>DEFAULT</jsf>.serialize(m);
-
- <jc>// Or just use toString().</jc>
- json = m.toString();
- </p>
- <ul class='doctree'>
- <li class='info'>
- As a general rule, if you do not specify a target type during parsing, or if the target type cannot be
- determined through reflection, the parsers automatically generate <l>ObjectMaps</l> and <l>ObjectLists</l>.
- </ul>
-
- <h6 class='topic'>Additional Information</h6>
- <ul class='doctree'>
- <li class='jc'>
- {@link org.apache.juneau.ObjectMap}
- <li class='jc'>
- {@link org.apache.juneau.ObjectList}
- </ul>
- </div>
-
- <!-- ======================================================================================================== -->
- <a id="Core.ConfigurableProperties"></a>
- <h3 class='topic' onclick='toggle(this)'>2.5 - Configurable Properties</h3>
- <div class='topic'>
- <p>
- Serializers and parsers have a wide variety of configurable properties.
- <br>For example, the following code shows how to configure a JSON serializer:
- </p>
- <p class='bcode'>
- JsonSerializer s = <jk>new</jk> JsonSerializerBuilder().simple().ws().sq().build();
- </p>
- <p>
- However, each of the serializers and parsers already contain reusable instances with common configurations.
- <br>For example, JSON has the following predefined reusable serializers and parsers:
- </p>
- <ul class='doctree'>
- <li class='jc'>
- {@link org.apache.juneau.json.JsonSerializer}
- <ul>
- <li class='jf'>
- {@link org.apache.juneau.json.JsonSerializer#DEFAULT DEFAULT}
- <li class='jf'>
- {@link org.apache.juneau.json.JsonSerializer#DEFAULT_LAX DEFAULT_LAX}
- <li class='jf'>
- {@link org.apache.juneau.json.JsonSerializer#DEFAULT_READABLE DEFAULT_READABLE}
- <li class='jf'>
- {@link org.apache.juneau.json.JsonSerializer#DEFAULT_LAX_READABLE DEFAULT_LAX_READABLE}
- </ul>
- </li>
- <li class='jc'>
- {@link org.apache.juneau.json.JsonParser}
- <ul>
- <li class='jf'>
- {@link org.apache.juneau.json.JsonParser#DEFAULT DEFAULT}
- <li class='jf'>
- {@link org.apache.juneau.json.JsonParser#DEFAULT_STRICT DEFAULT_STRICT}
- </ul>
- </li>
- </ul>
- <p>
- These can be used directly, as follows:
- </p>
- <p class='bcode'>
- <jc>// Serialize a POJO to LAX JSON.</jc>
- String json = JsonSerializer.<jsf>DEFAULT_LAX</jsf>.serialize(myPojo);
- </p>
- <p>
- Serializers and parsers can be locked to prevent further modification to the properties.
- They can also be cloned to copy the configuration of other serializers and parsers.
- </p>
- <p class='bcode'>
- <jc>// Clone and customize an existing serializer.</jc>
- JsonSerializer s = JsonSerializer.<jsf>DEFAULT_LAX</jsf>
- .builder()
- .quoteChar(<js>'"'</js>)
- .build();
-
- <jc>// Lock it so that the configuration cannot be changed.</jc>
- s.lock();
- </p>
-
- <h6 class='topic'>Additional Information</h6>
- <p>
- The following is a list of all configurable properties across all serializers and parsers.
- </p>
- <ul class='doctree'>
- <li class='jc'>
- <a class='doclink' href='org/apache/juneau/BeanContext.html#ConfigProperties'>BeanContext</a>
- - Properties associated with handling beans on serializers and parsers.
- <ul>
- <li class='jc'>
- <a class='doclink' href='org/apache/juneau/serializer/SerializerContext.html#ConfigProperties'>SerializerContext</a>
- - Configurable properties common to all serializers.
- <ul>
- <li class='jc'>
- <a class='doclink' href='org/apache/juneau/html/HtmlSerializerContext.html#ConfigProperties'>HtmlSerializerContext</a>
- - Configurable properties on the HTML serializer.
- <ul>
- <li class='jc'>
- <a class='doclink' href='org/apache/juneau/html/HtmlDocSerializerContext.html#ConfigProperties'>HtmlDocSerializerContext</a>
- - Configurable properties on the HTML document serializer.
- </ul>
- </li>
- <li class='jic'>
- <a class='doclink' href='org/apache/juneau/jena/RdfCommonContext.html#ConfigProperties'>RdfCommonContext</a>
- - Configurable properties common to the RDF serializers and parsers.
- <ul>
- <li class='jc'>
- <a class='doclink' href='org/apache/juneau/jena/RdfSerializerContext.html#ConfigProperties'>RdfSerializerContext</a>
- - Configurable properties on the RDF serializers.
- </ul>
- </li>
- <li class='jc'>
- <a class='doclink' href='org/apache/juneau/json/JsonSerializerContext.html#ConfigProperties'>JsonSerializerContext</a>
- - Configurable properties on the JSON serializer.
- <li class='jc'>
- <a class='doclink' href='org/apache/juneau/msgpack/MsgPackSerializerContext.html#ConfigProperties'>MsgPackSerializerContext</a>
- - Configurable properties on the MessagePack serializer.
- <li class='jc'>
- <a class='doclink' href='org/apache/juneau/soap/SoapXmlSerializerContext.html#ConfigProperties'>SoapXmlSerializerContext</a>
- - Configurable properties on the SOAP/XML serializer.
- <li class='jc'>
- <a class='doclink' href='org/apache/juneau/urlencoding/UonSerializerContext.html#ConfigProperties'>UonSerializerContext</a>
- - Configurable properties on the URL-Encoding and UON serializers.
- <li class='jc'>
- <a class='doclink' href='org/apache/juneau/xml/XmlSerializerContext.html#ConfigProperties'>XmlSerializerContext</a>
- - Configurable properties on the XML serializer.
- </ul>
- </li>
- <li class='jc'>
- <a class='doclink' href='org/apache/juneau/parser/ParserContext.html#ConfigProperties'>ParserContext</a>
- - Configurable properties common to all parsers.
- <ul>
- <li class='jc'>
- <a class='doclink' href='org/apache/juneau/html/HtmlParserContext.html#ConfigProperties'>HtmlParserContext</a>
- - Configurable properties on the HTML parser.
- <li class='jic'>
- <a class='doclink' href='org/apache/juneau/jena/RdfCommonContext.html#ConfigProperties'>RdfCommonContext</a>
- - Configurable properties common to the RDF serializers and parsers.
- <ul>
- <li class='jc'><a class='doclink' href='org/apache/juneau/jena/RdfParserContext.html#ConfigProperties'>RdfParserContext</a>
- - Configurable properties on the RDF parsers.
- </ul>
- </li>
- <li class='jc'>
- <a class='doclink' href='org/apache/juneau/json/JsonParserContext.html#ConfigProperties'>JsonParserContext</a>
- - Configurable properties on the JSON parser.
- <li class='jc'>
- <a class='doclink' href='org/apache/juneau/msgpack/MsgPackParserContext.html#ConfigProperties'>MsgPackParserContext</a>
- - Configurable properties on the MessagePack parser.
- <li class='jc'>
- <a class='doclink' href='org/apache/juneau/urlencoding/UonParserContext.html#ConfigProperties'>UonParserContext</a>
- - Configurable properties on the URL-Encoding and UON parsers.
- <li class='jc'>
- <a class='doclink' href='org/apache/juneau/xml/XmlParserContext.html#ConfigProperties'>XmlParserContext</a>
- - Configurable properties on the XML parser.
- </ul>
- </li>
- </ul>
- </li>
- <li class='jc'>
- <a class='doclink' href='org/apache/juneau/server/RestContext.html#ConfigProperties'>RestContext</a>
- - Configurable properties on the REST servlet.
- </li>
- </ul>
- </div>
-
- <!-- ======================================================================================================== -->
- <a id="Core.Transforms"></a>
- <h3 class='topic' onclick='toggle(this)'>2.6 - Transforms</h3>
- <div class='topic'>
- <p>
- By default, the Juneau framework can serialize and parse a wide variety of POJOs out-of-the-box.
- However, two special classes are provided tailor how certain Java objects are handled by the framework.
- These classes are:
- </p>
- <ul class='doctree'>
- <li class='jc'>
- {@link org.apache.juneau.transform.PojoSwap}
- - Tailor how specific non-bean classes are handled by the framework.
- <li class='jc'>
- {@link org.apache.juneau.transform.BeanFilter}
- - Tailor how specific bean classes are handled by the framework.
- </ul>
- <p>
- Annotations are also provided that allow you to use transformations directly on class definitions:
- </p>
- <ul class='doctree'>
- <li class='ja'>
- {@link org.apache.juneau.annotation.Pojo @Pojo}
- - Used to tailor how non-bean POJOs get interpreted by the framework.
- <li class='ja'>
- {@link org.apache.juneau.annotation.Bean @Bean}
- - Used to tailor how beans get interpreted by the framework.
- <li class='ja'>
- {@link org.apache.juneau.annotation.BeanConstructor @BeanConstructor}
- - Maps constructor arguments to property names on beans with read-only properties.
- <li class='ja'>
- {@link org.apache.juneau.annotation.BeanIgnore @BeanIgnore}
- - Ignore classes, fields, and methods from being interpreted as bean or bean components.
- <li class='ja'>
- {@link org.apache.juneau.annotation.BeanProperty @BeanProperty}
- - Used to tailor how bean properties get interpreted by the framework.
- <li class='ja'>
- {@link org.apache.juneau.annotation.NameProperty @NameProperty}
- - Identifies a setter as a method for setting the name of a POJO as it's known by its parent object.
- <li class='ja'>
- {@link org.apache.juneau.annotation.ParentProperty @ParentProperty}
- - Identifies a setter as a method for adding a parent reference to a child object.
- <li class='ja'>
- {@link org.apache.juneau.annotation.URI @URI}
- - Used to identify a class or bean property as a URI.
- </ul>
-
- <!-- ======================================================================================================== -->
- <a id="Core.PojoSwaps"></a>
- <h4 class='topic' onclick='toggle(this)'>2.6.1 - PojoSwaps</h4>
- <div class='topic'>
- <p>
- {@link org.apache.juneau.transform.PojoSwap PojoSwaps} are a critical component of Juneau.
- They allow the serializers and parsers to handle Java objects that wouldn't normally be serializable.
- </p>
- <p>
- Swaps are very easy to understand.
- Simply put, they can be thought of as 'object swappers' that swap in serializable objects for
- non-serializable ones during serialization, and vis-versa during parsing.
- </p>
- <p>
- Some examples of non-serializable POJOs are <code>File</code>, <code>Reader</code>,
- <code>Iterable</code>, etc...
- These are classes that aren't beans and cannot be represented as simple maps, collections, or primitives.
- </p>
- <p>
- In the following example, we introduce a <code>PojoSwap</code> that will swap in ISO8601 strings for
- <code>Date</code> objects:
- </p>
- <p class='bcode'>
- <jc>// Sample swap for converting Dates to ISO8601 strings.</jc>
- <jk>public class</jk> MyDateSwap <jk>extends</jk> PojoSwap<Date,String> {
-
- <jc>// ISO8601 formatter.</jc>
- <jk>private</jk> DateFormat <jf>format</jf> = <jk>new</jk> SimpleDateFormat(<js>"yyyy-MM-dd'T'HH:mm:ssZ"</js>);
-
- <jd>/** Converts a Date object to an ISO8601 string. */</jd>
- <ja>@Override</ja>
- <jk>public</jk> String swap(BeanSession session, Date o) {
- <jk>return</jk> <jf>format</jf>.format(o);
- }
-
- <jd>/** Converts an ISO8601 string to a Date object. */</jd>
- <ja>@Override</ja>
- <jk>public</jk> Date unswap(BeanSession session, String o, ClassMeta hint) <jk>throws</jk> ParseException {
- <jk>try</jk> {
- <jk>return</jk> <jf>format</jf>.parse(o);
- } <jk>catch</jk> (java.text.ParseException e) {
- <jk>throw new</jk> ParseException(e);
- }
- }
- }
- </p>
- <p>
- The swap can then be associated with serializers and parsers like so:
- </p>
- <p class='bcode'>
- <jc>// Sample bean with a Date field.</jc>
- <jk>public class</jk> MyBean {
- <jk>public</jk> Date <jf>date</jf> = <jk>new</jk> Date(112, 2, 3, 4, 5, 6);
- }
-
- <jc>// Create a new JSON serializer, associate our date swap with it, and serialize a sample bean.</jc>
- Serializer serializer = <jk>new</jk> JsonSerializerBuilder().pojoSwaps(MyDateSwap.<jk>class</jk>).build();
- String json = serializer.serialize(<jk>new</jk> MyBean()); <jc>// == "{date:'2012-03-03T04:05:06-0500'}"</jc>
-
- <jc>// Create a JSON parser, associate our date swap with it, and reconstruct our bean (including the date).</jc>
- ReaderParser parser = <jk>new</jk> JsonParserBuilder().pojoSwaps(MyDateSwap.<jk>class</jk>).build();
- MyBean bean = parser.parse(json, MyBean.<jk>class</jk>);
- <jk>int</jk> day = bean.<jf>date</jf>.getDay(); <jc>// == 3</jc>
- </p>
- <p>
- Several <code>PojoSwaps</code> are already provided for common Java objects:
- </p>
- <ul class='doctree'>
- <li class='jp'>
- <a class='doclink' href='org/apache/juneau/transforms/package-summary.html#TOC'>org.apache.juneau.transforms</a>
- <ul>
- <li class='jc'>
- {@link org.apache.juneau.transforms.ByteArrayBase64Swap}
- <li class='jac'>
- {@link org.apache.juneau.transforms.CalendarSwap}
- <li class='jac'>
- {@link org.apache.juneau.transforms.DateSwap}
- <li class='jc'>
- {@link org.apache.juneau.transforms.EnumerationSwap}
- <li class='jc'>
- {@link org.apache.juneau.transforms.IteratorSwap}
- <li class='jc'>
- {@link org.apache.juneau.transforms.ReaderSwap}
- <li class='jc'>
- {@link org.apache.juneau.transforms.XMLGregorianCalendarSwap}
- </ul>
- </li>
- </ul>
- <p>
- In particular, the {@link org.apache.juneau.transforms.CalendarSwap} and
- {@link org.apache.juneau.transforms.DateSwap} transforms provide a large number of customized swaps to
- ISO, RFC, or localized strings.
- </p>
- <ul class='doctree'>
- <li class='info'>
- The 'swapped' class type must be a serializable type.
- <br>See the definition for Category 4 objects in <a class='doclink'
- href='#Core.PojoCategories'>POJO Categories</a>.
- </ul>
- </div>
-
- <!-- ======================================================================================================== -->
- <a id="Core.SwapMethods"></a>
- <h4 class='topic' onclick='toggle(this)'>2.6.2 - Swap methods</h4>
- <div class='topic'>
- <p>
- Various methods can be defined on a class directly to affect how it gets serialized.
- This can often be simpler than using <code>PojoSwaps</code>.
- </p>
- <p>
- Objects serialized as <code>Strings</code> can be parsed back into their original objects by
- implementing one of the following methods on the class:
- </p>
- <ul class='spaced-list'>
- <li>
- <code><jk>public static</jk> T fromString(String)</code> method.
- <br>Any of the following method names also work:
- <ul>
- <li><code>valueOf(String)</code>
- <li><code>parse(String)</code>
- <li><code>parseString(String)</code>
- <li><code>forName(String)</code>
- <li><code>forString(String)</code>
- </ul>
- <li>
- <code><jk>public</jk> T(String)</code> constructor.
- </ul>
- <p>
- Note that these methods cover conversion from several built-in Java types, meaning the parsers can
- automatically construct these objects from strings:
- </p>
- <ul>
- <li><code>fromString(String)</code> - {@link java.util.UUID}
- <li><code>valueOf(String)</code> - {@link java.lang.Boolean}, {@link java.lang.Byte},
- {@link java.lang.Double}, {@link java.lang.Float},
- {@link java.lang.Integer}, {@link java.lang.Long}, {@link java.lang.Short}, {@link java.sql.Date},
- {@link java.sql.Time}, {@link java.sql.Timestamp}
- <li><code>parse(String)</code> - {@link java.text.DateFormat}, {@link java.text.MessageFormat},
- {@link java.text.NumberFormat}, {@link java.util.Date}, {@link java.util.logging.Level}
- <li><code>parseString(String)</code> - {@link javax.xml.bind.DatatypeConverter}
- <li><code>forName(String)</code> - {@link java.lang.Class}
- </ul>
- <p>
- If you want to force a bean-like class to be serialized as a string, you can use the
- {@link org.apache.juneau.annotation.BeanIgnore @BeanIgnore} annotation on the class to force it to be
- serialized to a string using the <code>toString()</code> method.
- </p>
- <p>
- Serializing to other intermediate objects can be accomplished by defining a swap method directly on the
- class:
- </p>
- <ul>
- <li><code><jk>public</jk> X swap(BeanSession)</code> method, where <code>X</code> is any serializable
- object.
- </ul>
- <p>
- The <code>BeanSession</code> parameter allows you access to various information about the current
- serialization session.
- For example, you could provide customized results based on the media type being produced
- ({@link org.apache.juneau.BeanSession#getMediaType()}).
- </p>
- <p>
- The following example shows how an HTML5 form template object can be created that gets serialized as a
- populated HTML5 {@link org.apache.juneau.dto.html5.Form} bean.
- </p>
- <p class='bcode'>
- <jk>import static</jk> org.apache.juneau.dto.html5.HtmlBuilder.*;
-
- <jd>/**
- * A simple HTML form template whose serialized form is an HTML5 Form object.
- */</jd>
- <jk>public class</jk> FormTemplate {
-
- <jk>private</jk> String <jf>action</jf>;
- <jk>private int</jk> <jf>value1</jf>;
- <jk>private boolean</jk> <jf>value2</jf>;
-
- <jc>// Some constructor that initializes our fields. </jc>
- <jk>public</jk> FormTemplate(String action, <jk>int</jk> value1, <jk>boolean</jk> value2) {
- <jk>this</jk>.<jf>action</jf> = action;
- <jk>this</jk>.<jf>value1</jf> = value1;
- <jk>this</jk>.<jf>value2</jf> = value2;
- }
-
- <jc>// Special swap method that converts this template to a serializable bean</jc>
- <jk>public</jk> Form swap(BeanSession session) {
- <jk>return</jk> <jsm>form</jsm>(<jf>action</jf>,
- <jsm>input</jsm>(<js>"text"</js>).name(<js>"v1"</js>).value(<jf>value1</jf>),
- <jsm>input</jsm>(<js>"text"</js>).name(<js>"v2"</js>).value(<jf>value2</jf>)
- );
- }
- }
- </p>
- <p>
- Swapped objects can be converted back into their original form by the parsers by specifying one of the
- following methods:
- </p>
- <ul>
- <li><code><jk>public static</jk> T unswap(BeanSession, X)</code> method where <code>X</code> is the
- swap class type.
- <li><code><jk>public</jk> T(X)</code> constructor where <code>X</code> is the swap class type.
- </ul>
- <p>
- The following shows how our form template class can be modified to allow the parsers to reconstruct our
- original object:
- </p>
- <p class='bcode'>
- <jk>import static</jk> org.apache.juneau.dto.html5.HtmlBuilder.*;
-
- <jd>/**
- * A simple HTML form template whose serialized form is an HTML5 Form object.
- * This time with parsing support.
- */</jd>
- <ja>@Bean</ja>(beanDictionary=HtmlBeanDictionary.<jk>class</jk>)
- <jk>public class</jk> FormTemplate {
-
- <jk>private</jk> String <jf>action</jf>;
- <jk>private int</jk> <jf>value1</jf>;
- <jk>private boolean</jk> <jf>value2</jf>;
-
- <jc>// Our 'unswap' constructor</jc>
- <jk>public</jk> FormTemplate(Form f) {
- <jk>this</jk>.<jf>action</jf> = f.getAttr(<js>"action"</js>);
- <jk>this</jk>.<jf>value1</jf> = f.getChild(Input.<jk>class</jk>, 0)
- .getAttr(<jk>int</jk>.<jk>class</jk>, <js>"value"</js>);
- <jk>this</jk>.<jf>value2</jf> = f.getChild(Input.<jk>class</jk>, 1)
- .getAttr(<jk>boolean</jk>.<jk>class</jk>, <js>"value"</js>);
- }
-
- <jk>public</jk> FormTemplate(String action, <jk>int</jk> value1, <jk>boolean</jk> value2) {
- <jk>this</jk>.<jf>action</jf> = action;
- <jk>this</jk>.<jf>value1</jf> = value1;
- <jk>this</jk>.<jf>value2</jf> = value2;
- }
-
- <jk>public</jk> Form swap(BeanSession session) {
- <jk>return</jk> <jsm>form</jsm>(<jf>action</jf>,
- <jsm>input</jsm>(<js>"text"</js>).name(<js>"v1"</js>).value(<jf>value1</jf>),
- <jsm>input</jsm>(<js>"text"</js>).name(<js>"v2"</js>).value(<jf>value2</jf>)
- );
- }
- }
- </div>
-
- <!-- ======================================================================================================== -->
- <a id="Core.BeanFilters"></a>
- <h4 class='topic' onclick='toggle(this)'>2.6.3 - BeanFilters and @Bean annotations</h4>
- <div class='topic'>
- <p>
- {@link org.apache.juneau.transform.BeanFilter BeanFilters} are used to control aspects of how beans are
- handled during serialization and parsing.
- They allow you to control various aspects of beans, such as...
- </p>
- <ul>
- <li>Which properties to include or exclude.
- <li>Property order.
- <li>Property naming conventions.
- <li>Overriding reading and writing of properties.
- </ul>
- <p>
- In practice, however, it's simpler to use the {@link org.apache.juneau.annotation.Bean @Bean} and
- {@link org.apache.juneau.annotation.BeanProperty @BeanProperty} annotations on your bean classes.
- The annotations are functionally equivalent to the bean filter class.
- </p>
- <p class='bcode'>
- <jc>// Address class with only street/city/state properties (in that order).</jc>
- <jc>// All other properties are ignored.</jc>
- <ja>@Bean</ja>(properties=<js>"street,city,state"</js>)
- <jk>public class</jk> Address {
- ...
- </p>
- <p>
- Bean filters are defined through {@link org.apache.juneau.transform.BeanFilterBuilder BeanFilterBuilders}.
- The programmatic equivalent to the the annotation above would be:
- </p>
- <p class='bcode'>
- <jk>public class</jk> MyAddressBeanFilter <jk>extends</jk> BeanFilterBuilder {
-
- <jc>// Must provide a no-arg constructor!</jc>
- <jk>public</jk> MyAddressBeanFilter() {
- <jk>super</jk>(Address.<jk>class</jk>); <jc>// The bean class that this filter applies to.</jc>
- setIncludeProperties(<js>"street,city,state"</js>); <jc>// The properties we want exposed.</jc>
- }
- }
- </p>
- <p>
- Bean filters are added to serializers and parsers using the <code>*BeanFilters(Class...)</code> methods.
- For example:
- </p>
- <p class='bcode'>
- <jc>// Create a new JSON serializer and associate a bean filter with it.</jc>
- Serializer serializer = <jk>new</jk> JsonSerializerBuilder().beanFilters(MyAddressBeanFilter.<jk>class</jk>).build();
- </p>
- <p>
- Note that if you use the annotation, you do NOT need to set anything on the serializers/parsers.
- The annotations will be detected and bean filters will automatically be created for them.
- </p>
- <p>
- The <code>addBeanFilter(Class...)</code> method also allows you to pass in interfaces.
- Any class that's not a subclass of {@link org.apache.juneau.transform.BeanFilterBuilder} get interpreted
- as bean interface classes.
- These cause bean implementations of those interfaces to only expose the properties defined on the
- interface.
- </p>
- <p class='bcode'>
- <jc>// An interface with the 3 properties we want serialized.</jc>
- <jk>public interface</jk> AddressInterface {
- <jk>public</jk> String getStreet();
- <jk>public</jk> String getCity();
- <jk>public</jk> String getState();
- }
-
- <jc>// Our bean implementation.</jc>
- <jk>public class</jk> Address <jk>implements</jk> AddressInterface {
- ...
- }
-
- <jc>// Create a new JSON serializer that only exposes street,city,state on Address bean.</jc>
- Serializer serializer = <jk>new</jk> JsonSerializerBuilder().beanFilters(AddressInterface.<jk>class</jk>).build();
- </p>
-
- <h6 class='topic'>Additional Information</h6>
- <ul class='doctree'>
- <li class='jp'>
- <a class='doclink' href='org/apache/juneau/transform/package-summary.html#TOC'>org.apache.juneau.transform</a>
- </ul>
- </div>
-
- </div>
-
- <!-- ======================================================================================================== -->
- <a id="Core.BeanDictionaries"></a>
- <h3 class='topic' onclick='toggle(this)'>2.7 - Bean Names and Dictionaries</h3>
- <div class='topic'>
- <p>
- While parsing into beans, Juneau attempts to determine the class types of bean properties through
- reflection on the bean property getter or setter.
- Often this is insufficient if the property type is an interface or abstract class that cannot be
- instantiated.
- This is where bean names and dictionaries come into play.
- </p>
- <p>
- Bean names and dictionary are used for identifying class types when they cannot be inferred through
- reflection.
- </p>
- <p>
- Bean classes are given names through the {@link org.apache.juneau.annotation.Bean#typeName() @Bean.typeName()}
- annotation.
- These names are then added to the serialized output as virtual <js>"_type"</js> properties (or element
- names in XML).
- </p>
- <p>
- On the parsing side, these type names are resolved to classes through the use of bean dictionaries.
- </p>
- <p>
- For example, if a bean property is of type <code>Object</code>, then the serializer will add
- <js>"_type"</js> attributes so that the class can be determined during parsing.
- </p>
- <p class='bcode'>
- <ja>@Bean</ja>(typeName=<js>"foo"</js>)
- <jk>public class</jk> Foo {
- <jc>// A bean property where the object types cannot be inferred since it's an Object[].</jc>
- <ja>@BeanProperty</ja>(typeDictionary={Bar.<jk>class</jk>,Baz.<jk>class</jk>})
- <jk>public</jk> Object[] x = <jk>new</jk> Object[]{<jk>new</jk> Bar(), <jk>new</jk> Baz()};
- }
-
- <ja>@Bean</ja>(typeName=<js>"bar"</js>)
- <jk>public class</jk> Bar {}
-
- <ja>@Bean</ja>(typeName=<js>"baz"</js>)
- <jk>public class</jk> Baz {}
- </p>
- <p>
- When serialized as JSON, <js>"_type"</js> attributes would be added when needed to infer the type during
- parsing:
- </p>
- <p class='bcode'>
- {
- x: [
- {_type:<js>'bar'</js>},
- {_type:<js>'baz'</js>}
- ]
- }
- </p>
- <p>
- Type names can be represented slightly differently in different languages.
- For example, the dictionary name is used as element names when serialized to XML.
- This allows the <code>typeName</code> annotation to be used as a shortcut for defining element names for
- beans.
- </p>
- <p>
- When serialized as XML, the bean is rendered as:
- </p>
- <p class='bcode'>
- <xt><foo></xt>
- <xt><x></xt>
- <xt><bar/></xt>
- <xt><baz/></xt>
- <xt></x></xt>
- <xt></foo></xt>
- </p>
- <p>
- Bean dictionaries are defined at two levels:
- </p>
- <ul>
- <li>On individual bean properties through the
- {@link org.apache.juneau.annotation.BeanProperty#beanDictionary() @BeanProperty.beanDictionary()}
- annotation.
- <li>Globally for a parser using the {@link org.apache.juneau.parser.ParserBuilder#beanDictionary(Class...)}
- method.
- </ul>
- <ul class='doctree'>
- <li class='info'>
- Type names do not need to be universally unique.
- However, they must be unique within a dictionary.
- <li class='info'>
- The following reserved words cannot be used as type names:
- <code>object, array, number, boolean, null</code>.
- <li class='info'>
- Serialized type names are DISABLED by default.
- They must be enabled on the serializer using the
- {@link org.apache.juneau.serializer.SerializerContext#SERIALIZER_addBeanTypeProperties}
- configuration property.
- <li class='info'>
- The <js>"_type"</js> property name can be overridden using the
- {@link org.apache.juneau.BeanContext#BEAN_beanTypePropertyName} configuration property.
- </ul>
-
- <!-- ======================================================================================================== -->
- <a id="Core.BeanSubTypes"></a>
- <h4 class='topic' onclick='toggle(this)'>2.7.1 - Bean Subtypes</h4>
- <div class='topic'>
- <p>
- In addition to the bean type name support described above, simplified support is provided
- for bean subtypes.
- </p>
- <p>
- Bean subtypes are similar in concept to bean type names, except for the following differences:
- </p>
- <ul>
- <li>You specify the list of possible subclasses through an annotation on a parent bean class.
- <li>You do not need to register the subtype classes on the bean dictionary of the parser.
- </ul>
- <p>
- In the following example, the abstract class has two subclasses:
- </p>
- <p class='bcode'>
- <jc>// Abstract superclass</jc>
- <ja>@Bean</ja>(
- beanDictionary={A1.<jk>class</jk>, A2.<jk>class</jk>}
- )
- <jk>public abstract class</jk> A {
- <jk>public</jk> String <jf>f0</jf> = <js>"f0"</js>;
- }
-
- <jc>// Subclass 1</jc>
- <ja>@Bean</ja>(typeName=<js>"A1"</js>)
- <jk>public class</jk> A1 <jk>extends</jk> A {
- <jk>public</jk> String <jf>f1</jf>;
- }
-
- <jc>// Subclass 2</jc>
- <ja>@Bean</ja>(typeName=<js>"A2"</js>)
- <jk>public class</jk> A2 <jk>extends</jk> A {
- <jk>public</jk> String <jf>f2</jf>;
- }
- </p>
- <p>
- When serialized, the subtype is serialized as a virtual <js>"_type"</js> property:
- </p>
- <p class='bcode'>
- JsonSerializer s = JsonSerializer.<jsf>DEFAULT_LAX</jsf>;
- A1 a1 = <jk>new</jk> A1();
- a1.<jf>f1</jf> = <js>"f1"</js>;
- String r = s.serialize(a1);
- <jsm>assertEquals</jsm>(<js>"{_type:'A1',f1:'f1',f0:'f0'}"</js>, r);
- </p>
- <p>
- The following shows what happens when parsing back into the original object.
- </p>
- <p class='bcode'>
- JsonParser p = JsonParser.<jsf>DEFAULT</jsf>;
- A a = p.parse(r, A.<jk>class</jk>);
- <jsm>assertTrue</jsm>(a <jk>instanceof</jk> A1);
- </p>
- </div>
- </div>
-
- <!-- ======================================================================================================== -->
- <a id="Core.VirtualBeans"></a>
- <h3 class='topic' onclick='toggle(this)'>2.8 - Virtual Beans</h3>
- <div class='topic'>
- <p>
- The {@link org.apache.juneau.BeanContext#BEAN_useInterfaceProxies} 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.9 - POJO Categories</h3>
- <div class='topic'>
- <p>
- The following chart shows POJOs categorized into groups and whether they can be serialized or parsed:
- </p>
- <table class='styled' style='border-collapse: collapse;'>
- <tr><th>Group</th><th>Description</th><th>Examples</th><th>Can<br>serialize?</th><th>Can<br>parse?</th></tr>
- <tr class='dark bb' style='background-color:lightyellow;'>
- <td style='text-align:center'>1</td>
- <td><b>Java primitive objects</b></td>
- <td>
- <ul class='normal'>
- <li>{@code String}
- <li>{@code Integer}
- <li>{@code Float}
- <li>{@code Boolean}
- </ul>
- </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'>2</td>
- <td><b>Java Collections Framework objects and Java arrays</b></td>
- <td> </td>
- <td> </td>
- <td> </td>
- </tr>
- <tr class='light bb'>
- <td style='text-align:center'>2a</td>
- <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, 3ac, 4a, 5a] objects.
- </td>
- <td>
- <ul class='normal'>
- <li><code>HashSet<String,Integer></code>
- <li><code>TreeMap<Integer,Bean></code>
- <li><code>List<<jk>int</jk>[][]></code>
- <li><code>Bean[]</code>
- </ul>
- </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='light bb'>
- <td style='text-align:center'>2b</td>
- <td>
- <b>With non-standard keys/values</b>
- <br>Map keys are group [2, 3, 4b, 5b, 6] objects.
- <br>Map, Collection, and array values are group [3b, 4b, 5b, 6] objects.
- </td>
- <td>
- <ul class='normal'>
- <li><code>HashSet<Bean,Integer></code>
- <li><code>TreeMap<Integer,Reader></code>
- </ul>
- </td>
- <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='dark bb' style='background-color:lightyellow'>
- <td style='text-align:center'>3</td>
- <td><b>Java Beans</b></td>
- <td> </td>
- <td> </td>
- <td> </td>
- </tr>
- <tr class='light bb'>
- <td style='text-align:center'>3a</td>
- <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, 3ac, 4a, 5a] objects.
- </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='light bb'>
- <td style='text-align:center'>3b</td>
- <td>
- <b>With non-standard properties or not true beans</b>
- <br>These include true beans that have no-arg constructors and one or more properties defined by getter
- and setter methods or properties, but property types include group [3b, 4b, 5b, 6] objects.
- <br>This also includes classes that look like beans but aren't true beans.
- For example, classes that have getters but not setters, or classes without no-arg constructors.
- </td>
- <td> </td>
- <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>
- <b>Swapped objects</b>
- <br>These are objects that are not directly serializable, but have
- {@link org.apache.juneau.transform.PojoSwap PojoSwaps} associated with them.
- The purpose of a POJO swap is to convert an object to another object that is easier to serialize
- and parse.
- For example, the {@link org.apache.juneau.transforms.DateSwap.ISO8601DT} class can be used to
- serialize {@link java.util.Date} objects to ISO8601 strings, and parse them back into
- {@link java.util.Date} objects.
- </td>
- <td> </td>
- <td> </td>
- <td> </td>
- </tr>
- <tr class='light bb'>
- <td style='text-align:center'>4a</td>
- <td>
- <b>2-way swapped to group [1, 2a, 3ac] objects</b>
- <br>For example, a swap that converts a {@code Date} to a {@code String}.
- </td>
- <td>
- <ul class='normal'>
- <li><code>java.util.Date</code>
- <li><code>java.util.GregorianCalendar</code>
- </ul>
- </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='light bb'>
- <td style='text-align:center'>4b</td>
- <td>
- <b>1-way swapped to group [1, 2, 3] objects</b>
- <br>For example, a swap that converts an {@code Iterator} to a {@code List}.
- This would be one way, since you cannot reconstruct an {@code Iterator}.
- </td>
- <td>
- <ul class='normal'>
- <li><code>java.util.Iterator</code>
- </ul>
- </td>
- <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='dark bb' style='background-color:lightyellow'>
- <td style='text-align:center'>5</td>
- <td>
- <b>Non-serializable objects with standard methods for converting to a serializable form</b><br>
- </td>
- <td> </td>
- <td> </td>
- <td> </td>
- </tr>
- <tr class='light bb' style='background-color:lightyellow'>
- <td style='text-align:center'>5a</td>
- <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, 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:
- <ul>
- <li><code><jk>public static</jk> T fromString(String);</code>
- <li><code><jk>public static</jk> T valueOf(String);</code>
- <li><code><jk>public static</jk> T parse(String);</code>
- <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, 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>
- <ul class='normal'>
- <li><code>java.lang.Class</code>
- <li><code>java.sql.Time</code>
- <li><code>java.sql.Timestamp</code>
- <li><code>java.text.MessageFormat</code>
- <li><code>java.text.NumberFormat</code>
- <li><code>java.util.Date</code>
- <li><code>java.util.UUID</code>
- <li><code>java.util.logging.Level</code>
- <li><code>javax.xml.bind.DatatypeConverter</code>
- </ul>
- </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='light bb' style='background-color:lightyellow'>
- <td style='text-align:center'>5b</td>
- <td>
- Classes that only have a method to convert to a serializable form:
- <ul>
- <li><code><jk>public</jk> X swap(BeanSession);</code> where <code>X</code> is in groups
- [1, 2, 3].
- <li><code><jk>public</jk> String toString();</code> where the string is any meaningful data.
- </ul>
- </td>
- <td> </td>
- <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='dark' style='background-color:lightyellow'>
- <td style='text-align:center'>6</td>
- <td>
- <b>All other objects</b>
- <br>Anything that doesn't fall into one of the groups above are simply converted to {@code Strings}
- using the {@code toString()} method.
- </td>
- <td> </td>
- <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>
- </table>
- <ul class='doctree'>
- <li class='info'>
- Serializers are designed to work on tree-shaped POJO models.
- These are models where there are no referential loops (e.g. leaves with references to nodes, or nodes
- in one branch referencing nodes in another branch).
- There is a serializer setting {@code detectRecursions} to look for and handle these kinds of loops
- (by setting these references to <jk>null</jk>), but it is not enabled by default since it introduces
- a moderate performance penalty.
- </ul>
- </div>
-
- <!-- ======================================================================================================== -->
- <a id="Core.SVL"></a>
- <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".
- In a nutshell, Simple Variable Language (or SVL) is text that contains variables of the form
- <js>"$varName{varKey}"</js>.
- </p>
- <p>
- Variables can be recursively nested within the varKey (e.g. <js>"$FOO{$BAR{xxx},$BAZ{xxx}}"</js>).
- Variables can also return values that themselves contain more variables.
- </p>
- <p class='bcode'>
- <jc>// Use the default variable resolver to resolve a string that contains $S (system property) variables</jc>
- String myProperty = VarResolver.<jsf>DEFAULT</jsf>.resolve(<js>"The Java home directory is $S{java.home}"</js>);
- </p>
- <p>
- The following shows how variables can be arbitrarily nested...
- </p>
- <p class='bcode'>
- <jc>// Look up a property in the following order:
- // 1) MYPROPERTY environment variable.
- // 2) 'my.property' system property if environment variable not found.
- // 3) 'not found' string if system property not found.</jc>
- String myproperty = VarResolver.<jsf>DEFAULT</jsf>.resolve(<js>"$E{MYPROPERTY,$S{my.property,not found}}"</js>);
- </p>
- <p>
- SVL is a large topic on it's own.
- It is used extensively in the ConfigFile, REST and Microservice APIs.
- </p>
-
- <h6 class='topic'>Additional Information</h6>
- <ul class='doctree'>
- <li class='jp'>
- <a class='doclink' href='org/apache/juneau/svl/package-summary.html#TOC'>org.apache.juneau.svl</a>
- - Simple Variable Language Javadocs.
- </ul>
- </div>
-
- <!-- ======================================================================================================== -->
- <a id="Core.ConfigFile"></a>
- <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.
- </p>
- <p>
- An example of an INI file:
- </p>
- <p class='bcode'>
- <cc># Default section</cc>
- <ck>key1</ck> = <cv>1</cv>
- <ck>key2</ck> = <cv>true</cv>
- <ck>key3</ck> = <cv>[1,2,3]</cv>
- <ck>key4</ck> = <cv>http://foo</cv>
-
- <cc># Section 1</cc>
- <cs>[Section1]</cs>
- <ck>key1</ck> = <cv>2</cv>
- <ck>key2</ck> = <cv>false</cv>
- <ck>key3</ck> = <cv>[4,5,6]</cv>
- <ck>key4</ck> = <cv>http://bar</cv>
- </p>
- <p>
- This class can be used to easily access contents of the file:
- </p>
- <p class='bcode'>
- <jk>int</jk> key1;
- <jk>boolean</jk> key2;
- <jk>int</jk>[] key3;
- URL key4;
-
- <jc>// Load our config file</jc>
- ConfigFile f = <jk>new</jk> ConfigFileBuilder().build(<js>"MyConfig.cfg"</js>);
-
- <jc>// Read values from default section</jc>
- key1 = f.getInt(<js>"key1"</js>);
- key2 = f.getBoolean(<js>"key2"</js>);
- key3 = f.getObject(<jk>int</jk>[].<jk>class</jk>, <js>"key3"</js>);
- key4 = f.getObject(URL.<jk>class</jk>, <js>"key4"</js>);
-
- <jc>// Read values from section #1</jc>
- key1 = f.getInt(<js>"Section1/key1"</js>);
- key2 = f.getBoolean(<js>"Section1/key2"</js>);
- key3 = f.getObject(<jk>int</jk>[].<jk>class</jk>, <js>"Section1/key3"</js>);
- key4 = f.getObject(URL.<jk>class</jk>, <js>"Section1/key4"</js>);
- </p>
- <p>
- The interface also allows a config file to be easily constructed programmatically:
- </p>
- <p class='bcode'>
- <jc>// Construct the sample INI file programmatically</jc>
- ConfigFile cf = <jk>new</jk> ConfigFileBuilder().build(<js>"MyConfig.cfg"</js>)
- .addLines(<jk>null</jk>,
- <js>"# Default section"</js>,
- <js>"key1 = 1"</js>,
- <js>"key2 = true"</js>,
- <js>"key3 = [1,2,3]"</js>,
- <js>"key4 = http://foo"</js>,
- <js>""</js>)
- .addHeaderComments(<js>"Section1"</js>,
- <js>"# Section 1"</js>)
- .addLines(<js>"Section1"</js>,
- <js>"key1 = 2"</js>,
- <js>"key2 = false"</js>,
- <js>"key3 = [4,5,6]"</js>,
- <js>"key4 = http://bar"</js>)
- .save();
- </p>
- <p>
- The following is equivalent, except that it uses {@link org.apache.juneau.ini.ConfigFile#put(String, Object)}
- to set values:
- </p>
- <p class='bcode'>
- <jc>// Construct the sample INI file programmatically</jc>
- ConfigFile cf = <jk>new</jk> ConfigFileBuilder().build(<js>"MyConfig.cfg"</js>)
- .addLines(<jk>null</jk>,
- <js>"# Default section"</js>)
- .addHeaderComments(<js>"section1"</js>,
- <js>"# Section 1"</js>);
- cf.put(<js>"key1"</js>, 1);
- cf.put(<js>"key2"</js>, <jk>true</jk>);
- cf.put(<js>"key3"</js>, <jk>new int</jk>[]{1,2,3});
- cf.put(<js>"key4"</js>, <jk>new</jk> URL(<js>"http://foo"</js>));
- cf.put(<js>"Section1/key1"</js>, 2);
- cf.put(<js>"Section1/key2"</js>, <jk>false</jk>);
- cf.put(<js>"Section1/key3"</js>, <jk>new int</jk>[]{4,5,6});
- cf.put(<js>"Section1/key4"</js>, <jk>new</jk> URL(<js>"http://bar"</js>));
- cf.save();
- </p>
- <p>
- Values are LAX JSON (i.e. unquoted attributes, single quotes) except for top-level strings which are left
- unquoted.
- Any parsable object types are supported as values (e.g. arrays, collections, beans, swappable objects,
- enums, etc...).
- </p>
- <p>
- The config file looks deceptively simple, the config file API is a very powerful feature with many
- capabilities, including:
- </p>
- <ul class='spaced-list'>
- <li>
- The ability to use variables to reference environment variables, system properties, other config file
- entries, and a host of other types.
- <li>
- APIs for updating, modifying, and saving configuration files without losing comments or formatting.
- <li>
- Extensive listener APIs.
- </ul>
-
- <h6 class='topic'>Example:</h6>
- <p class='bcode'>
- <cc>#--------------------------</cc>
- <cc># My section</cc>
- <cc>#--------------------------</cc>
- <cs>[MySection]</cs>
-
- <cc># An integer</cc>
- <ck>anInt</ck> = <cv>1</cv>
-
- <cc># A boolean</cc>
- <ck>aBoolean</ck> = <cv>true</cv>
-
- <cc># An int array</cc>
- <ck>anIntArray</ck> = <cv>[1,2,3]</cv>
-
- <cc># A POJO that can be converted from a String</cc>
- <ck>aURL</ck> = <cv>http://foo </cv>
-
- <cc># A POJO that can be converted from JSON</cc>
- <ck>aBean</ck> = <cv>{foo:'bar',baz:123}</cv>
-
- <cc># A system property</cc>
- <ck>locale</ck> = <cv>$S{java.locale, en_US}</cv>
-
- <cc># An environment variable</cc>
- <ck>path</ck> = <cv>$E{PATH, unknown}</cv>
-
- <cc># A manifest file entry</cc>
- <ck>mainClass</ck> = <cv>$MF{Main-Class}</cv>
-
- <cc># Another value in this config file</cc>
- <ck>sameAsAnInt</ck> = <cv>$C{MySection/anInt}</cv>
-
- <cc># A command-line argument in the form "myarg=foo"</cc>
- <ck>myArg</ck> = <cv>$ARG{myarg}</cv>
-
- <cc># The first command-line argument</cc>
- <ck>firstArg</ck> = <cv>$ARG{0}</cv>
-
- <cc># Look for system property, or env var if that doesn't exist, or command-line arg if that doesn't exist.</cc>
- <ck>nested</ck> = <cv>$S{mySystemProperty,$E{MY_ENV_VAR,$ARG{0}}}</cv>
-
- <cc># A POJO with embedded variables</cc>
- <ck>aBean2</ck> = <cv>{foo:'$ARG{0}',baz:$C{MySection/anInt}}</cv>
-
- </p>
- <p class='bcode'>
- <jc>// Java code for accessing config entries above.</jc>
- ConfigFile cf = Microservice.<jsm>getConfig</jsm>();
-
- <jk>int</jk> anInt = cf.getInt(<js>"MySection/anInt"</js>);
- <jk>boolean</jk> aBoolean = cf.getBoolean(<js>"MySection/aBoolean"</js>);
- <jk>int</jk>[] anIntArray = cf.getObject(<jk>int</jk>[].<jk>class</jk>, <js>"MySection/anIntArray"</js>);
- URL aURL = cf.getObject(URL.<jk>class</jk>, <js>"MySection/aURL"</js>);
- MyBean aBean = cf.getObject(MyBean.<jk>class</jk>, <js>"MySection/aBean"</js>);
- Locale locale = cf.getObject(Locale.<jk>class</jk>, <js>"MySection/locale"</js>);
- String path = cf.getString(<js>"MySection/path"</js>);
- String mainClass = cf.getString(<js>"MySection/mainClass"</js>);
- <jk>int</jk> sameAsAnInt = cf.getInt(<js>"MySection/sameAsAnInt"</js>);
- String myArg = cf.getString(<js>"MySection/myArg"</js>);
- String firstArg = cf.getString(<js>"MySection/firstArg"</js>);
- </p>
- <p>
- Config files can also be used to directly populate beans using the
- {@link org.apache.juneau.ini.ConfigFile#getSectionAsBean(String,Class,boolean)}:
- </p>
- <p class='bcode'>
- <jc>// Example config file</jc>
- <cs>[MyAddress]</cs>
- <ck>name</ck> = <cv>John Smith</cv>
- <ck>street</ck> = <cv>123 Main Street</cv>
- <ck>city</ck> = <cv>Anywhere</cv>
- <ck>state</ck> = <cv>NY</cv>
- <ck>zip</ck> = <cv>12345</cv>
-
- <jc>// Example bean</jc>
- <jk>public class</jk> Address {
- public String name, street, city;
- public StateEnum state;
- public int zip;
- }
-
- <jc>// Example usage</jc>
- ConfigFile cf = <jk>new</jk> ConfigFileBuilder().build(<js>"MyConfig.cfg"</js>);
- Address myAddress = cf.getSectionAsBean(<js>"MySection"</js>, Address.<jk>class</jk>);
- </p>
- <p>
- Config file sections can also be accessed via interface proxies using
- {@link org.apache.juneau.ini.ConfigFile#getSectionAsInterface(String,Class)}:
- </p>
- <p class='bcode'>
- <jc>// Example config file</jc>
- <cs>[MySection]</cs>
- <ck>string</ck> = <cv>foo</cv>
- <ck>int</ck> = <cv>123</cv>
- <ck>enum</ck> = <cv>ONE</cv>
- <ck>bean</ck> = <cv>{foo:'bar',baz:123}</cv>
- <ck>int3dArray</ck> = <cv>[[[123,null],null],null]</cv>
- <ck>bean1d3dListMap</ck> = <cv>{key:[[[[{foo:'bar',baz:123}]]]]}</cv>
-
- <jc>// Example interface</jc>
- <jk>public interface</jk> MyConfigInterface {
-
- String getString();
- <jk>void</jk> setString(String x);
-
- <jk>int</jk> getInt();
- <jk>void</jk> setInt(<jk>int</jk> x);
-
- MyEnum getEnum();
- <jk>void</jk> setEnum(MyEnum x);
-
- MyBean getBean();
- <jk>void</jk> setBean(MyBean x);
-
- <jk>int</jk>[][][] getInt3dArray();
- <jk>void</jk> setInt3dArray(<jk>int</jk>[][][] x);
-
- Map<String,List<MyBean[][][]>> getBean1d3dListMap();
- <jk>void</jk> setBean1d3dListMap(Map<String,List<MyBean[][][]>> x);
- }
-
- <jc>// Example usage</jc>
- ConfigFile cf = <jk>new</jk> ConfigFileBuilder().build(<js>"MyConfig.cfg"</js>);
- MyConfigInterface ci = cf.getSectionAsInterface(<js>"MySection"</js>, MyConfigInterface.<jk>class</jk>);
- <jk>int</jk> myInt = ci.getInt();
- ci.setBean(<jk>new</jk> MyBean());
- cf.save();
- </p>
-
- <h6 class='topic'>Additional Information</h6>
- <ul class='doctree'>
- <li class='jp'>
- <a class='doclink' href='org/apache/juneau/ini/package-summary.html#TOC'>org.apache.juneau.ini</a>
- - Config API Javadocs.
- </ul>
- </div>
-
- <!-- ======================================================================================================== -->
- <a id="Core.SupportedLanguages"></a>
- <h3 class='topic' onclick='toggle(this)'>2.12 - Supported Languages</h3>
- <div class='topic'>
- <p>
- Extensive javadocs exist for individual language support.
- Refer to these docs for language-specific information.
- </p>
-
- <h6 class='topic'>Additional Information</h6>
- <ul class='doctree'>
- <li class='jp'>
- <a class='doclink' href='org/apache/juneau/html/package-summary.html#TOC'>org.apache.juneau.html</a>
- - HTML support.
- <li class='jp'>
- <a class='doclink' href='org/apache/juneau/jena/package-summary.html#TOC'>org.apache.juneau.jena</a>
- - RDF support.
- <li class='jp'>
- <a class='doclink' href='org/apache/juneau/jso/package-summary.html#TOC'>org.apache.juneau.jso</a>
- - Java Serialized Object support.
- <li class='jp'>
- <a class='doclink' href='org/apache/juneau/json/package-summary.html#TOC'>org.apache.juneau.json</a>
- - JSON support.
- <li class='jp'>
- <a class='doclink' href='org/apache/juneau/msgpack/package-summary.html#TOC'>org.apache.juneau.msgpack</a>
- - MessagePack support.
- <li class='jp'>
- <a class='doclink' href='org/apache/juneau/plaintext/package-summary.html#TOC'>org.apache.juneau.plaintext</a>
- - Plain-text support.
- <li class='jp'>
- <a class='doclink' href='org/apache/juneau/soap/package-summary.html#TOC'>org.apache.juneau.soap</a>
- - SOAP support.
- <li class='jp'>
- <a class='doclink' href='org/apache/juneau/urlencoding/package-summary.html#TOC'>org.apache.juneau.urlencoding</a>
- - URL-Encoding and UON support.
- <li class='jp'>
- <a class='doclink' href='org/apache/juneau/xml/package-summary.html#TOC'>org.apache.juneau.xml</a>
- - XML support.
- <li class='jp'>
- <a class='doclink' href='org/apache/juneau/dto/atom/package-summary.html#TOC'>org.apache.juneau.dto.atom</a>
- - ATOM support.
- <li class='jp'>
- <a class='doclink' href='org/apache/juneau/dto/cognos/package-summary.html#TOC'>org.apache.juneau.dto.cognos</a>
- - Cognos support.
- </ul>
- </div>
-
- <!-- ======================================================================================================== -->
- <a id="Core.JacksonComparison"></a>
- <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.
- Whereas Jackson was created to work primarily with JSON, Juneau was created to work for multiple languages.
- Therefore, the terminology and annotations in Juneau are similar, but language-agnostic.
- </p>
- <p>
- The following charts describe equivalent features between the two libraries:
- </p>
-
- <h6 class='topic'>Annotations</h6>
- <table class='styled'>
- <tr><th>Jackson</th><th>Juneau</th></tr>
- <tr>
- <td>
- <ja>@JsonGetter</ja>
- <br><ja>@JsonSetter</ja>
- </td>
- <td>
- {@link org.apache.juneau.annotation.BeanProperty @BeanProperty}
- </td>
- </tr>
- <tr>
- <td>
- <ja>@JsonAnyGetter</ja>
- <br><ja>@JsonAnySetter</ja>
- </td>
- <td>
- {@link org.apache.juneau.annotation.BeanProperty#name() @BeanProperty(name="*")}
- </td>
- </tr>
- <tr>
- <td>
- <ja>@JsonIgnore</ja>
- <br><ja>@JsonIgnoreType</ja>
- </td>
- <td>
- {@link org.apache.juneau.annotation.BeanIgnore @BeanIgnore}
- </td>
- </tr>
- <tr>
- <td><code><ja>@JsonIgnoreProperties</ja>({...})</code></td>
- <td>
- {@link org.apache.juneau.annotation.Bean#excludeProperties @Bean(excludeProperties="...")}
- </td>
- </tr>
- <tr>
- <td><code><ja>@JsonAutoDetect</ja>(fieldVisibility=...)</code></td>
- <td>
- No equivalent annotation, but can be controlled via:
- <br>{@link org.apache.juneau.BeanContext#BEAN_beanFieldVisibility}
- <br>{@link org.apache.juneau.BeanContext#BEAN_methodVisibility}
- <br>Future annotation support planned.
- </td>
- </tr>
- <tr>
- <td>
- <ja>@JsonCreator</ja>
- <br><ja>@JsonProperty</ja>
- </td>
- <td>
- {@link org.apache.juneau.annotation.BeanConstructor @BeanConstructor}
- </td>
- </tr>
- <tr>
- <td><ja>@JacksonInject</ja></td>
- <td>
- No equivalent.
- <br>Future support planned.
- </td>
-
- </tr>
- <tr>
- <td>
- <ja>@JsonSerialize</ja>
- <br><ja>@JsonDeserialize</ja>
- </td>
- <td>
- Juneau uses swaps to convert non-serializable object to serializable forms:
- <br>{@link org.apache.juneau.annotation.BeanProperty#swap() @BeanProperty(swap=...)}
- <br>{@link org.apache.juneau.annotation.Pojo#swap() @Pojo(swap=...)}
- </td>
- </tr>
- <tr>
- <td><ja>@JsonInclude</ja></td>
- <td>
- No equivalent annotation, but can be controlled via various settings:
- <br>{@link org.apache.juneau.BeanContext}
- <br>{@link org.apache.juneau.serializer.SerializerContext}
- <br>Future annotation support planned.
- </td>
- </tr>
- <tr>
- <td><ja>@JsonPropertyOrder</ja></td>
- <td>
- {@link org.apache.juneau.annotation.Bean#properties @Bean(properties="...")}
- <br>{@link org.apache.juneau.annotation.Bean#sort @Bean(sort=x)}
- </td>
- </tr>
- <tr>
- <td>
- <ja>@JsonValue</ja>
- <br><ja>@JsonRawValue</ja>
- </td>
- <td>
- No equivalents.
- <br>Future support unlikely since these are JSON-centric.
- </td>
- </tr>
- </table>
- </div>
-</div>
-
-<!-- ======================================================================================================== -->
-<a id="DTOs"></a>
-<h2 class='topic' onclick='toggle(this)'>3 - Juneau Data Transfer Objects (org.apache.juneau.dto)</h2>
-<div class='topic'>
- <p>
- The Juneau Core library contains several predefined POJOs for generating commonly-used document types.
- This section describes support for these POJOs.
- </p>
-
- <!-- ======================================================================================================== -->
- <a id="DTOs.HTML5"></a>
- <h3 class='topic' onclick='toggle(this)'>3.1 - HTML5</h3>
- <div class='topic'>
- <p>
- The Juneau HTML5 DTOs are simply beans with fluent-style setters that allow you to quickly construct HTML
- fragments as Java objects. These object can then be serialized to HTML using one of the existing HTML
- serializers, or to other languages such as JSON using the JSON serializers.
- </p>
- <p>
- The {@link org.apache.juneau.dto.html5.HtmlBuilder} class is a utility class with predefined static methods
- that allow you to easily construct DTO instances in a minimal amount of code.
- </p>
- <p>
- The following examples show how to create HTML tables.
- </p>
- <table class='styled' style='width:auto'>
- <tr>
- <th>Java code</th>
- <th>HTML</th>
- </tr>
- <tr>
- <td class='code'>
- <jk>import static</jk> org.apache.juneau.dto.html5.HtmlBuilder.*;
-
- Object mytable =
- <jsm>table</jsm>(
- <jsm>tr</jsm>(
- <jsm>th</jsm>(<js>"c1"</js>),
- <jsm>th</jsm>(<js>"c2"</js>)
- ),
- <jsm>tr</jsm>(
- <jsm>td</jsm>(<js>"v1"</js>),
- <jsm>td</jsm>(<js>"v2"</js>)
- )
- );
-
- String html = HtmlSerializer.<jsf>DEFAULT</jsf>.se
<TRUNCATED>
[6/6] incubator-juneau git commit: Support serializing directly from
Readers and InputStreams.
Posted by ja...@apache.org.
Support serializing directly from Readers and InputStreams.
Project: http://git-wip-us.apache.org/repos/asf/incubator-juneau/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-juneau/commit/b37d99ba
Tree: http://git-wip-us.apache.org/repos/asf/incubator-juneau/tree/b37d99ba
Diff: http://git-wip-us.apache.org/repos/asf/incubator-juneau/diff/b37d99ba
Branch: refs/heads/master
Commit: b37d99bac5ddc63de368d5dbdd98f25347540ce7
Parents: 23fe563
Author: JamesBognar <ja...@apache.org>
Authored: Sun Aug 27 18:22:10 2017 -0400
Committer: JamesBognar <ja...@apache.org>
Committed: Sun Aug 27 18:22:10 2017 -0400
----------------------------------------------------------------------
.../java/org/apache/juneau/jena/RdfParser.java | 23 +-
.../apache/juneau/jena/RdfParserBuilder.java | 2 +-
.../org/apache/juneau/jena/RdfSerializer.java | 41 +-
.../juneau/jena/RdfSerializerBuilder.java | 2 +-
.../juneau/jena/RdfSerializerSession.java | 5 +-
.../test/java/org/apache/juneau/ComboInput.java | 11 +-
.../org/apache/juneau/ComboRoundTripTest.java | 708 +
.../org/apache/juneau/ComboSerializeTest.java | 367 +
.../test/java/org/apache/juneau/ComboTest.java | 708 -
.../org/apache/juneau/DynaBeanComboTest.java | 2 +-
.../apache/juneau/dto/html5/Html5ComboTest.java | 2 +-
.../dto/html5/Html5TemplateComboTest.java | 2 +-
.../apache/juneau/parser/ParserGroupTest.java | 25 +-
.../serializer/ReaderObjectComboTest.java | 439 +
.../juneau/serializer/SerializerGroupTest.java | 34 +-
.../transforms/BeanDictionaryComboTest.java | 2 +-
.../ByteArrayBase64SwapComboTest.java | 2 +-
.../transforms/CalendarSwapComboTest.java | 2 +-
.../juneau/transforms/DateSwapComboTest.java | 2 +-
.../juneau/transforms/ReaderObjectSwapTest.java | 494 +
.../org/apache/juneau/annotation/Consumes.java | 72 -
.../org/apache/juneau/annotation/Produces.java | 85 -
.../java/org/apache/juneau/csv/CsvParser.java | 4 +-
.../org/apache/juneau/csv/CsvSerializer.java | 4 +-
.../apache/juneau/csv/CsvSerializerSession.java | 1 -
.../apache/juneau/html/HtmlDocSerializer.java | 29 +-
.../java/org/apache/juneau/html/HtmlParser.java | 4 +-
.../juneau/html/HtmlSchemaDocSerializer.java | 32 +-
.../org/apache/juneau/html/HtmlSerializer.java | 32 +-
.../juneau/html/HtmlSerializerSession.java | 11 +-
.../juneau/html/HtmlStrippedDocSerializer.java | 29 +-
.../java/org/apache/juneau/http/MediaType.java | 32 +-
.../org/apache/juneau/internal/IOUtils.java | 99 +-
.../java/org/apache/juneau/jso/JsoParser.java | 4 +-
.../org/apache/juneau/jso/JsoSerializer.java | 4 +-
.../apache/juneau/jso/JsoSerializerSession.java | 3 +-
.../java/org/apache/juneau/json/JsonParser.java | 14 +-
.../juneau/json/JsonSchemaSerializer.java | 8 +-
.../json/JsonSchemaSerializerSession.java | 1 -
.../org/apache/juneau/json/JsonSerializer.java | 39 +-
.../juneau/json/JsonSerializerSession.java | 5 +-
.../apache/juneau/msgpack/MsgPackParser.java | 6 +-
.../juneau/msgpack/MsgPackSerializer.java | 4 +-
.../msgpack/MsgPackSerializerSession.java | 8 +-
.../apache/juneau/parser/InputStreamParser.java | 15 +-
.../java/org/apache/juneau/parser/Parser.java | 53 +-
.../org/apache/juneau/parser/ParserSession.java | 4 +-
.../apache/juneau/parser/ParserSessionArgs.java | 5 -
.../org/apache/juneau/parser/ReaderParser.java | 13 +-
.../java/org/apache/juneau/parser/package.html | 6 +-
.../juneau/plaintext/PlainTextParser.java | 17 +-
.../juneau/plaintext/PlainTextSerializer.java | 33 +-
.../plaintext/PlainTextSerializerSession.java | 1 -
.../serializer/OutputStreamSerializer.java | 33 +-
.../OutputStreamSerializerSession.java | 1 -
.../apache/juneau/serializer/Serializer.java | 70 +-
.../juneau/serializer/SerializerSession.java | 5 +-
.../serializer/SerializerSessionArgs.java | 5 -
.../juneau/serializer/WriterSerializer.java | 33 +-
.../serializer/WriterSerializerSession.java | 1 -
.../org/apache/juneau/serializer/package.html | 6 +-
.../apache/juneau/soap/SoapXmlSerializer.java | 4 +-
.../juneau/soap/SoapXmlSerializerSession.java | 1 -
.../java/org/apache/juneau/uon/UonParser.java | 21 +-
.../org/apache/juneau/uon/UonParserSession.java | 14 +-
.../org/apache/juneau/uon/UonSerializer.java | 32 +-
.../apache/juneau/uon/UonSerializerSession.java | 5 +-
.../juneau/urlencoding/UrlEncodingParser.java | 4 +-
.../urlencoding/UrlEncodingSerializer.java | 36 +-
.../UrlEncodingSerializerSession.java | 4 +-
.../org/apache/juneau/xml/XmlDocSerializer.java | 2 -
.../juneau/xml/XmlDocSerializerSession.java | 1 -
.../java/org/apache/juneau/xml/XmlParser.java | 19 +-
.../xml/XmlSchemaDocSerializerSession.java | 1 -
.../apache/juneau/xml/XmlSchemaSerializer.java | 4 +-
.../juneau/xml/XmlSchemaSerializerSession.java | 1 -
.../org/apache/juneau/xml/XmlSerializer.java | 35 +-
.../apache/juneau/xml/XmlSerializerSession.java | 53 +-
juneau-core/src/main/javadoc/overview.html | 22623 +++++++++--------
.../juneau/examples/rest/PhotosResource.java | 7 +-
.../juneau/rest/test/AcceptCharsetResource.java | 7 +-
.../rest/test/CharsetEncodingsResource.java | 7 +-
.../rest/test/DefaultContentTypesResource.java | 27 +-
.../apache/juneau/rest/test/GroupsResource.java | 7 +-
.../juneau/rest/test/HeadersResource.java | 7 +-
.../juneau/rest/test/InheritanceResource.java | 39 +-
.../juneau/rest/test/NlsPropertyResource.java | 4 +-
.../juneau/rest/test/OnPostCallResource.java | 4 +-
.../juneau/rest/test/OnPreCallResource.java | 4 +-
.../juneau/rest/test/ParsersResource.java | 13 +-
.../juneau/rest/test/PropertiesResource.java | 7 +-
.../juneau/rest/test/SerializersResource.java | 13 +-
.../java/org/apache/juneau/rest/package.html | 6 +-
.../juneau/rest/response/DefaultHandler.java | 3 +-
94 files changed, 14126 insertions(+), 12593 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfParser.java
----------------------------------------------------------------------
diff --git a/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfParser.java b/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfParser.java
index d68c70a..a94c123 100644
--- a/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfParser.java
+++ b/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfParser.java
@@ -16,7 +16,6 @@ import static org.apache.juneau.jena.Constants.*;
import static org.apache.juneau.jena.RdfCommonContext.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.parser.*;
/**
@@ -45,11 +44,10 @@ import org.apache.juneau.parser.*;
*
* See <a class="doclink" href="package-summary.html#TOC">RDF Overview</a> for an overview of RDF support in Juneau.
*/
-@Consumes(value="text/xml+rdf")
public class RdfParser extends ReaderParser {
/** Default XML parser, all default settings.*/
- public static final RdfParser DEFAULT_XML = new RdfParser(PropertyStore.create());
+ public static final RdfParser DEFAULT_XML = new Xml(PropertyStore.create());
/** Default Turtle parser, all default settings.*/
public static final RdfParser DEFAULT_TURTLE = new Turtle(PropertyStore.create());
@@ -62,7 +60,6 @@ public class RdfParser extends ReaderParser {
/** Consumes RDF/XML input */
- @Consumes("text/xml+rdf")
public static class Xml extends RdfParser {
/**
@@ -71,12 +68,11 @@ public class RdfParser extends ReaderParser {
* @param propertyStore The property store containing all the settings for this object.
*/
public Xml(PropertyStore propertyStore) {
- super(propertyStore.copy().append(RDF_language, LANG_RDF_XML));
+ super(propertyStore.copy().append(RDF_language, LANG_RDF_XML), "text/xml+rdf");
}
}
/** Consumes N-Triple input */
- @Consumes(value="text/n-triple")
public static class NTriple extends RdfParser {
/**
@@ -85,12 +81,11 @@ public class RdfParser extends ReaderParser {
* @param propertyStore The property store containing all the settings for this object.
*/
public NTriple(PropertyStore propertyStore) {
- super(propertyStore.copy().append(RDF_language, LANG_NTRIPLE));
+ super(propertyStore.copy().append(RDF_language, LANG_NTRIPLE), "text/n-triple");
}
}
/** Consumes Turtle input */
- @Consumes(value="text/turtle")
public static class Turtle extends RdfParser {
/**
@@ -99,12 +94,11 @@ public class RdfParser extends ReaderParser {
* @param propertyStore The property store containing all the settings for this object.
*/
public Turtle(PropertyStore propertyStore) {
- super(propertyStore.copy().append(RDF_language, LANG_TURTLE));
+ super(propertyStore.copy().append(RDF_language, LANG_TURTLE), "text/turtle");
}
}
/** Consumes N3 input */
- @Consumes(value="text/n3")
public static class N3 extends RdfParser {
/**
@@ -113,7 +107,7 @@ public class RdfParser extends ReaderParser {
* @param propertyStore The property store containing all the settings for this object.
*/
public N3(PropertyStore propertyStore) {
- super(propertyStore.copy().append(RDF_language, LANG_N3));
+ super(propertyStore.copy().append(RDF_language, LANG_N3), "text/n3");
}
}
@@ -124,12 +118,13 @@ public class RdfParser extends ReaderParser {
* 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 RdfParser(PropertyStore propertyStore) {
- super(propertyStore);
+ public RdfParser(PropertyStore propertyStore, String...consumes) {
+ super(propertyStore, consumes);
this.ctx = createContext(RdfParserContext.class);
}
-
+
@Override /* CoreObject */
public RdfParserBuilder builder() {
return new RdfParserBuilder(propertyStore);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfParserBuilder.java
----------------------------------------------------------------------
diff --git a/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfParserBuilder.java b/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfParserBuilder.java
index 61b60ca..095d45a 100644
--- a/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfParserBuilder.java
+++ b/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfParserBuilder.java
@@ -47,7 +47,7 @@ public class RdfParserBuilder extends ParserBuilder {
@Override /* CoreObjectBuilder */
public RdfParser build() {
- return new RdfParser(propertyStore);
+ return new RdfParser(propertyStore, "text/xml+rdf");
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializer.java b/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializer.java
index e19d8b2..b574186 100644
--- a/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializer.java
+++ b/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializer.java
@@ -16,7 +16,6 @@ import static org.apache.juneau.jena.Constants.*;
import static org.apache.juneau.jena.RdfCommonContext.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.serializer.*;
/**
@@ -42,7 +41,6 @@ import org.apache.juneau.serializer.*;
*
* See <a class="doclink" href="package-summary.html#TOC">RDF Overview</a> for an overview of RDF support in Juneau.
*/
-@Produces(value="text/xml+rdf+abbrev", contentType="text/xml+rdf")
public class RdfSerializer extends WriterSerializer {
/** Default RDF/XML serializer, all default settings.*/
@@ -62,7 +60,6 @@ public class RdfSerializer extends WriterSerializer {
/** Produces RDF/XML output */
- @Produces("text/xml+rdf")
public static class Xml extends RdfSerializer {
/**
@@ -71,12 +68,11 @@ public class RdfSerializer extends WriterSerializer {
* @param propertyStore The property store containing all the settings for this object.
*/
public Xml(PropertyStore propertyStore) {
- super(propertyStore.copy().append(RDF_language, LANG_RDF_XML));
+ super(propertyStore.copy().append(RDF_language, LANG_RDF_XML), "text/xml+rdf");
}
}
/** Produces Abbreviated RDF/XML output */
- @Produces(value="text/xml+rdf+abbrev", contentType="text/xml+rdf")
public static class XmlAbbrev extends RdfSerializer {
/**
@@ -85,12 +81,11 @@ public class RdfSerializer extends WriterSerializer {
* @param propertyStore The property store containing all the settings for this object.
*/
public XmlAbbrev(PropertyStore propertyStore) {
- super(propertyStore.copy().append(RDF_language, LANG_RDF_XML_ABBREV));
+ super(propertyStore.copy().append(RDF_language, LANG_RDF_XML_ABBREV), "text/xml+rdf", "text/xml+rdf+abbrev");
}
}
/** Produces N-Triple output */
- @Produces("text/n-triple")
public static class NTriple extends RdfSerializer {
/**
@@ -99,12 +94,11 @@ public class RdfSerializer extends WriterSerializer {
* @param propertyStore The property store containing all the settings for this object.
*/
public NTriple(PropertyStore propertyStore) {
- super(propertyStore.copy().append(RDF_language, LANG_NTRIPLE));
+ super(propertyStore.copy().append(RDF_language, LANG_NTRIPLE), "text/n-triple");
}
}
/** Produces Turtle output */
- @Produces("text/turtle")
public static class Turtle extends RdfSerializer {
/**
@@ -113,12 +107,11 @@ public class RdfSerializer extends WriterSerializer {
* @param propertyStore The property store containing all the settings for this object.
*/
public Turtle(PropertyStore propertyStore) {
- super(propertyStore.copy().append(RDF_language, LANG_TURTLE));
+ super(propertyStore.copy().append(RDF_language, LANG_TURTLE), "text/turtle");
}
}
/** Produces N3 output */
- @Produces("text/n3")
public static class N3 extends RdfSerializer {
/**
@@ -127,7 +120,7 @@ public class RdfSerializer extends WriterSerializer {
* @param propertyStore The property store containing all the settings for this object.
*/
public N3(PropertyStore propertyStore) {
- super(propertyStore.copy().append(RDF_language, LANG_N3));
+ super(propertyStore.copy().append(RDF_language, LANG_N3), "text/n3");
}
}
@@ -136,11 +129,27 @@ public class RdfSerializer extends WriterSerializer {
/**
* 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.
+ * @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 RdfSerializer(PropertyStore propertyStore) {
- super(propertyStore);
+ public RdfSerializer(PropertyStore propertyStore, String produces, String...accept) {
+ super(propertyStore, produces, accept);
this.ctx = createContext(RdfSerializerContext.class);
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerBuilder.java
----------------------------------------------------------------------
diff --git a/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerBuilder.java b/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerBuilder.java
index 196bdfa..59b15c5 100644
--- a/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerBuilder.java
+++ b/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerBuilder.java
@@ -47,7 +47,7 @@ public class RdfSerializerBuilder extends SerializerBuilder {
@Override /* CoreObjectBuilder */
public RdfSerializer build() {
- return new RdfSerializer(propertyStore);
+ return new RdfSerializer(propertyStore, "text/xml+rdf");
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java b/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java
index d033c45..0f66237 100644
--- a/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java
+++ b/juneau-core-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java
@@ -63,7 +63,6 @@ public final class RdfSerializerSession 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 RdfSerializerSession(RdfSerializerContext ctx, SerializerSessionArgs args) {
super(ctx, args);
@@ -293,6 +292,10 @@ public final class RdfSerializerSession extends WriterSerializerSession {
case MULTI_VALUED: serializeToMultiProperties(c, eType, bpm, attrName, parentResource); break;
default: n = serializeToContainer(c, eType, m.createSeq());
}
+
+ } else if (sType.isReader() || sType.isInputStream()) {
+ n = m.createLiteral(encodeTextInvalidChars(IOUtils.read(o)));
+
} else {
n = m.createLiteral(encodeTextInvalidChars(toString(o)));
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core-test/src/test/java/org/apache/juneau/ComboInput.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/ComboInput.java b/juneau-core-test/src/test/java/org/apache/juneau/ComboInput.java
index 2bfc196..3ee1389 100644
--- a/juneau-core-test/src/test/java/org/apache/juneau/ComboInput.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/ComboInput.java
@@ -21,7 +21,7 @@ import java.lang.reflect.*;
public class ComboInput<T> {
final String label;
- final Object in;
+ private final T in;
final Type type;
final String json, jsonT, jsonR, xml, xmlT, xmlR, xmlNs, html, htmlT, htmlR, uon, uonT, uonR, urlEncoding,
urlEncodingT, urlEncodingR, msgPack, msgPackT, rdfXml, rdfXmlT, rdfXmlR;
@@ -79,6 +79,15 @@ public class ComboInput<T> {
}
/**
+ * Returns the input object.
+ * Override this method if you want it dynamically created each time.
+ * @throws Exception
+ */
+ public T getInput() throws Exception {
+ return in;
+ }
+
+ /**
* Override this method if you want to do a post-parse verification on the object.
* <p>
* Note that a Function would be preferred here, but it's not available in Java 6.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core-test/src/test/java/org/apache/juneau/ComboRoundTripTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/ComboRoundTripTest.java b/juneau-core-test/src/test/java/org/apache/juneau/ComboRoundTripTest.java
new file mode 100644
index 0000000..4da5f1e
--- /dev/null
+++ b/juneau-core-test/src/test/java/org/apache/juneau/ComboRoundTripTest.java
@@ -0,0 +1,708 @@
+// ***************************************************************************************************************************
+// * 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;
+
+import static org.apache.juneau.jena.Constants.*;
+import static org.junit.Assert.*;
+
+import java.util.*;
+
+import org.apache.juneau.html.*;
+import org.apache.juneau.jena.*;
+import org.apache.juneau.json.*;
+import org.apache.juneau.msgpack.*;
+import org.apache.juneau.parser.*;
+import org.apache.juneau.serializer.*;
+import org.apache.juneau.uon.*;
+import org.apache.juneau.urlencoding.*;
+import org.apache.juneau.xml.*;
+import org.junit.*;
+import org.junit.runners.*;
+
+/**
+ * Superclass for tests that verify results against all supported content types.
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+@SuppressWarnings({"unchecked","rawtypes"})
+public abstract class ComboRoundTripTest {
+
+ /* Parameter template */
+// {
+// "MyLabel",
+// myInput,
+// /* Json */ "xxx",
+// /* JsonT */ "xxx",
+// /* JsonR */ "xxx",
+// /* Xml */ "xxx",
+// /* XmlT */ "xxx",
+// /* XmlR */ "xxx",
+// /* XmlNs */ "xxx",
+// /* Html */ "xxx",
+// /* HtmlT */ "xxx",
+// /* HtmlR */ "xxx",
+// /* Uon */ "xxx",
+// /* UonT */ "xxx",
+// /* UonR */ "xxx",
+// /* UrlEnc */ "xxx",
+// /* UrlEncT */ "xxx",
+// /* UrlEncR */ "xxx",
+// /* MsgPack */ "xxx",
+// /* MsgPackT */ "xxx",
+// /* RdfXml */ "xxx",
+// /* RdfXmlT */ "xxx",
+// /* RdfXmlR */ "xxx",
+// },
+
+ private final ComboInput comboInput;
+
+ // These are the names of all the tests.
+ // You can comment out the names here to skip them.
+ private static final String[] runTests = {
+ "serializeJson",
+ "parseJson",
+ "serializeJsonT",
+ "parseJsonT",
+ "serializeJsonR",
+ "parseJsonR",
+ "serializeXml",
+ "parseXml",
+ "serializeXmlT",
+ "parseXmlT",
+ "serializeXmlR",
+ "parseXmlR",
+ "serializeXmlNs",
+ "parseXmlNs",
+ "serializeHtml",
+ "parseHtml",
+ "serializeHtmlT",
+ "parseHtmlT",
+ "serializeHtmlR",
+ "parseHtmlR",
+ "serializeUon",
+ "parseUon",
+ "serializeUonT",
+ "parseUonT",
+ "serializeUonR",
+ "parseUonR",
+ "serializeUrlEncoding",
+ "parseUrlEncoding",
+ "serializeUrlEncodingT",
+ "parseUrlEncodingT",
+ "serializeUrlEncodingR",
+ "parseUrlEncodingR",
+ "serializeMsgPack",
+ "parseMsgPack",
+ "parseMsgPackJsonEquivalency",
+ "serializeMsgPackT",
+ "parseMsgPackT",
+ "parseMsgPackTJsonEquivalency",
+ "serializeRdfXml",
+ "parseRdfXml",
+ "serializeRdfXmlT",
+ "parseRdfXmlT",
+ "serializeRdfXmlR",
+ "parseRdfXmlR",
+ };
+
+ private static final Set<String> runTestsSet = new HashSet<String>(Arrays.asList(runTests));
+
+ private final boolean SKIP_RDF_TESTS = Boolean.getBoolean("skipRdfTests");
+
+ private Map<Serializer,Serializer> serializerMap = new IdentityHashMap<Serializer,Serializer>();
+ private Map<Parser,Parser> parserMap = new IdentityHashMap<Parser,Parser>();
+
+ public ComboRoundTripTest(ComboInput<?> comboInput) {
+ this.comboInput = comboInput;
+ }
+
+ private Serializer getSerializer(Serializer s) throws Exception {
+ Serializer s2 = serializerMap.get(s);
+ if (s2 == null) {
+ s2 = applySettings(s);
+ serializerMap.put(s, s2);
+ }
+ return s2;
+ }
+
+ private Parser getParser(Parser p) throws Exception {
+ Parser p2 = parserMap.get(p);
+ if (p2 == null) {
+ p2 = applySettings(p);
+ parserMap.put(p, p2);
+ }
+ return p2;
+ }
+
+ private void testSerialize(String testName, Serializer s, String expected) throws Exception {
+ try {
+ s = getSerializer(s);
+
+ boolean isRdf = s instanceof RdfSerializer;
+
+ if ((isRdf && SKIP_RDF_TESTS) || expected.isEmpty() || ! runTestsSet.contains(testName) ) {
+ System.err.println(comboInput.label + "/" + testName + " for "+s.getClass().getSimpleName()+" skipped.");
+ return;
+ }
+
+ String r = s.isWriterSerializer() ? ((WriterSerializer)s).serialize(comboInput.getInput()) : ((OutputStreamSerializer)s).serializeToHex(comboInput.getInput());
+
+ // Can't control RdfSerializer output well, so manually remove namespace declarations
+ // double-quotes with single-quotes, and spaces with tabs.
+ // Also because RDF sucks really bad and can't be expected to produce consistent testable results,
+ // we must also do an expensive sort-then-compare operation to verify the results.
+ if (isRdf)
+ r = r.replaceAll("<rdf:RDF[^>]*>", "<rdf:RDF>").replace('"', '\'');
+
+ // Specifying "xxx" in the expected results will spit out what we should populate the field with.
+ if (expected.equals("xxx")) {
+ System.out.println(comboInput.label + "/" + testName + "=\n" + r.replaceAll("\n", "\\\\n").replaceAll("\t", "\\\\t")); // NOT DEBUG
+ System.out.println(r);
+ }
+
+ if (isRdf)
+ TestUtils.assertEqualsAfterSort(expected, r, "{0}/{1} parse-normal failed", comboInput.label, testName);
+ else
+ TestUtils.assertEquals(expected, r, "{0}/{1} parse-normal failed", comboInput.label, testName);
+
+ } catch (AssertionError e) {
+ throw e;
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new AssertionError(comboInput.label + "/" + testName + " failed. exception=" + e.getLocalizedMessage());
+ }
+ }
+
+ private void testParse(String testName, Serializer s, Parser p, String expected) throws Exception {
+ try {
+ s = getSerializer(s);
+ p = getParser(p);
+
+ boolean isRdf = s instanceof RdfSerializer;
+
+ if ((isRdf && SKIP_RDF_TESTS) || expected.isEmpty() || ! runTestsSet.contains(testName) ) {
+ System.err.println(comboInput.label + "/" + testName + " for "+s.getClass().getSimpleName()+" skipped.");
+ return;
+ }
+
+ String r = s.isWriterSerializer() ? ((WriterSerializer)s).serialize(comboInput.getInput()) : ((OutputStreamSerializer)s).serializeToHex(comboInput.getInput());
+ Object o = p.parse(r, comboInput.type);
+ r = s.isWriterSerializer() ? ((WriterSerializer)s).serialize(o) : ((OutputStreamSerializer)s).serializeToHex(o);
+
+ if (isRdf)
+ r = r.replaceAll("<rdf:RDF[^>]*>", "<rdf:RDF>").replace('"', '\'');
+
+ if (isRdf)
+ TestUtils.assertEqualsAfterSort(expected, r, "{0}/{1} parse-normal failed", comboInput.label, testName);
+ else
+ TestUtils.assertEquals(expected, r, "{0}/{1} parse-normal failed", comboInput.label, testName);
+
+ } catch (AssertionError e) {
+ throw e;
+ } catch (Exception e) {
+ throw new Exception(comboInput.label + "/" + testName + " failed.", e);
+ }
+ }
+
+ private void testParseVerify(String testName, Serializer s, Parser p) throws Exception {
+ try {
+ s = getSerializer(s);
+ p = getParser(p);
+
+ String r = s.isWriterSerializer() ? ((WriterSerializer)s).serialize(comboInput.getInput()) : ((OutputStreamSerializer)s).serializeToHex(comboInput.getInput());
+ Object o = p.parse(r, comboInput.type);
+
+ comboInput.verify(o);
+ } catch (AssertionError e) {
+ throw e;
+ } catch (Exception e) {
+ throw new Exception(comboInput.label + "/" + testName + " failed.", e);
+ }
+ }
+
+
+ private void testParseJsonEquivalency(String testName, OutputStreamSerializer s, InputStreamParser p, String expected) throws Exception {
+ try {
+ s = (OutputStreamSerializer)getSerializer(s);
+ p = (InputStreamParser)getParser(p);
+ WriterSerializer sJson = (WriterSerializer)getSerializer(this.sJson);
+
+ String r = s.serializeToHex(comboInput.getInput());
+ Object o = p.parse(r, comboInput.type);
+ r = sJson.serialize(o);
+ assertEquals(comboInput.label + "/" + testName + " parse-normal failed on JSON equivalency", expected, r);
+ } catch (AssertionError e) {
+ throw e;
+ } catch (Exception e) {
+ throw new Exception(comboInput.label + "/" + testName + " failed.", e);
+ }
+ }
+
+ protected Serializer applySettings(Serializer s) throws Exception {
+ return s;
+ }
+
+ protected Parser applySettings(Parser p) throws Exception {
+ return p;
+ }
+
+ //--------------------------------------------------------------------------------
+ // JSON
+ //--------------------------------------------------------------------------------
+ WriterSerializer sJson = JsonSerializer.DEFAULT_LAX;
+ ReaderParser pJson = JsonParser.DEFAULT;
+
+ @Test
+ public void a11_serializeJson() throws Exception {
+ testSerialize("serializeJson", sJson, comboInput.json);
+ }
+
+ @Test
+ public void a12_parseJson() throws Exception {
+ testParse("parseJson", sJson, pJson, comboInput.json);
+ }
+
+ @Test
+ public void a13_verifyJson() throws Exception {
+ testParseVerify("verifyJson", sJson, pJson);
+ }
+
+ //--------------------------------------------------------------------------------
+ // JSON - 't' property
+ //--------------------------------------------------------------------------------
+ WriterSerializer sJsonT = new JsonSerializerBuilder().simple().beanTypePropertyName("t").build();
+ ReaderParser pJsonT = new JsonParserBuilder().beanTypePropertyName("t").build();
+
+ @Test
+ public void a21_serializeJsonT() throws Exception {
+ testSerialize("serializeJsonT", sJsonT, comboInput.jsonT);
+ }
+
+ @Test
+ public void a22_parseJsonT() throws Exception {
+ testParse("parseJsonT", sJsonT, pJsonT, comboInput.jsonT);
+ }
+
+ @Test
+ public void a23_verifyJsonT() throws Exception {
+ testParseVerify("verifyJsonT", sJsonT, pJsonT);
+ }
+
+ //--------------------------------------------------------------------------------
+ // JSON - Readable
+ //--------------------------------------------------------------------------------
+ WriterSerializer sJsonR = JsonSerializer.DEFAULT_LAX_READABLE;
+ ReaderParser pJsonR = JsonParser.DEFAULT;
+
+ @Test
+ public void a31_serializeJsonR() throws Exception {
+ testSerialize("serializeJsonR", sJsonR, comboInput.jsonR);
+ }
+
+ @Test
+ public void a32_parseJsonR() throws Exception {
+ testParse("parseJsonR", sJsonR, pJsonR, comboInput.jsonR);
+ }
+
+ @Test
+ public void a33_verifyJsonR() throws Exception {
+ testParseVerify("verifyJsonR", sJsonR, pJsonR);
+ }
+
+ //--------------------------------------------------------------------------------
+ // XML
+ //--------------------------------------------------------------------------------
+ WriterSerializer sXml = XmlSerializer.DEFAULT_SQ;
+ ReaderParser pXml = XmlParser.DEFAULT;
+
+ @Test
+ public void b11_serializeXml() throws Exception {
+ testSerialize("serializeXml", sXml, comboInput.xml);
+ }
+
+ @Test
+ public void b12_parseXml() throws Exception {
+ testParse("parseXml", sXml, pXml, comboInput.xml);
+ }
+
+ @Test
+ public void b13_verifyXml() throws Exception {
+ testParseVerify("verifyXml", sXml, pXml);
+ }
+
+ //--------------------------------------------------------------------------------
+ // XML - 't' property
+ //--------------------------------------------------------------------------------
+ WriterSerializer sXmlT = new XmlSerializerBuilder().sq().beanTypePropertyName("t").build();
+ ReaderParser pXmlT = new XmlParserBuilder().beanTypePropertyName("t").build();
+
+ @Test
+ public void b21_serializeXmlT() throws Exception {
+ testSerialize("serializeXmlT", sXmlT, comboInput.xmlT);
+ }
+
+ @Test
+ public void b22_parseXmlT() throws Exception {
+ testParse("parseXmlT", sXmlT, pXmlT, comboInput.xmlT);
+ }
+
+ @Test
+ public void b23_verifyXmlT() throws Exception {
+ testParseVerify("parseXmlTVerify", sXmlT, pXmlT);
+ }
+
+ //--------------------------------------------------------------------------------
+ // XML - Readable
+ //--------------------------------------------------------------------------------
+ WriterSerializer sXmlR = XmlSerializer.DEFAULT_SQ_READABLE;
+ ReaderParser pXmlR = XmlParser.DEFAULT;
+
+ @Test
+ public void b31_serializeXmlR() throws Exception {
+ testSerialize("serializeXmlR", sXmlR, comboInput.xmlR);
+ }
+
+ @Test
+ public void b32_parseXmlR() throws Exception {
+ testParse("parseXmlR", sXmlR, pXmlR, comboInput.xmlR);
+ }
+
+ @Test
+ public void b33_verifyXmlR() throws Exception {
+ testParseVerify("parseXmlRVerify", sXmlR, pXmlR);
+ }
+
+ //--------------------------------------------------------------------------------
+ // XML - Namespaces
+ //--------------------------------------------------------------------------------
+ WriterSerializer sXmlNs = XmlSerializer.DEFAULT_NS_SQ;
+ ReaderParser pXmlNs = XmlParser.DEFAULT;
+
+ @Test
+ public void b41_serializeXmlNs() throws Exception {
+ testSerialize("serializeXmlNs", sXmlNs, comboInput.xmlNs);
+ }
+
+ @Test
+ public void b42_parseXmlNs() throws Exception {
+ testParse("parseXmlNs", sXmlNs, pXmlNs, comboInput.xmlNs);
+ }
+
+ @Test
+ public void b43_verifyXmlNs() throws Exception {
+ testParseVerify("verifyXmlNs", sXmlNs, pXmlNs);
+ }
+
+ //--------------------------------------------------------------------------------
+ // HTML
+ //--------------------------------------------------------------------------------
+ WriterSerializer sHtml = HtmlSerializer.DEFAULT_SQ;
+ ReaderParser pHtml = HtmlParser.DEFAULT;
+
+ @Test
+ public void c11_serializeHtml() throws Exception {
+ testSerialize("serializeHtml", sHtml, comboInput.html);
+ }
+
+ @Test
+ public void c12_parseHtml() throws Exception {
+ testParse("parseHtml", sHtml, pHtml, comboInput.html);
+ }
+
+ @Test
+ public void c13_verifyHtml() throws Exception {
+ testParseVerify("verifyHtml", sHtml, pHtml);
+ }
+
+ //--------------------------------------------------------------------------------
+ // HTML - 't' property
+ //--------------------------------------------------------------------------------
+ WriterSerializer sHtmlT = new HtmlSerializerBuilder().sq().beanTypePropertyName("t").build();
+ ReaderParser pHtmlT = new HtmlParserBuilder().beanTypePropertyName("t").build();
+
+ @Test
+ public void c21_serializeHtmlT() throws Exception {
+ testSerialize("serializeHtmlT", sHtmlT, comboInput.htmlT);
+ }
+
+ @Test
+ public void c22_parseHtmlT() throws Exception {
+ testParse("parseHtmlT", sHtmlT, pHtmlT, comboInput.htmlT);
+ }
+
+ @Test
+ public void c23_verifyHtmlT() throws Exception {
+ testParseVerify("verifyHtmlT", sHtmlT, pHtmlT);
+ }
+
+ //--------------------------------------------------------------------------------
+ // HTML - Readable
+ //--------------------------------------------------------------------------------
+ WriterSerializer sHtmlR = HtmlSerializer.DEFAULT_SQ_READABLE;
+ ReaderParser pHtmlR = HtmlParser.DEFAULT;
+
+ @Test
+ public void c31_serializeHtmlR() throws Exception {
+ testSerialize("serializeHtmlR", sHtmlR, comboInput.htmlR);
+ }
+
+ @Test
+ public void c32_parseHtmlR() throws Exception {
+ testParse("parseHtmlR", sHtmlR, pHtmlR, comboInput.htmlR);
+ }
+
+ @Test
+ public void c33_verifyHtmlR() throws Exception {
+ testParseVerify("verifyHtmlR", sHtmlR, pHtmlR);
+ }
+
+ //--------------------------------------------------------------------------------
+ // UON
+ //--------------------------------------------------------------------------------
+ WriterSerializer sUon = UonSerializer.DEFAULT;
+ ReaderParser pUon = UonParser.DEFAULT;
+
+ @Test
+ public void d11_serializeUon() throws Exception {
+ testSerialize("serializeUon", sUon, comboInput.uon);
+ }
+
+ @Test
+ public void d12_parseUon() throws Exception {
+ testParse("parseUon", sUon, pUon, comboInput.uon);
+ }
+
+ @Test
+ public void d13_verifyUon() throws Exception {
+ testParseVerify("verifyUon", sUon, pUon);
+ }
+
+ //--------------------------------------------------------------------------------
+ // UON - 't' property
+ //--------------------------------------------------------------------------------
+ WriterSerializer sUonT = new UonSerializerBuilder().beanTypePropertyName("t").build();
+ ReaderParser pUonT = new UonParserBuilder().beanTypePropertyName("t").build();
+
+ @Test
+ public void d21_serializeUonT() throws Exception {
+ testSerialize("serializeUonT", sUonT, comboInput.uonT);
+ }
+
+ @Test
+ public void d22_parseUonT() throws Exception {
+ testParse("parseUonT", sUonT, pUonT, comboInput.uonT);
+ }
+
+ @Test
+ public void d23_verifyUonT() throws Exception {
+ testParseVerify("verifyUonT", sUonT, pUonT);
+ }
+
+ //--------------------------------------------------------------------------------
+ // UON - Readable
+ //--------------------------------------------------------------------------------
+ WriterSerializer sUonR = UonSerializer.DEFAULT_READABLE;
+ ReaderParser pUonR = UonParser.DEFAULT;
+
+ @Test
+ public void d31_serializeUonR() throws Exception {
+ testSerialize("serializeUonR", sUonR, comboInput.uonR);
+ }
+
+ @Test
+ public void d32_parseUonR() throws Exception {
+ testParse("parseUonR", sUonR, pUonR, comboInput.uonR);
+ }
+
+ @Test
+ public void d33_verifyUonR() throws Exception {
+ testParseVerify("verifyUonR", sUonR, pUonR);
+ }
+
+ //--------------------------------------------------------------------------------
+ // UrlEncoding
+ //--------------------------------------------------------------------------------
+ WriterSerializer sUrlEncoding = UrlEncodingSerializer.DEFAULT;
+ ReaderParser pUrlEncoding = UrlEncodingParser.DEFAULT;
+
+ @Test
+ public void e11_serializeUrlEncoding() throws Exception {
+ testSerialize("serializeUrlEncoding", sUrlEncoding, comboInput.urlEncoding);
+ }
+
+ @Test
+ public void e12_parseUrlEncoding() throws Exception {
+ testParse("parseUrlEncoding", sUrlEncoding, pUrlEncoding, comboInput.urlEncoding);
+ }
+
+ @Test
+ public void e13_verifyUrlEncoding() throws Exception {
+ testParseVerify("verifyUrlEncoding", sUrlEncoding, pUrlEncoding);
+ }
+
+ //--------------------------------------------------------------------------------
+ // UrlEncoding - 't' property
+ //--------------------------------------------------------------------------------
+ WriterSerializer sUrlEncodingT = new UrlEncodingSerializerBuilder().beanTypePropertyName("t").build();
+ ReaderParser pUrlEncodingT = new UrlEncodingParserBuilder().beanTypePropertyName("t").build();
+
+ @Test
+ public void e21_serializeUrlEncodingT() throws Exception {
+ testSerialize("serializeUrlEncodingT", sUrlEncodingT, comboInput.urlEncodingT);
+ }
+
+ @Test
+ public void e22_parseUrlEncodingT() throws Exception {
+ testParse("parseUrlEncodingT", sUrlEncodingT, pUrlEncodingT, comboInput.urlEncodingT);
+ }
+
+ @Test
+ public void e23_verifyUrlEncodingT() throws Exception {
+ testParseVerify("verifyUrlEncodingT", sUrlEncodingT, pUrlEncodingT);
+ }
+
+ //--------------------------------------------------------------------------------
+ // UrlEncoding - Readable
+ //--------------------------------------------------------------------------------
+ WriterSerializer sUrlEncodingR = UrlEncodingSerializer.DEFAULT_READABLE;
+ ReaderParser pUrlEncodingR = UrlEncodingParser.DEFAULT;
+
+ @Test
+ public void e31_serializeUrlEncodingR() throws Exception {
+ testSerialize("serializeUrlEncodingR", sUrlEncodingR, comboInput.urlEncodingR);
+ }
+
+ @Test
+ public void e32_parseUrlEncodingR() throws Exception {
+ testParse("parseUrlEncodingR", sUrlEncodingR, pUrlEncodingR, comboInput.urlEncodingR);
+ }
+
+ @Test
+ public void e33_verifyUrlEncodingR() throws Exception {
+ testParseVerify("verifyUrlEncodingR", sUrlEncodingR, pUrlEncodingR);
+ }
+
+ //--------------------------------------------------------------------------------
+ // MsgPack
+ //--------------------------------------------------------------------------------
+ OutputStreamSerializer sMsgPack = MsgPackSerializer.DEFAULT;
+ InputStreamParser pMsgPack = MsgPackParser.DEFAULT;
+
+ @Test
+ public void f11_serializeMsgPack() throws Exception {
+ testSerialize("serializeMsgPack", sMsgPack, comboInput.msgPack);
+ }
+
+ @Test
+ public void f12_parseMsgPack() throws Exception {
+ testParse("parseMsgPack", sMsgPack, pMsgPack, comboInput.msgPack);
+ }
+
+ @Test
+ public void f13_parseMsgPackJsonEquivalency() throws Exception {
+ testParseJsonEquivalency("parseMsgPackJsonEquivalency", sMsgPack, pMsgPack, comboInput.json);
+ }
+
+ @Test
+ public void f14_verifyMsgPack() throws Exception {
+ testParseVerify("verifyMsgPack", sMsgPack, pMsgPack);
+ }
+
+ //--------------------------------------------------------------------------------
+ // MsgPack - 't' property
+ //--------------------------------------------------------------------------------
+ OutputStreamSerializer sMsgPackT = new MsgPackSerializerBuilder().beanTypePropertyName("t").build();
+ InputStreamParser pMsgPackT = new MsgPackParserBuilder().beanTypePropertyName("t").build();
+
+ @Test
+ public void f21_serializeMsgPackT() throws Exception {
+ testSerialize("serializeMsgPackT", sMsgPackT, comboInput.msgPackT);
+ }
+
+ @Test
+ public void f22_parseMsgPackT() throws Exception {
+ testParse("parseMsgPackT", sMsgPackT, pMsgPackT, comboInput.msgPackT);
+ }
+
+ @Test
+ public void f23_parseMsgPackTJsonEquivalency() throws Exception {
+ testParseJsonEquivalency("parseMsgPackTJsonEquivalency", sMsgPackT, pMsgPackT, comboInput.json);
+ }
+
+ @Test
+ public void f24_verifyMsgPackT() throws Exception {
+ testParseVerify("verifyMsgPackT", sMsgPackT, pMsgPackT);
+ }
+
+ //--------------------------------------------------------------------------------
+ // RdfXml
+ //--------------------------------------------------------------------------------
+ WriterSerializer sRdfXml = RdfSerializer.DEFAULT_XMLABBREV;
+ ReaderParser pRdfXml = RdfParser.DEFAULT_XML;
+
+ @Test
+ public void g11_serializeRdfXml() throws Exception {
+ testSerialize("serializeRdfXml", sRdfXml, comboInput.rdfXml);
+ }
+
+ @Test
+ public void g12_parseRdfXml() throws Exception {
+ testParse("parseRdfXml", sRdfXml, pRdfXml, comboInput.rdfXml);
+ }
+
+ @Test
+ public void g13_verifyRdfXml() throws Exception {
+ testParseVerify("verifyRdfXml", sRdfXml, pRdfXml);
+ }
+
+ //--------------------------------------------------------------------------------
+ // RdfXml - 't' property
+ //--------------------------------------------------------------------------------
+ WriterSerializer sRdfXmlT = new RdfSerializerBuilder().language(LANG_RDF_XML_ABBREV).beanTypePropertyName("t").build();
+ ReaderParser pRdfXmlT = new RdfParserBuilder().beanTypePropertyName("t").build();
+
+ @Test
+ public void g21_serializeRdfXmlT() throws Exception {
+ testSerialize("serializeRdfXmlT", sRdfXmlT, comboInput.rdfXmlT);
+ }
+
+ @Test
+ public void g22_parseRdfXmlT() throws Exception {
+ testParse("parseRdfXmlT", sRdfXmlT, pRdfXmlT, comboInput.rdfXmlT);
+ }
+
+ @Test
+ public void g23_verifyRdfXmlT() throws Exception {
+ testParseVerify("parseRdfXmlTVerify", sRdfXmlT, pRdfXmlT);
+ }
+
+ //--------------------------------------------------------------------------------
+ // RdfXml - Readable
+ //--------------------------------------------------------------------------------
+ WriterSerializer sRdfXmlR = new RdfSerializerBuilder().language(LANG_RDF_XML_ABBREV).ws().build();
+ ReaderParser pRdfXmlR = RdfParser.DEFAULT_XML;
+
+ @Test
+ public void g31_serializeRdfXmlR() throws Exception {
+ testSerialize("serializeRdfXmlR", sRdfXmlR, comboInput.rdfXmlR);
+ }
+
+ @Test
+ public void g32_parseRdfXmlR() throws Exception {
+ testParse("parseRdfXmlR", sRdfXmlR, pRdfXmlR, comboInput.rdfXmlR);
+ }
+
+ @Test
+ public void g33_verifyRdfXmlR() throws Exception {
+ testParseVerify("Verify", sRdfXmlR, pRdfXmlR);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core-test/src/test/java/org/apache/juneau/ComboSerializeTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/ComboSerializeTest.java b/juneau-core-test/src/test/java/org/apache/juneau/ComboSerializeTest.java
new file mode 100644
index 0000000..6768d91
--- /dev/null
+++ b/juneau-core-test/src/test/java/org/apache/juneau/ComboSerializeTest.java
@@ -0,0 +1,367 @@
+// ***************************************************************************************************************************
+// * 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;
+
+import static org.apache.juneau.jena.Constants.*;
+
+import java.util.*;
+
+import org.apache.juneau.html.*;
+import org.apache.juneau.internal.*;
+import org.apache.juneau.jena.*;
+import org.apache.juneau.json.*;
+import org.apache.juneau.msgpack.*;
+import org.apache.juneau.serializer.*;
+import org.apache.juneau.uon.*;
+import org.apache.juneau.urlencoding.*;
+import org.apache.juneau.xml.*;
+import org.junit.*;
+import org.junit.runners.*;
+
+/**
+ * Superclass for tests that verify results against all supported content types.
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+@SuppressWarnings({"rawtypes"})
+public abstract class ComboSerializeTest {
+
+ /* Parameter template */
+// {
+// "MyLabel",
+// myInput,
+// /* Json */ "xxx",
+// /* JsonT */ "xxx",
+// /* JsonR */ "xxx",
+// /* Xml */ "xxx",
+// /* XmlT */ "xxx",
+// /* XmlR */ "xxx",
+// /* XmlNs */ "xxx",
+// /* Html */ "xxx",
+// /* HtmlT */ "xxx",
+// /* HtmlR */ "xxx",
+// /* Uon */ "xxx",
+// /* UonT */ "xxx",
+// /* UonR */ "xxx",
+// /* UrlEnc */ "xxx",
+// /* UrlEncT */ "xxx",
+// /* UrlEncR */ "xxx",
+// /* MsgPack */ "xxx",
+// /* MsgPackT */ "xxx",
+// /* RdfXml */ "xxx",
+// /* RdfXmlT */ "xxx",
+// /* RdfXmlR */ "xxx",
+// },
+
+ private final ComboInput comboInput;
+
+ // These are the names of all the tests.
+ // You can comment out the names here to skip them.
+ private static final String[] runTests = {
+ "serializeJson",
+ "serializeJsonT",
+ "serializeJsonR",
+ "serializeXml",
+ "serializeXmlT",
+ "serializeXmlR",
+ "serializeXmlNs",
+ "serializeHtml",
+ "serializeHtmlT",
+ "serializeHtmlR",
+ "serializeUon",
+ "serializeUonT",
+ "serializeUonR",
+ "serializeUrlEncoding",
+ "serializeUrlEncodingT",
+ "serializeUrlEncodingR",
+ "serializeMsgPack",
+ "serializeMsgPackT",
+ "serializeRdfXml",
+ "serializeRdfXmlT",
+ "serializeRdfXmlR",
+ };
+
+ private static final Set<String> runTestsSet = new HashSet<String>(Arrays.asList(runTests));
+
+ private final boolean SKIP_RDF_TESTS = Boolean.getBoolean("skipRdfTests");
+
+ private Map<Serializer,Serializer> serializerMap = new IdentityHashMap<Serializer,Serializer>();
+
+ public ComboSerializeTest(ComboInput<?> comboInput) {
+ this.comboInput = comboInput;
+ }
+
+ private Serializer getSerializer(Serializer s) throws Exception {
+ Serializer s2 = serializerMap.get(s);
+ if (s2 == null) {
+ s2 = applySettings(s);
+ serializerMap.put(s, s2);
+ }
+ return s2;
+ }
+
+ private void testSerialize(String testName, Serializer s, String expected) throws Exception {
+ try {
+ s = getSerializer(s);
+
+ boolean isRdf = s instanceof RdfSerializer;
+
+ if ((isRdf && SKIP_RDF_TESTS) || expected.equals("SKIP") || ! runTestsSet.contains(testName) ) {
+ System.err.println(comboInput.label + "/" + testName + " for "+s.getClass().getSimpleName()+" skipped.");
+ return;
+ }
+
+ String r = s.isWriterSerializer() ? ((WriterSerializer)s).serialize(comboInput.getInput()) : ((OutputStreamSerializer)s).serializeToHex(comboInput.getInput());
+
+ // Can't control RdfSerializer output well, so manually remove namespace declarations
+ // double-quotes with single-quotes, and spaces with tabs.
+ // Also because RDF sucks really bad and can't be expected to produce consistent testable results,
+ // we must also do an expensive sort-then-compare operation to verify the results.
+ if (isRdf)
+ r = r.replaceAll("<rdf:RDF[^>]*>", "<rdf:RDF>").replace('"', '\'');
+
+ // Specifying "xxx" in the expected results will spit out what we should populate the field with.
+ if (expected.equals("xxx")) {
+ System.out.println(comboInput.label + "/" + testName + "=\n" + r.replaceAll("\n", "\\\\n").replaceAll("\t", "\\\\t")); // NOT DEBUG
+ System.out.println(r);
+ if (s instanceof MsgPackSerializer) {
+ System.out.println("decoded=["+new String(StringUtils.fromHex(r))+"]");
+ }
+ }
+
+ if (isRdf)
+ TestUtils.assertEqualsAfterSort(expected, r, "{0}/{1} serialize-normal failed", comboInput.label, testName);
+ else
+ TestUtils.assertEquals(expected, r, "{0}/{1} serialize-normal failed", comboInput.label, testName);
+
+ } catch (AssertionError e) {
+ throw e;
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new AssertionError(comboInput.label + "/" + testName + " failed. exception=" + e.getLocalizedMessage());
+ }
+ }
+
+ protected Serializer applySettings(Serializer s) throws Exception {
+ return s;
+ }
+
+ //--------------------------------------------------------------------------------
+ // JSON
+ //--------------------------------------------------------------------------------
+ WriterSerializer sJson = JsonSerializer.DEFAULT_LAX;
+
+ @Test
+ public void a11_serializeJson() throws Exception {
+ testSerialize("serializeJson", sJson, comboInput.json);
+ }
+
+ //--------------------------------------------------------------------------------
+ // JSON - 't' property
+ //--------------------------------------------------------------------------------
+ WriterSerializer sJsonT = new JsonSerializerBuilder().simple().beanTypePropertyName("t").build();
+
+ @Test
+ public void a21_serializeJsonT() throws Exception {
+ testSerialize("serializeJsonT", sJsonT, comboInput.jsonT);
+ }
+
+ //--------------------------------------------------------------------------------
+ // JSON - Readable
+ //--------------------------------------------------------------------------------
+ WriterSerializer sJsonR = JsonSerializer.DEFAULT_LAX_READABLE;
+
+ @Test
+ public void a31_serializeJsonR() throws Exception {
+ testSerialize("serializeJsonR", sJsonR, comboInput.jsonR);
+ }
+
+ //--------------------------------------------------------------------------------
+ // XML
+ //--------------------------------------------------------------------------------
+ WriterSerializer sXml = XmlSerializer.DEFAULT_SQ;
+
+ @Test
+ public void b11_serializeXml() throws Exception {
+ testSerialize("serializeXml", sXml, comboInput.xml);
+ }
+
+ //--------------------------------------------------------------------------------
+ // XML - 't' property
+ //--------------------------------------------------------------------------------
+ WriterSerializer sXmlT = new XmlSerializerBuilder().sq().beanTypePropertyName("t").build();
+
+ @Test
+ public void b21_serializeXmlT() throws Exception {
+ testSerialize("serializeXmlT", sXmlT, comboInput.xmlT);
+ }
+
+ //--------------------------------------------------------------------------------
+ // XML - Readable
+ //--------------------------------------------------------------------------------
+ WriterSerializer sXmlR = XmlSerializer.DEFAULT_SQ_READABLE;
+
+ @Test
+ public void b31_serializeXmlR() throws Exception {
+ testSerialize("serializeXmlR", sXmlR, comboInput.xmlR);
+ }
+
+ //--------------------------------------------------------------------------------
+ // XML - Namespaces
+ //--------------------------------------------------------------------------------
+ WriterSerializer sXmlNs = XmlSerializer.DEFAULT_NS_SQ;
+
+ @Test
+ public void b41_serializeXmlNs() throws Exception {
+ testSerialize("serializeXmlNs", sXmlNs, comboInput.xmlNs);
+ }
+
+ //--------------------------------------------------------------------------------
+ // HTML
+ //--------------------------------------------------------------------------------
+ WriterSerializer sHtml = HtmlSerializer.DEFAULT_SQ;
+
+ @Test
+ public void c11_serializeHtml() throws Exception {
+ testSerialize("serializeHtml", sHtml, comboInput.html);
+ }
+
+ //--------------------------------------------------------------------------------
+ // HTML - 't' property
+ //--------------------------------------------------------------------------------
+ WriterSerializer sHtmlT = new HtmlSerializerBuilder().sq().beanTypePropertyName("t").build();
+
+ @Test
+ public void c21_serializeHtmlT() throws Exception {
+ testSerialize("serializeHtmlT", sHtmlT, comboInput.htmlT);
+ }
+
+ //--------------------------------------------------------------------------------
+ // HTML - Readable
+ //--------------------------------------------------------------------------------
+ WriterSerializer sHtmlR = HtmlSerializer.DEFAULT_SQ_READABLE;
+
+ @Test
+ public void c31_serializeHtmlR() throws Exception {
+ testSerialize("serializeHtmlR", sHtmlR, comboInput.htmlR);
+ }
+
+ //--------------------------------------------------------------------------------
+ // UON
+ //--------------------------------------------------------------------------------
+ WriterSerializer sUon = UonSerializer.DEFAULT;
+
+ @Test
+ public void d11_serializeUon() throws Exception {
+ testSerialize("serializeUon", sUon, comboInput.uon);
+ }
+
+ //--------------------------------------------------------------------------------
+ // UON - 't' property
+ //--------------------------------------------------------------------------------
+ WriterSerializer sUonT = new UonSerializerBuilder().beanTypePropertyName("t").build();
+
+ @Test
+ public void d21_serializeUonT() throws Exception {
+ testSerialize("serializeUonT", sUonT, comboInput.uonT);
+ }
+
+ //--------------------------------------------------------------------------------
+ // UON - Readable
+ //--------------------------------------------------------------------------------
+ WriterSerializer sUonR = UonSerializer.DEFAULT_READABLE;
+
+ @Test
+ public void d31_serializeUonR() throws Exception {
+ testSerialize("serializeUonR", sUonR, comboInput.uonR);
+ }
+
+ //--------------------------------------------------------------------------------
+ // UrlEncoding
+ //--------------------------------------------------------------------------------
+ WriterSerializer sUrlEncoding = UrlEncodingSerializer.DEFAULT;
+
+ @Test
+ public void e11_serializeUrlEncoding() throws Exception {
+ testSerialize("serializeUrlEncoding", sUrlEncoding, comboInput.urlEncoding);
+ }
+
+ //--------------------------------------------------------------------------------
+ // UrlEncoding - 't' property
+ //--------------------------------------------------------------------------------
+ WriterSerializer sUrlEncodingT = new UrlEncodingSerializerBuilder().beanTypePropertyName("t").build();
+
+ @Test
+ public void e21_serializeUrlEncodingT() throws Exception {
+ testSerialize("serializeUrlEncodingT", sUrlEncodingT, comboInput.urlEncodingT);
+ }
+
+ //--------------------------------------------------------------------------------
+ // UrlEncoding - Readable
+ //--------------------------------------------------------------------------------
+ WriterSerializer sUrlEncodingR = UrlEncodingSerializer.DEFAULT_READABLE;
+
+ @Test
+ public void e31_serializeUrlEncodingR() throws Exception {
+ testSerialize("serializeUrlEncodingR", sUrlEncodingR, comboInput.urlEncodingR);
+ }
+
+ //--------------------------------------------------------------------------------
+ // MsgPack
+ //--------------------------------------------------------------------------------
+ OutputStreamSerializer sMsgPack = MsgPackSerializer.DEFAULT;
+
+ @Test
+ public void f11_serializeMsgPack() throws Exception {
+ testSerialize("serializeMsgPack", sMsgPack, comboInput.msgPack);
+ }
+
+ //--------------------------------------------------------------------------------
+ // MsgPack - 't' property
+ //--------------------------------------------------------------------------------
+ OutputStreamSerializer sMsgPackT = new MsgPackSerializerBuilder().beanTypePropertyName("t").build();
+
+ @Test
+ public void f21_serializeMsgPackT() throws Exception {
+ testSerialize("serializeMsgPackT", sMsgPackT, comboInput.msgPackT);
+ }
+
+ //--------------------------------------------------------------------------------
+ // RdfXml
+ //--------------------------------------------------------------------------------
+ WriterSerializer sRdfXml = RdfSerializer.DEFAULT_XMLABBREV;
+
+ @Test
+ public void g11_serializeRdfXml() throws Exception {
+ testSerialize("serializeRdfXml", sRdfXml, comboInput.rdfXml);
+ }
+
+ //--------------------------------------------------------------------------------
+ // RdfXml - 't' property
+ //--------------------------------------------------------------------------------
+ WriterSerializer sRdfXmlT = new RdfSerializerBuilder().language(LANG_RDF_XML_ABBREV).beanTypePropertyName("t").build();
+
+ @Test
+ public void g21_serializeRdfXmlT() throws Exception {
+ testSerialize("serializeRdfXmlT", sRdfXmlT, comboInput.rdfXmlT);
+ }
+
+ //--------------------------------------------------------------------------------
+ // RdfXml - Readable
+ //--------------------------------------------------------------------------------
+ WriterSerializer sRdfXmlR = new RdfSerializerBuilder().language(LANG_RDF_XML_ABBREV).ws().build();
+
+ @Test
+ public void g31_serializeRdfXmlR() throws Exception {
+ testSerialize("serializeRdfXmlR", sRdfXmlR, comboInput.rdfXmlR);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core-test/src/test/java/org/apache/juneau/ComboTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/ComboTest.java b/juneau-core-test/src/test/java/org/apache/juneau/ComboTest.java
deleted file mode 100644
index 510fe01..0000000
--- a/juneau-core-test/src/test/java/org/apache/juneau/ComboTest.java
+++ /dev/null
@@ -1,708 +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;
-
-import static org.apache.juneau.jena.Constants.*;
-import static org.junit.Assert.*;
-
-import java.util.*;
-
-import org.apache.juneau.html.*;
-import org.apache.juneau.jena.*;
-import org.apache.juneau.json.*;
-import org.apache.juneau.msgpack.*;
-import org.apache.juneau.parser.*;
-import org.apache.juneau.serializer.*;
-import org.apache.juneau.uon.*;
-import org.apache.juneau.urlencoding.*;
-import org.apache.juneau.xml.*;
-import org.junit.*;
-import org.junit.runners.*;
-
-/**
- * Superclass for tests that verify results against all supported content types.
- */
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-@SuppressWarnings({"unchecked","rawtypes"})
-public abstract class ComboTest {
-
- /* Parameter template */
-// {
-// "MyLabel",
-// myInput,
-// /* Json */ "xxx",
-// /* JsonT */ "xxx",
-// /* JsonR */ "xxx",
-// /* Xml */ "xxx",
-// /* XmlT */ "xxx",
-// /* XmlR */ "xxx",
-// /* XmlNs */ "xxx",
-// /* Html */ "xxx",
-// /* HtmlT */ "xxx",
-// /* HtmlR */ "xxx",
-// /* Uon */ "xxx",
-// /* UonT */ "xxx",
-// /* UonR */ "xxx",
-// /* UrlEnc */ "xxx",
-// /* UrlEncT */ "xxx",
-// /* UrlEncR */ "xxx",
-// /* MsgPack */ "xxx",
-// /* MsgPackT */ "xxx",
-// /* RdfXml */ "xxx",
-// /* RdfXmlT */ "xxx",
-// /* RdfXmlR */ "xxx",
-// },
-
- private final ComboInput comboInput;
-
- // These are the names of all the tests.
- // You can comment out the names here to skip them.
- private static final String[] runTests = {
- "serializeJson",
- "parseJson",
- "serializeJsonT",
- "parseJsonT",
- "serializeJsonR",
- "parseJsonR",
- "serializeXml",
- "parseXml",
- "serializeXmlT",
- "parseXmlT",
- "serializeXmlR",
- "parseXmlR",
- "serializeXmlNs",
- "parseXmlNs",
- "serializeHtml",
- "parseHtml",
- "serializeHtmlT",
- "parseHtmlT",
- "serializeHtmlR",
- "parseHtmlR",
- "serializeUon",
- "parseUon",
- "serializeUonT",
- "parseUonT",
- "serializeUonR",
- "parseUonR",
- "serializeUrlEncoding",
- "parseUrlEncoding",
- "serializeUrlEncodingT",
- "parseUrlEncodingT",
- "serializeUrlEncodingR",
- "parseUrlEncodingR",
- "serializeMsgPack",
- "parseMsgPack",
- "parseMsgPackJsonEquivalency",
- "serializeMsgPackT",
- "parseMsgPackT",
- "parseMsgPackTJsonEquivalency",
- "serializeRdfXml",
- "parseRdfXml",
- "serializeRdfXmlT",
- "parseRdfXmlT",
- "serializeRdfXmlR",
- "parseRdfXmlR",
- };
-
- private static final Set<String> runTestsSet = new HashSet<String>(Arrays.asList(runTests));
-
- private final boolean SKIP_RDF_TESTS = Boolean.getBoolean("skipRdfTests");
-
- private Map<Serializer,Serializer> serializerMap = new IdentityHashMap<Serializer,Serializer>();
- private Map<Parser,Parser> parserMap = new IdentityHashMap<Parser,Parser>();
-
- public ComboTest(ComboInput<?> comboInput) {
- this.comboInput = comboInput;
- }
-
- private Serializer getSerializer(Serializer s) throws Exception {
- Serializer s2 = serializerMap.get(s);
- if (s2 == null) {
- s2 = applySettings(s);
- serializerMap.put(s, s2);
- }
- return s2;
- }
-
- private Parser getParser(Parser p) throws Exception {
- Parser p2 = parserMap.get(p);
- if (p2 == null) {
- p2 = applySettings(p);
- parserMap.put(p, p2);
- }
- return p2;
- }
-
- private void testSerialize(String testName, Serializer s, String expected) throws Exception {
- try {
- s = getSerializer(s);
-
- boolean isRdf = s instanceof RdfSerializer;
-
- if ((isRdf && SKIP_RDF_TESTS) || expected.isEmpty() || ! runTestsSet.contains(testName) ) {
- System.err.println(comboInput.label + "/" + testName + " for "+s.getClass().getSimpleName()+" skipped.");
- return;
- }
-
- String r = s.isWriterSerializer() ? ((WriterSerializer)s).serialize(comboInput.in) : ((OutputStreamSerializer)s).serializeToHex(comboInput.in);
-
- // Can't control RdfSerializer output well, so manually remove namespace declarations
- // double-quotes with single-quotes, and spaces with tabs.
- // Also because RDF sucks really bad and can't be expected to produce consistent testable results,
- // we must also do an expensive sort-then-compare operation to verify the results.
- if (isRdf)
- r = r.replaceAll("<rdf:RDF[^>]*>", "<rdf:RDF>").replace('"', '\'');
-
- // Specifying "xxx" in the expected results will spit out what we should populate the field with.
- if (expected.equals("xxx")) {
- System.out.println(comboInput.label + "/" + testName + "=\n" + r.replaceAll("\n", "\\\\n").replaceAll("\t", "\\\\t")); // NOT DEBUG
- System.out.println(r);
- }
-
- if (isRdf)
- TestUtils.assertEqualsAfterSort(expected, r, "{0}/{1} parse-normal failed", comboInput.label, testName);
- else
- TestUtils.assertEquals(expected, r, "{0}/{1} parse-normal failed", comboInput.label, testName);
-
- } catch (AssertionError e) {
- throw e;
- } catch (Exception e) {
- e.printStackTrace();
- throw new AssertionError(comboInput.label + "/" + testName + " failed. exception=" + e.getLocalizedMessage());
- }
- }
-
- private void testParse(String testName, Serializer s, Parser p, String expected) throws Exception {
- try {
- s = getSerializer(s);
- p = getParser(p);
-
- boolean isRdf = s instanceof RdfSerializer;
-
- if ((isRdf && SKIP_RDF_TESTS) || expected.isEmpty() || ! runTestsSet.contains(testName) ) {
- System.err.println(comboInput.label + "/" + testName + " for "+s.getClass().getSimpleName()+" skipped.");
- return;
- }
-
- String r = s.isWriterSerializer() ? ((WriterSerializer)s).serialize(comboInput.in) : ((OutputStreamSerializer)s).serializeToHex(comboInput.in);
- Object o = p.parse(r, comboInput.type);
- r = s.isWriterSerializer() ? ((WriterSerializer)s).serialize(o) : ((OutputStreamSerializer)s).serializeToHex(o);
-
- if (isRdf)
- r = r.replaceAll("<rdf:RDF[^>]*>", "<rdf:RDF>").replace('"', '\'');
-
- if (isRdf)
- TestUtils.assertEqualsAfterSort(expected, r, "{0}/{1} parse-normal failed", comboInput.label, testName);
- else
- TestUtils.assertEquals(expected, r, "{0}/{1} parse-normal failed", comboInput.label, testName);
-
- } catch (AssertionError e) {
- throw e;
- } catch (Exception e) {
- throw new Exception(comboInput.label + "/" + testName + " failed.", e);
- }
- }
-
- private void testParseVerify(String testName, Serializer s, Parser p) throws Exception {
- try {
- s = getSerializer(s);
- p = getParser(p);
-
- String r = s.isWriterSerializer() ? ((WriterSerializer)s).serialize(comboInput.in) : ((OutputStreamSerializer)s).serializeToHex(comboInput.in);
- Object o = p.parse(r, comboInput.type);
-
- comboInput.verify(o);
- } catch (AssertionError e) {
- throw e;
- } catch (Exception e) {
- throw new Exception(comboInput.label + "/" + testName + " failed.", e);
- }
- }
-
-
- private void testParseJsonEquivalency(String testName, OutputStreamSerializer s, InputStreamParser p, String expected) throws Exception {
- try {
- s = (OutputStreamSerializer)getSerializer(s);
- p = (InputStreamParser)getParser(p);
- WriterSerializer sJson = (WriterSerializer)getSerializer(this.sJson);
-
- String r = s.serializeToHex(comboInput.in);
- Object o = p.parse(r, comboInput.type);
- r = sJson.serialize(o);
- assertEquals(comboInput.label + "/" + testName + " parse-normal failed on JSON equivalency", expected, r);
- } catch (AssertionError e) {
- throw e;
- } catch (Exception e) {
- throw new Exception(comboInput.label + "/" + testName + " failed.", e);
- }
- }
-
- protected Serializer applySettings(Serializer s) throws Exception {
- return s;
- }
-
- protected Parser applySettings(Parser p) throws Exception {
- return p;
- }
-
- //--------------------------------------------------------------------------------
- // JSON
- //--------------------------------------------------------------------------------
- WriterSerializer sJson = JsonSerializer.DEFAULT_LAX;
- ReaderParser pJson = JsonParser.DEFAULT;
-
- @Test
- public void a11_serializeJson() throws Exception {
- testSerialize("serializeJson", sJson, comboInput.json);
- }
-
- @Test
- public void a12_parseJson() throws Exception {
- testParse("parseJson", sJson, pJson, comboInput.json);
- }
-
- @Test
- public void a13_verifyJson() throws Exception {
- testParseVerify("verifyJson", sJson, pJson);
- }
-
- //--------------------------------------------------------------------------------
- // JSON - 't' property
- //--------------------------------------------------------------------------------
- WriterSerializer sJsonT = new JsonSerializerBuilder().simple().beanTypePropertyName("t").build();
- ReaderParser pJsonT = new JsonParserBuilder().beanTypePropertyName("t").build();
-
- @Test
- public void a21_serializeJsonT() throws Exception {
- testSerialize("serializeJsonT", sJsonT, comboInput.jsonT);
- }
-
- @Test
- public void a22_parseJsonT() throws Exception {
- testParse("parseJsonT", sJsonT, pJsonT, comboInput.jsonT);
- }
-
- @Test
- public void a23_verifyJsonT() throws Exception {
- testParseVerify("verifyJsonT", sJsonT, pJsonT);
- }
-
- //--------------------------------------------------------------------------------
- // JSON - Readable
- //--------------------------------------------------------------------------------
- WriterSerializer sJsonR = JsonSerializer.DEFAULT_LAX_READABLE;
- ReaderParser pJsonR = JsonParser.DEFAULT;
-
- @Test
- public void a31_serializeJsonR() throws Exception {
- testSerialize("serializeJsonR", sJsonR, comboInput.jsonR);
- }
-
- @Test
- public void a32_parseJsonR() throws Exception {
- testParse("parseJsonR", sJsonR, pJsonR, comboInput.jsonR);
- }
-
- @Test
- public void a33_verifyJsonR() throws Exception {
- testParseVerify("verifyJsonR", sJsonR, pJsonR);
- }
-
- //--------------------------------------------------------------------------------
- // XML
- //--------------------------------------------------------------------------------
- WriterSerializer sXml = XmlSerializer.DEFAULT_SQ;
- ReaderParser pXml = XmlParser.DEFAULT;
-
- @Test
- public void b11_serializeXml() throws Exception {
- testSerialize("serializeXml", sXml, comboInput.xml);
- }
-
- @Test
- public void b12_parseXml() throws Exception {
- testParse("parseXml", sXml, pXml, comboInput.xml);
- }
-
- @Test
- public void b13_verifyXml() throws Exception {
- testParseVerify("verifyXml", sXml, pXml);
- }
-
- //--------------------------------------------------------------------------------
- // XML - 't' property
- //--------------------------------------------------------------------------------
- WriterSerializer sXmlT = new XmlSerializerBuilder().sq().beanTypePropertyName("t").build();
- ReaderParser pXmlT = new XmlParserBuilder().beanTypePropertyName("t").build();
-
- @Test
- public void b21_serializeXmlT() throws Exception {
- testSerialize("serializeXmlT", sXmlT, comboInput.xmlT);
- }
-
- @Test
- public void b22_parseXmlT() throws Exception {
- testParse("parseXmlT", sXmlT, pXmlT, comboInput.xmlT);
- }
-
- @Test
- public void b23_verifyXmlT() throws Exception {
- testParseVerify("parseXmlTVerify", sXmlT, pXmlT);
- }
-
- //--------------------------------------------------------------------------------
- // XML - Readable
- //--------------------------------------------------------------------------------
- WriterSerializer sXmlR = XmlSerializer.DEFAULT_SQ_READABLE;
- ReaderParser pXmlR = XmlParser.DEFAULT;
-
- @Test
- public void b31_serializeXmlR() throws Exception {
- testSerialize("serializeXmlR", sXmlR, comboInput.xmlR);
- }
-
- @Test
- public void b32_parseXmlR() throws Exception {
- testParse("parseXmlR", sXmlR, pXmlR, comboInput.xmlR);
- }
-
- @Test
- public void b33_verifyXmlR() throws Exception {
- testParseVerify("parseXmlRVerify", sXmlR, pXmlR);
- }
-
- //--------------------------------------------------------------------------------
- // XML - Namespaces
- //--------------------------------------------------------------------------------
- WriterSerializer sXmlNs = XmlSerializer.DEFAULT_NS_SQ;
- ReaderParser pXmlNs = XmlParser.DEFAULT;
-
- @Test
- public void b41_serializeXmlNs() throws Exception {
- testSerialize("serializeXmlNs", sXmlNs, comboInput.xmlNs);
- }
-
- @Test
- public void b42_parseXmlNs() throws Exception {
- testParse("parseXmlNs", sXmlNs, pXmlNs, comboInput.xmlNs);
- }
-
- @Test
- public void b43_verifyXmlNs() throws Exception {
- testParseVerify("verifyXmlNs", sXmlNs, pXmlNs);
- }
-
- //--------------------------------------------------------------------------------
- // HTML
- //--------------------------------------------------------------------------------
- WriterSerializer sHtml = HtmlSerializer.DEFAULT_SQ;
- ReaderParser pHtml = HtmlParser.DEFAULT;
-
- @Test
- public void c11_serializeHtml() throws Exception {
- testSerialize("serializeHtml", sHtml, comboInput.html);
- }
-
- @Test
- public void c12_parseHtml() throws Exception {
- testParse("parseHtml", sHtml, pHtml, comboInput.html);
- }
-
- @Test
- public void c13_verifyHtml() throws Exception {
- testParseVerify("verifyHtml", sHtml, pHtml);
- }
-
- //--------------------------------------------------------------------------------
- // HTML - 't' property
- //--------------------------------------------------------------------------------
- WriterSerializer sHtmlT = new HtmlSerializerBuilder().sq().beanTypePropertyName("t").build();
- ReaderParser pHtmlT = new HtmlParserBuilder().beanTypePropertyName("t").build();
-
- @Test
- public void c21_serializeHtmlT() throws Exception {
- testSerialize("serializeHtmlT", sHtmlT, comboInput.htmlT);
- }
-
- @Test
- public void c22_parseHtmlT() throws Exception {
- testParse("parseHtmlT", sHtmlT, pHtmlT, comboInput.htmlT);
- }
-
- @Test
- public void c23_verifyHtmlT() throws Exception {
- testParseVerify("verifyHtmlT", sHtmlT, pHtmlT);
- }
-
- //--------------------------------------------------------------------------------
- // HTML - Readable
- //--------------------------------------------------------------------------------
- WriterSerializer sHtmlR = HtmlSerializer.DEFAULT_SQ_READABLE;
- ReaderParser pHtmlR = HtmlParser.DEFAULT;
-
- @Test
- public void c31_serializeHtmlR() throws Exception {
- testSerialize("serializeHtmlR", sHtmlR, comboInput.htmlR);
- }
-
- @Test
- public void c32_parseHtmlR() throws Exception {
- testParse("parseHtmlR", sHtmlR, pHtmlR, comboInput.htmlR);
- }
-
- @Test
- public void c33_verifyHtmlR() throws Exception {
- testParseVerify("verifyHtmlR", sHtmlR, pHtmlR);
- }
-
- //--------------------------------------------------------------------------------
- // UON
- //--------------------------------------------------------------------------------
- WriterSerializer sUon = UonSerializer.DEFAULT;
- ReaderParser pUon = UonParser.DEFAULT;
-
- @Test
- public void d11_serializeUon() throws Exception {
- testSerialize("serializeUon", sUon, comboInput.uon);
- }
-
- @Test
- public void d12_parseUon() throws Exception {
- testParse("parseUon", sUon, pUon, comboInput.uon);
- }
-
- @Test
- public void d13_verifyUon() throws Exception {
- testParseVerify("verifyUon", sUon, pUon);
- }
-
- //--------------------------------------------------------------------------------
- // UON - 't' property
- //--------------------------------------------------------------------------------
- WriterSerializer sUonT = new UonSerializerBuilder().beanTypePropertyName("t").build();
- ReaderParser pUonT = new UonParserBuilder().beanTypePropertyName("t").build();
-
- @Test
- public void d21_serializeUonT() throws Exception {
- testSerialize("serializeUonT", sUonT, comboInput.uonT);
- }
-
- @Test
- public void d22_parseUonT() throws Exception {
- testParse("parseUonT", sUonT, pUonT, comboInput.uonT);
- }
-
- @Test
- public void d23_verifyUonT() throws Exception {
- testParseVerify("verifyUonT", sUonT, pUonT);
- }
-
- //--------------------------------------------------------------------------------
- // UON - Readable
- //--------------------------------------------------------------------------------
- WriterSerializer sUonR = UonSerializer.DEFAULT_READABLE;
- ReaderParser pUonR = UonParser.DEFAULT;
-
- @Test
- public void d31_serializeUonR() throws Exception {
- testSerialize("serializeUonR", sUonR, comboInput.uonR);
- }
-
- @Test
- public void d32_parseUonR() throws Exception {
- testParse("parseUonR", sUonR, pUonR, comboInput.uonR);
- }
-
- @Test
- public void d33_verifyUonR() throws Exception {
- testParseVerify("verifyUonR", sUonR, pUonR);
- }
-
- //--------------------------------------------------------------------------------
- // UrlEncoding
- //--------------------------------------------------------------------------------
- WriterSerializer sUrlEncoding = UrlEncodingSerializer.DEFAULT;
- ReaderParser pUrlEncoding = UrlEncodingParser.DEFAULT;
-
- @Test
- public void e11_serializeUrlEncoding() throws Exception {
- testSerialize("serializeUrlEncoding", sUrlEncoding, comboInput.urlEncoding);
- }
-
- @Test
- public void e12_parseUrlEncoding() throws Exception {
- testParse("parseUrlEncoding", sUrlEncoding, pUrlEncoding, comboInput.urlEncoding);
- }
-
- @Test
- public void e13_verifyUrlEncoding() throws Exception {
- testParseVerify("verifyUrlEncoding", sUrlEncoding, pUrlEncoding);
- }
-
- //--------------------------------------------------------------------------------
- // UrlEncoding - 't' property
- //--------------------------------------------------------------------------------
- WriterSerializer sUrlEncodingT = new UrlEncodingSerializerBuilder().beanTypePropertyName("t").build();
- ReaderParser pUrlEncodingT = new UrlEncodingParserBuilder().beanTypePropertyName("t").build();
-
- @Test
- public void e21_serializeUrlEncodingT() throws Exception {
- testSerialize("serializeUrlEncodingT", sUrlEncodingT, comboInput.urlEncodingT);
- }
-
- @Test
- public void e22_parseUrlEncodingT() throws Exception {
- testParse("parseUrlEncodingT", sUrlEncodingT, pUrlEncodingT, comboInput.urlEncodingT);
- }
-
- @Test
- public void e23_verifyUrlEncodingT() throws Exception {
- testParseVerify("verifyUrlEncodingT", sUrlEncodingT, pUrlEncodingT);
- }
-
- //--------------------------------------------------------------------------------
- // UrlEncoding - Readable
- //--------------------------------------------------------------------------------
- WriterSerializer sUrlEncodingR = UrlEncodingSerializer.DEFAULT_READABLE;
- ReaderParser pUrlEncodingR = UrlEncodingParser.DEFAULT;
-
- @Test
- public void e31_serializeUrlEncodingR() throws Exception {
- testSerialize("serializeUrlEncodingR", sUrlEncodingR, comboInput.urlEncodingR);
- }
-
- @Test
- public void e32_parseUrlEncodingR() throws Exception {
- testParse("parseUrlEncodingR", sUrlEncodingR, pUrlEncodingR, comboInput.urlEncodingR);
- }
-
- @Test
- public void e33_verifyUrlEncodingR() throws Exception {
- testParseVerify("verifyUrlEncodingR", sUrlEncodingR, pUrlEncodingR);
- }
-
- //--------------------------------------------------------------------------------
- // MsgPack
- //--------------------------------------------------------------------------------
- OutputStreamSerializer sMsgPack = MsgPackSerializer.DEFAULT;
- InputStreamParser pMsgPack = MsgPackParser.DEFAULT;
-
- @Test
- public void f11_serializeMsgPack() throws Exception {
- testSerialize("serializeMsgPack", sMsgPack, comboInput.msgPack);
- }
-
- @Test
- public void f12_parseMsgPack() throws Exception {
- testParse("parseMsgPack", sMsgPack, pMsgPack, comboInput.msgPack);
- }
-
- @Test
- public void f13_parseMsgPackJsonEquivalency() throws Exception {
- testParseJsonEquivalency("parseMsgPackJsonEquivalency", sMsgPack, pMsgPack, comboInput.json);
- }
-
- @Test
- public void f14_verifyMsgPack() throws Exception {
- testParseVerify("verifyMsgPack", sMsgPack, pMsgPack);
- }
-
- //--------------------------------------------------------------------------------
- // MsgPack - 't' property
- //--------------------------------------------------------------------------------
- OutputStreamSerializer sMsgPackT = new MsgPackSerializerBuilder().beanTypePropertyName("t").build();
- InputStreamParser pMsgPackT = new MsgPackParserBuilder().beanTypePropertyName("t").build();
-
- @Test
- public void f21_serializeMsgPackT() throws Exception {
- testSerialize("serializeMsgPackT", sMsgPackT, comboInput.msgPackT);
- }
-
- @Test
- public void f22_parseMsgPackT() throws Exception {
- testParse("parseMsgPackT", sMsgPackT, pMsgPackT, comboInput.msgPackT);
- }
-
- @Test
- public void f23_parseMsgPackTJsonEquivalency() throws Exception {
- testParseJsonEquivalency("parseMsgPackTJsonEquivalency", sMsgPackT, pMsgPackT, comboInput.json);
- }
-
- @Test
- public void f24_verifyMsgPackT() throws Exception {
- testParseVerify("verifyMsgPackT", sMsgPackT, pMsgPackT);
- }
-
- //--------------------------------------------------------------------------------
- // RdfXml
- //--------------------------------------------------------------------------------
- WriterSerializer sRdfXml = RdfSerializer.DEFAULT_XMLABBREV;
- ReaderParser pRdfXml = RdfParser.DEFAULT_XML;
-
- @Test
- public void g11_serializeRdfXml() throws Exception {
- testSerialize("serializeRdfXml", sRdfXml, comboInput.rdfXml);
- }
-
- @Test
- public void g12_parseRdfXml() throws Exception {
- testParse("parseRdfXml", sRdfXml, pRdfXml, comboInput.rdfXml);
- }
-
- @Test
- public void g13_verifyRdfXml() throws Exception {
- testParseVerify("verifyRdfXml", sRdfXml, pRdfXml);
- }
-
- //--------------------------------------------------------------------------------
- // RdfXml - 't' property
- //--------------------------------------------------------------------------------
- WriterSerializer sRdfXmlT = new RdfSerializerBuilder().language(LANG_RDF_XML_ABBREV).beanTypePropertyName("t").build();
- ReaderParser pRdfXmlT = new RdfParserBuilder().beanTypePropertyName("t").build();
-
- @Test
- public void g21_serializeRdfXmlT() throws Exception {
- testSerialize("serializeRdfXmlT", sRdfXmlT, comboInput.rdfXmlT);
- }
-
- @Test
- public void g22_parseRdfXmlT() throws Exception {
- testParse("parseRdfXmlT", sRdfXmlT, pRdfXmlT, comboInput.rdfXmlT);
- }
-
- @Test
- public void g23_verifyRdfXmlT() throws Exception {
- testParseVerify("parseRdfXmlTVerify", sRdfXmlT, pRdfXmlT);
- }
-
- //--------------------------------------------------------------------------------
- // RdfXml - Readable
- //--------------------------------------------------------------------------------
- WriterSerializer sRdfXmlR = new RdfSerializerBuilder().language(LANG_RDF_XML_ABBREV).ws().build();
- ReaderParser pRdfXmlR = RdfParser.DEFAULT_XML;
-
- @Test
- public void g31_serializeRdfXmlR() throws Exception {
- testSerialize("serializeRdfXmlR", sRdfXmlR, comboInput.rdfXmlR);
- }
-
- @Test
- public void g32_parseRdfXmlR() throws Exception {
- testParse("parseRdfXmlR", sRdfXmlR, pRdfXmlR, comboInput.rdfXmlR);
- }
-
- @Test
- public void g33_verifyRdfXmlR() throws Exception {
- testParseVerify("Verify", sRdfXmlR, pRdfXmlR);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core-test/src/test/java/org/apache/juneau/DynaBeanComboTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/DynaBeanComboTest.java b/juneau-core-test/src/test/java/org/apache/juneau/DynaBeanComboTest.java
index f15b238..9afaaf8 100644
--- a/juneau-core-test/src/test/java/org/apache/juneau/DynaBeanComboTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/DynaBeanComboTest.java
@@ -29,7 +29,7 @@ import org.junit.runners.*;
*/
@RunWith(Parameterized.class)
@SuppressWarnings({"javadoc"})
-public class DynaBeanComboTest extends ComboTest {
+public class DynaBeanComboTest extends ComboRoundTripTest {
@Parameterized.Parameters
public static Collection<Object[]> getParameters() {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core-test/src/test/java/org/apache/juneau/dto/html5/Html5ComboTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/dto/html5/Html5ComboTest.java b/juneau-core-test/src/test/java/org/apache/juneau/dto/html5/Html5ComboTest.java
index 5ef24a7..1e25392 100755
--- a/juneau-core-test/src/test/java/org/apache/juneau/dto/html5/Html5ComboTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/dto/html5/Html5ComboTest.java
@@ -26,7 +26,7 @@ import org.junit.runners.*;
*/
@RunWith(Parameterized.class)
@SuppressWarnings({"javadoc"})
-public class Html5ComboTest extends ComboTest {
+public class Html5ComboTest extends ComboRoundTripTest {
private static final B btag = b("bbb");
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core-test/src/test/java/org/apache/juneau/dto/html5/Html5TemplateComboTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/dto/html5/Html5TemplateComboTest.java b/juneau-core-test/src/test/java/org/apache/juneau/dto/html5/Html5TemplateComboTest.java
index 7fad0fb..e3a3267 100644
--- a/juneau-core-test/src/test/java/org/apache/juneau/dto/html5/Html5TemplateComboTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/dto/html5/Html5TemplateComboTest.java
@@ -28,7 +28,7 @@ import org.junit.runners.*;
*/
@RunWith(Parameterized.class)
@SuppressWarnings({"javadoc"})
-public class Html5TemplateComboTest extends ComboTest {
+public class Html5TemplateComboTest extends ComboRoundTripTest {
@Parameterized.Parameters
public static Collection<Object[]> getParameters() {
[3/6] incubator-juneau git commit: Support serializing directly from
Readers and InputStreams.
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java
index 66d6bae..42ae307 100644
--- a/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java
@@ -15,7 +15,6 @@ package org.apache.juneau.json;
import static org.apache.juneau.serializer.SerializerContext.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.serializer.*;
/**
@@ -31,7 +30,6 @@ import org.apache.juneau.serializer.*;
*
* Produces the JSON-schema for the JSON produced by the {@link JsonSerializer} class with the same properties.
*/
-@Produces(value="application/json+schema,text/json+schema",contentType="application/json")
public final class JsonSchemaSerializer extends JsonSerializer {
/**
@@ -42,8 +40,10 @@ public final class JsonSchemaSerializer extends JsonSerializer {
public JsonSchemaSerializer(PropertyStore propertyStore) {
super(
propertyStore.copy()
- .append(SERIALIZER_detectRecursions, true)
- .append(SERIALIZER_ignoreRecursions, true)
+ .append(SERIALIZER_detectRecursions, true)
+ .append(SERIALIZER_ignoreRecursions, true),
+ "application/json",
+ "application/json+schema", "text/json+schema"
);
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializerSession.java
index f9e875d..17e3a31 100644
--- a/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializerSession.java
@@ -40,7 +40,6 @@ public class JsonSchemaSerializerSession extends JsonSerializerSession {
* 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 JsonSchemaSerializerSession(JsonSerializerContext 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/JsonSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializer.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializer.java
index db0a78d..0709660 100644
--- a/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializer.java
@@ -17,7 +17,6 @@ import static org.apache.juneau.json.JsonSerializerContext.*;
import java.util.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.serializer.*;
/**
@@ -98,7 +97,6 @@ import org.apache.juneau.serializer.*;
* String json = serializer.serialize(someObject);
* </p>
*/
-@Produces("application/json,text/json")
public class JsonSerializer extends WriterSerializer {
/** Default serializer, all default settings.*/
@@ -137,7 +135,6 @@ public class JsonSerializer extends WriterSerializer {
}
/** Default serializer, single quotes, simple mode. */
- @Produces(value="application/json+simple,text/json+simple",contentType="application/json")
public static class Simple extends JsonSerializer {
/**
@@ -148,8 +145,10 @@ public class JsonSerializer extends WriterSerializer {
public Simple(PropertyStore propertyStore) {
super(
propertyStore.copy()
- .append(JSON_simpleMode, true)
- .append(SERIALIZER_quoteChar, '\'')
+ .append(JSON_simpleMode, true)
+ .append(SERIALIZER_quoteChar, '\''),
+ "application/json",
+ "application/json+simple", "text/json+simple"
);
}
}
@@ -201,10 +200,36 @@ public class JsonSerializer extends WriterSerializer {
/**
* 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 JsonSerializer(PropertyStore propertyStore) {
- super(propertyStore);
+ this(propertyStore, "application/json", "application/json", "text/json");
+ }
+
+ /**
+ * 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 JsonSerializer(PropertyStore propertyStore, String produces, String...accept) {
+ super(propertyStore, produces, accept);
this.ctx = createContext(JsonSerializerContext.class);
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerSession.java
index 12c9433..c9266a2 100644
--- a/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerSession.java
@@ -17,6 +17,7 @@ import static org.apache.juneau.json.JsonSerializerContext.*;
import java.util.*;
import org.apache.juneau.*;
+import org.apache.juneau.internal.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.transform.*;
@@ -45,7 +46,6 @@ public class JsonSerializerSession 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 JsonSerializerSession(JsonSerializerContext ctx, SerializerSessionArgs args) {
super(ctx, args);
@@ -135,6 +135,9 @@ public class JsonSerializerSession extends WriterSerializerSession {
else if (sType.isArray()) {
serializeCollection(out, toList(sType.getInnerClass(), o), eType);
}
+ else if (sType.isReader() || sType.isInputStream()) {
+ IOUtils.pipe(o, out);
+ }
else
out.stringValue(toString(o));
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParser.java b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParser.java
index 0d9ab31..e30d678 100644
--- a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParser.java
@@ -13,7 +13,6 @@
package org.apache.juneau.msgpack;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.parser.*;
/**
@@ -30,13 +29,12 @@ import org.apache.juneau.parser.*;
* <li>{@link MsgPackParserContext}
* </ul>
*/
-@Consumes("octal/msgpack")
public class MsgPackParser extends InputStreamParser {
/** Default parser, all default settings.*/
public static final MsgPackParser DEFAULT = new MsgPackParser(PropertyStore.create());
-
+
private final MsgPackParserContext ctx;
/**
@@ -45,7 +43,7 @@ public class MsgPackParser extends InputStreamParser {
* @param propertyStore The property store containing all the settings for this object.
*/
public MsgPackParser(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "octal/msgpack");
this.ctx = createContext(MsgPackParserContext.class);
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializer.java b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializer.java
index ad4dbce..ab5442f 100644
--- a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializer.java
@@ -13,7 +13,6 @@
package org.apache.juneau.msgpack;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.serializer.*;
/**
@@ -34,7 +33,6 @@ import org.apache.juneau.serializer.*;
* <li>{@link BeanContext}
* </ul>
*/
-@Produces("octal/msgpack")
public class MsgPackSerializer extends OutputStreamSerializer {
/** Default serializer, all default settings.*/
@@ -49,7 +47,7 @@ public class MsgPackSerializer extends OutputStreamSerializer {
* @param propertyStore The property store containing all the settings for this object.
*/
public MsgPackSerializer(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "octal/msgpack");
this.ctx = createContext(MsgPackSerializerContext.class);
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerSession.java
index 4a8177d..9b81a16 100644
--- a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerSession.java
@@ -17,6 +17,7 @@ import static org.apache.juneau.msgpack.MsgPackSerializerContext.*;
import java.util.*;
import org.apache.juneau.*;
+import org.apache.juneau.internal.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.transform.*;
@@ -43,7 +44,6 @@ public final class MsgPackSerializerSession extends OutputStreamSerializerSessio
* 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 MsgPackSerializerSession(MsgPackSerializerContext ctx, SerializerSessionArgs args) {
super(ctx, args);
@@ -143,7 +143,11 @@ public final class MsgPackSerializerSession extends OutputStreamSerializerSessio
}
else if (sType.isArray()) {
serializeCollection(out, toList(sType.getInnerClass(), o), eType);
- } else
+ }
+ else if (sType.isReader() || sType.isInputStream()) {
+ IOUtils.pipe(o, out);
+ }
+ else
out.appendString(toString(o));
if (! isRecursion)
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/parser/InputStreamParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/parser/InputStreamParser.java b/juneau-core/src/main/java/org/apache/juneau/parser/InputStreamParser.java
index 9fb15d6..29b11ce 100644
--- a/juneau-core/src/main/java/org/apache/juneau/parser/InputStreamParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/parser/InputStreamParser.java
@@ -13,7 +13,6 @@
package org.apache.juneau.parser;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
/**
* Subclass of {@link Parser} for byte-based parsers.
@@ -25,23 +24,17 @@ import org.apache.juneau.annotation.*;
* <ul>
* <li><code>parse(InputStream, ClassMeta, ParserContext)</code>
* </ul>
- *
- * <h6 class='topic'>@Consumes annotation</h6>
- *
- * The media types that this parser can handle is specified through the {@link Consumes @Consumes} annotation.
- *
- * <p>
- * However, the media types can also be specified programmatically by overriding the {@link #getMediaTypes()} method.
- */
+ */
public abstract class InputStreamParser extends Parser {
/**
* 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>).
*/
- protected InputStreamParser(PropertyStore propertyStore) {
- super(propertyStore);
+ protected InputStreamParser(PropertyStore propertyStore, String...consumes) {
+ super(propertyStore, consumes);
}
@Override /* Parser */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/parser/Parser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/parser/Parser.java b/juneau-core/src/main/java/org/apache/juneau/parser/Parser.java
index b077654..b365a54 100644
--- a/juneau-core/src/main/java/org/apache/juneau/parser/Parser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/parser/Parser.java
@@ -12,15 +12,11 @@
// ***************************************************************************************************************************
package org.apache.juneau.parser;
-import static org.apache.juneau.internal.StringUtils.*;
-import static org.apache.juneau.internal.ReflectionUtils.*;
-
import java.io.*;
import java.lang.reflect.*;
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.transforms.*;
@@ -29,13 +25,6 @@ import org.apache.juneau.utils.*;
/**
* Parent class for all Juneau parsers.
*
- * <h6 class='topic'>@Consumes annotation</h6>
- *
- * The media types that this parser can handle is specified through the {@link Consumes @Consumes} annotation.
- *
- * <p>
- * However, the media types can also be specified programmatically by overriding the {@link #getMediaTypes()} method.
- *
* <h6 class='topic'>Valid data conversions</h6>
*
* Parsers can parse any parsable POJO types, as specified in the <a class="doclink"
@@ -144,20 +133,15 @@ import org.apache.juneau.utils.*;
public abstract class Parser extends CoreObject {
/** General parser properties currently set on this parser. */
- private final MediaType[] mediaTypes;
+ private final MediaType[] consumes;
// Hidden constructor to force subclass from InputStreamParser or ReaderParser.
- Parser(PropertyStore propertyStore) {
+ Parser(PropertyStore propertyStore, String...consumes) {
super(propertyStore);
- Consumes c = getAnnotation(Consumes.class, getClass());
- if (c == null)
- throw new FormattedRuntimeException("Class ''{0}'' is missing the @Consumes annotation", c);
-
- String[] mt = split(c.value());
- this.mediaTypes = new MediaType[mt.length];
- for (int i = 0; i < mt.length; i++) {
- mediaTypes[i] = MediaType.forString(mt[i]);
+ this.consumes = new MediaType[consumes.length];
+ for (int i = 0; i < consumes.length; i++) {
+ this.consumes[i] = MediaType.forString(consumes[i]);
}
}
@@ -359,9 +343,19 @@ public abstract class Parser extends CoreObject {
* @return The new context.
*/
public final ParserSession createSession() {
- return createSession(null);
+ return createSession(createDefaultSessionArgs());
}
+ /**
+ * Creates the session arguments object that gets passed to the {@link #createSession(ParserSessionArgs)} method.
+ *
+ * @return
+ * A new default session arguments object.
+ * <p>The arguments can be modified before passing to the {@link #createSession(ParserSessionArgs)}.
+ */
+ protected final ParserSessionArgs createDefaultSessionArgs() {
+ return new ParserSessionArgs(ObjectMap.EMPTY_MAP, null, null, null, getPrimaryMediaType(), null);
+ }
//--------------------------------------------------------------------------------
// Optional methods
@@ -467,23 +461,20 @@ public abstract class Parser extends CoreObject {
//--------------------------------------------------------------------------------
/**
- * Returns the media types handled based on the value of the {@link Consumes} annotation on the parser class.
- *
- * <p>
- * This method can be overridden by subclasses to determine the media types programmatically.
+ * Returns the media types handled based on the values passed to the <code>consumes</code> constructor parameter.
*
* @return The list of media types. Never <jk>null</jk>.
*/
- public MediaType[] getMediaTypes() {
- return mediaTypes;
+ public final MediaType[] getMediaTypes() {
+ return consumes;
}
/**
- * Returns the first media type specified on this parser via the {@link Consumes} annotation.
+ * Returns the first media type handled based on the values passed to the <code>consumes</code> constructor parameter.
*
* @return The media type.
*/
- public MediaType getPrimaryMediaType() {
- return mediaTypes == null || mediaTypes.length == 0 ? null : mediaTypes[0];
+ public final MediaType getPrimaryMediaType() {
+ return consumes == null || consumes.length == 0 ? null : consumes[0];
}
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/parser/ParserSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/parser/ParserSession.java b/juneau-core/src/main/java/org/apache/juneau/parser/ParserSession.java
index 938f643..cbb2a85 100644
--- a/juneau-core/src/main/java/org/apache/juneau/parser/ParserSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/parser/ParserSession.java
@@ -54,11 +54,9 @@ public abstract class ParserSession extends BeanSession {
* Runtime session arguments.
*/
protected ParserSession(ParserContext ctx, ParserSessionArgs args) {
- super(ctx != null ? ctx : ParserContext.DEFAULT, args != null ? args : ParserSessionArgs.DEFAULT);
+ super(ctx != null ? ctx : ParserContext.DEFAULT, args);
if (ctx == null)
ctx = ParserContext.DEFAULT;
- if (args == null)
- args = ParserSessionArgs.DEFAULT;
Class<?> listenerClass;
ObjectMap p = getProperties();
if (p.isEmpty()) {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/parser/ParserSessionArgs.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/parser/ParserSessionArgs.java b/juneau-core/src/main/java/org/apache/juneau/parser/ParserSessionArgs.java
index 65ce23e..8e43052 100644
--- a/juneau-core/src/main/java/org/apache/juneau/parser/ParserSessionArgs.java
+++ b/juneau-core/src/main/java/org/apache/juneau/parser/ParserSessionArgs.java
@@ -23,11 +23,6 @@ import org.apache.juneau.http.*;
*/
public final class ParserSessionArgs extends BeanSessionArgs {
- /**
- * Default session arguments.
- */
- protected static final ParserSessionArgs DEFAULT = new ParserSessionArgs(ObjectMap.EMPTY_MAP, null, null, null, null, null);
-
final Method javaMethod;
final Object outer;
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/parser/ReaderParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/parser/ReaderParser.java b/juneau-core/src/main/java/org/apache/juneau/parser/ReaderParser.java
index a987a5e..0d107a8 100644
--- a/juneau-core/src/main/java/org/apache/juneau/parser/ReaderParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/parser/ReaderParser.java
@@ -13,7 +13,6 @@
package org.apache.juneau.parser;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
/**
* Subclass of {@link Parser} for characters-based parsers.
@@ -25,13 +24,6 @@ import org.apache.juneau.annotation.*;
* <ul>
* <li><code>parse(ParserSession, ClassMeta)</code>
* </ul>
- *
- * <h6 class='topic'>@Consumes annotation</h6>
- *
- * The media types that this parser can handle is specified through the {@link Consumes @Consumes} annotation.
- *
- * <p>
- * However, the media types can also be specified programmatically by overriding the {@link #getMediaTypes()} method.
*/
public abstract class ReaderParser extends Parser {
@@ -39,9 +31,10 @@ public abstract class ReaderParser extends Parser {
* 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>, <js>"*​/json"</js>).
*/
- protected ReaderParser(PropertyStore propertyStore) {
- super(propertyStore);
+ protected ReaderParser(PropertyStore propertyStore, String...consumes) {
+ super(propertyStore, consumes);
}
@Override /* Parser */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/parser/package.html
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/parser/package.html b/juneau-core/src/main/java/org/apache/juneau/parser/package.html
index f3203e9..98a4ca0 100644
--- a/juneau-core/src/main/java/org/apache/juneau/parser/package.html
+++ b/juneau-core/src/main/java/org/apache/juneau/parser/package.html
@@ -112,15 +112,13 @@
<p>
Defining a new parser is quite simple if you subclass directly from {@link org.apache.juneau.parser.ReaderParser}
or {@link org.apache.juneau.parser.InputStreamParser}.
- In each case, you simply need to implement a single method and specify a
- {@link org.apache.juneau.annotation.Consumes} annotation.
+ In each case, you simply need to implement a single method .
</p>
<p>
The following example shows a simple parser that converts input streams to images using standard JRE classes.
</p>
<p class='bcode'>
<jd>/** Parser for converting byte streams to images */</jd>
- <ja>@Consumes</ja>(<js>"image/png,image/jpeg"</js>)
<jk>public class</jk> ImageParser <jk>extends</jk> InputStreamParser {
<jd>/**
@@ -128,7 +126,7 @@
* <ja>@param</ja> propertyStore The property store containing all the settings for this object.
*/</jd>
<jk>public</jk> ImageParser(PropertyStore propertyStore) {
- <jk>super</jk>(propertyStore);
+ <jk>super</jk>(propertyStore, <js>"image/png"</js>, <js>"image/jpeg"</js>);
}
<ja>@Override</ja> <jc>/* Parser */</jc>
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextParser.java b/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextParser.java
index c5a2695..959560a 100644
--- a/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextParser.java
@@ -13,7 +13,6 @@
package org.apache.juneau.plaintext;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.transform.*;
@@ -44,7 +43,6 @@ import org.apache.juneau.transform.*;
* <li>{@link ParserContext}
* </ul>
*/
-@Consumes("text/plain")
public class PlainTextParser extends ReaderParser {
/** Default parser, all default settings.*/
@@ -57,7 +55,20 @@ public class PlainTextParser extends ReaderParser {
* @param propertyStore The property store containing all the settings for this object.
*/
public PlainTextParser(PropertyStore propertyStore) {
- super(propertyStore);
+ this(propertyStore, "text/plain");
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param propertyStore The property store containing all the settings for this object.
+ * @param consumes The media types that this parser consumes.
+ * <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>
+ */
+ public PlainTextParser(PropertyStore propertyStore, String...consumes) {
+ super(propertyStore, consumes);
}
@Override /* CoreObject */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextSerializer.java b/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextSerializer.java
index 910e2d5..a813865 100644
--- a/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextSerializer.java
@@ -13,7 +13,6 @@
package org.apache.juneau.plaintext;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.transform.*;
@@ -43,7 +42,6 @@ import org.apache.juneau.transform.*;
* <li>{@link BeanContext}
* </ul>
*/
-@Produces("text/plain")
public class PlainTextSerializer extends WriterSerializer {
/** Default serializer, all default settings.*/
@@ -54,13 +52,40 @@ public class PlainTextSerializer extends WriterSerializer {
/**
* 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 PlainTextSerializer(PropertyStore propertyStore) {
- super(propertyStore);
+ this(propertyStore, "text/plain");
+ }
+
+ /**
+ * 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 PlainTextSerializer(PropertyStore propertyStore, String produces, String...accept) {
+ super(propertyStore, produces, accept);
this.ctx = createContext(SerializerContext.class);
}
+
@Override /* CoreObject */
public PlainTextSerializerBuilder builder() {
return new PlainTextSerializerBuilder(propertyStore);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextSerializerSession.java
index 0e69e09..5915f82 100644
--- a/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextSerializerSession.java
@@ -34,7 +34,6 @@ public class PlainTextSerializerSession 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 PlainTextSerializerSession(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/serializer/OutputStreamSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/OutputStreamSerializer.java b/juneau-core/src/main/java/org/apache/juneau/serializer/OutputStreamSerializer.java
index b481f2e..2baede9 100644
--- a/juneau-core/src/main/java/org/apache/juneau/serializer/OutputStreamSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/serializer/OutputStreamSerializer.java
@@ -15,28 +15,35 @@ package org.apache.juneau.serializer;
import static org.apache.juneau.internal.StringUtils.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
/**
* Subclass of {@link Serializer} for byte-based serializers.
- *
- * <h6 class='topic'>@Produces annotation</h6>
- *
- * The media types that this serializer can produce is specified through the {@link Produces @Produces} annotation.
- *
- * <p>
- * However, the media types can also be specified programmatically by overriding the {@link #getMediaTypes()}
- * and {@link #getResponseContentType()} methods.
*/
public abstract class OutputStreamSerializer extends Serializer {
/**
* 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.
+ * @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>
*/
- protected OutputStreamSerializer(PropertyStore propertyStore) {
- super(propertyStore);
+ protected OutputStreamSerializer(PropertyStore propertyStore, String produces, String...accept) {
+ super(propertyStore, produces, accept);
}
@@ -66,7 +73,7 @@ public abstract class OutputStreamSerializer extends Serializer {
*/
@Override
public final byte[] serialize(Object o) throws SerializeException {
- return createSession(null).serialize(o);
+ return createSession(createDefaultSessionArgs()).serialize(o);
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/serializer/OutputStreamSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/OutputStreamSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/serializer/OutputStreamSerializerSession.java
index 8098566..f0637f5 100644
--- a/juneau-core/src/main/java/org/apache/juneau/serializer/OutputStreamSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/serializer/OutputStreamSerializerSession.java
@@ -38,7 +38,6 @@ public abstract class OutputStreamSerializerSession extends SerializerSession {
* 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 OutputStreamSerializerSession(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/serializer/Serializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/Serializer.java b/juneau-core/src/main/java/org/apache/juneau/serializer/Serializer.java
index d2640c3..f04e615 100644
--- a/juneau-core/src/main/java/org/apache/juneau/serializer/Serializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/serializer/Serializer.java
@@ -12,13 +12,9 @@
// ***************************************************************************************************************************
package org.apache.juneau.serializer;
-import static org.apache.juneau.internal.StringUtils.*;
-import static org.apache.juneau.internal.ReflectionUtils.*;
-
import java.io.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.http.*;
/**
@@ -39,35 +35,25 @@ import org.apache.juneau.http.*;
* <p>
* Subclasses should extend directly from {@link OutputStreamSerializer} or {@link WriterSerializer} depending on
* whether it's a stream or character based serializer.
- *
- * <h6 class='topic'>@Produces annotation</h6>
- *
- * The media types that this serializer can produce is specified through the {@link Produces @Produces} annotation.
- * <br>
- * However, the media types can also be specified programmatically by overriding the {@link #getMediaTypes()}
- * and {@link #getResponseContentType()} methods.
*/
public abstract class Serializer extends CoreObject {
- private final MediaType[] mediaTypes;
- private final MediaType contentType;
+ private final MediaType[] accept;
+ private final MediaType produces;
// Hidden constructors to force subclass from OuputStreamSerializer or WriterSerializer.
- Serializer(PropertyStore propertyStore) {
+ Serializer(PropertyStore propertyStore, String produces, String...accept) {
super(propertyStore);
- Produces p = getAnnotation(Produces.class, getClass());
- if (p == null)
- throw new FormattedRuntimeException("Class ''{0}'' is missing the @Produces annotation", getClass());
-
- String[] mt = split(p.value());
- this.mediaTypes = new MediaType[mt.length];
- for (int i = 0; i < mt.length; i++) {
- mediaTypes[i] = MediaType.forString(mt[i]);
+ this.produces = MediaType.forString(produces);
+ if (accept.length == 0) {
+ this.accept = new MediaType[]{this.produces};
+ } else {
+ this.accept = new MediaType[accept.length];
+ for (int i = 0; i < accept.length; i++) {
+ this.accept[i] = MediaType.forString(accept[i]);
+ }
}
-
- String ct = p.contentType().isEmpty() ? this.mediaTypes[0].toString() : p.contentType();
- contentType = ct.isEmpty() ? null : MediaType.forString(ct);
}
@Override /* CoreObject */
@@ -94,7 +80,6 @@ public abstract class Serializer extends CoreObject {
* 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}.
* @return
* The new session object.
* <br>Note that you must call {@link SerializerSession#close()} on this object to perform any necessary
@@ -116,7 +101,18 @@ public abstract class Serializer extends CoreObject {
* cleanup.
*/
public final SerializerSession createSession() {
- return createSession(null);
+ return createSession(createDefaultSessionArgs());
+ }
+
+ /**
+ * Creates the session arguments object that gets passed to the {@link #createSession(SerializerSessionArgs)} method.
+ *
+ * @return
+ * A new default session arguments object.
+ * <p>The arguments can be modified before passing to the {@link #createSession(SerializerSessionArgs)}.
+ */
+ public final SerializerSessionArgs createDefaultSessionArgs() {
+ return new SerializerSessionArgs(ObjectMap.EMPTY_MAP, null, null, null, getResponseContentType(), null);
}
/**
@@ -176,24 +172,12 @@ public abstract class Serializer extends CoreObject {
//--------------------------------------------------------------------------------
/**
- * Returns the media types handled based on the value of the {@link Produces} annotation on the serializer class.
- *
- * <p>
- * This method can be overridden by subclasses to determine the media types programmatically.
+ * Returns the media types handled based on the value of the <code>accept</code> parameter passed into the constructor.
*
* @return The list of media types. Never <jk>null</jk>.
*/
public final MediaType[] getMediaTypes() {
- return mediaTypes;
- }
-
- /**
- * Returns the first media type specified on this serializer via the {@link Produces} annotation.
- *
- * @return The media type.
- */
- public final MediaType getPrimaryMediaType() {
- return mediaTypes == null || mediaTypes.length == 0 ? null : mediaTypes[0];
+ return accept;
}
/**
@@ -212,7 +196,7 @@ public abstract class Serializer extends CoreObject {
*
* @return The response content type. If <jk>null</jk>, then the matched media type is used.
*/
- public MediaType getResponseContentType() {
- return contentType;
+ public final MediaType getResponseContentType() {
+ return produces;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java
index f2428b6..a243fcc 100644
--- a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java
@@ -90,14 +90,11 @@ public abstract class SerializerSession extends BeanSession {
* 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 SerializerSession(SerializerContext ctx, SerializerSessionArgs args) {
- super(ctx != null ? ctx : SerializerContext.DEFAULT, args != null ? args : SerializerSessionArgs.DEFAULT);
+ super(ctx != null ? ctx : SerializerContext.DEFAULT, args);
if (ctx == null)
ctx = SerializerContext.DEFAULT;
- if (args == null)
- args = SerializerSessionArgs.DEFAULT;
this.javaMethod = args.javaMethod;
UriResolution uriResolution;
UriRelativity uriRelativity;
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSessionArgs.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSessionArgs.java b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSessionArgs.java
index 68077b4..e1c2928 100644
--- a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSessionArgs.java
+++ b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSessionArgs.java
@@ -26,11 +26,6 @@ import org.apache.juneau.http.*;
*/
public final class SerializerSessionArgs extends BeanSessionArgs {
- /**
- * Default session arguments.
- */
- public static final SerializerSessionArgs DEFAULT = new SerializerSessionArgs(ObjectMap.EMPTY_MAP, null, null, null, null, null);
-
final Method javaMethod;
final UriContext uriContext;
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializer.java b/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializer.java
index 11d2138..3449dff 100644
--- a/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializer.java
@@ -13,29 +13,36 @@
package org.apache.juneau.serializer;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.utils.*;
/**
* Subclass of {@link Serializer} for character-based serializers.
- *
- * <h6 class='topic'>@Produces annotation</h6>
- *
- * The media types that this serializer can produce is specified through the {@link Produces @Produces} annotation.
- *
- * <p>
- * However, the media types can also be specified programmatically by overriding the {@link #getMediaTypes()}
- * and {@link #getResponseContentType()} methods.
*/
public abstract class WriterSerializer extends Serializer {
/**
* 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.
+ * @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>
*/
- protected WriterSerializer(PropertyStore propertyStore) {
- super(propertyStore);
+ protected WriterSerializer(PropertyStore propertyStore, String produces, String...accept) {
+ super(propertyStore, produces, accept);
}
@@ -65,7 +72,7 @@ public abstract class WriterSerializer extends Serializer {
*/
@Override /* Serializer */
public final String serialize(Object o) throws SerializeException {
- return createSession(null).serialize(o);
+ return createSession(createDefaultSessionArgs()).serialize(o);
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializerSession.java
index b91085f..fdea9d3 100644
--- a/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializerSession.java
@@ -43,7 +43,6 @@ public abstract class WriterSerializerSession extends SerializerSession {
* 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 WriterSerializerSession(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/serializer/package.html
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/package.html b/juneau-core/src/main/java/org/apache/juneau/serializer/package.html
index 0057ce8..a7d9f87 100644
--- a/juneau-core/src/main/java/org/apache/juneau/serializer/package.html
+++ b/juneau-core/src/main/java/org/apache/juneau/serializer/package.html
@@ -114,8 +114,7 @@
<p>
Defining a new serializer is quite simple if you subclass directly from
{@link org.apache.juneau.serializer.WriterSerializer} or {@link org.apache.juneau.serializer.OutputStreamSerializer}.
- <br>In each case, you simply need to implement a single method and specify a
- {@link org.apache.juneau.annotation.Produces} annotation.
+ <br>In each case, you simply need to implement a single method .
</p>
<p>
The following example shows a simple serializer that converts images to output streams using standard JRE
@@ -123,7 +122,6 @@
</p>
<p class='bcode'>
<jd>/** Serializer for converting images to byte streams */</jd>
- <ja>@Produces</ja>(<js>"image/png,image/jpeg"</js>)
<jk>public class</jk> ImageSerializer <jk>extends</jk> OutputStreamSerializer {
<jd>/**
@@ -131,7 +129,7 @@
* <ja>@param</ja> propertyStore The property store containing all the settings for this object.
*/</jd>
<jk>public</jk> ImageSerializer(PropertyStore propertyStore) {
- <jk>super</jk>(propertyStore);
+ <jk>super</jk>(propertyStore, <jk>null</jk>, <js>"image/png"</js>, <js>"image/jpeg"</js>);
}
<ja>@Override</ja> <jc>/* Serializer */</jc>
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializer.java b/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializer.java
index 77f722b..1c58cb9 100644
--- a/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializer.java
@@ -13,7 +13,6 @@
package org.apache.juneau.soap;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.xml.*;
@@ -39,7 +38,6 @@ import org.apache.juneau.xml.*;
* <li>{@link BeanContext}
* </ul>
*/
-@Produces(value="text/xml+soap",contentType="text/xml")
public final class SoapXmlSerializer extends XmlSerializer {
private final SoapXmlSerializerContext ctx;
@@ -50,7 +48,7 @@ public final class SoapXmlSerializer extends XmlSerializer {
* @param propertyStore The property store containing all the settings for this object.
*/
public SoapXmlSerializer(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/xml", "text/xml+soap");
this.ctx = createContext(SoapXmlSerializerContext.class);
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerSession.java
index c899e44..39857b2 100644
--- a/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerSession.java
@@ -40,7 +40,6 @@ public class SoapXmlSerializerSession 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}.
*/
public SoapXmlSerializerSession(SoapXmlSerializerContext 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/uon/UonParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/uon/UonParser.java b/juneau-core/src/main/java/org/apache/juneau/uon/UonParser.java
index 7410a7d..ffc8a6b 100644
--- a/juneau-core/src/main/java/org/apache/juneau/uon/UonParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/uon/UonParser.java
@@ -15,7 +15,6 @@ package org.apache.juneau.uon;
import static org.apache.juneau.uon.UonParserContext.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.parser.*;
/**
@@ -38,7 +37,6 @@ import org.apache.juneau.parser.*;
* <li>{@link BeanContext}
* </ul>
*/
-@Consumes("text/uon")
public class UonParser extends ReaderParser {
/** Reusable instance of {@link UonParser}, all default settings. */
@@ -67,10 +65,23 @@ public class UonParser extends ReaderParser {
/**
* 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 UonParser(PropertyStore propertyStore) {
- super(propertyStore);
+ this(propertyStore, "text/uon");
+ }
+
+ /**
+ * 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>, <js>"*​/json"</js>).
+ */
+ public UonParser(PropertyStore propertyStore, String...consumes) {
+ super(propertyStore, consumes);
this.ctx = createContext(UonParserContext.class);
}
@@ -85,7 +96,7 @@ public class UonParser extends ReaderParser {
* @return A new parser session.
*/
protected final UonParserSession createParameterSession() {
- return new UonParserSession(ctx);
+ return new UonParserSession(ctx, createDefaultSessionArgs(), false);
}
@Override /* Parser */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/uon/UonParserSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/uon/UonParserSession.java b/juneau-core/src/main/java/org/apache/juneau/uon/UonParserSession.java
index 7d50309..9f731d4 100644
--- a/juneau-core/src/main/java/org/apache/juneau/uon/UonParserSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/uon/UonParserSession.java
@@ -68,11 +68,17 @@ public class UonParserSession extends ReaderParserSession {
* The main difference is that characters are never decoded, and the {@link UonParserContext#UON_decodeChars}
* property is always ignored.
*
- * @param ctx The context to copy setting from.
+ * @param ctx
+ * The context creating this session object.
+ * The context contains all the configuration settings for this object.
+ * @param args
+ * Runtime session arguments.
+ * @param decodeChars
+ * Whether to decode characters.
*/
- protected UonParserSession(UonParserContext ctx) {
- super(ctx, null);
- decodeChars = false;
+ protected UonParserSession(UonParserContext ctx, ParserSessionArgs args, boolean decodeChars) {
+ super(ctx, args);
+ this.decodeChars = decodeChars;
}
@Override /* ParserSession */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializer.java b/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializer.java
index 5f1dc23..bb99e3c 100644
--- a/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializer.java
@@ -16,7 +16,6 @@ import static org.apache.juneau.serializer.SerializerContext.*;
import static org.apache.juneau.uon.UonSerializerContext.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.serializer.*;
/**
@@ -125,7 +124,6 @@ import org.apache.juneau.serializer.*;
* String s = UonSerializer.<jsf>DEFAULT</jsf>.serialize(s);
* </p>
*/
-@Produces("text/uon")
public class UonSerializer extends WriterSerializer {
/** Reusable instance of {@link UonSerializer}, all default settings. */
@@ -173,10 +171,36 @@ public class UonSerializer extends WriterSerializer {
/**
* 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 UonSerializer(PropertyStore propertyStore) {
- super(propertyStore);
+ this(propertyStore, "text/uon");
+ }
+
+ /**
+ * 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 UonSerializer(PropertyStore propertyStore, String produces, String...accept) {
+ super(propertyStore, produces, accept);
this.ctx = createContext(UonSerializerContext.class);
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializerSession.java
index 34039bc..b6e8952 100644
--- a/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializerSession.java
@@ -18,6 +18,7 @@ import static org.apache.juneau.uon.UonSerializerContext.*;
import java.util.*;
import org.apache.juneau.*;
+import org.apache.juneau.internal.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.transform.*;
@@ -45,7 +46,6 @@ public class UonSerializerSession 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}.
*/
public UonSerializerSession(UonSerializerContext ctx, Boolean encode, SerializerSessionArgs args) {
super(ctx, args);
@@ -166,6 +166,9 @@ public class UonSerializerSession extends WriterSerializerSession {
else if (sType.isArray()) {
serializeCollection(out, toList(sType.getInnerClass(), o), eType);
}
+ else if (sType.isReader() || sType.isInputStream()) {
+ IOUtils.pipe(o, out);
+ }
else {
out.appendObject(o, false);
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParser.java b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParser.java
index 399c882..3c2d729 100644
--- a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParser.java
@@ -19,7 +19,6 @@ import static org.apache.juneau.internal.StringUtils.*;
import java.util.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.uon.*;
@@ -49,7 +48,6 @@ import org.apache.juneau.uon.*;
* </ul>
*/
@SuppressWarnings({ "unchecked", "hiding" })
-@Consumes("application/x-www-form-urlencoded")
public class UrlEncodingParser extends UonParser implements PartParser {
/** Reusable instance of {@link UrlEncodingParser}. */
@@ -64,7 +62,7 @@ public class UrlEncodingParser extends UonParser implements PartParser {
* @param propertyStore The property store containing all the settings for this object.
*/
public UrlEncodingParser(PropertyStore propertyStore) {
- super(propertyStore.copy().append(UON_decodeChars, true));
+ super(propertyStore.copy().append(UON_decodeChars, true), "application/x-www-form-urlencoded");
this.ctx = createContext(UrlEncodingParserContext.class);
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializer.java b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializer.java
index 9f872c0..9170cc2 100644
--- a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializer.java
@@ -21,7 +21,6 @@ import java.io.*;
import java.net.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.uon.*;
@@ -126,7 +125,6 @@ import org.apache.juneau.uon.*;
* String s = UrlEncodingSerializer.<jsf>DEFAULT</jsf>.serialize(s);
* </p>
*/
-@Produces("application/x-www-form-urlencoded")
@SuppressWarnings("hiding")
public class UrlEncodingSerializer extends UonSerializer implements PartSerializer {
@@ -145,7 +143,6 @@ public class UrlEncodingSerializer extends UonSerializer implements PartSerializ
/**
* Equivalent to <code><jk>new</jk> UrlEncodingSerializerBuilder().expandedParams(<jk>true</jk>).build();</code>.
*/
- @Produces(value="application/x-www-form-urlencoded",contentType="application/x-www-form-urlencoded")
public static class Expanded extends UrlEncodingSerializer {
/**
@@ -193,13 +190,40 @@ public class UrlEncodingSerializer extends UonSerializer implements PartSerializ
/**
* 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 UrlEncodingSerializer(PropertyStore propertyStore) {
- super(propertyStore.copy().append(UON_encodeChars, true));
+ this(propertyStore, "application/x-www-form-urlencoded");
+ }
+
+ /**
+ * 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 UrlEncodingSerializer(PropertyStore propertyStore, String produces, String...accept) {
+ super(propertyStore.copy().append(UON_encodeChars, true), produces, accept);
this.ctx = createContext(UrlEncodingSerializerContext.class);
}
+
@Override /* CoreObject */
public UrlEncodingSerializerBuilder builder() {
return new UrlEncodingSerializerBuilder(propertyStore);
@@ -242,7 +266,7 @@ public class UrlEncodingSerializer extends UonSerializer implements PartSerializ
}
StringWriter w = new StringWriter();
- UonSerializerSession s = new UonSerializerSession(ctx, urlEncode, SerializerSessionArgs.DEFAULT);
+ UonSerializerSession s = new UonSerializerSession(ctx, urlEncode, createDefaultSessionArgs());
s.serialize(w, o);
return w.toString();
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.java
index 46e36d2..cce9b4d 100644
--- a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.java
@@ -18,6 +18,7 @@ import java.lang.reflect.*;
import java.util.*;
import org.apache.juneau.*;
+import org.apache.juneau.internal.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.transform.*;
import org.apache.juneau.uon.*;
@@ -46,7 +47,6 @@ public class UrlEncodingSerializerSession extends UonSerializerSession {
* 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 UrlEncodingSerializerSession(UrlEncodingSerializerContext ctx, Boolean encode, SerializerSessionArgs args) {
super(ctx, encode, args);
@@ -128,6 +128,8 @@ public class UrlEncodingSerializerSession extends UonSerializerSession {
} else if (sType.isCollection() || sType.isArray()) {
Map m = sType.isCollection() ? getCollectionMap((Collection)o) : getCollectionMap(o);
serializeCollectionMap(out, m, getClassMeta(Map.class, Integer.class, Object.class));
+ } else if (sType.isReader() || sType.isInputStream()) {
+ IOUtils.pipe(o, out);
} else {
// All other types can't be serialized as key/value pairs, so we create a
// mock key/value pair with a "_value" key.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/xml/XmlDocSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlDocSerializer.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlDocSerializer.java
index 6e70c35..f04c2d4 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlDocSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlDocSerializer.java
@@ -15,7 +15,6 @@ package org.apache.juneau.xml;
import static org.apache.juneau.xml.XmlSerializerContext.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.serializer.*;
/**
@@ -37,7 +36,6 @@ import org.apache.juneau.serializer.*;
public class XmlDocSerializer extends XmlSerializer {
/** Default serializer without namespaces. */
- @Produces(value="text/xml",contentType="text/xml")
public static class Ns extends XmlDocSerializer {
/**
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/xml/XmlDocSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlDocSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlDocSerializerSession.java
index b889889..a7a8748 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlDocSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlDocSerializerSession.java
@@ -34,7 +34,6 @@ public class XmlDocSerializerSession 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 XmlDocSerializerSession(XmlSerializerContext 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/xml/XmlParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParser.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParser.java
index cd81507..fbc6ae2 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParser.java
@@ -13,7 +13,6 @@
package org.apache.juneau.xml;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.parser.*;
/**
@@ -35,7 +34,6 @@ import org.apache.juneau.parser.*;
* <li>{@link BeanContext}
* </ul>
*/
-@Consumes("text/xml,application/xml")
public class XmlParser extends ReaderParser {
/** Default parser, all default settings.*/
@@ -47,10 +45,23 @@ public class XmlParser extends ReaderParser {
/**
* 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 XmlParser(PropertyStore propertyStore) {
- super(propertyStore);
+ this(propertyStore, "text/xml", "application/xml");
+ }
+
+ /**
+ * 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>, <js>"*​/json"</js>).
+ */
+ public XmlParser(PropertyStore propertyStore, String...consumes) {
+ super(propertyStore, consumes);
this.ctx = createContext(XmlParserContext.class);
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaDocSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaDocSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaDocSerializerSession.java
index 23429a4..8d4a7aa 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaDocSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaDocSerializerSession.java
@@ -34,7 +34,6 @@ public class XmlSchemaDocSerializerSession extends XmlSchemaSerializerSession {
* 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 XmlSchemaDocSerializerSession(XmlSerializerContext 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/xml/XmlSchemaSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializer.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializer.java
index 26ba629..aba1879 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializer.java
@@ -13,7 +13,6 @@
package org.apache.juneau.xml;
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(value="text/xml+schema",contentType="text/xml")
public class XmlSchemaSerializer extends XmlSerializer {
/**
@@ -47,7 +45,7 @@ public class XmlSchemaSerializer extends XmlSerializer {
* @param propertyStore Initialize with the specified config property store.
*/
public XmlSchemaSerializer(PropertyStore propertyStore) {
- super(propertyStore.copy().append(XmlSerializerContext.XML_enableNamespaces, true));
+ super(propertyStore.copy().append(XmlSerializerContext.XML_enableNamespaces, true), "text/xml", "text/xml+schema");
}
@Override /* Serializer */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializerSession.java
index f3b9120..6de01ec 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializerSession.java
@@ -49,7 +49,6 @@ public class XmlSchemaSerializerSession 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 XmlSchemaSerializerSession(XmlSerializerContext 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/xml/XmlSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java
index e836a67..2a81c03 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java
@@ -16,7 +16,6 @@ import static org.apache.juneau.serializer.SerializerContext.*;
import static org.apache.juneau.xml.XmlSerializerContext.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.json.*;
import org.apache.juneau.serializer.*;
@@ -121,7 +120,6 @@ import org.apache.juneau.serializer.*;
* <li>{@link SqReadable} - Default serializer, single quotes, whitespace added.
* </ul>
*/
-@Produces("text/xml")
public class XmlSerializer extends WriterSerializer {
/** Default serializer without namespaces. */
@@ -170,7 +168,6 @@ public class XmlSerializer extends WriterSerializer {
}
/** Default serializer without namespaces. */
- @Produces(value="text/xml+simple",contentType="text/xml")
public static class Ns extends XmlSerializer {
/**
@@ -179,7 +176,7 @@ public class XmlSerializer extends WriterSerializer {
* @param propertyStore The property store containing all the settings for this object.
*/
public Ns(PropertyStore propertyStore) {
- super(propertyStore.copy().append(XML_enableNamespaces, true));
+ super(propertyStore.copy().append(XML_enableNamespaces, true), "text/xml", "text/xml+simple");
}
}
@@ -217,10 +214,36 @@ public class XmlSerializer extends WriterSerializer {
/**
* 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 XmlSerializer(PropertyStore propertyStore) {
- super(propertyStore);
+ this(propertyStore, "text/xml");
+ }
+
+ /**
+ * 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 XmlSerializer(PropertyStore propertyStore, String produces, String...accept) {
+ super(propertyStore, produces, accept);
this.ctx = createContext(XmlSerializerContext.class);
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java
index 1603f0d..d1c348d 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java
@@ -25,6 +25,7 @@ import java.lang.reflect.*;
import java.util.*;
import org.apache.juneau.*;
+import org.apache.juneau.internal.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.transform.*;
import org.apache.juneau.xml.annotation.*;
@@ -63,7 +64,6 @@ public class XmlSerializerSession 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 XmlSerializerSession(XmlSerializerContext ctx, SerializerSessionArgs args) {
super(ctx, args);
@@ -344,6 +344,7 @@ public class XmlSerializerSession extends WriterSerializerSession {
o = null;
boolean isCollapsed = false; // If 'true', this is a collection and we're not rendering the outer element.
+ boolean isRaw = (sType.isReader() || sType.isInputStream()) && o != null;
// Get the JSON type string.
if (o == null) {
@@ -390,7 +391,7 @@ public class XmlSerializerSession extends WriterSerializerSession {
boolean cr = o != null && (sType.isMapOrBean() || sType.isCollectionOrArray()) && ! isMixed;
String en = elementName;
- if (en == null) {
+ if (en == null && ! isRaw) {
en = type.toString();
type = null;
}
@@ -406,25 +407,29 @@ public class XmlSerializerSession extends WriterSerializerSession {
// Render the start tag.
if (! isCollapsed) {
- out.oTag(i, elementNs, en, encodeEn);
- if (addNamespaceUris) {
- out.attr((String)null, "xmlns", defaultNamespace.getUri());
+ if (en != null) {
+ out.oTag(i, elementNs, en, encodeEn);
+ if (addNamespaceUris) {
+ out.attr((String)null, "xmlns", defaultNamespace.getUri());
- for (Namespace n : namespaces)
- out.attr("xmlns", n.getName(), n.getUri());
- }
- if (! isExpectedType) {
- if (resolvedDictionaryName != null)
- out.attr(dns, getBeanTypePropertyName(eType), resolvedDictionaryName);
- else if (type != null && type != STRING)
- out.attr(dns, getBeanTypePropertyName(eType), type);
+ for (Namespace n : namespaces)
+ out.attr("xmlns", n.getName(), n.getUri());
+ }
+ if (! isExpectedType) {
+ if (resolvedDictionaryName != null)
+ out.attr(dns, getBeanTypePropertyName(eType), resolvedDictionaryName);
+ else if (type != null && type != STRING)
+ out.attr(dns, getBeanTypePropertyName(eType), type);
+ }
+ } else {
+ out.i(i);
}
if (o == null) {
if ((sType.isBoolean() || sType.isNumber()) && ! sType.isNullable())
o = sType.getPrimitiveDefault();
}
- if (o != null && ! (sType.isMapOrBean()))
+ if (o != null && ! (sType.isMapOrBean() || en == null))
out.append('>');
if (cr && ! (sType.isMapOrBean()))
@@ -463,6 +468,8 @@ public class XmlSerializerSession extends WriterSerializerSession {
serializeCollection(out, o, sType, eType, pMeta, isMixed);
if (isCollapsed)
this.indent++;
+ } else if (sType.isReader() || sType.isInputStream()) {
+ IOUtils.pipe(o, out);
} else {
if (format == XMLTEXT)
out.append(toString(o));
@@ -475,16 +482,18 @@ public class XmlSerializerSession extends WriterSerializerSession {
// Render the end tag.
if (! isCollapsed) {
- if (rc == CR_EMPTY) {
- if (isHtmlMode())
- out.append('>').eTag(elementNs, en, encodeEn);
- else
+ if (en != null) {
+ if (rc == CR_EMPTY) {
+ if (isHtmlMode())
+ out.append('>').eTag(elementNs, en, encodeEn);
+ else
+ out.append('/').append('>');
+ } else if (rc == CR_VOID || o == null) {
out.append('/').append('>');
- } else if (rc == CR_VOID || o == null) {
- out.append('/').append('>');
+ }
+ else
+ out.ie(cr && rc != CR_MIXED ? i : 0).eTag(elementNs, en, encodeEn);
}
- else
- out.ie(cr && rc != CR_MIXED ? i : 0).eTag(elementNs, en, encodeEn);
if (! isMixed)
out.nl(i);
}
[5/6] incubator-juneau git commit: Support serializing directly from
Readers and InputStreams.
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core-test/src/test/java/org/apache/juneau/parser/ParserGroupTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/parser/ParserGroupTest.java b/juneau-core-test/src/test/java/org/apache/juneau/parser/ParserGroupTest.java
index 32c22de..62b17dc 100755
--- a/juneau-core-test/src/test/java/org/apache/juneau/parser/ParserGroupTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/parser/ParserGroupTest.java
@@ -15,7 +15,6 @@ package org.apache.juneau.parser;
import static org.apache.juneau.TestUtils.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.json.*;
import org.junit.*;
@@ -46,24 +45,21 @@ public class ParserGroupTest {
}
- @Consumes("text/foo,text/foo_a")
public static class Parser1 extends JsonParser {
public Parser1(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/foo", "text/foo_a");
}
}
- @Consumes("text/foo+bar,text/foo+bar_a")
public static class Parser2 extends JsonParser {
public Parser2(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/foo+bar", "text/foo+bar_a");
}
}
- @Consumes("text/baz,text/baz_a")
public static class Parser3 extends JsonParser {
public Parser3(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/baz", "text/baz_a");
}
}
@@ -88,38 +84,33 @@ public class ParserGroupTest {
assertObjectEquals("['text/5','text/3','text/4','text/4a','text/1','text/2','text/2a']", g.getSupportedMediaTypes());
}
- @Consumes("text/1")
public static class P1 extends JsonParser {
public P1(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/1");
}
}
- @Consumes("text/2,text/2a")
public static class P2 extends JsonParser {
public P2(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/2", "text/2a");
}
}
- @Consumes("text/3")
public static class P3 extends JsonParser {
public P3(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/3");
}
}
- @Consumes("text/4,text/4a")
public static class P4 extends JsonParser {
public P4(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/4", "text/4a");
}
}
- @Consumes("text/5")
public static class P5 extends JsonParser {
public P5(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "text/5");
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core-test/src/test/java/org/apache/juneau/serializer/ReaderObjectComboTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/serializer/ReaderObjectComboTest.java b/juneau-core-test/src/test/java/org/apache/juneau/serializer/ReaderObjectComboTest.java
new file mode 100644
index 0000000..b439593
--- /dev/null
+++ b/juneau-core-test/src/test/java/org/apache/juneau/serializer/ReaderObjectComboTest.java
@@ -0,0 +1,439 @@
+// ***************************************************************************************************************************
+// * 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.serializer;
+
+import java.io.*;
+import java.util.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.internal.*;
+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 ReaderObjectComboTest extends ComboSerializeTest {
+
+ @Parameterized.Parameters
+ public static Collection<Object[]> getParameters() {
+ return Arrays.asList(new Object[][] {
+ { /* 0 */
+ new ComboInput<Reader>(
+ "SimpleReader",
+ Reader.class,
+ null,
+ /* Json */ "foobar",
+ /* JsonT */ "foobar",
+ /* JsonR */ "foobar",
+ /* Xml */ "foobar",
+ /* XmlT */ "foobar",
+ /* XmlR */ "foobar\n",
+ /* XmlNs */ "foobar",
+ /* Html */ "foobar",
+ /* HtmlT */ "foobar",
+ /* HtmlR */ "foobar",
+ /* Uon */ "foobar",
+ /* UonT */ "foobar",
+ /* UonR */ "foobar",
+ /* UrlEnc */ "foobar",
+ /* UrlEncT */ "foobar",
+ /* UrlEncR */ "foobar",
+ /* MsgPack */ "666F6F626172",
+ /* MsgPackT */ "666F6F626172",
+ /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<j:value>foobar</j:value>\n</rdf:Description>\n</rdf:RDF>\n",
+ /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<j:value>foobar</j:value>\n</rdf:Description>\n</rdf:RDF>\n",
+ /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <j:value>foobar</j:value>\n </rdf:Description>\n</rdf:RDF>\n"
+ ) {
+ @Override
+ public Reader getInput() {
+ return new StringReader("foobar");
+ }
+ }
+ },
+ { /* 1 */
+ new ComboInput<InputStream>(
+ "SimpleInputStream",
+ InputStream.class,
+ null,
+ /* Json */ "foobar",
+ /* JsonT */ "foobar",
+ /* JsonR */ "foobar",
+ /* Xml */ "foobar",
+ /* XmlT */ "foobar",
+ /* XmlR */ "foobar\n",
+ /* XmlNs */ "foobar",
+ /* Html */ "foobar",
+ /* HtmlT */ "foobar",
+ /* HtmlR */ "foobar",
+ /* Uon */ "foobar",
+ /* UonT */ "foobar",
+ /* UonR */ "foobar",
+ /* UrlEnc */ "foobar",
+ /* UrlEncT */ "foobar",
+ /* UrlEncR */ "foobar",
+ /* MsgPack */ "666F6F626172",
+ /* MsgPackT */ "666F6F626172",
+ /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<j:value>foobar</j:value>\n</rdf:Description>\n</rdf:RDF>\n",
+ /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<j:value>foobar</j:value>\n</rdf:Description>\n</rdf:RDF>\n",
+ /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <j:value>foobar</j:value>\n </rdf:Description>\n</rdf:RDF>\n"
+ ) {
+ @Override
+ public InputStream getInput() throws Exception {
+ return IOUtils.toInputStream("foobar");
+ }
+ }
+ },
+ { /* 2 */
+ new ComboInput<BeanWithReaderField>(
+ "BeanWithReaderField",
+ BeanWithReaderField.class,
+ null,
+ /* Json */ "{f:fv}",
+ /* JsonT */ "{f:fv}",
+ /* JsonR */ "{\n\tf: fv\n}",
+ /* Xml */ "<object><f>fv</f></object>",
+ /* XmlT */ "<object><f>fv</f></object>",
+ /* XmlR */ "<object>\n\t<f>fv</f>\n</object>\n",
+ /* XmlNs */ "<object><f>fv</f></object>",
+ /* Html */ "<table><tr><td>f</td><td>fv</td></tr></table>",
+ /* HtmlT */ "<table><tr><td>f</td><td>fv</td></tr></table>",
+ /* HtmlR */ "<table>\n\t<tr>\n\t\t<td>f</td>\n\t\t<td>fv</td>\n\t</tr>\n</table>\n",
+ /* Uon */ "(f=fv)",
+ /* UonT */ "(f=fv)",
+ /* UonR */ "(\n\tf=fv\n)",
+ /* UrlEnc */ "f=fv",
+ /* UrlEncT */ "f=fv",
+ /* UrlEncR */ "f=fv",
+ /* MsgPack */ "81A1666676",
+ /* MsgPackT */ "81A1666676",
+ /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>fv</jp:f>\n</rdf:Description>\n</rdf:RDF>\n",
+ /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>fv</jp:f>\n</rdf:Description>\n</rdf:RDF>\n",
+ /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <jp:f>fv</jp:f>\n </rdf:Description>\n</rdf:RDF>\n"
+ ) {
+ @Override
+ public BeanWithReaderField getInput() throws Exception {
+ return new BeanWithReaderField().init();
+ }
+ }
+ },
+ { /* 3 */
+ new ComboInput<BeanWithReader1dField>(
+ "BeanWithReader1dField",
+ BeanWithReader1dField.class,
+ null,
+ /* Json */ "{f:[fv1,fv2,null]}",
+ /* JsonT */ "{f:[fv1,fv2,null]}",
+ /* JsonR */ "{\n\tf: [\n\t\tfv1,\n\t\tfv2,\n\t\tnull\n\t]\n}",
+ /* Xml */ "<object><f>fv1fv2<null/></f></object>",
+ /* XmlT */ "<object><f>fv1fv2<null/></f></object>",
+ /* XmlR */ "<object>\n\t<f>\n\t\tfv1\n\t\tfv2\n\t\t<null/>\n\t</f>\n</object>\n",
+ /* XmlNs */ "<object><f>fv1fv2<null/></f></object>",
+ /* Html */ "<table><tr><td>f</td><td><ul><li>fv1</li><li>fv2</li><li><null/></li></ul></td></tr></table>",
+ /* HtmlT */ "<table><tr><td>f</td><td><ul><li>fv1</li><li>fv2</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>fv1</li>\n\t\t\t\t<li>fv2</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=@(fv1,fv2,null))",
+ /* UonT */ "(f=@(fv1,fv2,null))",
+ /* UonR */ "(\n\tf=@(\n\t\tfv1,\n\t\tfv2,\n\t\tnull\n\t)\n)",
+ /* UrlEnc */ "f=@(fv1,fv2,null)",
+ /* UrlEncT */ "f=@(fv1,fv2,null)",
+ /* UrlEncR */ "f=@(\n\tfv1,\n\tfv2,\n\tnull\n)",
+ /* MsgPack */ "81A16693667631667632C0",
+ /* MsgPackT */ "81A16693667631667632C0",
+ /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>\n<rdf:Seq>\n<rdf:li>fv1</rdf:li>\n<rdf:li>fv2</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>fv1</rdf:li>\n<rdf:li>fv2</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>fv1</rdf:li>\n <rdf:li>fv2</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"
+ ) {
+ @Override
+ public BeanWithReader1dField getInput() throws Exception {
+ return new BeanWithReader1dField().init();
+ }
+ }
+ },
+ { /* 4 */
+ new ComboInput<BeanWithReaderNullField>(
+ "BeanWithReaderNullField",
+ BeanWithReaderNullField.class,
+ null,
+ /* Json */ "{f:null}",
+ /* JsonT */ "{f:null}",
+ /* JsonR */ "{\n\tf: null\n}",
+ /* Xml */ "<object><f _type='null'/></object>",
+ /* XmlT */ "<object><f t='null'/></object>",
+ /* XmlR */ "<object>\n\t<f _type='null'/>\n</object>\n",
+ /* XmlNs */ "<object><f _type='null'/></object>",
+ /* Html */ "<table><tr><td>f</td><td><null/></td></tr></table>",
+ /* HtmlT */ "<table><tr><td>f</td><td><null/></td></tr></table>",
+ /* HtmlR */ "<table>\n\t<tr>\n\t\t<td>f</td>\n\t\t<td><null/></td>\n\t</tr>\n</table>\n",
+ /* Uon */ "(f=null)",
+ /* UonT */ "(f=null)",
+ /* UonR */ "(\n\tf=null\n)",
+ /* UrlEnc */ "f=null",
+ /* UrlEncT */ "f=null",
+ /* UrlEncR */ "f=null",
+ /* MsgPack */ "81A166C0",
+ /* MsgPackT */ "81A166C0",
+ /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<jp:f rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Description>\n</rdf:RDF>\n",
+ /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<jp:f rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Description>\n</rdf:RDF>\n",
+ /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <jp:f rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n </rdf:Description>\n</rdf:RDF>\n"
+ ) {
+ @Override
+ public BeanWithReaderNullField getInput() throws Exception {
+ return new BeanWithReaderNullField().init();
+ }
+ }
+ },
+ { /* 5 */
+ new ComboInput<BeanWithReaderListField>(
+ "BeanWithReaderListField",
+ BeanWithReaderListField.class,
+ null,
+ /* Json */ "{f:[fv1,fv2,null]}",
+ /* JsonT */ "{f:[fv1,fv2,null]}",
+ /* JsonR */ "{\n\tf: [\n\t\tfv1,\n\t\tfv2,\n\t\tnull\n\t]\n}",
+ /* Xml */ "<object><f>fv1fv2<null/></f></object>",
+ /* XmlT */ "<object><f>fv1fv2<null/></f></object>",
+ /* XmlR */ "<object>\n\t<f>\n\t\tfv1\n\t\tfv2\n\t\t<null/>\n\t</f>\n</object>\n",
+ /* XmlNs */ "<object><f>fv1fv2<null/></f></object>",
+ /* Html */ "<table><tr><td>f</td><td><ul><li>fv1</li><li>fv2</li><li><null/></li></ul></td></tr></table>",
+ /* HtmlT */ "<table><tr><td>f</td><td><ul><li>fv1</li><li>fv2</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>fv1</li>\n\t\t\t\t<li>fv2</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=@(fv1,fv2,null))",
+ /* UonT */ "(f=@(fv1,fv2,null))",
+ /* UonR */ "(\n\tf=@(\n\t\tfv1,\n\t\tfv2,\n\t\tnull\n\t)\n)",
+ /* UrlEnc */ "f=@(fv1,fv2,null)",
+ /* UrlEncT */ "f=@(fv1,fv2,null)",
+ /* UrlEncR */ "f=@(\n\tfv1,\n\tfv2,\n\tnull\n)",
+ /* MsgPack */ "81A16693667631667632C0",
+ /* MsgPackT */ "81A16693667631667632C0",
+ /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>\n<rdf:Seq>\n<rdf:li>fv1</rdf:li>\n<rdf:li>fv2</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>fv1</rdf:li>\n<rdf:li>fv2</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>fv1</rdf:li>\n <rdf:li>fv2</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"
+ ) {
+ @Override
+ public BeanWithReaderListField getInput() throws Exception {
+ return new BeanWithReaderListField().init();
+ }
+ }
+ },
+ { /* 6 */
+ new ComboInput<BeanWithReaderMapField>(
+ "BeanWithReaderMapField",
+ BeanWithReaderMapField.class,
+ null,
+ /* Json */ "{f:{foo:fv1,bar:null,null:fv2}}",
+ /* JsonT */ "{f:{foo:fv1,bar:null,null:fv2}}",
+ /* JsonR */ "{\n\tf: {\n\t\tfoo: fv1,\n\t\tbar: null,\n\t\tnull: fv2\n\t}\n}",
+ /* Xml */ "<object><f><foo>fv1</foo><bar _type='null'/><_x0000_>fv2</_x0000_></f></object>",
+ /* XmlT */ "<object><f><foo>fv1</foo><bar t='null'/><_x0000_>fv2</_x0000_></f></object>",
+ /* XmlR */ "<object>\n\t<f>\n\t\t<foo>fv1</foo>\n\t\t<bar _type='null'/>\n\t\t<_x0000_>fv2</_x0000_>\n\t</f>\n</object>\n",
+ /* XmlNs */ "<object><f><foo>fv1</foo><bar _type='null'/><_x0000_>fv2</_x0000_></f></object>",
+ /* Html */ "<table><tr><td>f</td><td><table><tr><td>foo</td><td>fv1</td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td>fv2</td></tr></table></td></tr></table>",
+ /* HtmlT */ "<table><tr><td>f</td><td><table><tr><td>foo</td><td>fv1</td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td>fv2</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>fv1</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>fv2</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=fv1,bar=null,null=fv2))",
+ /* UonT */ "(f=(foo=fv1,bar=null,null=fv2))",
+ /* UonR */ "(\n\tf=(\n\t\tfoo=fv1,\n\t\tbar=null,\n\t\tnull=fv2\n\t)\n)",
+ /* UrlEnc */ "f=(foo=fv1,bar=null,null=fv2)",
+ /* UrlEncT */ "f=(foo=fv1,bar=null,null=fv2)",
+ /* UrlEncR */ "f=(\n\tfoo=fv1,\n\tbar=null,\n\tnull=fv2\n)",
+ /* MsgPack */ "81A16683A3666F6F667631A3626172C0C0667632",
+ /* MsgPackT */ "81A16683A3666F6F667631A3626172C0C0667632",
+ /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<jp:f rdf:parseType='Resource'>\n<jp:foo>fv1</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_>fv2</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>fv1</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_>fv2</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>fv1</jp:foo>\n <jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n <jp:_x0000_>fv2</jp:_x0000_>\n </jp:f>\n </rdf:Description>\n</rdf:RDF>\n"
+ ) {
+ @Override
+ public BeanWithReaderMapField getInput() throws Exception {
+ return new BeanWithReaderMapField().init();
+ }
+ }
+ },
+ { /* 7 */
+ new ComboInput<BeanWithReaderBeanListField>(
+ "BeanWithReaderBeanListField",
+ BeanWithReaderBeanListField.class,
+ null,
+ /* Json */ "{f:[{f1:f1v,f2:[f2v1,f2v2,null],f3:null,f4:[f4v1,f4v2,null],f5:{foo:f5v1,bar:null,null:f5v2}},null]}",
+ /* JsonT */ "{f:[{f1:f1v,f2:[f2v1,f2v2,null],f3:null,f4:[f4v1,f4v2,null],f5:{foo:f5v1,bar:null,null:f5v2}},null]}",
+ /* JsonR */ "{\n\tf: [\n\t\t{\n\t\t\tf1: f1v,\n\t\t\tf2: [\n\t\t\t\tf2v1,\n\t\t\t\tf2v2,\n\t\t\t\tnull\n\t\t\t],\n\t\t\tf3: null,\n\t\t\tf4: [\n\t\t\t\tf4v1,\n\t\t\t\tf4v2,\n\t\t\t\tnull\n\t\t\t],\n\t\t\tf5: {\n\t\t\t\tfoo: f5v1,\n\t\t\t\tbar: null,\n\t\t\t\tnull: f5v2\n\t\t\t}\n\t\t},\n\t\tnull\n\t]\n}",
+ /* Xml */ "<object><f><object><f1>f1v</f1><f2>f2v1f2v2<null/></f2><f3 _type='null'/><f4>f4v1f4v2<null/></f4><f5><foo>f5v1</foo><bar _type='null'/><_x0000_>f5v2</_x0000_></f5></object><null/></f></object>",
+ /* XmlT */ "<object><f><object><f1>f1v</f1><f2>f2v1f2v2<null/></f2><f3 t='null'/><f4>f4v1f4v2<null/></f4><f5><foo>f5v1</foo><bar t='null'/><_x0000_>f5v2</_x0000_></f5></object><null/></f></object>",
+ /* XmlR */ "<object>\n\t<f>\n\t\t<object>\n\t\t\t<f1>f1v</f1>\n\t\t\t<f2>\n\t\t\t\tf2v1\n\t\t\t\tf2v2\n\t\t\t\t<null/>\n\t\t\t</f2>\n\t\t\t<f3 _type='null'/>\n\t\t\t<f4>\n\t\t\t\tf4v1\n\t\t\t\tf4v2\n\t\t\t\t<null/>\n\t\t\t</f4>\n\t\t\t<f5>\n\t\t\t\t<foo>f5v1</foo>\n\t\t\t\t<bar _type='null'/>\n\t\t\t\t<_x0000_>f5v2</_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>f1v</f1><f2>f2v1f2v2<null/></f2><f3 _type='null'/><f4>f4v1f4v2<null/></f4><f5><foo>f5v1</foo><bar _type='null'/><_x0000_>f5v2</_x0000_></f5></object><null/></f></object>",
+ /* Html */ "<table><tr><td>f</td><td><ul><li><table><tr><td>f1</td><td>f1v</td></tr><tr><td>f2</td><td><ul><li>f2v1</li><li>f2v2</li><li><null/></li></ul></td></tr><tr><td>f3</td><td><null/></td></tr><tr><td>f4</td><td><ul><li>f4v1</li><li>f4v2</li><li><null/></li></ul></td></tr><tr><td>f5</td><td><table><tr><td>foo</td><td>f5v1</td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td>f5v2</td></tr></table></td></tr></table></li><li><null/></li></ul></td></tr></table>",
+ /* HtmlT */ "<table><tr><td>f</td><td><ul><li><table><tr><td>f1</td><td>f1v</td></tr><tr><td>f2</td><td><ul><li>f2v1</li><li>f2v2</li><li><null/></li></ul></td></tr><tr><td>f3</td><td><null/></td></tr><tr><td>f4</td><td><ul><li>f4v1</li><li>f4v2</li><li><null/></li></ul></td></tr><tr><td>f5</td><td><table><tr><td>foo</td><td>f5v1</td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td>f5v2</td></tr></table></td></tr></table></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>\n\t\t\t\t\t<table>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>f1</td>\n\t\t\t\t\t\t\t<td>f1v</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>f2</td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t\t\t<li>f2v1</li>\n\t\t\t\t\t\t\t\t\t<li>f2v2</li>\n\t\t\t\t\t\t\t\t\t<li><null/></li>\n\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>f3</td>\n\t\t\t\t\t\t\t<td><null/></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>f4</td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t\t\t<li>f4v1</li>\n\t\t\t\t\t\t\t\t\t<li>f4v2</li>\n\t\t\t\t\t\t\t\t\t<li><null/></li>\n\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>f5</td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t<table>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<td>foo</td>\n\t\t\t\t\t\t\t\t\t\t<td>f5v1</td>\n\t\t\t\t\t\t\t\
t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<td>bar</td>\n\t\t\t\t\t\t\t\t\t\t<td><null/></td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<td><null/></td>\n\t\t\t\t\t\t\t\t\t\t<td>f5v2</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t</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=@((f1=f1v,f2=@(f2v1,f2v2,null),f3=null,f4=@(f4v1,f4v2,null),f5=(foo=f5v1,bar=null,null=f5v2)),null))",
+ /* UonT */ "(f=@((f1=f1v,f2=@(f2v1,f2v2,null),f3=null,f4=@(f4v1,f4v2,null),f5=(foo=f5v1,bar=null,null=f5v2)),null))",
+ /* UonR */ "(\n\tf=@(\n\t\t(\n\t\t\tf1=f1v,\n\t\t\tf2=@(\n\t\t\t\tf2v1,\n\t\t\t\tf2v2,\n\t\t\t\tnull\n\t\t\t),\n\t\t\tf3=null,\n\t\t\tf4=@(\n\t\t\t\tf4v1,\n\t\t\t\tf4v2,\n\t\t\t\tnull\n\t\t\t),\n\t\t\tf5=(\n\t\t\t\tfoo=f5v1,\n\t\t\t\tbar=null,\n\t\t\t\tnull=f5v2\n\t\t\t)\n\t\t),\n\t\tnull\n\t)\n)",
+ /* UrlEnc */ "f=@((f1=f1v,f2=@(f2v1,f2v2,null),f3=null,f4=@(f4v1,f4v2,null),f5=(foo=f5v1,bar=null,null=f5v2)),null)",
+ /* UrlEncT */ "f=@((f1=f1v,f2=@(f2v1,f2v2,null),f3=null,f4=@(f4v1,f4v2,null),f5=(foo=f5v1,bar=null,null=f5v2)),null)",
+ /* UrlEncR */ "f=@(\n\t(\n\t\tf1=f1v,\n\t\tf2=@(\n\t\t\tf2v1,\n\t\t\tf2v2,\n\t\t\tnull\n\t\t),\n\t\tf3=null,\n\t\tf4=@(\n\t\t\tf4v1,\n\t\t\tf4v2,\n\t\t\tnull\n\t\t),\n\t\tf5=(\n\t\t\tfoo=f5v1,\n\t\t\tbar=null,\n\t\t\tnull=f5v2\n\t\t)\n\t),\n\tnull\n)",
+ /* MsgPack */ "81A1669285A26631663176A26632936632763166327632C0A26633C0A26634936634763166347632C0A2663583A3666F6F66357631A3626172C0C066357632C0",
+ /* MsgPackT */ "81A1669285A26631663176A26632936632763166327632C0A26633C0A26634936634763166347632C0A2663583A3666F6F66357631A3626172C0C066357632C0",
+ /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>\n<rdf:Seq>\n<rdf:li rdf:parseType='Resource'>\n<jp:f1>f1v</jp:f1>\n<jp:f2>\n<rdf:Seq>\n<rdf:li>f2v1</rdf:li>\n<rdf:li>f2v2</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:f3 rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:f4>\n<rdf:Seq>\n<rdf:li>f4v1</rdf:li>\n<rdf:li>f4v2</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>f5v1</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_>f5v2</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>f1v</jp:f1>\n<jp:f2>\n<rdf:Seq>\n<rdf:li>f2v1</rdf:li>\n<rdf:li>f2v2</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:f3 rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:f4>\n<rdf:Seq>\n<rdf:li>f4v1</rdf:li>\n<rdf:li>f4v2</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>f5v1</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_>f5v2</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>f1v</jp:f1>\n <jp:f2>\n <rdf:Seq>\n <rdf:li>f2v1</rdf:li>\n <rdf:li>f2v2</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:f3 rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n <jp:f4>\n <rdf:Seq>\n <rdf:li>f4v1</rdf:li>\n <rdf:li>f4v2</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>f5v1</jp:foo>\n <jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n <jp:_x0000_>f5v2</jp:_x0000_>\n </jp:f5>\n </rdf:li>\n <rdf:li rdf:r
esource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n </rdf:Seq>\n </jp:f>\n </rdf:Description>\n</rdf:RDF>\n"
+ ) {
+ @Override
+ public BeanWithReaderBeanListField getInput() throws Exception {
+ return new BeanWithReaderBeanListField().init();
+ }
+ }
+ },
+ { /* 8 */
+ new ComboInput<BeanWithReaderBeanMapField>(
+ "BeanWithReaderBeanMapField",
+ BeanWithReaderBeanMapField.class,
+ null,
+ /* Json */ "{f:{foo:{f1:f1v,f2:[f2v1,f2v2,null],f3:null,f4:[f4v1,f4v2,null],f5:{foo:f5v1,bar:null,null:f5v2}},bar:null,null:{f1:f1v,f2:[f2v1,f2v2,null],f3:null,f4:[f4v1,f4v2,null],f5:{foo:f5v1,bar:null,null:f5v2}}}}",
+ /* JsonT */ "{f:{foo:{f1:f1v,f2:[f2v1,f2v2,null],f3:null,f4:[f4v1,f4v2,null],f5:{foo:f5v1,bar:null,null:f5v2}},bar:null,null:{f1:f1v,f2:[f2v1,f2v2,null],f3:null,f4:[f4v1,f4v2,null],f5:{foo:f5v1,bar:null,null:f5v2}}}}",
+ /* JsonR */ "{\n\tf: {\n\t\tfoo: {\n\t\t\tf1: f1v,\n\t\t\tf2: [\n\t\t\t\tf2v1,\n\t\t\t\tf2v2,\n\t\t\t\tnull\n\t\t\t],\n\t\t\tf3: null,\n\t\t\tf4: [\n\t\t\t\tf4v1,\n\t\t\t\tf4v2,\n\t\t\t\tnull\n\t\t\t],\n\t\t\tf5: {\n\t\t\t\tfoo: f5v1,\n\t\t\t\tbar: null,\n\t\t\t\tnull: f5v2\n\t\t\t}\n\t\t},\n\t\tbar: null,\n\t\tnull: {\n\t\t\tf1: f1v,\n\t\t\tf2: [\n\t\t\t\tf2v1,\n\t\t\t\tf2v2,\n\t\t\t\tnull\n\t\t\t],\n\t\t\tf3: null,\n\t\t\tf4: [\n\t\t\t\tf4v1,\n\t\t\t\tf4v2,\n\t\t\t\tnull\n\t\t\t],\n\t\t\tf5: {\n\t\t\t\tfoo: f5v1,\n\t\t\t\tbar: null,\n\t\t\t\tnull: f5v2\n\t\t\t}\n\t\t}\n\t}\n}",
+ /* Xml */ "<object><f><foo><f1>f1v</f1><f2>f2v1f2v2<null/></f2><f3 _type='null'/><f4>f4v1f4v2<null/></f4><f5><foo>f5v1</foo><bar _type='null'/><_x0000_>f5v2</_x0000_></f5></foo><bar _type='null'/><_x0000_><f1>f1v</f1><f2>f2v1f2v2<null/></f2><f3 _type='null'/><f4>f4v1f4v2<null/></f4><f5><foo>f5v1</foo><bar _type='null'/><_x0000_>f5v2</_x0000_></f5></_x0000_></f></object>",
+ /* XmlT */ "<object><f><foo><f1>f1v</f1><f2>f2v1f2v2<null/></f2><f3 t='null'/><f4>f4v1f4v2<null/></f4><f5><foo>f5v1</foo><bar t='null'/><_x0000_>f5v2</_x0000_></f5></foo><bar t='null'/><_x0000_><f1>f1v</f1><f2>f2v1f2v2<null/></f2><f3 t='null'/><f4>f4v1f4v2<null/></f4><f5><foo>f5v1</foo><bar t='null'/><_x0000_>f5v2</_x0000_></f5></_x0000_></f></object>",
+ /* XmlR */ "<object>\n\t<f>\n\t\t<foo>\n\t\t\t<f1>f1v</f1>\n\t\t\t<f2>\n\t\t\t\tf2v1\n\t\t\t\tf2v2\n\t\t\t\t<null/>\n\t\t\t</f2>\n\t\t\t<f3 _type='null'/>\n\t\t\t<f4>\n\t\t\t\tf4v1\n\t\t\t\tf4v2\n\t\t\t\t<null/>\n\t\t\t</f4>\n\t\t\t<f5>\n\t\t\t\t<foo>f5v1</foo>\n\t\t\t\t<bar _type='null'/>\n\t\t\t\t<_x0000_>f5v2</_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>f1v</f1>\n\t\t\t<f2>\n\t\t\t\tf2v1\n\t\t\t\tf2v2\n\t\t\t\t<null/>\n\t\t\t</f2>\n\t\t\t<f3 _type='null'/>\n\t\t\t<f4>\n\t\t\t\tf4v1\n\t\t\t\tf4v2\n\t\t\t\t<null/>\n\t\t\t</f4>\n\t\t\t<f5>\n\t\t\t\t<foo>f5v1</foo>\n\t\t\t\t<bar _type='null'/>\n\t\t\t\t<_x0000_>f5v2</_x0000_>\n\t\t\t</f5>\n\t\t</_x0000_>\n\t</f>\n</object>\n",
+ /* XmlNs */ "<object><f><foo><f1>f1v</f1><f2>f2v1f2v2<null/></f2><f3 _type='null'/><f4>f4v1f4v2<null/></f4><f5><foo>f5v1</foo><bar _type='null'/><_x0000_>f5v2</_x0000_></f5></foo><bar _type='null'/><_x0000_><f1>f1v</f1><f2>f2v1f2v2<null/></f2><f3 _type='null'/><f4>f4v1f4v2<null/></f4><f5><foo>f5v1</foo><bar _type='null'/><_x0000_>f5v2</_x0000_></f5></_x0000_></f></object>",
+ /* Html */ "<table><tr><td>f</td><td><table><tr><td>foo</td><td><table><tr><td>f1</td><td>f1v</td></tr><tr><td>f2</td><td><ul><li>f2v1</li><li>f2v2</li><li><null/></li></ul></td></tr><tr><td>f3</td><td><null/></td></tr><tr><td>f4</td><td><ul><li>f4v1</li><li>f4v2</li><li><null/></li></ul></td></tr><tr><td>f5</td><td><table><tr><td>foo</td><td>f5v1</td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td>f5v2</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>f1v</td></tr><tr><td>f2</td><td><ul><li>f2v1</li><li>f2v2</li><li><null/></li></ul></td></tr><tr><td>f3</td><td><null/></td></tr><tr><td>f4</td><td><ul><li>f4v1</li><li>f4v2</li><li><null/></li></ul></td></tr><tr><td>f5</td><td><table><tr><td>foo</td><td>f5v1</td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td>f5v2</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>f1v</td></tr><tr><td>f2</td><td><ul><li>f2v1</li><li>f2v2</li><li><null/></li></ul></td></tr><tr><td>f3</td><td><null/></td></tr><tr><td>f4</td><td><ul><li>f4v1</li><li>f4v2</li><li><null/></li></ul></td></tr><tr><td>f5</td><td><table><tr><td>foo</td><td>f5v1</td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td>f5v2</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>f1v</td></tr><tr><td>f2</td><td><ul><li>f2v1</li><li>f2v2</li><li><null/></li></ul></td></tr><tr><td>f3</td><td><null/></td></tr><tr><td>f4</td><td><ul><li>f4v1</li><li>f4v2</li><li><null/></li></ul></td></tr><tr><td>f5</td><td><table><tr><td>foo</td><td>f5v1</td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td>f5v2</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>f1v</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>f2v1</li>\n\t\t\t\t\t\t\t\t\t\t<li>f2v2</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>f3</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>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>f4v1</li>\n\t\t\t\t\t\t\t\t\t\t<li>f4v2</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>f5v1</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>f5v2</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>f1v</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>f2v1</li>\n\t\t\t\t\t\t\t\t\t\t<li>f2v2</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>f3</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>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>f4v1</li>\n\t\t\t\t\t\t\t\t\t\t<li>f4v2</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>f5v1</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>f5v2</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=f1v,f2=@(f2v1,f2v2,null),f3=null,f4=@(f4v1,f4v2,null),f5=(foo=f5v1,bar=null,null=f5v2)),bar=null,null=(f1=f1v,f2=@(f2v1,f2v2,null),f3=null,f4=@(f4v1,f4v2,null),f5=(foo=f5v1,bar=null,null=f5v2))))",
+ /* UonT */ "(f=(foo=(f1=f1v,f2=@(f2v1,f2v2,null),f3=null,f4=@(f4v1,f4v2,null),f5=(foo=f5v1,bar=null,null=f5v2)),bar=null,null=(f1=f1v,f2=@(f2v1,f2v2,null),f3=null,f4=@(f4v1,f4v2,null),f5=(foo=f5v1,bar=null,null=f5v2))))",
+ /* UonR */ "(\n\tf=(\n\t\tfoo=(\n\t\t\tf1=f1v,\n\t\t\tf2=@(\n\t\t\t\tf2v1,\n\t\t\t\tf2v2,\n\t\t\t\tnull\n\t\t\t),\n\t\t\tf3=null,\n\t\t\tf4=@(\n\t\t\t\tf4v1,\n\t\t\t\tf4v2,\n\t\t\t\tnull\n\t\t\t),\n\t\t\tf5=(\n\t\t\t\tfoo=f5v1,\n\t\t\t\tbar=null,\n\t\t\t\tnull=f5v2\n\t\t\t)\n\t\t),\n\t\tbar=null,\n\t\tnull=(\n\t\t\tf1=f1v,\n\t\t\tf2=@(\n\t\t\t\tf2v1,\n\t\t\t\tf2v2,\n\t\t\t\tnull\n\t\t\t),\n\t\t\tf3=null,\n\t\t\tf4=@(\n\t\t\t\tf4v1,\n\t\t\t\tf4v2,\n\t\t\t\tnull\n\t\t\t),\n\t\t\tf5=(\n\t\t\t\tfoo=f5v1,\n\t\t\t\tbar=null,\n\t\t\t\tnull=f5v2\n\t\t\t)\n\t\t)\n\t)\n)",
+ /* UrlEnc */ "f=(foo=(f1=f1v,f2=@(f2v1,f2v2,null),f3=null,f4=@(f4v1,f4v2,null),f5=(foo=f5v1,bar=null,null=f5v2)),bar=null,null=(f1=f1v,f2=@(f2v1,f2v2,null),f3=null,f4=@(f4v1,f4v2,null),f5=(foo=f5v1,bar=null,null=f5v2)))",
+ /* UrlEncT */ "f=(foo=(f1=f1v,f2=@(f2v1,f2v2,null),f3=null,f4=@(f4v1,f4v2,null),f5=(foo=f5v1,bar=null,null=f5v2)),bar=null,null=(f1=f1v,f2=@(f2v1,f2v2,null),f3=null,f4=@(f4v1,f4v2,null),f5=(foo=f5v1,bar=null,null=f5v2)))",
+ /* UrlEncR */ "f=(\n\tfoo=(\n\t\tf1=f1v,\n\t\tf2=@(\n\t\t\tf2v1,\n\t\t\tf2v2,\n\t\t\tnull\n\t\t),\n\t\tf3=null,\n\t\tf4=@(\n\t\t\tf4v1,\n\t\t\tf4v2,\n\t\t\tnull\n\t\t),\n\t\tf5=(\n\t\t\tfoo=f5v1,\n\t\t\tbar=null,\n\t\t\tnull=f5v2\n\t\t)\n\t),\n\tbar=null,\n\tnull=(\n\t\tf1=f1v,\n\t\tf2=@(\n\t\t\tf2v1,\n\t\t\tf2v2,\n\t\t\tnull\n\t\t),\n\t\tf3=null,\n\t\tf4=@(\n\t\t\tf4v1,\n\t\t\tf4v2,\n\t\t\tnull\n\t\t),\n\t\tf5=(\n\t\t\tfoo=f5v1,\n\t\t\tbar=null,\n\t\t\tnull=f5v2\n\t\t)\n\t)\n)",
+ /* MsgPack */ "81A16683A3666F6F85A26631663176A26632936632763166327632C0A26633C0A26634936634763166347632C0A2663583A3666F6F66357631A3626172C0C066357632A3626172C0C085A26631663176A26632936632763166327632C0A26633C0A26634936634763166347632C0A2663583A3666F6F66357631A3626172C0C066357632",
+ /* MsgPackT */ "81A16683A3666F6F85A26631663176A26632936632763166327632C0A26633C0A26634936634763166347632C0A2663583A3666F6F66357631A3626172C0C066357632A3626172C0C085A26631663176A26632936632763166327632C0A26633C0A26634936634763166347632C0A2663583A3666F6F66357631A3626172C0C066357632",
+ /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<jp:f rdf:parseType='Resource'>\n<jp:foo rdf:parseType='Resource'>\n<jp:f1>f1v</jp:f1>\n<jp:f2>\n<rdf:Seq>\n<rdf:li>f2v1</rdf:li>\n<rdf:li>f2v2</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:f3 rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:f4>\n<rdf:Seq>\n<rdf:li>f4v1</rdf:li>\n<rdf:li>f4v2</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>f5v1</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_>f5v2</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>f1v</jp:f1>\n<jp:f2>\n<rdf:Seq>\n<rdf:li>f2v1</rdf:li>\n<rdf:li>f2v2</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:f3 rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:f4>\n<rdf:Seq>\n<rdf:li>f4v1</rdf:li>\n<rdf:li>f4v2</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>f5v1</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_>f5v2</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>f1v</jp:f1>\n<jp:f2>\n<rdf:Seq>\n<rdf:li>f2v1</rdf:li>\n<rdf:li>f2v2</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:f3 rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:f4>\n<rdf:Seq>\n<rdf:li>f4v1</rdf:li>\n<rdf:li>f4v2</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>f5v1</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_>f5v2</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>f1v</jp:f1>\n<jp:f2>\n<rdf:Seq>\n<rdf:li>f2v1</rdf:li>\n<rdf:li>f2v2</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:f3 rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:f4>\n<rdf:Seq>\n<rdf:li>f4v1</rdf:li>\n<rdf:li>f4v2</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>f5v1</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_>f5v2</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>f1v</jp:f1>\n <jp:f2>\n <rdf:Seq>\n <rdf:li>f2v1</rdf:li>\n <rdf:li>f2v2</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:f3 rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n <jp:f4>\n <rdf:Seq>\n <rdf:li>f4v1</rdf:li>\n <rdf:li>f4v2</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>f5v1</jp:foo>\n <jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n <jp:_x0000_>f5v2</jp:_x0000_>\n </jp:f5>\n </jp:foo>\n <jp:bar rdf:resource='http://www.w3.org/1999/02/22-rd
f-syntax-ns#nil'/>\n <jp:_x0000_ rdf:parseType='Resource'>\n <jp:f1>f1v</jp:f1>\n <jp:f2>\n <rdf:Seq>\n <rdf:li>f2v1</rdf:li>\n <rdf:li>f2v2</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:f3 rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n <jp:f4>\n <rdf:Seq>\n <rdf:li>f4v1</rdf:li>\n <rdf:li>f4v2</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>f5v1</jp:foo>\n <jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n <jp:_x0000_>f5v2</jp:_x0000_>\n </jp:f5>\n </jp:_x0000_>\n </jp:f>\n </rdf:Description>\n</rdf:RDF>\n"
+ ) {
+ @Override
+ public BeanWithReaderBeanMapField getInput() throws Exception {
+ return new BeanWithReaderBeanMapField().init();
+ }
+ }
+ },
+ });
+ }
+
+ public ReaderObjectComboTest(ComboInput<?> comboInput) {
+ super(comboInput);
+ }
+
+ @Override
+ protected Serializer applySettings(Serializer s) throws Exception {
+ return s.builder().trimNullProperties(false).build();
+ }
+
+ public static class BeanWithReaderField {
+ public Reader f;
+ public BeanWithReaderField init() {
+ f = new StringReader("fv");
+ return this;
+ }
+ }
+
+ public static class BeanWithReader1dField {
+ public Reader[] f;
+ public BeanWithReader1dField init() {
+ f = new Reader[]{new StringReader("fv1"),new StringReader("fv2"),null};
+ return this;
+ }
+ }
+
+ public static class BeanWithReaderNullField {
+ public Reader f;
+ public BeanWithReaderNullField init() {
+ f = null;
+ return this;
+ }
+ }
+
+ public static class BeanWithReaderListField {
+ public List<Reader> f;
+ public BeanWithReaderListField init() {
+ f = new AList<Reader>()
+ .append(new StringReader("fv1"))
+ .append(new StringReader("fv2"))
+ .append(null)
+ ;
+ return this;
+ }
+ }
+
+ public static class BeanWithReaderMapField {
+ public Map<String,Reader> f;
+ public BeanWithReaderMapField init() {
+ f = new AMap<String,Reader>()
+ .append("foo", new StringReader("fv1"))
+ .append("bar", null)
+ .append(null, new StringReader("fv2"))
+ ;
+ return this;
+ }
+ }
+
+ public static class BeanWithReaderBeanListField {
+ public List<B> f;
+ public BeanWithReaderBeanListField init() {
+ f = new AList<B>()
+ .append(new B().init())
+ .append(null)
+ ;
+ return this;
+ }
+ }
+
+ public static class BeanWithReaderBeanMapField {
+ public Map<String,B> f;
+ public BeanWithReaderBeanMapField init() {
+ f = new AMap<String,B>()
+ .append("foo", new B().init())
+ .append("bar", null)
+ .append(null, new B().init())
+ ;
+ return this;
+ }
+ }
+
+ public static class B {
+ public Reader f1;
+ public Reader[] f2;
+ public Reader f3;
+ public List<Reader> f4;
+ public Map<String,Reader> f5;
+
+ public B init() {
+ f1 = new StringReader("f1v");
+ f2 = new Reader[]{new StringReader("f2v1"),new StringReader("f2v2"),null};
+ f3 = null;
+ f4 = new AList<Reader>()
+ .append(new StringReader("f4v1"))
+ .append(new StringReader("f4v2"))
+ .append(null)
+ ;
+ f5 = new AMap<String,Reader>()
+ .append("foo", new StringReader("f5v1"))
+ .append("bar", null)
+ .append(null, new StringReader("f5v2"))
+ ;
+ return this;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core-test/src/test/java/org/apache/juneau/serializer/SerializerGroupTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/serializer/SerializerGroupTest.java b/juneau-core-test/src/test/java/org/apache/juneau/serializer/SerializerGroupTest.java
index ef0d788..b5e2db9 100755
--- a/juneau-core-test/src/test/java/org/apache/juneau/serializer/SerializerGroupTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/serializer/SerializerGroupTest.java
@@ -15,7 +15,6 @@ package org.apache.juneau.serializer;
import static org.apache.juneau.TestUtils.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.json.*;
import org.junit.*;
@@ -51,24 +50,21 @@ public class SerializerGroupTest {
}
- @Produces("text/foo,text/foo_a")
public static class SA1 extends JsonSerializer {
public SA1(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "application/json", "text/foo", "text/foo_a");
}
}
- @Produces("text/foo+bar,text/foo+bar_a")
public static class SA2 extends JsonSerializer {
public SA2(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "application/json", "text/foo+bar", "text/foo+bar_a");
}
}
- @Produces("text/baz,text/baz_a")
public static class SA3 extends JsonSerializer {
public SA3(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "application/json", "text/baz", "text/baz_a");
}
}
@@ -93,38 +89,33 @@ public class SerializerGroupTest {
assertObjectEquals("['text/5','text/3','text/4','text/4a','text/1','text/2','text/2a']", g.getSupportedMediaTypes());
}
- @Produces("text/1")
public static class SB1 extends JsonSerializer {
public SB1(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "application/json", "text/1");
}
}
- @Produces("text/2,text/2a")
public static class SB2 extends JsonSerializer {
public SB2(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "application/json", "text/2", "text/2a");
}
}
- @Produces("text/3")
public static class SB3 extends JsonSerializer {
public SB3(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "application/json", "text/3");
}
}
- @Produces("text/4,text/4a")
public static class SB4 extends JsonSerializer {
public SB4(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "application/json", "text/4", "text/4a");
}
}
- @Produces("text/5")
public static class SB5 extends JsonSerializer {
public SB5(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "application/json", "text/5");
}
}
@@ -143,24 +134,21 @@ public class SerializerGroupTest {
assertType(SC3.class, g.getSerializer("foo/foo"));
}
- @Produces("text/*")
public static class SC1 extends JsonSerializer {
public SC1(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "application/json", "text/*");
}
}
- @Produces("*/json")
public static class SC2 extends JsonSerializer {
public SC2(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "application/json", "*/json");
}
}
- @Produces("*/*")
public static class SC3 extends JsonSerializer {
public SC3(PropertyStore propertyStore) {
- super(propertyStore);
+ super(propertyStore, "application/json", "*/*");
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core-test/src/test/java/org/apache/juneau/transforms/BeanDictionaryComboTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/transforms/BeanDictionaryComboTest.java b/juneau-core-test/src/test/java/org/apache/juneau/transforms/BeanDictionaryComboTest.java
index 3ab7ec2..6b03b7b 100644
--- a/juneau-core-test/src/test/java/org/apache/juneau/transforms/BeanDictionaryComboTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/transforms/BeanDictionaryComboTest.java
@@ -29,7 +29,7 @@ import org.junit.runners.*;
*/
@RunWith(Parameterized.class)
@SuppressWarnings({"javadoc"})
-public class BeanDictionaryComboTest extends ComboTest {
+public class BeanDictionaryComboTest extends ComboRoundTripTest {
@Parameterized.Parameters
public static Collection<Object[]> getParameters() {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core-test/src/test/java/org/apache/juneau/transforms/ByteArrayBase64SwapComboTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/transforms/ByteArrayBase64SwapComboTest.java b/juneau-core-test/src/test/java/org/apache/juneau/transforms/ByteArrayBase64SwapComboTest.java
index cf580f8..10308a0 100644
--- a/juneau-core-test/src/test/java/org/apache/juneau/transforms/ByteArrayBase64SwapComboTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/transforms/ByteArrayBase64SwapComboTest.java
@@ -28,7 +28,7 @@ import org.junit.runners.*;
*/
@RunWith(Parameterized.class)
@SuppressWarnings({"javadoc"})
-public class ByteArrayBase64SwapComboTest extends ComboTest {
+public class ByteArrayBase64SwapComboTest extends ComboRoundTripTest {
@Parameterized.Parameters
public static Collection<Object[]> getParameters() {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core-test/src/test/java/org/apache/juneau/transforms/CalendarSwapComboTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/transforms/CalendarSwapComboTest.java b/juneau-core-test/src/test/java/org/apache/juneau/transforms/CalendarSwapComboTest.java
index 9aa0b1d..a240e74 100644
--- a/juneau-core-test/src/test/java/org/apache/juneau/transforms/CalendarSwapComboTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/transforms/CalendarSwapComboTest.java
@@ -29,7 +29,7 @@ import org.junit.runners.*;
*/
@RunWith(Parameterized.class)
@SuppressWarnings({"javadoc"})
-public class CalendarSwapComboTest extends ComboTest {
+public class CalendarSwapComboTest extends ComboRoundTripTest {
private static Calendar singleDate = new GregorianCalendar(TimeZone.getTimeZone("PST"));
static {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core-test/src/test/java/org/apache/juneau/transforms/DateSwapComboTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/transforms/DateSwapComboTest.java b/juneau-core-test/src/test/java/org/apache/juneau/transforms/DateSwapComboTest.java
index 2c24884..c611b0e 100644
--- a/juneau-core-test/src/test/java/org/apache/juneau/transforms/DateSwapComboTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/transforms/DateSwapComboTest.java
@@ -29,7 +29,7 @@ import org.junit.runners.*;
*/
@RunWith(Parameterized.class)
@SuppressWarnings({"javadoc"})
-public class DateSwapComboTest extends ComboTest {
+public class DateSwapComboTest extends ComboRoundTripTest {
private static Date singleDate = CalendarSwapTest.testDate.getTime();